java.lang.Object
io.sf.carte.doc.DOMTokenSetImpl
- All Implemented Interfaces:
DOMTokenList
,Serializable
,Iterable<String>
A sorted set implementation of the
DOMTokenList
interface.
The implementation is optimized for an use case where most instances of this class will only host a single token. Hence, it can hold a reference to a single String or to a sorted set, depending on the number of items in this list/set.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the given token to this collection.protected void
addUnchecked
(String token) protected void
argumentCheckVoidSpaces
(String token) static boolean
checkMultipleToken
(String value) Utility method intended for cross-package internal use by the library.void
clear()
Empty this set.boolean
Does this collection contains this token?boolean
containsAll
(DOMTokenList otherlist) Does this collection contain all the tokens in the suppliedDOMTokenList
?boolean
containsAll
(Collection<String> tokenSet) Does this collection contain all the tokens in the given collection?int
Gets the number of tokens stored in this collection.Gets the value of the collection as a String, with the tokens alphabetically ordered.getValue()
Gets the value of the collection as a String.item
(int index) Retrieves a token from the collection by its index.iterator()
Obtain an iterator over the members of this set.void
Removes the given token from this collection.protected void
removeUnchecked
(String token) void
Replaces an existing token with a new token.protected void
replaceUnchecked
(String oldToken, String newToken) void
Sets the value of the collection as a String.boolean
If the given token exists in this collection, remove it; otherwise add it.protected boolean
toggleUnchecked
(String token) toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
DOMTokenSetImpl
public DOMTokenSetImpl()
-
-
Method Details
-
getValue
Description copied from interface:DOMTokenList
Gets the value of the collection as a String.- Specified by:
getValue
in interfaceDOMTokenList
- Returns:
- the value of the collection as a String.
-
getSortedValue
Description copied from interface:DOMTokenList
Gets the value of the collection as a String, with the tokens alphabetically ordered.- Specified by:
getSortedValue
in interfaceDOMTokenList
- Returns:
- the value of the collection as an alphabetically ordered string.
-
setValue
Sets the value of the collection as a String.- Parameters:
value
- the string value of the collection- Throws:
DOMException
-SYNTAX_ERR
ifvalue
isnull
.
-
checkMultipleToken
Utility method intended for cross-package internal use by the library.- Parameters:
value
- the value to check.- Returns:
true
if the value contains more than one token.
-
getLength
public int getLength()Description copied from interface:DOMTokenList
Gets the number of tokens stored in this collection.- Specified by:
getLength
in interfaceDOMTokenList
- Returns:
- the number of tokens stored in this collection.
-
item
Description copied from interface:DOMTokenList
Retrieves a token from the collection by its index.- Specified by:
item
in interfaceDOMTokenList
- Parameters:
index
- the index.- Returns:
- the token in the given place of this collection, or
null
if the index is negative, greater than or equal to the length of this collection.
-
iterator
Description copied from interface:DOMTokenList
Obtain an iterator over the members of this set.- Specified by:
iterator
in interfaceDOMTokenList
- Specified by:
iterator
in interfaceIterable<String>
- Returns:
- an iterator over the members of this set.
-
contains
Description copied from interface:DOMTokenList
Does this collection contains this token?- Specified by:
contains
in interfaceDOMTokenList
- Parameters:
token
- the token.- Returns:
true
if the list contains the given token,false
otherwise.
-
containsAll
Description copied from interface:DOMTokenList
Does this collection contain all the tokens in the suppliedDOMTokenList
?- Specified by:
containsAll
in interfaceDOMTokenList
- Parameters:
otherlist
- anotherDOMTokenList
.- Returns:
true
if this list contains all the tokens in the givenotherlist
,false
otherwise.
-
containsAll
Description copied from interface:DOMTokenList
Does this collection contain all the tokens in the given collection?- Specified by:
containsAll
in interfaceDOMTokenList
- Parameters:
tokenSet
- the collection of tokens.- Returns:
true
if the list contains all the tokens in the given set, false otherwise.
-
add
Description copied from interface:DOMTokenList
Adds the given token to this collection.If the set already contains the token, then do nothing.
- Specified by:
add
in interfaceDOMTokenList
- Parameters:
token
- the token to add.- Throws:
DOMException
- SYNTAX_ERR if the token isnull
or empty. INVALID_CHARACTER_ERR if the token contains spaces.
-
addUnchecked
- Throws:
DOMException
-
remove
Description copied from interface:DOMTokenList
Removes the given token from this collection.- Specified by:
remove
in interfaceDOMTokenList
- Parameters:
token
- the token to remove.- Throws:
DOMException
- SYNTAX_ERR if the token isnull
or empty. INVALID_CHARACTER_ERR if the token contains spaces.
-
removeUnchecked
- Throws:
DOMException
-
toggle
Description copied from interface:DOMTokenList
If the given token exists in this collection, remove it; otherwise add it.- Specified by:
toggle
in interfaceDOMTokenList
- Parameters:
token
- the token to toggle.- Returns:
true
if the token is added,false
if it is removed.- Throws:
DOMException
- SYNTAX_ERR if the token isnull
or empty. INVALID_CHARACTER_ERR if the token contains spaces.
-
toggleUnchecked
- Throws:
DOMException
-
replace
Description copied from interface:DOMTokenList
Replaces an existing token with a new token.If the set does not contain the token, do nothing.
- Specified by:
replace
in interfaceDOMTokenList
- Parameters:
oldToken
- the token that has to be replaced.newToken
- the new token.- Throws:
DOMException
- SYNTAX_ERR if any of the tokens isnull
or empty. INVALID_CHARACTER_ERR if any of the tokens contains spaces.
-
replaceUnchecked
- Throws:
DOMException
-
clear
public void clear()Empty this set.After calling this method, the length of this set is zero.
-
argumentCheckVoidSpaces
- Throws:
DOMException
-
toString
-