Package org.eclipse.jetty.util
Class Fields
- java.lang.Object
-
- org.eclipse.jetty.util.Fields
-
- All Implemented Interfaces:
java.lang.Iterable<Fields.Field>
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Fields.Field
A named list of string values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.String name, java.lang.String value)
Adds the given value to a field with the given name, creating aFields.Field
is none exists for the given name.void
clear()
Empties thisFields
instance from all fieldsboolean
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(java.lang.String name, java.lang.String value)
Inserts or replaces the given name/value pair as a single-valuedFields.Field
.void
put(Fields.Field field)
Inserts or replaces the givenFields.Field
, mapped to thefield's name
Fields.Field
remove(java.lang.String name)
Removes theFields.Field
with the given namejava.lang.String
toString()
-
-
-
Constructor Detail
-
Fields
public Fields()
Creates an empty, modifiable, case insensitive
Fields
instance.- See Also:
Fields(Fields, boolean)
-
Fields
public Fields(boolean caseSensitive)
Creates an empty, modifiable, case insensitive
Fields
instance.- Parameters:
caseSensitive
- whether thisFields
instance must be case sensitive- See Also:
Fields(Fields, boolean)
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getNames
public java.util.Set<java.lang.String> getNames()
- Returns:
- a set of field names
-
get
public Fields.Field get(java.lang.String name)
- Parameters:
name
- the field name- Returns:
- the
Fields.Field
with the given name, or null if no such field exists
-
put
public void put(java.lang.String name, java.lang.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(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.- Parameters:
name
- the field namevalue
- the field value to add
-
remove
public Fields.Field remove(java.lang.String name)
Removes the
Fields.Field
with 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
Fields
instance is empty
-
getSize
public int getSize()
- Returns:
- the number of fields
-
iterator
public java.util.Iterator<Fields.Field> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<Fields.Field>
- Returns:
- an iterator over the
Fields.Field
s present in this instance
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-