public class StringValue extends AtomicValue
Internally the value is held as a wrapper around a UnicodeString, which allows
a variety of implementations
The equals and compareTo methods support ordering in codepoint
collation sequence.
| Modifier and Type | Class and Description |
|---|---|
static class |
StringValue.Builder |
static class |
StringValue.CharacterIterator
CharacterIterator is used to iterate over the characters in a string,
returning them as integers representing the Unicode code-point.
|
| Modifier and Type | Field and Description |
|---|---|
protected UnicodeString |
content |
static StringValue |
EMPTY_STRING |
static StringValue |
FALSE |
static StringValue |
SINGLE_SPACE |
static StringValue |
TRUE |
static StringValue |
ZERO_LENGTH_UNTYPED |
typeLabel| Modifier | Constructor and Description |
|---|---|
protected |
StringValue()
Protected constructor for use by subtypes
|
|
StringValue(java.lang.String value)
Constructor from String.
|
|
StringValue(java.lang.String value,
AtomicType typeLabel)
Constructor from String.
|
|
StringValue(UnicodeString content)
Construct an instance that wraps a supplied
UnicodeString, with the default
type xs:string |
|
StringValue(UnicodeString content,
AtomicType type)
Construct an instance that wraps a supplied
UnicodeString, with a supplied atomic type |
| Modifier and Type | Method and Description |
|---|---|
static StringValue |
bmp(java.lang.String content)
Construct a StringValue whose content is known to consist entirely of BMP characters
(codepoints less than 65536, with no surrogate pairs)
|
IntIterator |
codePoints()
Get an iterator over the Unicode codepoints in the value.
|
StringValue |
copyAsSubType(AtomicType typeLabel)
Create a copy of this atomic value, with a different type label
|
boolean |
effectiveBooleanValue()
Get the effective boolean value of a string
|
boolean |
equals(java.lang.Object o)
Test whether this StringValue is equal to another under the rules of the codepoint collation.
|
Base64BinaryValue |
getCodepointCollationKey()
Get an atomic value that encapsulates this match key.
|
UnicodeString |
getContent()
Get the content of this
StringItem |
UnicodeString |
getPrimitiveStringValue()
Convert the value to a string, using the serialization rules for the primitive type.
|
BuiltInAtomicType |
getPrimitiveType()
Determine the primitive type of the value.
|
UnicodeString |
getUnicodeStringValue()
Get the value of the item as a UnicodeString.
|
XPathComparable |
getXPathComparable(StringCollator collator,
int implicitTimezone)
Get an object value that implements the XPath equality and ordering comparison semantics for this value.
|
AtomicMatchKey |
getXPathMatchKey(StringCollator collator,
int implicitTimezone)
Get an object value that implements the XPath equality and ordering comparison semantics for this value.
|
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isEmpty()
Determine whether the string is a zero-length string.
|
boolean |
isIdentical(AtomicValue v)
Determine whether two atomic values are identical, as determined by XML Schema rules.
|
AtomicIterator |
iterateCharacters()
Iterate over a string, returning a sequence of integers representing the Unicode code-point values
|
long |
length()
Get the length of this string, in code points
|
int |
length32()
Get the length of this string, in code points
|
static StringValue |
makeStringValue(java.lang.CharSequence value)
Factory method.
|
static StringValue |
makeUntypedAtomic(UnicodeString value)
Factory method for untyped atomic values
|
static StringValue |
makeUStringValue(UnicodeString value) |
java.lang.String |
toShortString()
Provide a short string showing the contents of the item, suitable
for use in error messages
|
java.lang.String |
toString()
Display as a string.
|
asAtomic, asMapKey, atomize, checkPermittedContents, checkValidInJavascript, getCanonicalLexicalRepresentation, getCardinality, getComponent, getGenre, getItemType, getLength, getUType, head, identityHashCode, isIdentical, isNaN, isUntypedAtomic, itemAt, iterate, iterator, setTypeLabel, showclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetStringValue, isStreamed, reduce, subsequenceasIterable, concatenate, containsNode, materializemakeRepeatableprotected UnicodeString content
public static final StringValue EMPTY_STRING
public static final StringValue SINGLE_SPACE
public static final StringValue TRUE
public static final StringValue FALSE
public static final StringValue ZERO_LENGTH_UNTYPED
protected StringValue()
public StringValue(UnicodeString content)
UnicodeString, with the default
type xs:stringcontent - the UnicodeString to wrappublic StringValue(UnicodeString content, AtomicType type)
UnicodeString, with a supplied atomic typecontent - the UnicodeString to wraptype - the requested atomic typepublic StringValue(java.lang.String value)
value - the String value.public StringValue(java.lang.String value,
AtomicType typeLabel)
value - the String value.typeLabel - the type of the value to be created. The caller must ensure that this is
a type derived from xs:string and that the string is valid against this type.public static StringValue makeUntypedAtomic(UnicodeString value)
value - the string valuepublic StringValue copyAsSubType(AtomicType typeLabel)
copyAsSubType in class AtomicValuetypeLabel - the type label of the new copy. The caller is responsible for checking that
the value actually conforms to this type.public static StringValue bmp(java.lang.String content)
content - the content of the string, which the caller guarantees to contain
no surrogate pairspublic BuiltInAtomicType getPrimitiveType()
getPrimitiveType in class AtomicValuepublic static StringValue makeStringValue(java.lang.CharSequence value)
value - the String value. Null is taken as equivalent to "".public static StringValue makeUStringValue(UnicodeString value)
public UnicodeString getPrimitiveStringValue()
AtomicValuegetPrimitiveStringValue in class AtomicValuepublic UnicodeString getContent()
StringItempublic long length()
public int length32()
java.lang.UnsupportedOperationException - if the string contains more than 2^31 code pointspublic boolean isEmpty()
public AtomicIterator iterateCharacters()
public AtomicMatchKey getXPathMatchKey(StringCollator collator, int implicitTimezone)
getXPathMatchKey in class AtomicValuecollator - Collation to be used for comparing stringsimplicitTimezone - the XPath dynamic evaluation context, used in cases where the comparison is context
sensitivepublic Base64BinaryValue getCodepointCollationKey()
public IntIterator codePoints()
public int hashCode()
AtomicValuehashCode in class AtomicValuepublic boolean equals(java.lang.Object o)
equals in class AtomicValueo - the value to be compared with this valuepublic boolean effectiveBooleanValue()
effectiveBooleanValue in interface GroundedValueeffectiveBooleanValue in class AtomicValuepublic java.lang.String toString()
toString in class AtomicValuegetUnicodeStringValue()public UnicodeString getUnicodeStringValue()
AtomicValuegetUnicodeStringValue in interface AtomicSequencegetUnicodeStringValue in interface GroundedValuegetUnicodeStringValue in interface ItemgetUnicodeStringValue in class AtomicValuepublic java.lang.String toShortString()
ItemtoShortString in interface GroundedValuetoShortString in interface ItemtoShortString in class AtomicValuepublic XPathComparable getXPathComparable(StringCollator collator, int implicitTimezone) throws NoDynamicContextException
AtomicValuegetXPathComparable in class AtomicValuecollator - the collation to be used when comparing stringsimplicitTimezone - the implicit timezone in the dynamic context, used when comparing
dates/times with and without timezoneNoDynamicContextException - if the supplied implicit timezone is "NO_TIMEZONE" (meaning
unknown), and the implicit timezone is actually required because the value in question is a date/time
value with no timezone. This can cause a failure to evaluate expressions statically (because the implicit
timezone is not known statically), and it will then be caught, meaning that the expression has to be
evaluated dynamically.public boolean isIdentical(AtomicValue v)
Note that even this check ignores the type annotation of the value. The integer 3 and the short 3 are considered identical, even though they are not fully interchangeable. "Identical" means the same point in the value space, regardless of type annotation.
NaN is identical to itself.
isIdentical in class AtomicValuev - the other value to be compared with this oneCopyright (c) 2004-2022 Saxonica Limited. All rights reserved.