Package net.sf.saxon.om
Class One<T extends Item>
java.lang.Object
net.sf.saxon.om.ZeroOrOne<T>
net.sf.saxon.om.One<T>
- All Implemented Interfaces:
GroundedValue
,Sequence
A sequence containing exactly one item. The main use of this class is in declaring the expected arguments
of reflexive method calls, where the use of One(T) rather than T emphasizes that the value must not be null/empty,
and generates type-checking code to ensure that it is not empty.
To extract the wrapped item, use ZeroOrOne.head()
.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic One
<BooleanValue> bool
(boolean value) Convenience function to create a singleton boolean valuestatic One
<DoubleValue> dbl
(double value) Convenience function to create a singleton double valuestatic One
<IntegerValue> integer
(long value) Convenience function to create a singleton integer valuestatic One
<StringValue> Convenience function to create a singleton string valuestatic One
<StringValue> string
(UnicodeString value) Convenience function to create a singleton string valueMethods inherited from class net.sf.saxon.om.ZeroOrOne
effectiveBooleanValue, empty, getLength, getStringValue, getUnicodeStringValue, head, itemAt, iterate, reduce, subsequence, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, materialize, toShortString
Methods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Constructor Details
-
One
Create an instance of the class- Parameters:
item
- The single item to be contained in the sequence. Must not be null.- Throws:
NullPointerException
- if item is null.
-
-
Method Details
-
bool
Convenience function to create a singleton boolean value- Parameters:
value
- the boolean value- Returns:
- the boolean value wrapped as a One<BooleanValue>
-
string
Convenience function to create a singleton string value- Parameters:
value
- the string value.. If null, the result will represent a zero-length string- Returns:
- the string value wrapped as a One<StringValue>
-
string
Convenience function to create a singleton string value- Parameters:
value
- the string value.. If null, the result will represent a zero-length string- Returns:
- the string value wrapped as a One<StringValue>
-
integer
Convenience function to create a singleton integer value- Parameters:
value
- the integer value- Returns:
- the integer value wrapped as a One<IntegerValue>
-
dbl
Convenience function to create a singleton double value- Parameters:
value
- the double value- Returns:
- the double value wrapped as a One<DoubleValue>
-