public class NameValue extends Data implements java.lang.Comparable
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
name
stores the name of the pair.
|
private java.lang.String |
value
stores the corresponding value to the name in the pair.
|
Constructor and Description |
---|
NameValue()
the default constructor which initialises the class member variables.
|
NameValue(java.lang.String name,
java.lang.String value)
Initialises the class member variables to the values passed in the
arguments.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a copy of this object
|
int |
compareTo(java.lang.Object o)
Implementation of the
Comparable interface. |
java.lang.String |
getKey()
Returns the key associated with this tuple.
|
java.lang.String |
getValue()
Returns the value associated with this tuple.
|
void |
setKey(java.lang.String key)
Sets the key associated with this tuple.
|
void |
setValue(java.lang.String value)
Sets the value associated with this tuple.
|
java.lang.String |
toString()
Writes out the contents of the class to a String
in form suitable for displaying.
|
setToString, vectorToString
private java.lang.String name
private java.lang.String value
public NameValue()
public NameValue(java.lang.String name, java.lang.String value)
name
- corresponds to the name in the NameValue pair.value
- corresponds to the value for the name in the NameValue pair.public void setKey(java.lang.String key)
key
- the key associated with the tuple.public void setValue(java.lang.String value)
value
- the value associated with the tuple.public java.lang.String getKey()
public java.lang.String getValue()
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
public int compareTo(java.lang.Object o)
Comparable
interface.
Compares this object with the specified object for order. Returns a
negative integer, zero, or a positive integer as this object is
less than, equal to, or greater than the specified object. The
NameValue are compared by their keys.compareTo
in interface java.lang.Comparable
o
- is the object to be comparedjava.lang.ClassCastException
- if the specified object's type
prevents it from being compared to this Object.