Package com.helger.css.decl
Class CSSExpression
- java.lang.Object
-
- com.helger.css.decl.CSSExpression
-
- All Implemented Interfaces:
ICSSSourceLocationAware
,ICSSWriteable
@NotThreadSafe public class CSSExpression extends Object implements ICSSWriteable, ICSSSourceLocationAware
Represents a single expression consisting of several expression members- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description CSSExpression()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CSSExpression
addMember(int nIndex, ICSSExpressionMember aMember)
Add an expression memberCSSExpression
addMember(ICSSExpressionMember aMember)
Add an expression memberCSSExpression
addNumber(double dValue)
Shortcut method to add a numeric valueCSSExpression
addNumber(float fValue)
Shortcut method to add a numeric valueCSSExpression
addNumber(int nValue)
Shortcut method to add a numeric valueCSSExpression
addNumber(int nIndex, double dValue)
Shortcut method to add a numeric valueCSSExpression
addNumber(int nIndex, float fValue)
Shortcut method to add a numeric valueCSSExpression
addNumber(int nIndex, int nValue)
Shortcut method to add a numeric valueCSSExpression
addNumber(int nIndex, long nValue)
Shortcut method to add a numeric valueCSSExpression
addNumber(long nValue)
Shortcut method to add a numeric valueCSSExpression
addString(int nIndex, String sValue)
Shortcut method to add a string value that is automatically quoted insideCSSExpression
addString(String sValue)
Shortcut method to add a string value that is automatically quoted insideCSSExpression
addTermSimple(int nIndex, String sValue)
Shortcut method to add a simple text value.CSSExpression
addTermSimple(String sValue)
Shortcut method to add a simple text value.CSSExpression
addURI(int nIndex, String sURI)
Shortcut method to add a URI valueCSSExpression
addURI(String sURI)
Shortcut method to add a URI valuestatic CSSExpression
createNumber(double dValue)
Create a CSS expression only containing a numeric valuestatic CSSExpression
createNumber(float fValue)
Create a CSS expression only containing a numeric valuestatic CSSExpression
createNumber(int nValue)
Create a CSS expression only containing a numeric valuestatic CSSExpression
createNumber(long nValue)
Create a CSS expression only containing a numeric valuestatic CSSExpression
createSimple(String sValue)
Create a CSS expression only containing a text valuestatic CSSExpression
createString(String sValue)
Create a CSS expression only containing a stringstatic CSSExpression
createURI(String sURI)
Create a CSS expression only containing a URIboolean
equals(Object o)
com.helger.commons.collection.impl.ICommonsList<ICSSExpressionMember>
getAllMembers()
com.helger.commons.collection.impl.ICommonsList<CSSExpressionMemberTermSimple>
getAllSimpleMembers()
String
getAsCSSString(ICSSWriterSettings aSettings, int nIndentLevel)
Get the contents of this object as a serialized CSS string for writing to an output.ICSSExpressionMember
getMemberAtIndex(int nIndex)
Get the expression member at the specified index.int
getMemberCount()
static String
getQuotedStringValue(String sValue)
Get a quoted string value.CSSSourceLocation
getSourceLocation()
int
hashCode()
com.helger.commons.state.EChange
removeAllMembers()
Remove all members.com.helger.commons.state.EChange
removeMember(int nMemberIndex)
Remove the expression member at the specified incom.helger.commons.state.EChange
removeMember(ICSSExpressionMember aMember)
Remove the passed expression membervoid
setSourceLocation(CSSSourceLocation aSourceLocation)
Set the source location of the object, determined while parsing.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.css.ICSSWriteable
getAsCSSString, getAsCSSString
-
-
-
-
Method Detail
-
addMember
@Nonnull public CSSExpression addMember(@Nonnull ICSSExpressionMember aMember)
Add an expression member- Parameters:
aMember
- The member to be added. May not benull
.- Returns:
- this
-
addMember
@Nonnull public CSSExpression addMember(@Nonnegative int nIndex, @Nonnull ICSSExpressionMember aMember)
Add an expression member- Parameters:
nIndex
- The index where the member should be added. Must be ≥ 0.aMember
- The member to be added. May not benull
.- Returns:
- this
-
addTermSimple
@Nonnull public CSSExpression addTermSimple(@Nonnull @Nonempty String sValue)
Shortcut method to add a simple text value.- Parameters:
sValue
- The value to be added. May neither benull
nor empty.- Returns:
- this
-
addTermSimple
@Nonnull public CSSExpression addTermSimple(@Nonnegative int nIndex, @Nonnull @Nonempty String sValue)
Shortcut method to add a simple text value.- Parameters:
nIndex
- The index where the member should be added. Must be ≥ 0.sValue
- The value to be added. May neither benull
nor empty.- Returns:
- this
-
addNumber
@Nonnull public CSSExpression addNumber(int nValue)
Shortcut method to add a numeric value- Parameters:
nValue
- The value to be added.- Returns:
- this
-
addNumber
@Nonnull public CSSExpression addNumber(@Nonnegative int nIndex, int nValue)
Shortcut method to add a numeric value- Parameters:
nIndex
- The index where the member should be added. Must be ≥ 0.nValue
- The value to be added.- Returns:
- this
-
addNumber
@Nonnull public CSSExpression addNumber(long nValue)
Shortcut method to add a numeric value- Parameters:
nValue
- The value to be added.- Returns:
- this
-
addNumber
@Nonnull public CSSExpression addNumber(@Nonnegative int nIndex, long nValue)
Shortcut method to add a numeric value- Parameters:
nIndex
- The index where the member should be added. Must be ≥ 0.nValue
- The value to be added.- Returns:
- this
-
addNumber
@Nonnull public CSSExpression addNumber(float fValue)
Shortcut method to add a numeric value- Parameters:
fValue
- The value to be added.- Returns:
- this
-
addNumber
@Nonnull public CSSExpression addNumber(@Nonnegative int nIndex, float fValue)
Shortcut method to add a numeric value- Parameters:
nIndex
- The index where the member should be added. Must be ≥ 0.fValue
- The value to be added.- Returns:
- this
-
addNumber
@Nonnull public CSSExpression addNumber(double dValue)
Shortcut method to add a numeric value- Parameters:
dValue
- The value to be added.- Returns:
- this
-
addNumber
@Nonnull public CSSExpression addNumber(@Nonnegative int nIndex, double dValue)
Shortcut method to add a numeric value- Parameters:
nIndex
- The index where the member should be added. Must be ≥ 0.dValue
- The value to be added.- Returns:
- this
-
getQuotedStringValue
@Nonnull @Nonempty public static String getQuotedStringValue(@Nonnull String sValue)
Get a quoted string value. Every double quote (") is replaced to a backslash and a double quote (\").- Parameters:
sValue
- The source value. May not benull
.- Returns:
- An opening double quote + the quoted string + a closing double quote
- Since:
- 6.1.2
-
addString
@Nonnull public CSSExpression addString(@Nonnull String sValue)
Shortcut method to add a string value that is automatically quoted inside- Parameters:
sValue
- The value to be quoted and than added. May not benull
.- Returns:
- this
-
addString
@Nonnull public CSSExpression addString(@Nonnegative int nIndex, @Nonnull String sValue)
Shortcut method to add a string value that is automatically quoted inside- Parameters:
nIndex
- The index where the member should be added. Must be ≥ 0.sValue
- The value to be quoted and than added. May not benull
.- Returns:
- this
-
addURI
@Nonnull public CSSExpression addURI(@Nonnull @Nonempty String sURI)
Shortcut method to add a URI value- Parameters:
sURI
- The value to be added. May neither benull
nor empty- Returns:
- this
-
addURI
@Nonnull public CSSExpression addURI(@Nonnegative int nIndex, @Nonnull @Nonempty String sURI)
Shortcut method to add a URI value- Parameters:
nIndex
- The index where the member should be added. Must be ≥ 0.sURI
- The value to be added. May neither benull
nor empty- Returns:
- this
-
removeMember
@Nonnull public com.helger.commons.state.EChange removeMember(@Nullable ICSSExpressionMember aMember)
Remove the passed expression member- Parameters:
aMember
- The member to be removed. May benull
.- Returns:
EChange
-
removeMember
@Nonnull public com.helger.commons.state.EChange removeMember(@Nonnegative int nMemberIndex)
Remove the expression member at the specified in- Parameters:
nMemberIndex
- the index of the member to be removed. May not be < 0.- Returns:
EChange
-
removeAllMembers
@Nonnull public com.helger.commons.state.EChange removeAllMembers()
Remove all members.- Returns:
EChange.CHANGED
if any member was removed,EChange.UNCHANGED
otherwise. Nevernull
.- Since:
- 3.7.3
-
getAllMembers
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<ICSSExpressionMember> getAllMembers()
- Returns:
- A copy of all contained expression members. Never
null
.
-
getMemberAtIndex
@Nullable public ICSSExpressionMember getMemberAtIndex(@Nonnegative int nIndex)
Get the expression member at the specified index.- Parameters:
nIndex
- The index to be retrieved- Returns:
null
if an invalid member index was passed.
-
getMemberCount
@Nonnegative public int getMemberCount()
- Returns:
- The number of expression members present. Always ≥ 0.
-
getAllSimpleMembers
@Nonnull public com.helger.commons.collection.impl.ICommonsList<CSSExpressionMemberTermSimple> getAllSimpleMembers()
- Returns:
- A list with all expression members that are of type
CSSExpressionMemberTermSimple
-
getAsCSSString
@Nonnull public String getAsCSSString(@Nonnull ICSSWriterSettings aSettings, @Nonnegative int nIndentLevel)
Description copied from interface:ICSSWriteable
Get the contents of this object as a serialized CSS string for writing to an output.- Specified by:
getAsCSSString
in interfaceICSSWriteable
- Parameters:
aSettings
- The settings to be used to format the output. May not benull
.nIndentLevel
- The current indentation level- Returns:
- The content of this object as CSS string. Never
null
.
-
getSourceLocation
@Nullable public final CSSSourceLocation getSourceLocation()
- Specified by:
getSourceLocation
in interfaceICSSSourceLocationAware
- Returns:
- The source location of this object when it was read by the parser.
May be
null
if an object was not read but manually created.
-
setSourceLocation
public final void setSourceLocation(@Nullable CSSSourceLocation aSourceLocation)
Description copied from interface:ICSSSourceLocationAware
Set the source location of the object, determined while parsing.- Specified by:
setSourceLocation
in interfaceICSSSourceLocationAware
- Parameters:
aSourceLocation
- The source location to use. May benull
.
-
createSimple
@Nonnull public static CSSExpression createSimple(@Nonnull @Nonempty String sValue)
Create a CSS expression only containing a text value- Parameters:
sValue
- The value to be wrapped in an expression- Returns:
- The CSS expression to be used.
-
createString
@Nonnull public static CSSExpression createString(@Nonnull @Nonempty String sValue)
Create a CSS expression only containing a string- Parameters:
sValue
- The value to be wrapped in a string- Returns:
- The CSS expression to be used.
-
createNumber
@Nonnull public static CSSExpression createNumber(int nValue)
Create a CSS expression only containing a numeric value- Parameters:
nValue
- The value to be wrapped in an expression- Returns:
- The CSS expression to be used.
-
createNumber
@Nonnull public static CSSExpression createNumber(long nValue)
Create a CSS expression only containing a numeric value- Parameters:
nValue
- The value to be wrapped in an expression- Returns:
- The CSS expression to be used.
-
createNumber
@Nonnull public static CSSExpression createNumber(float fValue)
Create a CSS expression only containing a numeric value- Parameters:
fValue
- The value to be wrapped in an expression- Returns:
- The CSS expression to be used.
-
createNumber
@Nonnull public static CSSExpression createNumber(double dValue)
Create a CSS expression only containing a numeric value- Parameters:
dValue
- The value to be wrapped in an expression- Returns:
- The CSS expression to be used.
-
createURI
@Nonnull public static CSSExpression createURI(@Nonnull @Nonempty String sURI)
Create a CSS expression only containing a URI- Parameters:
sURI
- The URI to be wrapped in an expression- Returns:
- The CSS expression to be used.
-
-