Package org.eclipse.jetty.util
Class Fields
- java.lang.Object
-
- org.eclipse.jetty.util.Fields
-
- All Implemented Interfaces:
Iterable<Fields.Field>
public class Fields extends Object implements Iterable<Fields.Field>
A container for name/value pairs, known as fields.
A
Fields.Fieldis 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFields.FieldA named list of string values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(String name, String value)Adds the given value to a field with the given name, creating aFields.Fieldis none exists for the given name.voidclear()Empties thisFieldsinstance from all fieldsbooleanequals(Object obj)Fields.Fieldget(String name)Set<String>getNames()intgetSize()inthashCode()booleanisEmpty()Iterator<Fields.Field>iterator()voidput(String name, String value)Inserts or replaces the given name/value pair as a single-valuedFields.Field.voidput(Fields.Field field)Inserts or replaces the givenFields.Field, mapped to thefield's nameFields.Fieldremove(String name)Removes theFields.Fieldwith the given nameStringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
Fields
public Fields()
Creates an empty, modifiable, case insensitive
Fieldsinstance.- See Also:
Fields(Fields, boolean)
-
Fields
public Fields(boolean caseSensitive)
Creates an empty, modifiable, case insensitive
Fieldsinstance.- Parameters:
caseSensitive- whether thisFieldsinstance must be case sensitive- See Also:
Fields(Fields, boolean)
-
-
Method Detail
-
get
public Fields.Field get(String name)
- Parameters:
name- the field name- Returns:
- the
Fields.Fieldwith the given name, or null if no such field exists
-
put
public void put(String name, String value)
Inserts or replaces the given name/value pair as a single-valued
Fields.Field.- Parameters:
name- the field namevalue- the field value
-
put
public void put(Fields.Field field)
Inserts or replaces the given
Fields.Field, mapped to thefield's name- Parameters:
field- the field to put
-
add
public void add(String name, String value)
Adds the given value to a field with the given name, creating a
Fields.Fieldis none exists for the given name.- Parameters:
name- the field namevalue- the field value to add
-
remove
public Fields.Field remove(String name)
Removes the
Fields.Fieldwith the given name- Parameters:
name- the name of the field to remove- Returns:
- the removed field, or null if no such field existed
-
isEmpty
public boolean isEmpty()
- Returns:
- whether this
Fieldsinstance is empty
-
getSize
public int getSize()
- Returns:
- the number of fields
-
iterator
public Iterator<Fields.Field> iterator()
- Specified by:
iteratorin interfaceIterable<Fields.Field>- Returns:
- an iterator over the
Fields.Fields present in this instance
-
-