Class IdentifierNode
- All Implemented Interfaces:
ParseTreeNode
An identifier is immutable.
An identifer consists of one or more IdentifierSegment
s. A segment
is either:
- An unquoted value such as '
CA
', - A value quoted in brackets, such as '
[San Francisco]
', or - A key of one or more parts, each of which is prefixed with '&',
such as '
&[Key 1]&Key2&[5]
'.
Segment types are indicated by the Quoting
enumeration.
A key segment is of type Quoting.KEY
, and has one or more
component parts accessed via the
IdentifierSegment.getKeyParts()
method. The parts
are of type Quoting.UNQUOTED
or 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:
- Segment #0 is QUOTED, name "Customers"
- Segment #1 is QUOTED, name "City"
- Segment #2 is a
KEY
. It has 3 sub-segments:- Sub-segment #0 is QUOTED, name "San Francisco"
- Sub-segment #1 is UNQUOTED, name "CA"
- Sub-segment #2 is UNQUOTED, name "USA"
- Segment #3 is a KEY. It has 1 sub-segment:
- Sub-segment #0 is QUOTED, name "cust1234"
- Author:
- jhyde
-
Constructor Summary
ConstructorsConstructorDescriptionIdentifierNode
(List<IdentifierSegment> segments) Creates an identifier containing a list of segments.IdentifierNode
(IdentifierSegment... segments) Creates an identifier containing one or more segments. -
Method Summary
Modifier and TypeMethodDescription<T> T
accept
(ParseTreeVisitor<T> visitor) Accepts a visitor to this MDX parse tree node.append
(IdentifierSegment segment) Returns a new Identifier consisting of this one with another segment appended.deepCopy()
Creates a deep copy of this ParseTreeNode object.Returns the region of the source code which this node was created from, if it was created by parsing.Returns the list of segments which consistitute this identifier.getType()
Returns the type of this expression.static IdentifierNode
Converts an array of quoted name segments into an identifier.static IdentifierNode
parseIdentifier
(String identifier) Parses an MDX identifier string into anIdentifierNode
.toString()
void
unparse
(ParseTreeWriter writer) Converts this node into MDX text.
-
Constructor Details
-
IdentifierNode
Creates an identifier containing one or more segments.- Parameters:
segments
- Array of Segments, each consisting of a name and quoting style
-
IdentifierNode
Creates an identifier containing a list of segments.- Parameters:
segments
- List of segments
-
-
Method Details
-
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 interfaceParseTreeNode
- Returns:
- type of this expression
-
getSegmentList
Returns the list of segments which consistitute this identifier.- Returns:
- list of constituent segments
-
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 interfaceParseTreeNode
- Returns:
- Region of the source code this node was created from, if it was created by parsing
-
append
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
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 interfaceParseTreeNode
- Parameters:
visitor
- Visitor- Returns:
- T, the specific return type of the visitor
-
unparse
Description copied from interface:ParseTreeNode
Converts this node into MDX text.- Specified by:
unparse
in interfaceParseTreeNode
- Parameters:
writer
- Parse tree writer
-
toString
-
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 interfaceParseTreeNode
- Returns:
- The deep copy of this ParseTreeNode
-
parseIdentifier
Parses an MDX identifier string into anIdentifierNode
.It contains a list of
segments
, each of which is a name combined with a description of how the name wasquoted
. For example,
returns an IdentifierNode consisting of the following segments:parseIdentifier( "[Customers].USA.[South Dakota].[Sioux Falls].&[1245]")
- NameSegment("Customers", quoted=true),
- NameSegment("USA", quoted=false),
- NameSegment("South Dakota", quoted=true),
- NameSegment("Sioux Falls", quoted=true),
- KeySegment( { NameSegment("1245", quoted=true) } )
- Parameters:
identifier
- MDX identifier string- Returns:
- Identifier parse tree node
- Throws:
IllegalArgumentException
- if the format of the identifier is invalid- See Also:
-
ofNames
Converts an array of quoted name segments into an identifier.For example,
returns an IdentifierNode consisting of the following segments:IdentifierNode.ofNames("Store", "USA", "CA")
- NameSegment("Customers", quoted=true),
- NameSegment("USA", quoted=false),
- NameSegment("South Dakota", quoted=true),
- NameSegment("Sioux Falls", quoted=true),
- KeySegment( { NameSegment("1245", quoted=true) } )
- Parameters:
names
- Array of names- Returns:
- Identifier parse tree node
- See Also:
-