Package mondrian.xmla

Class XmlaUtil

java.lang.Object
mondrian.xmla.XmlaUtil
All Implemented Interfaces:
XmlaConstants

public class XmlaUtil extends Object implements XmlaConstants
Utility methods for XML/A implementation.
Author:
Gang Chen
  • Method Details

    • element2Text

      public static void element2Text(Element elem, StringWriter writer) throws XmlaException
      Throws:
      XmlaException
    • text2Element

      public static Element text2Element(String text) throws XmlaException
      Throws:
      XmlaException
    • stream2Element

      public static Element stream2Element(InputStream stream) throws XmlaException
      Throws:
      XmlaException
    • filterChildElements

      public static Element[] filterChildElements(Element parent, String ns, String lname)
    • textInElement

      public static String textInElement(Element elem)
    • rootThrowable

      public static Throwable rootThrowable(Throwable throwable)
      Finds root MondrianException in exception chain if exists, otherwise the input throwable.
      Parameters:
      throwable - Exception
      Returns:
      Root exception
    • normalizeNumericString

      public static String normalizeNumericString(String numericStr)
      Corrects for the differences between numeric strings arising because JDBC drivers use different representations for numbers (Double vs. BigDecimal) and these have different toString() behavior.

      If it contains a decimal point, then strip off trailing '0's. After stripping off the '0's, if there is nothing right of the decimal point, then strip off decimal point.

      Parameters:
      numericStr - Numeric string
      Returns:
      Normalized string
    • getMetadataRowset

      public static XmlaUtil.MetadataRowset getMetadataRowset(org.olap4j.OlapConnection connection, String methodName, Map<String,Object> restrictionMap)
      Returns a set of column headings and rows for a given metadata request.

      Leverages mondrian's implementation of the XML/A specification, and is exposed here for use by mondrian's olap4j driver.

      Parameters:
      connection - Connection
      methodName - Metadata method name per XMLA (e.g. "MDSCHEMA_CUBES")
      restrictionMap - Restrictions
      Returns:
      Set of rows and column headings
    • chooseResponseMimeType

      public static Enumeration.ResponseMimeType chooseResponseMimeType(String accept)
      Chooses the appropriate response mime type given an HTTP "Accept" header.

      The header can contain a list of mime types and optional qualities, for example "text/html, application/xhtml+xml,application/xml;q=0.9"

      Parameters:
      accept - Accept header
      Returns:
      Mime type, or null if none is acceptable
    • shouldEmitInvisibleMembers

      public static boolean shouldEmitInvisibleMembers(XmlaRequest request)
      Returns whether an XMLA request should return invisible members.

      According to the XMLA spec, it should not. But we allow the client to specify different behavior. In particular, the olap4j driver for XMLA may need to access invisible members.

      Returns true if the EmitInvisibleMembers property is specified and equal to "true".

      Parameters:
      request - XMLA request
      Returns:
      Whether to return invisible members
    • convertToLocale

      public static Locale convertToLocale(String value)