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 -
Method Summary
Modifier and TypeMethodDescriptionaddMember(int nIndex, ICSSExpressionMember aMember) Add an expression memberaddMember(ICSSExpressionMember aMember) Add an expression memberaddNumber(double dValue) Shortcut method to add a numeric valueaddNumber(float fValue) Shortcut method to add a numeric valueaddNumber(int nValue) Shortcut method to add a numeric valueaddNumber(int nIndex, double dValue) Shortcut method to add a numeric valueaddNumber(int nIndex, float fValue) Shortcut method to add a numeric valueaddNumber(int nIndex, int nValue) Shortcut method to add a numeric valueaddNumber(int nIndex, long nValue) Shortcut method to add a numeric valueaddNumber(long nValue) Shortcut method to add a numeric valueShortcut method to add a string value that is automatically quoted insideShortcut method to add a string value that is automatically quoted insideaddTermSimple(int nIndex, String sValue) Shortcut method to add a simple text value.addTermSimple(String sValue) Shortcut method to add a simple text value.Shortcut method to add a URI valueShortcut 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 CSSExpressionCreate a CSS expression only containing a URIbooleancom.helger.commons.collection.impl.ICommonsList<ICSSExpressionMember> com.helger.commons.collection.impl.ICommonsList<CSSExpressionMemberTermSimple> getAsCSSString(ICSSWriterSettings aSettings, int nIndentLevel) Get the contents of this object as a serialized CSS string for writing to an output.getMemberAtIndex(int nIndex) Get the expression member at the specified index.intstatic StringgetQuotedStringValue(String sValue) Get a quoted string value.final CSSSourceLocationinthashCode()com.helger.commons.state.EChangeRemove 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 memberfinal voidsetSourceLocation(CSSSourceLocation aSourceLocation) Set the source location of the object, determined while parsing.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.css.ICSSWriteable
getAsCSSString, getAsCSSString
-
Constructor Details
-
CSSExpression
public CSSExpression()
-
-
Method Details
-
addMember
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
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
Shortcut method to add a numeric value- Parameters:
nValue- The value to be added.- Returns:
- this
-
addNumber
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
Shortcut method to add a numeric value- Parameters:
nValue- The value to be added.- Returns:
- this
-
addNumber
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
Shortcut method to add a numeric value- Parameters:
fValue- The value to be added.- Returns:
- this
-
addNumber
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
Shortcut method to add a numeric value- Parameters:
dValue- The value to be added.- Returns:
- this
-
addNumber
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
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
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
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
Shortcut method to add a URI value- Parameters:
sURI- The value to be added. May neither benullnor empty- Returns:
- this
-
addURI
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
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
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
Get the expression member at the specified index.- Parameters:
nIndex- The index to be retrieved- Returns:
nullif an invalid member index was passed.
-
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
- 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
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.
-
equals
-
hashCode
public int hashCode() -
toString
-
createSimple
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
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
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
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
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
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
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.
-