Package org.simpleframework.xml.core
Class KeyBuilder.Key
- java.lang.Object
-
- org.simpleframework.xml.core.KeyBuilder.Key
-
- Enclosing class:
- KeyBuilder
private static class KeyBuilder.Key extends java.lang.Object
TheKey
object represents an object that can be used in a hash container. ThehashCode
and theequals
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 KeyBuilder.KeyType
type
This is the type of key that this represents.private java.lang.String
value
This is the value that is used to provide the hash code.
-
Constructor Summary
Constructors Constructor Description Key(KeyBuilder.KeyType type, java.lang.String value)
Constructor for theKey
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object value)
This is used to compare keys and determine equality.boolean
equals(KeyBuilder.Key key)
This is used to compare keys and determine equality.int
hashCode()
This returns the hash code for the key.java.lang.String
toString()
This returns the string representation of the key.
-
-
-
Field Detail
-
type
private final KeyBuilder.KeyType type
This is the type of key that this represents.
-
value
private final java.lang.String value
This is the value that is used to provide the hash code.
-
-
Constructor Detail
-
Key
public Key(KeyBuilder.KeyType type, java.lang.String value) throws java.lang.Exception
Constructor for theKey
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 forvalue
- this is the value used for the hash code- Throws:
java.lang.Exception
-
-
Method Detail
-
equals
public boolean equals(java.lang.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 classjava.lang.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 classjava.lang.Object
- Returns:
- this is the hash code generated from the value
-
toString
public java.lang.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 classjava.lang.Object
- Returns:
- this returns the string representation of the key
-
-