Class KeyBuilder.Key

java.lang.Object
org.simpleframework.xml.core.KeyBuilder.Key
Enclosing class:
KeyBuilder

private static class KeyBuilder.Key extends Object
The Key object represents an object that can be used in a hash container. The hashCode and the equals method will ensure that a label with the same XPath options will hash to the same position.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final KeyBuilder.KeyType
    This is the type of key that this represents.
    private final String
    This is the value that is used to provide the hash code.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the Key object.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    equals(Object value)
    This is used to compare keys and determine equality.
    boolean
    This is used to compare keys and determine equality.
    int
    This returns the hash code for the key.
    This returns the string representation of the key.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • type

      private final KeyBuilder.KeyType type
      This is the type of key that this represents.
    • value

      private final String value
      This is the value that is used to provide the hash code.
  • Constructor Details

    • Key

      public Key(KeyBuilder.KeyType type, String value) throws Exception
      Constructor for the Key object. This requires the label and a key type to create a unique key. The key type allows keys based on attributes to be differentiated from those created for elements.
      Parameters:
      type - this is the type that the key is created for
      value - this is the value used for the hash code
      Throws:
      Exception
  • Method Details

    • equals

      public boolean equals(Object value)
      This is used to compare keys and determine equality. If the key value is the same and the key type is the same then the key is considered equal, even if the labels are different.
      Overrides:
      equals in class Object
      Parameters:
      value - this is the value to compared to this
      Returns:
      this returns true if the object is equal
    • equals

      public boolean equals(KeyBuilder.Key key)
      This is used to compare keys and determine equality. If the key value is the same and the key type is the same then the key is considered equal, even if the labels are different.
      Parameters:
      key - this is the value to compared to this
      Returns:
      this returns true if the object is equal
    • hashCode

      public int hashCode()
      This returns the hash code for the key. The hash code is generated from the internal string the key represents.
      Overrides:
      hashCode in class Object
      Returns:
      this is the hash code generated from the value
    • toString

      public String toString()
      This returns the string representation of the key. This is used for debugging purposes in order to determine what the key was generated from.
      Overrides:
      toString in class Object
      Returns:
      this returns the string representation of the key