ariba.util.core
Class ReferenceSyntaxParser
java.lang.Object
ariba.util.core.ReferenceSyntaxParser
public class ReferenceSyntaxParser
- extends java.lang.Object
This class provides methods to parse Strings that may contain
remote and/or local references.
The syntax is as follows: $$, where
'remoteReference' specifies a String that locates the remote
reference. This class does not interpret this String. It
merely parse a given input string for this substring and hands
it back to its caller for processing. It is illegal for this
reference string to contain the '^' scope delimiter or the
substring "$<" or ">$".
'alias' specifies a key whose value can be obtained from the
resource specified 'remoteReference'. Again, this class does
not interpret this string. It is illegal for this reference
string to contain the '^' scope delimiter or the substring "$<"
or ">$".
The carat (^) scope delimiter is optional. If absent, this
means there is no remote reference, and the substring
enclosed within the $<...>$ delimiters is a local alias.
Again, it is up to the caller to interpret the local alias.
Note that nested references are not supported.
Field Summary |
static java.lang.String |
BeginDelimiter
Indicates the beginning of the reference token. |
static java.lang.String |
EndDelimiter
Indicates the end of the reference token. |
static char |
RemoteRefDelimiter
Separates the remote reference from the alias key
Would like to use colon (':') but that is too popular
Don't want to confuse those tokenizers that tokenize
with the colon as delimiters. |
static java.lang.String |
RemoteRefDelimiterString
Separates the remote reference from the alias key,
represented as a String
Would like to use colon (':') but that is too popular
Don't want to confuse those tokenizers that tokenize
with the colon as delimiters. |
Method Summary |
int[] |
getNextReference(java.lang.String str)
Returns the interval of the specified string that denotes
a substring that begins and ends with the specified
delimiters that this class understands. |
java.lang.String[] |
getReferenceAndAlias(java.lang.String strWithDelimiters)
Return a array of String (of at most 2 elements) that specifies the
(optional) remote reference, and the alias key. |
static java.lang.String |
makeReferenceString(java.lang.String reference,
java.lang.String alias)
Creates a string with the correct syntax understood by this
class to specify a reference to a given reference/alias pair. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BeginDelimiter
public static final java.lang.String BeginDelimiter
- Indicates the beginning of the reference token.
- See Also:
- Constant Field Values
EndDelimiter
public static final java.lang.String EndDelimiter
- Indicates the end of the reference token.
- See Also:
- Constant Field Values
RemoteRefDelimiter
public static final char RemoteRefDelimiter
- Separates the remote reference from the alias key
Would like to use colon (':') but that is too popular
Don't want to confuse those tokenizers that tokenize
with the colon as delimiters.
- See Also:
- Constant Field Values
RemoteRefDelimiterString
public static final java.lang.String RemoteRefDelimiterString
- Separates the remote reference from the alias key,
represented as a String
Would like to use colon (':') but that is too popular
Don't want to confuse those tokenizers that tokenize
with the colon as delimiters.
- See Also:
- Constant Field Values
ReferenceSyntaxParser
public ReferenceSyntaxParser()
- Empty Constructor to instantiate this class
getNextReference
public int[] getNextReference(java.lang.String str)
- Returns the interval of the specified string that denotes
a substring that begins and ends with the specified
delimiters that this class understands.
- Parameters:
str
- the input string that may contain 0 or more
subsequences that begin and end with the specified delimiters
that this class understands. If it is null or blank or empty,
just return null.
- Returns:
- an int array (i, j) of 2 integers. The first element
points to the position in the given str where the beginning
delmiter starts, in this case, str[i] == '$', str[i+1] ==
'<'. The second elements points to the position one past the
first occurrence of the end delimiter, in this case, str[j-2]
= '>', str[j-1] = '$'. Clearly, i > j. Returns null if
no such interval can be found.
Examples:
getNextReference("noReference") return null
getNextReference(">$xx$$yy") return (4, 13)
getNextReference("xx$$yy") return (2, 11)
getNextReference("x$$yy") return (2, 13)
getNextReference("$<>$") return (0,4), note that in this case
it is up to the caller to handler the empty string contained
by the delimiters.
getReferenceAndAlias
public java.lang.String[] getReferenceAndAlias(java.lang.String strWithDelimiters)
- Return a array of String (of at most 2 elements) that specifies the
(optional) remote reference, and the alias key.
- Parameters:
strWithDelimiters
- is a string that begins with
BeginDelimiter and ends with EndDelimiter.
- Returns:
- string array of 2 elements (all stripped of any delimiters):
Element 0: specifies the id to locate the reference resource. Note that
this can be null, which means that the next element (see below) refers
to a local alias.
Element 1: specifies the alias to be resolved by the reference specified
by element 0.
Note that the elements can contain empty or blank Strings. It is up to the
caller to decide if the contents of the String elements make sense.
makeReferenceString
public static java.lang.String makeReferenceString(java.lang.String reference,
java.lang.String alias)
- Creates a string with the correct syntax understood by this
class to specify a reference to a given reference/alias pair.
This created String can later be passed back as arguments
to the getNextReference or getReferenceAndAlias methods for
processing by possibly another component.
- Parameters:
reference
- the reference. Cannot contain the
carat ('^') character, or the ">$" or "$>" substrings. A
value of null designates local reference.alias
- the alias, cannot be null. Cannot contain the
carat ('^') character, or the ">$" or "$>" substrings.
- Returns:
- a reference String of the right syntax understood by
this class.
AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.