Package org.wildfly.security.authz
Class MapAttributes
- java.lang.Object
-
- org.wildfly.security.authz.MapAttributes
-
- All Implemented Interfaces:
Attributes
public class MapAttributes extends Object implements Attributes
A map-backed attributes collection.- Author:
- David M. Lloyd
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.wildfly.security.authz.Attributes
Attributes.Entry, Attributes.SetEntry
-
-
Field Summary
-
Fields inherited from interface org.wildfly.security.authz.Attributes
EMPTY
-
-
Constructor Summary
Constructors Constructor Description MapAttributes()Construct an instance using a hash map for backing store.MapAttributes(Map<String,? extends Collection<String>> original)Construct a new instance copying mappings from an original map.MapAttributes(Attributes original)Construct a new instance copying mappings from an original attributes collection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(String key, int idx, String value)Add a mapping for the given key at the given position.voidaddFirst(String key, String value)Add a value before the first mapping for the given key.voidaddLast(String key, String value)Add a value after the last mapping for the given key.voidclear()Clear this collection, resetting its size to zero.booleancontainsKey(String key)Determine if the given key has values in this collection.booleancontainsValue(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.Entryget(String key)Get the collection of values for the given key.Stringget(String key, int idx)Get the mapping for the given key at the given position.StringgetFirst(String key)Get the first value mapped to the given key.StringgetLast(String key)Get the last value mapped to the given key.intindexOf(String key, String value)Get the index of the first occurrence of the given value at the given key, if any.booleanisEmpty()Determine if this collection is empty.Set<String>keySet()Get a set comprised of all the keys in this collection.intlastIndexOf(String key, String value)Get the index of the last occurrence of the given value at the given key, if any.booleanremove(String key)Remove all values for the given key from this collection.Stringremove(String key, int idx)Remove and return the mapping for the given key at the given position.booleanremove(String key, int idx, String value)Remove the mapping for the given key at the given position if it matches the given existing value.booleanremoveAll(String key, String value)Remove the all occurrences of the given value under the given key, if any.StringremoveFirst(String key)Remove the first value mapped to the given key.booleanremoveFirst(String key, String value)Remove the first occurrence of the given value under the given key, if any.StringremoveLast(String key)Remove the last value mapped to the given key.booleanremoveLast(String key, String value)Remove the last occurrence of the given value under the given key, if any.voidremoveRange(String key, int from, int to)Remove all the values for the given key between thefromindex (inclusive) and thetoindex (exclusive).Stringset(String key, int idx, String value)Modify the mapping for the given key at the given position.booleanset(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 theexpectparameter.intsize()Get the number of keys in this attribute collection.intsize(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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.wildfly.security.authz.Attributes
addAll, addAll, asReadOnly
-
-
-
-
Constructor Detail
-
MapAttributes
public MapAttributes()
Construct an instance using a hash map for backing store.
-
MapAttributes
public MapAttributes(Map<String,? extends Collection<String>> original)
Construct a new instance copying mappings from an original map.- Parameters:
original- the original map
-
MapAttributes
public MapAttributes(Attributes original)
Construct a new instance copying mappings from an original attributes collection.- Parameters:
original- the original collection
-
-
Method Detail
-
keySet
public Set<String> keySet()
Description copied from interface:AttributesGet a set comprised of all the keys in this collection. The returned set can be used to modify this attributes collection.- Specified by:
keySetin interfaceAttributes- Returns:
- the set of all keys (not
null)
-
values
public Collection<String> values()
Description copied from interface:AttributesGet all the values of all the keys in this collection. The returned collection can be used to modify this attributes collection.- Specified by:
valuesin interfaceAttributes- Returns:
- the collection of all values (not
null)
-
entries
public Collection<Attributes.Entry> entries()
Description copied from interface:AttributesGet the entry collection. Changes to the entry collection will modify this attribute collection, if it is writable. The returned entries will remain up to date with the state of this collection.- Specified by:
entriesin interfaceAttributes- Returns:
- the entry collection
-
size
public int size(String key)
Description copied from interface:AttributesGet the number of values mapped to the given key.- Specified by:
sizein interfaceAttributes- Parameters:
key- the key- Returns:
- the number of mapped values
-
remove
public boolean remove(String key)
Description copied from interface:AttributesRemove all values for the given key from this collection.- Specified by:
removein interfaceAttributes- Parameters:
key- the key- Returns:
trueif the key was found,falseotherwise
-
add
public void add(String key, int idx, String value)
Description copied from interface:AttributesAdd a mapping for the given key at the given position.- Specified by:
addin interfaceAttributes- Parameters:
key- the keyidx- the indexvalue- the mapping value
-
get
public String get(String key, int idx)
Description copied from interface:AttributesGet the mapping for the given key at the given position.- Specified by:
getin interfaceAttributes- Parameters:
key- the keyidx- the index- Returns:
- the mapping value
-
set
public String set(String key, int idx, String value)
Description copied from interface:AttributesModify the mapping for the given key at the given position.- Specified by:
setin interfaceAttributes- Parameters:
key- the keyidx- the indexvalue- the mapping value- Returns:
- the previous mapping value
-
remove
public String remove(String key, int idx)
Description copied from interface:AttributesRemove and return the mapping for the given key at the given position. All later entries for that key are shifted up to fill in the gap left by the removed element.- Specified by:
removein interfaceAttributes- Parameters:
key- the keyidx- the index- Returns:
- the previous mapping value
-
copyAndRemove
public List<String> copyAndRemove(String key)
Description copied from interface:AttributesRemove all values for the given key from this collection, copying the values into a list which is returned.- Specified by:
copyAndRemovein interfaceAttributes- Parameters:
key- the key- Returns:
- the values as a list (not
null)
-
copyAndReplace
public List<String> copyAndReplace(String key, Collection<String> values)
Description copied from interface:AttributesReplace the mapping for the given key with the values copied from the given collection.- Specified by:
copyAndReplacein interfaceAttributes- Parameters:
key- the keyvalues- the new values- Returns:
- a list containing the previously mapped values
-
containsKey
public boolean containsKey(String key)
Description copied from interface:AttributesDetermine if the given key has values in this collection.- Specified by:
containsKeyin interfaceAttributes- Parameters:
key- the key- Returns:
trueif the key has values,falseotherwise
-
containsValue
public boolean containsValue(String key, String value)
Description copied from interface:AttributesDetermine if the given key has a mapping for the given value in this collection.- Specified by:
containsValuein interfaceAttributes- Parameters:
key- the keyvalue- the value- Returns:
trueif the key has a mapping to the given value,falseotherwise
-
removeRange
public void removeRange(String key, int from, int to)
Description copied from interface:AttributesRemove all the values for the given key between thefromindex (inclusive) and thetoindex (exclusive).- Specified by:
removeRangein interfaceAttributes- Parameters:
key- the keyfrom- the start index (inclusive)to- the end index (exclusive)
-
indexOf
public int indexOf(String key, String value)
Description copied from interface:AttributesGet the index of the first occurrence of the given value at the given key, if any.- Specified by:
indexOfin interfaceAttributes- Parameters:
key- the keyvalue- the value- Returns:
- the index, or -1 if the value was not found at the given key
-
lastIndexOf
public int lastIndexOf(String key, String value)
Description copied from interface:AttributesGet the index of the last occurrence of the given value at the given key, if any.- Specified by:
lastIndexOfin interfaceAttributes- Parameters:
key- the keyvalue- the value- Returns:
- the index, or -1 if the value was not found at the given key
-
set
public boolean set(String key, int idx, String expect, String update)
Description copied from interface:AttributesConditionally set a specific value of a given key to a new value, if the existing value matches theexpectparameter.- Specified by:
setin interfaceAttributes- Parameters:
key- the keyidx- the indexexpect- the expected valueupdate- the value to set- Returns:
trueif the actual value matched the expected value and was updated,falseotherwise
-
getFirst
public String getFirst(String key)
Description copied from interface:AttributesGet the first value mapped to the given key.- Specified by:
getFirstin interfaceAttributes- Parameters:
key- the key- Returns:
- the value
-
getLast
public String getLast(String key)
Description copied from interface:AttributesGet the last value mapped to the given key.- Specified by:
getLastin interfaceAttributes- Parameters:
key- the key- Returns:
- the value
-
addFirst
public void addFirst(String key, String value)
Description copied from interface:AttributesAdd a value before the first mapping for the given key.- Specified by:
addFirstin interfaceAttributes- Parameters:
key- the keyvalue- the value
-
addLast
public void addLast(String key, String value)
Description copied from interface:AttributesAdd a value after the last mapping for the given key.- Specified by:
addLastin interfaceAttributes- Parameters:
key- the keyvalue- the value
-
removeFirst
public boolean removeFirst(String key, String value)
Description copied from interface:AttributesRemove the first occurrence of the given value under the given key, if any.- Specified by:
removeFirstin interfaceAttributes- Parameters:
key- the keyvalue- the value to remove- Returns:
trueif the value was found and removed,falseotherwise
-
removeLast
public boolean removeLast(String key, String value)
Description copied from interface:AttributesRemove the last occurrence of the given value under the given key, if any.- Specified by:
removeLastin interfaceAttributes- Parameters:
key- the keyvalue- the value to remove- Returns:
trueif the value was found and removed,falseotherwise
-
removeFirst
public String removeFirst(String key)
Description copied from interface:AttributesRemove the first value mapped to the given key.- Specified by:
removeFirstin interfaceAttributes- Parameters:
key- the key- Returns:
- the value
-
removeLast
public String removeLast(String key)
Description copied from interface:AttributesRemove the last value mapped to the given key.- Specified by:
removeLastin interfaceAttributes- Parameters:
key- the key- Returns:
- the value
-
remove
public boolean remove(String key, int idx, String value)
Description copied from interface:AttributesRemove the mapping for the given key at the given position if it matches the given existing value. All later entries for that key are shifted up to fill in the gap left by the removed element.- Specified by:
removein interfaceAttributes- Parameters:
key- the keyidx- the indexvalue- the expected previous mapping value- Returns:
trueif the value matched and was removed,falseotherwise
-
removeAll
public boolean removeAll(String key, String value)
Description copied from interface:AttributesRemove the all occurrences of the given value under the given key, if any.- Specified by:
removeAllin interfaceAttributes- Parameters:
key- the keyvalue- the value to remove- Returns:
trueif the value was found and removed,falseotherwise
-
get
public Attributes.Entry get(String key)
Description copied from interface:AttributesGet the collection of values for the given key. The result may implementAttributes.SetEntryif the values are distinct (for example, a role or group set).- Specified by:
getin interfaceAttributes- Parameters:
key- the attribute name- Returns:
- the (possibly empty) attribute value collection
-
size
public int size()
Description copied from interface:AttributesGet the number of keys in this attribute collection.- Specified by:
sizein interfaceAttributes- Returns:
- the number of keys
-
isEmpty
public boolean isEmpty()
Description copied from interface:AttributesDetermine if this collection is empty.- Specified by:
isEmptyin interfaceAttributes- Returns:
trueif the collection is empty,falseotherwise
-
clear
public void clear()
Description copied from interface:AttributesClear this collection, resetting its size to zero.- Specified by:
clearin interfaceAttributes
-
-