org.olap4j.mdx
Class IdentifierNode

java.lang.Object
  extended by org.olap4j.mdx.IdentifierNode
All Implemented Interfaces:
ParseTreeNode

public class IdentifierNode
extends java.lang.Object
implements ParseTreeNode

Multi-part identifier.

An identifier is immutable.

An identifer consists of one or more IdentifierNode.Segments. A segment is either:

Segment types are indicated by the IdentifierNode.Quoting enumeration.

A key segment is of type IdentifierNode.Quoting.KEY, and has one or more component parts accessed via the IdentifierNode.Segment.getKeyParts() method. The parts are of type IdentifierNode.Quoting.UNQUOTED or IdentifierNode.Quoting.QUOTED.

A simple example is the identifier Measures.[Unit Sales]. It has two segments:

A more complex example illustrates a compound key. The identifier [Customers].[City].&[San Francisco]&CA&USA.&[cust1234] contains four segments as follows:

Version:
$Id: IdentifierNode.java 253 2009-06-30 03:06:10Z jhyde $
Author:
jhyde

Nested Class Summary
static class IdentifierNode.KeySegment
          Segment that represents a key or compound key.
static class IdentifierNode.NameSegment
          Component in a compound identifier that describes the name of an object.
static class IdentifierNode.Quoting
          Enumeration of styles by which the component of an identifier can be quoted.
static interface IdentifierNode.Segment
          Component in a compound identifier.
 
Constructor Summary
IdentifierNode(IdentifierNode.Segment... segments)
          Creates an identifier containing one or more segments.
IdentifierNode(java.util.List<IdentifierNode.Segment> segments)
          Creates an identifier containing a list of segments.
 
Method Summary
<T> T
accept(ParseTreeVisitor<T> visitor)
          Accepts a visitor to this MDX parse tree node.
 IdentifierNode append(IdentifierNode.Segment segment)
          Returns a new Identifier consisting of this one with another segment appended.
 IdentifierNode deepCopy()
          Creates a deep copy of this ParseTreeNode object.
 ParseRegion getRegion()
          Returns the region of the source code which this node was created from, if it was created by parsing.
 java.util.List<IdentifierNode.Segment> getSegmentList()
          Returns the list of segments which consistitute this identifier.
 Type getType()
          Returns the type of this expression.
static java.util.List<IdentifierNode.Segment> parseIdentifier(java.lang.String identifier)
          Parses an MDX identifier into a list of segments.
 java.lang.String toString()
           
 void unparse(ParseTreeWriter writer)
          Converts this node into MDX text.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IdentifierNode

public IdentifierNode(IdentifierNode.Segment... segments)
Creates an identifier containing one or more segments.

Parameters:
segments - Array of Segments, each consisting of a name and quoting style

IdentifierNode

public IdentifierNode(java.util.List<IdentifierNode.Segment> segments)
Creates an identifier containing a list of segments.

Parameters:
segments - List of segments
Method Detail

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

getSegmentList

public java.util.List<IdentifierNode.Segment> getSegmentList()
Returns the list of segments which consistitute this identifier.

Returns:
list of constituent segments

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

append

public IdentifierNode append(IdentifierNode.Segment segment)
Returns a new Identifier consisting of this one with another segment appended. Does not modify this Identifier.

Parameters:
segment - Name of segment
Returns:
New identifier

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

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

deepCopy

public IdentifierNode 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

parseIdentifier

public static java.util.List<IdentifierNode.Segment> parseIdentifier(java.lang.String identifier)
Parses an MDX identifier into a list of segments.

Each segment is a name combined with a description of how the name was quoted. For example,

parseIdentifier( "[Customers].USA.[South Dakota].[Sioux Falls].&[1245]")
returns
{ Segment("Customers", QUOTED), Segment("USA", UNQUOTED), Segment("South Dakota", QUOTED), Segment("Sioux Falls", QUOTED), Segment("1245", KEY) }

Parameters:
identifier - MDX identifier string
Returns:
List of name segments
Throws:
java.lang.IllegalArgumentException - if the format of the identifier is invalid
See Also:
Cube.lookupMember(String[])

SourceForge.net_Logo