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 ofCSSDeclaration
objects. 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 CSSDeclarationList
addDeclaration(int nIndex, CSSDeclaration aNewDeclaration)
Add a new declaration at the specified index.CSSDeclarationList
addDeclaration(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.CSSDeclaration
getDeclarationAtIndex(int nIndex)
int
getDeclarationCount()
CSSDeclaration
getDeclarationOfPropertyName(String sPropertyName)
Get the first declaration with the specified property name.boolean
hasDeclarations()
com.helger.commons.state.EChange
removeAllDeclarations()
Remove all declarations.com.helger.commons.state.EChange
removeDeclaration(int nDeclarationIndex)
Remove the declaration at the specified indexcom.helger.commons.state.EChange
removeDeclaration(CSSDeclaration aDeclaration)
Remove the given declarationCSSDeclarationList
setDeclarationAtIndex(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:IHasCSSDeclarations
Add a new declaration.- Specified by:
addDeclaration
in 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:IHasCSSDeclarations
Add a new declaration at the specified index.- Specified by:
addDeclaration
in 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:IHasCSSDeclarations
Remove the given declaration- Specified by:
removeDeclaration
in interfaceIHasCSSDeclarations<CSSDeclarationList>
- Parameters:
aDeclaration
- The declaration to be removed. May not benull
.- Returns:
EChange.CHANGED
if the declaration was successfully removed
-
removeDeclaration
@Nonnull public final com.helger.commons.state.EChange removeDeclaration(@Nonnegative int nDeclarationIndex)
Description copied from interface:IHasCSSDeclarations
Remove the declaration at the specified index- Specified by:
removeDeclaration
in interfaceIHasCSSDeclarations<CSSDeclarationList>
- Parameters:
nDeclarationIndex
- The index of the declaration to be removed. Must be ≥ 0.- Returns:
EChange.CHANGED
if the declaration was successfully removed,EChange.UNCHANGED
if the index was invalid.
-
removeAllDeclarations
@Nonnull public com.helger.commons.state.EChange removeAllDeclarations()
Remove all declarations.- Specified by:
removeAllDeclarations
in interfaceIHasCSSDeclarations<CSSDeclarationList>
- Returns:
EChange.CHANGED
if any declaration was removed,EChange.UNCHANGED
otherwise. Nevernull
.- Since:
- 3.7.3
-
getAllDeclarations
@Nonnull @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<CSSDeclaration> getAllDeclarations()
- Specified by:
getAllDeclarations
in interfaceIHasCSSDeclarations<CSSDeclarationList>
- Returns:
- A mutable, non-
null
copy of all contained declarations.
-
getDeclarationAtIndex
@Nullable public final CSSDeclaration getDeclarationAtIndex(@Nonnegative int nIndex)
- Specified by:
getDeclarationAtIndex
in interfaceIHasCSSDeclarations<CSSDeclarationList>
- Parameters:
nIndex
- The index to retrieve- Returns:
- The declaration at the specified index or
null
if the index is invalid
-
setDeclarationAtIndex
@Nonnull public CSSDeclarationList setDeclarationAtIndex(@Nonnegative int nIndex, @Nonnull CSSDeclaration aNewDeclaration)
Description copied from interface:IHasCSSDeclarations
Set the declaration at the specified index with a new one. If an existing declaration is present at that index, it is overwritten.- Specified by:
setDeclarationAtIndex
in 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:
hasDeclarations
in interfaceIHasCSSDeclarations<CSSDeclarationList>
- Returns:
true
if at least one declaration is present,false
if no declaration is present.
-
getDeclarationCount
@Nonnegative public int getDeclarationCount()
- Specified by:
getDeclarationCount
in interfaceIHasCSSDeclarations<CSSDeclarationList>
- Returns:
- The number of contained declarations. Always ≥ 0.
-
getDeclarationOfPropertyName
@Nullable public CSSDeclaration getDeclarationOfPropertyName(@Nullable String sPropertyName)
Description copied from interface:IHasCSSDeclarations
Get the first declaration with the specified property name. If no such property name is present,null
is 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:
getDeclarationOfPropertyName
in interfaceIHasCSSDeclarations<CSSDeclarationList>
- Parameters:
sPropertyName
- The property name of the declaration to search (e.g.color
). May benull
.- Returns:
null
if 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:IHasCSSDeclarations
Get all declarations within this list that have the specified property name. The comparison happens case insensitive (since v6.0.0).- Specified by:
getAllDeclarationsOfPropertyName
in interfaceIHasCSSDeclarations<CSSDeclarationList>
- Parameters:
sPropertyName
- The property name of the declaration to search (e.g.color
). May benull
.- Returns:
- Never
null
but maybe an empty list.
-
-