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
public class One<T extends Item> extends ZeroOrOne<T>
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()
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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>
string(java.lang.String value)
Convenience function to create a singleton string valuestatic One<StringValue>
string(UnicodeString value)
Convenience function to create a singleton string value-
Methods 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 Detail
-
One
public One(T item)
Create an instance of the class- Parameters:
item
- The single item to be contained in the sequence. Must not be null.- Throws:
java.lang.NullPointerException
- if item is null.
-
-
Method Detail
-
bool
public static One<BooleanValue> bool(boolean value)
Convenience function to create a singleton boolean value- Parameters:
value
- the boolean value- Returns:
- the boolean value wrapped as a One<BooleanValue>
-
string
public static One<StringValue> string(java.lang.String value)
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
public static One<StringValue> string(UnicodeString value)
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
public static One<IntegerValue> integer(long value)
Convenience function to create a singleton integer value- Parameters:
value
- the integer value- Returns:
- the integer value wrapped as a One<IntegerValue>
-
dbl
public static One<DoubleValue> dbl(double value)
Convenience function to create a singleton double value- Parameters:
value
- the double value- Returns:
- the double value wrapped as a One<DoubleValue>
-
-