public class CSSClass extends Object
Modifier and Type | Class and Description |
---|---|
class |
CSSClass.InvalidCSS
Exception class thrown when encountering invalid CSS.
|
Modifier and Type | Field and Description |
---|---|
private String |
name
CSS class name
|
private WeakReference<Object> |
owner
Owner.
|
private Collection<Pair<String,String>> |
statements
Actual CSS statements
|
Constructor and Description |
---|
CSSClass(Object owner,
String name)
Simplified constructor, empty statements list.
|
CSSClass(Object owner,
String name,
Collection<Pair<String,String>> statements)
Full constructor
|
CSSClass(Object owner,
String name,
CSSClass other)
Cloning constructor
|
Modifier and Type | Method and Description |
---|---|
void |
appendCSSDefinition(StringBuffer buf)
Append CSS definition to a stream
|
static boolean |
checkCSSStatement(String key,
String value)
Validate a single CSS statement.
|
static boolean |
checkCSSStatements(Collection<Pair<String,String>> statements)
Validate a set of CSS statements.
|
static boolean |
checkName(String name)
Verify that the name is an admissible CSS class name.
|
String |
getName()
Get the class name.
|
Object |
getOwner()
Get class owner.
|
String |
getStatement(String key)
Get the current value of a particular CSS statement.
|
Collection<Pair<String,String>> |
getStatements()
Get read-only collection access to all statements.
|
String |
inlineCSS()
Render CSS class to inline formatting
|
void |
removeStatement(String key)
Remove a CSS statement.
|
static String |
sanitizeName(String name)
Return a sanitized version of the given string.
|
void |
setName(String name)
Set the class name.
|
void |
setStatement(String key,
double value)
Set a CSS statement.
|
void |
setStatement(String key,
int value)
Set a CSS statement.
|
void |
setStatement(String key,
String value)
Set a CSS statement.
|
private String name
private Collection<Pair<String,String>> statements
private WeakReference<Object> owner
public CSSClass(Object owner, String name, Collection<Pair<String,String>> statements)
owner
- Class owner (to detect conflicts)name
- Class namestatements
- Collection of CSS statementspublic CSSClass(Object owner, String name)
owner
- Class owner.name
- Class name.public static boolean checkName(String name)
name
- name to usepublic static String sanitizeName(String name)
name
- name to sanitizepublic static boolean checkCSSStatement(String key, String value)
key
- Keyvalue
- Valuepublic static boolean checkCSSStatements(Collection<Pair<String,String>> statements)
statements
- Statements to checkpublic String getName()
public void setName(String name)
name
- new class name.public Object getOwner()
public String getStatement(String key)
key
- statement key.public Collection<Pair<String,String>> getStatements()
public void setStatement(String key, String value)
key
- Statement key.value
- Value or null (to unset)public void setStatement(String key, int value)
key
- Statement key.value
- Valuepublic void setStatement(String key, double value)
key
- Statement key.value
- Valuepublic void removeStatement(String key)
key
- Statement key.public void appendCSSDefinition(StringBuffer buf)
buf
- String buffer to append to.public String inlineCSS()