Class BinaryValue

java.lang.Object
net.sf.saxon.value.AtomicValue
net.sf.saxon.value.BinaryValue
All Implemented Interfaces:
Comparable<XPathComparable>, Iterable<AtomicValue>, AtomicMatchKey, XPathComparable, AtomicSequence, GroundedValue, IdentityComparable, Item, Sequence, ConversionResult
Direct Known Subclasses:
Base64BinaryValue, HexBinaryValue

public abstract class BinaryValue extends AtomicValue implements AtomicMatchKey, XPathComparable
A value of type xs:hexBinary or xs:base64Binary
  • Field Details

    • binaryValue

      protected final byte[] binaryValue
  • Constructor Details

    • BinaryValue

      protected BinaryValue(AtomicMetadata type, byte[] binaryValue)
  • Method Details

    • byteArrayHashCode

      protected static int byteArrayHashCode(byte[] value)
    • getBinaryValue

      public byte[] getBinaryValue()
      Get the binary value
      Returns:
      the binary value, as a byte array
    • getLengthInOctets

      public int getLengthInOctets()
      Get the number of octets in the value
      Returns:
      the number of octets (bytes) in the value
    • startsWith

      public boolean startsWith(byte[] bytes)
      Test whether the value starts with a given octet sequence
    • getXPathMatchKey

      public AtomicMatchKey getXPathMatchKey(StringCollator collator, int implicitTimezone, int specVersion)
      Description copied from class: AtomicValue
      Get an object value that implements the XPath equality comparison semantics for this value. A collation is supplied for comparing strings, and an implicit timezone for comparing date/time values that have no saved timezone. The returned object supports equality matching only, not ordering. An atomic value may return itself as its own AtomicMatchKey provided that its equality semantics are context-free.
      Specified by:
      getXPathMatchKey in class AtomicValue
      Parameters:
      collator - the collation to be used when comparing strings
      implicitTimezone - the implicit timezone in the dynamic context, used when comparing dates/times with and without timezone
      specVersion - the version of the XPath specification, typically 31 or 40
      Returns:
      an Object whose equals() and hashCode() methods implement the XPath comparison semantics with respect to this atomic value. If ordered is specified, the result will either be null if no ordering is defined, or will be a Comparable
    • asMapKey

      public AtomicMatchKey asMapKey(int specVersion)
      Description copied from class: AtomicValue
      Get a value whose equals() method follows the "same key" rules for comparing the keys of a map.
      Overrides:
      asMapKey in class AtomicValue
      Returns:
      a value with the property that the equals() and hashCode() methods follow the rules for comparing keys in maps.
    • getXPathComparable

      public XPathComparable getXPathComparable(StringCollator collator, int implicitTimezone, int specVersion)
      Get an object value that implements the XPath equality and ordering comparison semantics for this value. If the ordered parameter is set to true, the result will be a Comparable and will support a compareTo() method with the semantics of the XPath lt/gt operator, provided that the other operand is also obtained using the getXPathComparable() method. In all cases the result will support equals() and hashCode() methods that support the semantics of the XPath eq operator, again provided that the other operand is also obtained using the getXPathComparable() method. A context argument is supplied for use in cases where the comparison semantics are context-sensitive, for example where they depend on the implicit timezone or the default collation.
      Specified by:
      getXPathComparable in class AtomicValue
      Parameters:
      collator - collation to be used for comparing strings
      implicitTimezone - to be used for comparing dates/times with no timezone
      specVersion - the semantics of binary comparison change in XPath 4.0
      Returns:
      a key used for performing the comparison
    • equals

      public boolean equals(Object other)
      Test if the two hexBinary or Base64Binary values are equal. This implements the 4.0 semantics (hexBinary and base64Binary are comparable)
      Overrides:
      equals in class AtomicValue
      Parameters:
      other - the other value
      Returns:
      true (in a subclass) if the other operand is an atomic value and the two values are equal as defined by the XPath eq operator
    • hashCode

      public int hashCode()
      Description copied from class: AtomicValue
      Returns a hash code value for the object.
      Overrides:
      hashCode in class AtomicValue
    • compareTo

      public int compareTo(XPathComparable o)
      Specified by:
      compareTo in interface Comparable<XPathComparable>