Methods Summary |
---|
public java.lang.Object | clone()Makes a copy of the current instance.
NameValue retval = new NameValue();
retval.separator = this.separator;
retval.isQuotedString = this.isQuotedString;
retval.quotes = this.quotes;
retval.name = this.name;
if (value != null && value instanceof GenericObject) {
retval.value = ((GenericObject)this.value).clone();
} else retval.value = this.value;
return retval;
|
public java.lang.String | encode()Gets the encoded representation of this namevalue object.
Added doublequote for encoding doublequoted values
if (name != null && value != null) {
return name + separator + quotes +
value.toString() + quotes;
} else if (name == null && value != null) {
return quotes + value.toString() + quotes;
} else if (name != null && value == null) {
return name;
} else return "";
|
public boolean | equals(java.lang.Object other)Equality comparison predicate.
if (! other.getClass().equals(this.getClass()))
return false;
NameValue that = (NameValue) other;
if (this == that)
return true;
if (this.name == null && that.name != null ||
this.name != null && that.name == null) return false;
if (this.name != null && that.name != null &&
this.name.toLowerCase().compareTo
(that.name.toLowerCase()) != 0)
return false;
if (this.value != null && that.value == null ||
this.value == null && that.value != null)
return false;
if (this.value == that.value)
return true;
if (value instanceof String) {
// Quoted string comparisions are case sensitive.
if (isQuotedString)
return this.value.equals(that.value);
String val = (String) this.value;
String val1 = (String) that.value;
return val.toLowerCase().
equals(val1.toLowerCase());
} else return this.value.equals(that.value);
|
public java.lang.String | getName()Gets the name.
return name;
|
public java.lang.Object | getUnquotedValue()Gets the unquoted value.
return value;
|
public java.lang.Object | getValue()Gets the value.
if (isValueQuoted()) {
return "\"" + value + "\"";
} else {
return value;
}
|
public boolean | isValueQuoted()Returns true if the value is quoted in doublequotes.
return isQuotedString;
|
public void | setName(java.lang.String n)Sets the name member.
name = n;
|
public void | setQuotedValue()Sets the type of the field to be a quoted string.
A flag that indicates that doublequotes should be put around the
value when encoded
(for example name=value when value is doublequoted).
isQuotedString = true;
this.quotes = Separators.DOUBLE_QUOTE;
|
public void | setSeparator(java.lang.String sep)Sets the separator for the encoding method below.
separator = sep;
|
public void | setValue(java.lang.Object v)Sets the value member.
value = v;
if (value != null) {
if (value instanceof String) {
String str = (String)value;
if (str.startsWith("\"") && str.endsWith("\"")) {
setQuotedValue();
str = str.substring(1, str.length() - 1);
value = (Object)str;
}
}
}
|
public java.lang.String | toString()Converts the contents to a string.
return this.encode();
|