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().

  • Constructor Details

    • 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:
      NullPointerException - if item is null.
  • Method Details

    • 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(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>