public class Fields extends java.lang.Object implements java.lang.Iterable<Fields.Field>
A container for name/value pairs, known as fields.
A Fields.Field
is composed of a name string that can be case-sensitive
or case-insensitive (by specifying the option at the constructor) and
of a case-sensitive set of value strings.
The implementation of this class is not thread safe.
Modifier and Type | Class and Description |
---|---|
static class |
Fields.Field
A named list of string values.
|
Constructor and Description |
---|
Fields()
Creates an empty, modifiable, case insensitive
Fields instance. |
Fields(boolean caseSensitive)
Creates an empty, modifiable, case insensitive
Fields instance. |
Fields(Fields original,
boolean immutable)
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String name,
java.lang.String value)
Adds the given value to a field with the given name,
creating a
Fields.Field is none exists for the given name. |
void |
clear()
Empties this
Fields instance from all fields |
boolean |
equals(java.lang.Object obj) |
Fields.Field |
get(java.lang.String name) |
java.util.Set<java.lang.String> |
getNames() |
int |
getSize() |
int |
hashCode() |
boolean |
isEmpty() |
java.util.Iterator<Fields.Field> |
iterator() |
void |
put(Fields.Field field)
Inserts or replaces the given
Fields.Field , mapped to the field's name |
void |
put(java.lang.String name,
java.lang.String value)
Inserts or replaces the given name/value pair as a single-valued
Fields.Field . |
Fields.Field |
remove(java.lang.String name)
Removes the
Fields.Field with the given name |
java.lang.String |
toString() |
public Fields()
Creates an empty, modifiable, case insensitive Fields
instance.
Fields(Fields, boolean)
public Fields(boolean caseSensitive)
Creates an empty, modifiable, case insensitive Fields
instance.
caseSensitive
- whether this Fields
instance must be case sensitiveFields(Fields, boolean)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.util.Set<java.lang.String> getNames()
public Fields.Field get(java.lang.String name)
name
- the field nameFields.Field
with the given name, or null if no such field existspublic void put(java.lang.String name, java.lang.String value)
Inserts or replaces the given name/value pair as a single-valued Fields.Field
.
name
- the field namevalue
- the field valuepublic void put(Fields.Field field)
Inserts or replaces the given Fields.Field
, mapped to the field's name
field
- the field to putpublic void add(java.lang.String name, java.lang.String value)
Adds the given value to a field with the given name,
creating a Fields.Field
is none exists for the given name.
name
- the field namevalue
- the field value to addpublic Fields.Field remove(java.lang.String name)
Removes the Fields.Field
with the given name
name
- the name of the field to removepublic boolean isEmpty()
Fields
instance is emptypublic int getSize()
public java.util.Iterator<Fields.Field> iterator()
iterator
in interface java.lang.Iterable<Fields.Field>
Fields.Field
s present in this instancepublic java.lang.String toString()
toString
in class java.lang.Object
Copyright © 1995–2023 Webtide. All rights reserved.