Package io.sf.carte.doc
Class DOMTokenSetImpl
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given token to this collection.protected voidaddUnchecked(String token) protected voidargumentCheckVoidSpaces(String token) static booleancheckMultipleToken(String value) Utility method intended for cross-package internal use by the library.voidclear()Empty this set.booleanDoes this collection contains this token?booleancontainsAll(DOMTokenList otherlist) Does this collection contain all the tokens in the suppliedDOMTokenList?booleancontainsAll(Collection<String> tokenSet) Does this collection contain all the tokens in the given collection?intGets 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.voidRemoves the given token from this collection.protected voidremoveUnchecked(String token) voidReplaces an existing token with a new token.protected voidreplaceUnchecked(String oldToken, String newToken) voidSets the value of the collection as a String.booleanIf the given token exists in this collection, remove it; otherwise add it.protected booleantoggleUnchecked(String token) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
DOMTokenSetImpl
public DOMTokenSetImpl()
-
-
Method Details
-
getValue
Description copied from interface:DOMTokenListGets the value of the collection as a String.- Specified by:
getValuein interfaceDOMTokenList- Returns:
- the value of the collection as a String.
-
getSortedValue
Description copied from interface:DOMTokenListGets the value of the collection as a String, with the tokens alphabetically ordered.- Specified by:
getSortedValuein 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_ERRifvalueisnull.
-
checkMultipleToken
Utility method intended for cross-package internal use by the library.- Parameters:
value- the value to check.- Returns:
trueif the value contains more than one token.
-
getLength
public int getLength()Description copied from interface:DOMTokenListGets the number of tokens stored in this collection.- Specified by:
getLengthin interfaceDOMTokenList- Returns:
- the number of tokens stored in this collection.
-
item
Description copied from interface:DOMTokenListRetrieves a token from the collection by its index.- Specified by:
itemin interfaceDOMTokenList- Parameters:
index- the index.- Returns:
- the token in the given place of this collection, or
nullif the index is negative, greater than or equal to the length of this collection.
-
iterator
Description copied from interface:DOMTokenListObtain an iterator over the members of this set.- Specified by:
iteratorin interfaceDOMTokenList- Specified by:
iteratorin interfaceIterable<String>- Returns:
- an iterator over the members of this set.
-
contains
Description copied from interface:DOMTokenListDoes this collection contains this token?- Specified by:
containsin interfaceDOMTokenList- Parameters:
token- the token.- Returns:
trueif the list contains the given token,falseotherwise.
-
containsAll
Description copied from interface:DOMTokenListDoes this collection contain all the tokens in the suppliedDOMTokenList?- Specified by:
containsAllin interfaceDOMTokenList- Parameters:
otherlist- anotherDOMTokenList.- Returns:
trueif this list contains all the tokens in the givenotherlist,falseotherwise.
-
containsAll
Description copied from interface:DOMTokenListDoes this collection contain all the tokens in the given collection?- Specified by:
containsAllin interfaceDOMTokenList- Parameters:
tokenSet- the collection of tokens.- Returns:
trueif the list contains all the tokens in the given set, false otherwise.
-
add
Description copied from interface:DOMTokenListAdds the given token to this collection.If the set already contains the token, then do nothing.
- Specified by:
addin interfaceDOMTokenList- Parameters:
token- the token to add.- Throws:
DOMException- SYNTAX_ERR if the token isnullor empty. INVALID_CHARACTER_ERR if the token contains spaces.
-
addUnchecked
- Throws:
DOMException
-
remove
Description copied from interface:DOMTokenListRemoves the given token from this collection.- Specified by:
removein interfaceDOMTokenList- Parameters:
token- the token to remove.- Throws:
DOMException- SYNTAX_ERR if the token isnullor empty. INVALID_CHARACTER_ERR if the token contains spaces.
-
removeUnchecked
- Throws:
DOMException
-
toggle
Description copied from interface:DOMTokenListIf the given token exists in this collection, remove it; otherwise add it.- Specified by:
togglein interfaceDOMTokenList- Parameters:
token- the token to toggle.- Returns:
trueif the token is added,falseif it is removed.- Throws:
DOMException- SYNTAX_ERR if the token isnullor empty. INVALID_CHARACTER_ERR if the token contains spaces.
-
toggleUnchecked
- Throws:
DOMException
-
replace
Description copied from interface:DOMTokenListReplaces an existing token with a new token.If the set does not contain the token, do nothing.
- Specified by:
replacein interfaceDOMTokenList- Parameters:
oldToken- the token that has to be replaced.newToken- the new token.- Throws:
DOMException- SYNTAX_ERR if any of the tokens isnullor 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
-