Class com.ibm.xml.xpointer.StringTerm
java.lang.Object
|
+----com.ibm.xml.xpointer.StringTerm
- public class StringTerm
- extends java.lang.Object
- implements OtherTerm, java.io.Serializable
The StringTerm class provides support for string location terms in XPointers.
Absolute and relative location terms have as their target one or more elements. In order
to allow text, CDATASections, comments, and PIs to be the target of an XPointer, the string
location term is provided.
A string term specifies a location in terms of another location, called the location
source. The location source is the entire resource if there are no preceding location
terms; otherwise it is the location specified by the preceding term (which might be
relative to a location term before that).
The string term has the single keyword string
which selects one or more
strings or positions between strings in the location source. The following arguments
may be passed on the string
keyword:
- InstanceOrAll: Identifies the nth occurrence of the specified string. For a positive
instance number, it counts right from the beginning of the location source. For a negative
instance number, it counts left from the end of the location source. For the value
all
,
all occurrences of the string are used as candidates in forming the designated resource.
- SkipLit: Identifies the candidate string to be found within the location source. A
null
SkipLit string is considered to identify the position immediately
preceding each character in the location source. For example, assuming that the element
with ID x37
contains the character string "Thomas", the following
XPointer identifies the position before the third character ("o"):
id(x37).string(3,"")
- Position: Identifies a character offset from the start of the candidate
string(s) to the beginning of the desired final string match. The position number may not
be zero; if omitted, it is assumed to be 1. A positive position number counts right from
the beginning of the specified string. A negative position number counts left from the end
of the string; for example, position -1 is the position immediately preceding the last
character in the match. A position value of
end
selects the position immediately
following the last character of the match.
- Length: Specifies the number of characters to be selected. A length of zero or an
omitted length references a precise point preceding the character indicated by Position.
- Version:
- Revision: 80 1.4 src/com/ibm/xml/xpointer/StringTerm.java, xml4jsrc, xml4j-jtcsv, xml4j_1_0_4
- See Also:
- XPointer, OtherTerm
Constructor Summary
|
StringTerm(boolean isAll,
int instance,
java.lang.String string,
boolean isPosition,
boolean isEnd,
int position,
int length)
Constructor for specifying length and for full customization.
|
StringTerm(int instance,
java.lang.String string,
int position)
Constructor for string(instance,"string",position) .
|
StringTerm(java.lang.String string,
int position)
Constructor for string(all,"string",position) .
|
StringTerm(int instance,
java.lang.String string,
boolean isEnd)
Constructor for string(instance,"string",end) .
|
StringTerm(java.lang.String string,
boolean isEnd)
Constructor for string(all,"string",end) .
|
StringTerm(int instance,
java.lang.String string)
Constructor for string(instance,"string") .
|
StringTerm(java.lang.String string)
Constructor for string(all,"string") .
|
Method Summary
|
int
|
getInstance()
Returns the nth occurrence of string to be used in forming the designated
resource.
|
int
|
getLength()
Returns the number of characters to be selected.
|
int
|
getPosition()
Returns the character offset from the start of the candidate string(s) to
the beginning of the desired final string match.
|
java.lang.String
|
getString()
Returns the candidate string to be found within the location source.
|
boolean
|
hasPosition()
Returns whether position is specified.
|
boolean
|
isAll()
Returns whether all occurrences of string are used as candidates in forming
the designated resource.
|
boolean
|
isEnd()
Returns whether to select the position immediately following the last character of
the match.
|
java.lang.String
|
toString()
Returns this string term in the form of either:
string(all,"string")
string(instance,"string")
string(all,"string",end)
string(instance,"string",end)
string(all,"string",position)
string(instance,"string",position)
string(all,"string",end,length)
string(instance,"string",end,length)
string(all,"string",position,length)
string(instance,"string",position,length)
|
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StringTerm
public StringTerm(boolean isAll,
int instance,
java.lang.String string,
boolean isPosition,
boolean isEnd,
int position,
int length)
- Constructor for specifying length and for full customization.
- Parameters:
isAll
- =true
if all occurrences of string are used
as candidates in forming the designated resource. If
=false
, instance should be specified.
instance
- Select the nth occurrence of string in forming the
designated resource. Only relevant if isAll=false
.
string
- The candidate string to be found within the location source.
=null
identifies the position immediately
preceding each character in the location source.
isPosition
- =true
if position is specified. If
=false
, isEnd, position,
and length are not relevant.
isEnd
- =true
, selects the position immediately
following the last character of the match. If =false
,
position should be specified.
position
- Character offset from the start of the candidate string(s) to
the beginning of the desired final string match. Only
relevant if isEnd=false
.
length
- Specifies the number of characters to be selected.
StringTerm
public StringTerm(int instance,
java.lang.String string,
int position)
- Constructor for
string(instance,"string",position)
.
- Parameters:
instance
- Select the nth occurrence of string in forming the
designated resource.
string
- The candidate string to be found within the location source.
=null
identifies the position immediately
preceding each character in the location source.
StringTerm
public StringTerm(java.lang.String string,
int position)
- Constructor for
string(all,"string",position)
.
- Parameters:
string
- The candidate string to be found within the location source.
=null
identifies the position immediately
preceding each character in the location source.
StringTerm
public StringTerm(int instance,
java.lang.String string,
boolean isEnd)
- Constructor for
string(instance,"string",end)
.
- Parameters:
instance
- Select the nth occurrence of string in forming the
designated resource.
string
- The candidate string to be found within the location source.
=null
identifies the position immediately
preceding each character in the location source.
isEnd
- Should be =true
for this constructor.
StringTerm
public StringTerm(java.lang.String string,
boolean isEnd)
- Constructor for
string(all,"string",end)
.
- Parameters:
string
- The candidate string to be found within the location source.
=null
identifies the position immediately
preceding each character in the location source.
isEnd
- Should be =true
for this constructor.
StringTerm
public StringTerm(int instance,
java.lang.String string)
- Constructor for
string(instance,"string")
.
- Parameters:
instance
- Select the nth occurrence of string in forming the
designated resource.
string
- The candidate string to be found within the location source.
=null
identifies the position immediately
preceding each character in the location source.
StringTerm
public StringTerm(java.lang.String string)
- Constructor for
string(all,"string")
.
- Parameters:
string
- The candidate string to be found within the location source.
=null
identifies the position immediately
preceding each character in the location source.
isAll
public boolean isAll()
- Returns whether all occurrences of string are used as candidates in forming
the designated resource.
- Returns:
=true
if all occurrences of string are used
as candidates in forming the designated resource. If
=false
, instance has relevance.- See Also:
- getInstance
getInstance
public int getInstance()
- Returns the nth occurrence of string to be used in forming the designated
resource. Only relevant if isAll
=false
.
- Returns:
- The nth occurrence of string in forming the designated.
resource.
- See Also:
- isAll
getString
public java.lang.String getString()
- Returns the candidate string to be found within the location source.
- Returns:
- The candidate string (excluding quotes) to be found within
the location source.
=null
identifies the
position immediately preceding each character in the location source.
hasPosition
public boolean hasPosition()
- Returns whether position is specified.
- Returns:
=true
if position is specified. If
=false
, isEnd, position,
and length are not relevant.- See Also:
- isEnd, getPosition, getLength
isEnd
public boolean isEnd()
- Returns whether to select the position immediately following the last character of
the match. Only relevant if hasPosition
=true
.
- Returns:
=true
, selects the position immediately
following the last character of the match.
If =false
, position is relevant.- See Also:
- hasPosition, getPosition, getLength
getPosition
public int getPosition()
- Returns the character offset from the start of the candidate string(s) to
the beginning of the desired final string match. Only relevant if
hasPosition
=true
and isEnd=false
.
- Returns:
- Character offset from the start of the candidate string(s) to
the beginning of the desired final string match.
- See Also:
- hasPosition, isEnd, getLength
getLength
public int getLength()
- Returns the number of characters to be selected. Only relevant if
hasPosition
=true
.
- Returns:
- The number of characters to be selected, or -1 when no length
is specified.
- See Also:
- hasPosition, isEnd, getPosition
toString
public java.lang.String toString()
- Returns this string term in the form of either:
string(all,"string")
string(instance,"string")
string(all,"string",end)
string(instance,"string",end)
string(all,"string",position)
string(instance,"string",position)
string(all,"string",end,length)
string(instance,"string",end,length)
string(all,"string",position,length)
string(instance,"string",position,length)
- Returns:
- A string represention of this string term.
- Overrides:
- toString in class java.lang.Object