public class MapAttributes extends Object implements Attributes
Attributes.Entry, Attributes.SetEntry
EMPTY
Constructor and Description |
---|
MapAttributes()
Construct an instance using a hash map for backing store.
|
MapAttributes(Attributes original)
Construct a new instance copying mappings from an original attributes collection.
|
MapAttributes(Map<String,? extends Collection<String>> original)
Construct a new instance copying mappings from an original map.
|
Modifier and Type | Method and Description |
---|---|
void |
add(String key,
int idx,
String value)
Add a mapping for the given key at the given position.
|
void |
addFirst(String key,
String value)
Add a value before the first mapping for the given key.
|
void |
addLast(String key,
String value)
Add a value after the last mapping for the given key.
|
void |
clear()
Clear this collection, resetting its size to zero.
|
boolean |
containsKey(String key)
Determine if the given key has values in this collection.
|
boolean |
containsValue(String key,
String value)
Determine if the given key has a mapping for the given value in this collection.
|
List<String> |
copyAndRemove(String key)
Remove all values for the given key from this collection, copying the values into a list which is returned.
|
List<String> |
copyAndReplace(String key,
Collection<String> values)
Replace the mapping for the given key with the values copied from the given collection.
|
Collection<Attributes.Entry> |
entries()
Get the entry collection.
|
Attributes.Entry |
get(String key)
Get the collection of values for the given key.
|
String |
get(String key,
int idx)
Get the mapping for the given key at the given position.
|
String |
getFirst(String key)
Get the first value mapped to the given key.
|
String |
getLast(String key)
Get the last value mapped to the given key.
|
int |
indexOf(String key,
String value)
Get the index of the first occurrence of the given value at the given key, if any.
|
boolean |
isEmpty()
Determine if this collection is empty.
|
Set<String> |
keySet()
Get a set comprised of all the keys in this collection.
|
int |
lastIndexOf(String key,
String value)
Get the index of the last occurrence of the given value at the given key, if any.
|
boolean |
remove(String key)
Remove all values for the given key from this collection.
|
String |
remove(String key,
int idx)
Remove and return the mapping for the given key at the given position.
|
boolean |
remove(String key,
int idx,
String value)
Remove the mapping for the given key at the given position if it matches the given existing value.
|
boolean |
removeAll(String key,
String value)
Remove the all occurrences of the given value under the given key, if any.
|
String |
removeFirst(String key)
Remove the first value mapped to the given key.
|
boolean |
removeFirst(String key,
String value)
Remove the first occurrence of the given value under the given key, if any.
|
String |
removeLast(String key)
Remove the last value mapped to the given key.
|
boolean |
removeLast(String key,
String value)
Remove the last occurrence of the given value under the given key, if any.
|
void |
removeRange(String key,
int from,
int to)
Remove all the values for the given key between the
from index (inclusive) and the to index
(exclusive). |
String |
set(String key,
int idx,
String value)
Modify the mapping for the given key at the given position.
|
boolean |
set(String key,
int idx,
String expect,
String update)
Conditionally set a specific value of a given key to a new value, if the existing value matches the
expect
parameter. |
int |
size()
Get the number of keys in this attribute collection.
|
int |
size(String key)
Get the number of values mapped to the given key.
|
Collection<String> |
values()
Get all the values of all the keys in this collection.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addAll, addAll, asReadOnly
public MapAttributes()
public MapAttributes(Map<String,? extends Collection<String>> original)
original
- the original mappublic MapAttributes(Attributes original)
original
- the original collectionpublic Set<String> keySet()
Attributes
keySet
in interface Attributes
null
)public Collection<String> values()
Attributes
values
in interface Attributes
null
)public Collection<Attributes.Entry> entries()
Attributes
entries
in interface Attributes
public int size(String key)
Attributes
size
in interface Attributes
key
- the keypublic boolean remove(String key)
Attributes
remove
in interface Attributes
key
- the keytrue
if the key was found, false
otherwisepublic void add(String key, int idx, String value)
Attributes
add
in interface Attributes
key
- the keyidx
- the indexvalue
- the mapping valuepublic String get(String key, int idx)
Attributes
get
in interface Attributes
key
- the keyidx
- the indexpublic String set(String key, int idx, String value)
Attributes
set
in interface Attributes
key
- the keyidx
- the indexvalue
- the mapping valuepublic String remove(String key, int idx)
Attributes
remove
in interface Attributes
key
- the keyidx
- the indexpublic List<String> copyAndRemove(String key)
Attributes
copyAndRemove
in interface Attributes
key
- the keynull
)public List<String> copyAndReplace(String key, Collection<String> values)
Attributes
copyAndReplace
in interface Attributes
key
- the keyvalues
- the new valuespublic boolean containsKey(String key)
Attributes
containsKey
in interface Attributes
key
- the keytrue
if the key has values, false
otherwisepublic boolean containsValue(String key, String value)
Attributes
containsValue
in interface Attributes
key
- the keyvalue
- the valuetrue
if the key has a mapping to the given value, false
otherwisepublic void removeRange(String key, int from, int to)
Attributes
from
index (inclusive) and the to
index
(exclusive).removeRange
in interface Attributes
key
- the keyfrom
- the start index (inclusive)to
- the end index (exclusive)public int indexOf(String key, String value)
Attributes
indexOf
in interface Attributes
key
- the keyvalue
- the valuepublic int lastIndexOf(String key, String value)
Attributes
lastIndexOf
in interface Attributes
key
- the keyvalue
- the valuepublic boolean set(String key, int idx, String expect, String update)
Attributes
expect
parameter.set
in interface Attributes
key
- the keyidx
- the indexexpect
- the expected valueupdate
- the value to settrue
if the actual value matched the expected value and was updated, false
otherwisepublic String getFirst(String key)
Attributes
getFirst
in interface Attributes
key
- the keypublic String getLast(String key)
Attributes
getLast
in interface Attributes
key
- the keypublic void addFirst(String key, String value)
Attributes
addFirst
in interface Attributes
key
- the keyvalue
- the valuepublic void addLast(String key, String value)
Attributes
addLast
in interface Attributes
key
- the keyvalue
- the valuepublic boolean removeFirst(String key, String value)
Attributes
removeFirst
in interface Attributes
key
- the keyvalue
- the value to removetrue
if the value was found and removed, false
otherwisepublic boolean removeLast(String key, String value)
Attributes
removeLast
in interface Attributes
key
- the keyvalue
- the value to removetrue
if the value was found and removed, false
otherwisepublic String removeFirst(String key)
Attributes
removeFirst
in interface Attributes
key
- the keypublic String removeLast(String key)
Attributes
removeLast
in interface Attributes
key
- the keypublic boolean remove(String key, int idx, String value)
Attributes
remove
in interface Attributes
key
- the keyidx
- the indexvalue
- the expected previous mapping valuetrue
if the value matched and was removed, false
otherwisepublic boolean removeAll(String key, String value)
Attributes
removeAll
in interface Attributes
key
- the keyvalue
- the value to removetrue
if the value was found and removed, false
otherwisepublic Attributes.Entry get(String key)
Attributes
Attributes.SetEntry
if the values
are distinct (for example, a role or group set).get
in interface Attributes
key
- the attribute namepublic int size()
Attributes
size
in interface Attributes
public boolean isEmpty()
Attributes
isEmpty
in interface Attributes
true
if the collection is empty, false
otherwisepublic void clear()
Attributes
clear
in interface Attributes
Copyright © 2020 JBoss by Red Hat. All rights reserved.