public class NameValue extends Data implements Comparable
Modifier and Type | Field and Description |
---|---|
private String |
name
stores the name of the pair.
|
private 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(String name,
String value)
Initialises the class member variables to the values passed in the
arguments.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Returns a copy of this object
|
int |
compareTo(Object o)
Implementation of the
Comparable interface. |
String |
getKey()
Returns the key associated with this tuple.
|
String |
getValue()
Returns the value associated with this tuple.
|
void |
setKey(String key)
Sets the key associated with this tuple.
|
void |
setValue(String value)
Sets the value associated with this tuple.
|
String |
toString()
Writes out the contents of the class to a String
in form suitable for displaying.
|
setToString, vectorToString
private String name
private String value
public NameValue()
public void setKey(String key)
key
- the key associated with the tuple.public void setValue(String value)
value
- the value associated with the tuple.public String getKey()
public String getValue()
public Object clone()
public String toString()
public int compareTo(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 Comparable
o
- is the object to be comparedClassCastException
- if the specified object's type
prevents it from being compared to this Object.Copyright © 2011 The University of Southern California. All Rights Reserved.