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 CSSExpressionaddMember(int nIndex, ICSSExpressionMember aMember)Add an expression memberCSSExpressionaddMember(ICSSExpressionMember aMember)Add an expression memberCSSExpressionaddNumber(double dValue)Shortcut method to add a numeric valueCSSExpressionaddNumber(float fValue)Shortcut method to add a numeric valueCSSExpressionaddNumber(int nValue)Shortcut method to add a numeric valueCSSExpressionaddNumber(int nIndex, double dValue)Shortcut method to add a numeric valueCSSExpressionaddNumber(int nIndex, float fValue)Shortcut method to add a numeric valueCSSExpressionaddNumber(int nIndex, int nValue)Shortcut method to add a numeric valueCSSExpressionaddNumber(int nIndex, long nValue)Shortcut method to add a numeric valueCSSExpressionaddNumber(long nValue)Shortcut method to add a numeric valueCSSExpressionaddString(int nIndex, String sValue)Shortcut method to add a string value that is automatically quoted insideCSSExpressionaddString(String sValue)Shortcut method to add a string value that is automatically quoted insideCSSExpressionaddTermSimple(int nIndex, String sValue)Shortcut method to add a simple text value.CSSExpressionaddTermSimple(String sValue)Shortcut method to add a simple text value.CSSExpressionaddURI(int nIndex, String sURI)Shortcut method to add a URI valueCSSExpressionaddURI(String sURI)Shortcut method to add a URI valuestatic CSSExpressioncreateNumber(double dValue)Create a CSS expression only containing a numeric valuestatic CSSExpressioncreateNumber(float fValue)Create a CSS expression only containing a numeric valuestatic CSSExpressioncreateNumber(int nValue)Create a CSS expression only containing a numeric valuestatic CSSExpressioncreateNumber(long nValue)Create a CSS expression only containing a numeric valuestatic CSSExpressioncreateSimple(String sValue)Create a CSS expression only containing a text valuestatic CSSExpressioncreateString(String sValue)Create a CSS expression only containing a stringstatic CSSExpressioncreateURI(String sURI)Create a CSS expression only containing a URIbooleanequals(Object o)com.helger.commons.collection.impl.ICommonsList<ICSSExpressionMember>getAllMembers()com.helger.commons.collection.impl.ICommonsList<CSSExpressionMemberTermSimple>getAllSimpleMembers()StringgetAsCSSString(ICSSWriterSettings aSettings, int nIndentLevel)Get the contents of this object as a serialized CSS string for writing to an output.ICSSExpressionMembergetMemberAtIndex(int nIndex)Get the expression member at the specified index.intgetMemberCount()static StringgetQuotedStringValue(String sValue)Get a quoted string value.CSSSourceLocationgetSourceLocation()inthashCode()com.helger.commons.state.EChangeremoveAllMembers()Remove all members.com.helger.commons.state.EChangeremoveMember(int nMemberIndex)Remove the expression member at the specified incom.helger.commons.state.EChangeremoveMember(ICSSExpressionMember aMember)Remove the passed expression membervoidsetSourceLocation(CSSSourceLocation aSourceLocation)Set the source location of the object, determined while parsing.StringtoString()-
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 benullnor 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 benullnor 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 benullnor 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 benullnor 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.CHANGEDif any member was removed,EChange.UNCHANGEDotherwise. 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:
nullif 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:ICSSWriteableGet the contents of this object as a serialized CSS string for writing to an output.- Specified by:
getAsCSSStringin 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:
getSourceLocationin interfaceICSSSourceLocationAware- Returns:
- The source location of this object when it was read by the parser.
May be
nullif an object was not read but manually created.
-
setSourceLocation
public final void setSourceLocation(@Nullable CSSSourceLocation aSourceLocation)
Description copied from interface:ICSSSourceLocationAwareSet the source location of the object, determined while parsing.- Specified by:
setSourceLocationin 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.
-
-