Class OlapUtils

java.lang.Object
fr.becpg.repo.olap.OlapUtils

public class OlapUtils extends Object

OlapUtils class.

Version:
$Id: $Id
Author:
matthieu
  • Field Details

    • logger

      private static final org.apache.commons.logging.Log logger
      Constant logger
    • GROUPING_SPACES

      private static final String GROUPING_SPACES
      Grouping separators Mondrian may emit, depending on the locale.
      See Also:
    • PLAIN

      private static final Pattern PLAIN
      A number with no separator at all: `-1148`, `19`.
    • NUMERIC

      private static final Pattern NUMERIC
      Anything that can plausibly be a formatted number.
  • Constructor Details

    • OlapUtils

      private OlapUtils()

      Constructor for OlapUtils.

  • Method Details

    • readJsonFromUrl

      public static String readJsonFromUrl(String url, OlapContext olapContext) throws IOException

      readJsonFromUrl.

      Parameters:
      url - a String object.
      olapContext - a OlapContext object.
      Returns:
      a String object.
      Throws:
      IOException - if any.
    • sendCreateQueryPostRequest

      public static void sendCreateQueryPostRequest(OlapContext olapContext, String postUrl, String xml) throws IOException

      sendCreateQueryPostRequest.

      Parameters:
      olapContext - a OlapContext object.
      postUrl - a String object.
      xml - a String object.
      Throws:
      IOException - if any.
    • convertCell

      public static Object convertCell(String rawValue, String formattedValue)
      Converts one Saiku cell, preferring its raw value: value is formatted for the connection locale, properties.raw is the measure itself. Headers carry no raw value and fall back on convert(String). A whole raw value is returned as a Long so that a count keeps being published as a count by retrieveDataType.
      Parameters:
      rawValue - properties.raw, or null when absent
      formattedValue - value, the displayed one
      Returns:
      a Long, a Double, or the formatted value unchanged when neither is a number
    • convert

      public static Object convert(String value)
      Converts one Saiku display value — the fallback of convertCell(String, String), for the cells carrying no raw one. The value is formatted by Mondrian for the connection locale, so it is read rather than parsed: both separators present means the last one is the decimal one, the same separator twice means grouping, spaces always mean grouping. A single separator followed by exactly three digits stays undecidable — one and the same cellset carries "1.148" for a count and "19.468" for an average — and is read as a decimal, the historical behaviour.
      Parameters:
      value - a String object.
      Returns:
      a Long, a Double, or the value unchanged when it is not a number at all.
    • decimalSeparatorOf

      private static Character decimalSeparatorOf(String value)
      Which character carries the decimal point, or null when the value is a grouped integer. See convert(String) for the rules.
      Parameters:
      value - already stripped of spaces and known to be numeric
      Returns:
      the decimal separator, or null
    • stripGrouping

      private static String stripGrouping(String value, char decimal)
      Removes the grouping separators and normalises the decimal one to a dot, so the result can be handed to Double.valueOf(String).
      Parameters:
      value - already stripped of spaces
      decimal - the decimal separator
      Returns:
      a canonical numeric string