public class Attributes extends Object implements Iterable<Attribute>, Cloneable
Attributes are treated as a map: there can be only one value associated with an attribute key/name.
Attribute name and value comparisons are generally case sensitive. By default for HTML, attribute names are normalized to lower-case on parsing. That means you should use lower-case strings when referring to attributes by name.
Modifier and Type | Class and Description |
---|---|
private static class |
Attributes.Dataset |
Modifier and Type | Field and Description |
---|---|
protected static String |
dataPrefix |
private static String[] |
Empty |
private static String |
EmptyString |
private static int |
GrowthFactor |
private static int |
InitialCapacity |
(package private) String[] |
keys |
(package private) static int |
NotFound |
private int |
size |
(package private) String[] |
vals |
Constructor and Description |
---|
Attributes() |
Modifier and Type | Method and Description |
---|---|
private void |
add(String key,
String value) |
void |
addAll(Attributes incoming)
Add all the attributes from the incoming set to this set.
|
List<Attribute> |
asList()
Get the attributes as a List, for iteration.
|
private void |
checkCapacity(int minNewSize) |
(package private) static String |
checkNotNull(String val) |
Attributes |
clone() |
private static String[] |
copyOf(String[] orig,
int size) |
private static String |
dataKey(String key) |
Map<String,String> |
dataset()
Retrieves a filtered view of attributes that are HTML5 custom data attributes; that is, attributes with keys
starting with
data- . |
boolean |
equals(Object o)
Checks if these attributes are equal to another set of attributes, by comparing the two sets
|
String |
get(String key)
Get an attribute value by key.
|
String |
getIgnoreCase(String key)
Get an attribute's value by case-insensitive key
|
int |
hashCode()
Calculates the hashcode of these attributes, by iterating all attributes and summing their hashcodes.
|
boolean |
hasKey(String key)
Tests if these attributes contain an attribute with this key.
|
boolean |
hasKeyIgnoreCase(String key)
Tests if these attributes contain an attribute with this key.
|
String |
html()
Get the HTML representation of these attributes.
|
(package private) void |
html(Appendable accum,
Document.OutputSettings out) |
(package private) int |
indexOfKey(String key) |
private int |
indexOfKeyIgnoreCase(String key) |
Iterator<Attribute> |
iterator() |
void |
normalize()
Internal method.
|
Attributes |
put(Attribute attribute)
Set a new attribute, or replace an existing one by key.
|
Attributes |
put(String key,
boolean value)
Set a new boolean attribute, remove attribute if value is false.
|
Attributes |
put(String key,
String value)
Set a new attribute, or replace an existing one by key.
|
(package private) void |
putIgnoreCase(String key,
String value) |
private void |
remove(int index) |
void |
remove(String key)
Remove an attribute by key.
|
void |
removeIgnoreCase(String key)
Remove an attribute by key.
|
int |
size()
Get the number of attributes in this set.
|
String |
toString() |
finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected static final String dataPrefix
private static final int InitialCapacity
private static final int GrowthFactor
static final int NotFound
private static final String EmptyString
private int size
public Attributes()
private void checkCapacity(int minNewSize)
int indexOfKey(String key)
private int indexOfKeyIgnoreCase(String key)
static String checkNotNull(String val)
public String get(String key)
key
- the (case-sensitive) attribute keyhasKey(String)
public String getIgnoreCase(String key)
key
- the attribute namepublic Attributes put(String key, String value)
key
- case sensitive attribute keyvalue
- attribute valuevoid putIgnoreCase(String key, String value)
public Attributes put(String key, boolean value)
key
- case insensitive attribute keyvalue
- attribute valuepublic Attributes put(Attribute attribute)
attribute
- attribute with case sensitive keyprivate void remove(int index)
public void remove(String key)
key
- attribute key to removepublic void removeIgnoreCase(String key)
key
- attribute key to removepublic boolean hasKey(String key)
key
- case-sensitive key to check forpublic boolean hasKeyIgnoreCase(String key)
key
- key to check forpublic int size()
public void addAll(Attributes incoming)
incoming
- attributes to add to these attributes.public List<Attribute> asList()
public Map<String,String> dataset()
data-
.public String html()
SerializationException
- if the HTML representation of the attributes cannot be constructed.final void html(Appendable accum, Document.OutputSettings out) throws IOException
IOException
public boolean equals(Object o)
public int hashCode()
public Attributes clone()
public void normalize()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses