Package com.helger.css.decl
Class CSSDeclarationList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<ELEMENTTYPE>
-
- com.helger.commons.collection.impl.CommonsArrayList<DATATYPE>
-
- com.helger.css.decl.CSSWritableList<CSSDeclaration>
-
- com.helger.css.decl.CSSDeclarationList
-
- All Implemented Interfaces:
com.helger.commons.collection.impl.ICommonsCollection<CSSDeclaration>,com.helger.commons.collection.impl.ICommonsIterable<CSSDeclaration>,com.helger.commons.collection.impl.ICommonsList<CSSDeclaration>,com.helger.commons.lang.ICloneable<com.helger.commons.collection.impl.ICommonsList<CSSDeclaration>>,com.helger.commons.lang.IHasSize,com.helger.commons.traits.IGenericImplTrait<CSSDeclarationList>,IHasCSSDeclarations<CSSDeclarationList>,ICSSSourceLocationAware,ICSSWriteable,Serializable,Cloneable,Iterable<CSSDeclaration>,Collection<CSSDeclaration>,List<CSSDeclaration>,RandomAccess
- Direct Known Subclasses:
CSSDeclarationContainer
@NotThreadSafe public class CSSDeclarationList extends CSSWritableList<CSSDeclaration> implements IHasCSSDeclarations<CSSDeclarationList>
Represents a list ofCSSDeclarationobjects. This class emits all declarations in a row, without any surrounding block elements.- Author:
- Philip Helger
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description CSSDeclarationList()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CSSDeclarationListaddDeclaration(int nIndex, CSSDeclaration aNewDeclaration)Add a new declaration at the specified index.CSSDeclarationListaddDeclaration(CSSDeclaration aNewDeclaration)Add a new declaration.com.helger.commons.collection.impl.ICommonsList<CSSDeclaration>getAllDeclarations()com.helger.commons.collection.impl.ICommonsList<CSSDeclaration>getAllDeclarationsOfPropertyName(String sPropertyName)Get all declarations within this list that have the specified property name.CSSDeclarationgetDeclarationAtIndex(int nIndex)intgetDeclarationCount()CSSDeclarationgetDeclarationOfPropertyName(String sPropertyName)Get the first declaration with the specified property name.booleanhasDeclarations()com.helger.commons.state.EChangeremoveAllDeclarations()Remove all declarations.com.helger.commons.state.EChangeremoveDeclaration(int nDeclarationIndex)Remove the declaration at the specified indexcom.helger.commons.state.EChangeremoveDeclaration(CSSDeclaration aDeclaration)Remove the given declarationCSSDeclarationListsetDeclarationAtIndex(int nIndex, CSSDeclaration aNewDeclaration)Set the declaration at the specified index with a new one.-
Methods inherited from class com.helger.css.decl.CSSWritableList
equals, getAsCSSString, getSourceLocation, hashCode, setSourceLocation, toString
-
Methods inherited from class com.helger.commons.collection.impl.CommonsArrayList
createFiltered, createFiltered, createFiltered, createFiltered, createFiltered, createFiltered, createInstance, getClone
-
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
Methods inherited from class java.util.AbstractCollection
containsAll
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface com.helger.commons.collection.impl.ICommonsCollection
addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAll, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addAllMapped, addIf, addIfNotNull, addObject, getAtIndex, getAtIndex, getAtIndex, getAtIndexMapped, getAtIndexMapped, getAtIndexMapped, getAtIndexMapped, getCopyAsList, getCount, getSorted, iterator2, removeAll, removeObject, set, setAll, setAll, setAllMapped, setAllMapped
-
Methods inherited from interface com.helger.commons.collection.impl.ICommonsIterable
containsAny, containsNone, containsOnly, findAll, findAllInstanceOf, findAllMapped, findAllMapped, findAllMapped, findFirst, findFirst, findFirstIndex, findFirstMapped, findFirstMapped, findLastIndex, forEachBreakable, forEachByIndex, forEachThrowing, getCount
-
Methods inherited from interface com.helger.commons.collection.impl.ICommonsList
getAll, getAllInstanceOf, getAllMapped, getAllMapped, getAsUnmodifiable, getAtIndex, getFirst, getFirst, getLast, getLast, getSortedInline, removeAndReturnElementAtIndex, removeAtIndex, removeFirst, removeLast, reverse, setFirst, setLast, swapItems
-
Methods inherited from interface com.helger.css.ICSSWriteable
getAsCSSString, getAsCSSString, getAsCSSString
-
Methods inherited from interface com.helger.css.decl.IHasCSSDeclarations
addDeclaration, getAllDeclarationsOfPropertyNameCaseInsensitive, getDeclarationOfPropertyNameCaseInsensitive
-
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
-
-
-
-
Method Detail
-
addDeclaration
@Nonnull public final CSSDeclarationList addDeclaration(@Nonnull CSSDeclaration aNewDeclaration)
Description copied from interface:IHasCSSDeclarationsAdd a new declaration.- Specified by:
addDeclarationin interfaceIHasCSSDeclarations<CSSDeclarationList>- Parameters:
aNewDeclaration- The declaration to be added. May not benull.- Returns:
- this
-
addDeclaration
@Nonnull public CSSDeclarationList addDeclaration(@Nonnegative int nIndex, @Nonnull CSSDeclaration aNewDeclaration)
Description copied from interface:IHasCSSDeclarationsAdd a new declaration at the specified index.- Specified by:
addDeclarationin interfaceIHasCSSDeclarations<CSSDeclarationList>- Parameters:
nIndex- The index to retrieve. Must be ≥ 0. If the index is ≥ thangetDeclarationCount(), it behaves likeIHasCSSDeclarations.addDeclaration(CSSDeclaration).aNewDeclaration- The declaration to be added. May not benull.- Returns:
- this
-
removeDeclaration
@Nonnull public final com.helger.commons.state.EChange removeDeclaration(@Nonnull CSSDeclaration aDeclaration)
Description copied from interface:IHasCSSDeclarationsRemove the given declaration- Specified by:
removeDeclarationin interfaceIHasCSSDeclarations<CSSDeclarationList>- Parameters:
aDeclaration- The declaration to be removed. May not benull.- Returns:
EChange.CHANGEDif the declaration was successfully removed
-
removeDeclaration
@Nonnull public final com.helger.commons.state.EChange removeDeclaration(@Nonnegative int nDeclarationIndex)
Description copied from interface:IHasCSSDeclarationsRemove the declaration at the specified index- Specified by:
removeDeclarationin interfaceIHasCSSDeclarations<CSSDeclarationList>- Parameters:
nDeclarationIndex- The index of the declaration to be removed. Must be ≥ 0.- Returns:
EChange.CHANGEDif the declaration was successfully removed,EChange.UNCHANGEDif the index was invalid.
-
removeAllDeclarations
@Nonnull public com.helger.commons.state.EChange removeAllDeclarations()
Remove all declarations.- Specified by:
removeAllDeclarationsin interfaceIHasCSSDeclarations<CSSDeclarationList>- Returns:
EChange.CHANGEDif any declaration was removed,EChange.UNCHANGEDotherwise. Nevernull.- Since:
- 3.7.3
-
getAllDeclarations
@Nonnull @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<CSSDeclaration> getAllDeclarations()
- Specified by:
getAllDeclarationsin interfaceIHasCSSDeclarations<CSSDeclarationList>- Returns:
- A mutable, non-
nullcopy of all contained declarations.
-
getDeclarationAtIndex
@Nullable public final CSSDeclaration getDeclarationAtIndex(@Nonnegative int nIndex)
- Specified by:
getDeclarationAtIndexin interfaceIHasCSSDeclarations<CSSDeclarationList>- Parameters:
nIndex- The index to retrieve- Returns:
- The declaration at the specified index or
nullif the index is invalid
-
setDeclarationAtIndex
@Nonnull public CSSDeclarationList setDeclarationAtIndex(@Nonnegative int nIndex, @Nonnull CSSDeclaration aNewDeclaration)
Description copied from interface:IHasCSSDeclarationsSet the declaration at the specified index with a new one. If an existing declaration is present at that index, it is overwritten.- Specified by:
setDeclarationAtIndexin interfaceIHasCSSDeclarations<CSSDeclarationList>- Parameters:
nIndex- The index to retrieve. Must be ≥ 0. If the index is ≥ thangetDeclarationCount(), it behaves likeIHasCSSDeclarations.addDeclaration(CSSDeclaration).aNewDeclaration- The new declaration to be set.- Returns:
- this
-
hasDeclarations
public boolean hasDeclarations()
- Specified by:
hasDeclarationsin interfaceIHasCSSDeclarations<CSSDeclarationList>- Returns:
trueif at least one declaration is present,falseif no declaration is present.
-
getDeclarationCount
@Nonnegative public int getDeclarationCount()
- Specified by:
getDeclarationCountin interfaceIHasCSSDeclarations<CSSDeclarationList>- Returns:
- The number of contained declarations. Always ≥ 0.
-
getDeclarationOfPropertyName
@Nullable public CSSDeclaration getDeclarationOfPropertyName(@Nullable String sPropertyName)
Description copied from interface:IHasCSSDeclarationsGet the first declaration with the specified property name. If no such property name is present,nullis returned. If more than one declaration ith the specified property name is present, always the first in the list will be returned. The comparison happens case insensitive (since v6.0.0).- Specified by:
getDeclarationOfPropertyNamein interfaceIHasCSSDeclarations<CSSDeclarationList>- Parameters:
sPropertyName- The property name of the declaration to search (e.g.color). May benull.- Returns:
nullif no such property name was found.
-
getAllDeclarationsOfPropertyName
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<CSSDeclaration> getAllDeclarationsOfPropertyName(@Nullable String sPropertyName)
Description copied from interface:IHasCSSDeclarationsGet all declarations within this list that have the specified property name. The comparison happens case insensitive (since v6.0.0).- Specified by:
getAllDeclarationsOfPropertyNamein interfaceIHasCSSDeclarations<CSSDeclarationList>- Parameters:
sPropertyName- The property name of the declaration to search (e.g.color). May benull.- Returns:
- Never
nullbut maybe an empty list.
-
-