Class LiteralNode

java.lang.Object
org.olap4j.mdx.LiteralNode
All Implemented Interfaces:
ParseTreeNode

public class LiteralNode extends Object implements ParseTreeNode
Represents a constant value, such as a string or number, in a parse tree.

Symbols, such as the ASC keyword in Order([Store].Members, [Measures].[Unit Sales], ASC), are also represented as Literals.

A LiteralNode is immutable.

Author:
jhyde
  • Method Details

    • createNull

      public static LiteralNode createNull(ParseRegion region)
      Creates a literal with the NULL value.
      Parameters:
      region - Region of source code
      Returns:
      literal representing the NULL value
    • createString

      public static LiteralNode createString(ParseRegion region, String value)
      Creates a string literal.
      Parameters:
      region - Region of source code
      value - String value
      Returns:
      literal representing the string value
      See Also:
    • createSymbol

      public static LiteralNode createSymbol(ParseRegion region, String value)
      Creates a symbol literal.
      Parameters:
      region - Region of source code
      value - Name of symbol
      Returns:
      literal representing the symbol value
      See Also:
    • createNumeric

      public static LiteralNode createNumeric(ParseRegion region, BigDecimal value, boolean approximate)
      Creates a numeric literal.
      Parameters:
      region - Region of source code
      value - Value of literal; must not be null
      approximate - Whether the literal is approximate
      Returns:
      literal representing the integer value
    • accept

      public <T> T accept(ParseTreeVisitor<T> visitor)
      Description copied from interface: ParseTreeNode
      Accepts a visitor to this MDX parse tree node.

      The implementation should generally dispatches to the ParseTreeVisitor.visit(org.olap4j.mdx.SelectNode) method appropriate to the type of expression.

      Specified by:
      accept in interface ParseTreeNode
      Parameters:
      visitor - Visitor
      Returns:
      T, the specific return type of the visitor
    • getType

      public Type getType()
      Description copied from interface: ParseTreeNode
      Returns the type of this expression.

      Returns null if this node is not an expression, for instance a SELECT node.

      Specified by:
      getType in interface ParseTreeNode
      Returns:
      type of this expression
    • getRegion

      public ParseRegion getRegion()
      Description copied from interface: ParseTreeNode
      Returns the region of the source code which this node was created from, if it was created by parsing.

      A non-leaf node's region will encompass the regions of all of its children. For example, a the region of a function call node Crossjoin([Gender], {[Store].[USA]}) stretches from the first character of the function name to the closing parenthesis.

      Region may be null, if the node was created programmatically, not from a piece of source code.

      Specified by:
      getRegion in interface ParseTreeNode
      Returns:
      Region of the source code this node was created from, if it was created by parsing
    • getValue

      public Object getValue()
      Returns the value of this literal.

      Value is always of type String (if the literal is a string or a symbol), of type BigDecimal (if the literal is numeric), or null (if the literal is of null type).

      Returns:
      value
    • unparse

      public void unparse(ParseTreeWriter writer)
      Description copied from interface: ParseTreeNode
      Converts this node into MDX text.
      Specified by:
      unparse in interface ParseTreeNode
      Parameters:
      writer - Parse tree writer
    • deepCopy

      public LiteralNode deepCopy()
      Description copied from interface: ParseTreeNode
      Creates a deep copy of this ParseTreeNode object.

      Note: implementing classes can return the concrete type instead of ParseTreeNode (using Java 1.5 covariant return types)

      Specified by:
      deepCopy in interface ParseTreeNode
      Returns:
      The deep copy of this ParseTreeNode