Package mondrian.xmla

Class XmlaUtil

  • All Implemented Interfaces:
    XmlaConstants

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

      • XmlaUtil

        public XmlaUtil()
    • Method Detail

      • 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)
                                                         throws org.olap4j.OlapException
        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
        Throws:
        org.olap4j.OlapException
      • 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)