The CSS specification
Contains reference information on CSS and explains how CSS concepts are used in JViews TGO.
Describes the main syntax elements of CSS.
Describes how CSS is applied to style Java objects instead of XML documents.
Describes the role of the CSS engine with respect to graphic objects.
Describes the set of functions provided for use directly in your CSS files.
Describes the way CSS has been adapted to accommodate Java objects.
CSS Syntax
CSS syntax is described more fully in the Using CSS syntax in the style sheet topic of the JViews Diagrammer documentation.
The main elements of syntax are:
Style rule
A CSS document, or style sheet, consists of a set of style rules. Each style rule starts with a selector and is followed by a declaration.
Selector
A selector is composed of one or more simple selectors. A simple selector is made of minimal building blocks. When two or more simple selectors are aggregated into a selector, they are separated by combinators. A combinator is a single character; extra spaces are ignored.
Declaration
Declarations are property-value pairs that are enclosed in braces ({}). The separator is a colon (:). Each declaration is terminated by a semicolon (;). The property represents a predefined graphic attribute and the value is a literal, with its type dependent on the property. All property-value pairs are String.
Priority
Priority depends on specificity. Specificity is computed as three numbers, a-b-c (in a number system with a large base). The number of ID building blocks in the selector gives the first number a, the number of classes and attributes gives b, and the number of element types gives c.
Cascading
Cascading consists in supplying several sources for the style: the browser, the user, and the document in HTML environments. Each source is weighted in relation to the others, with document style taking precedence over user style, which takes precedence over browser style when the specificity is the same. CSS can also make use of internal cascading, when it imports other style sheets by referring to a URL.
Inheritance
Inheritance of declarations occurs when matched declarations are sorted according to the priority of the rules and declarations are merged. Higher priority settings override lower ones as described in
The priority of CSS rules.
Applying CSS to Java objects
The CSS selector is designed to match HTML or XML documents. It can also be used to match a hierarchy of Java™ objects accessible through a model interface. The declarations are then sorted for the objects in the model and are used depending on the application that controls the CSS engine. In JViews TGO, declarations create and customize one graphic object for each object in the model.
The input model represents the kernel of the CSS for Java engine. It provides these important categories of information:
The tree structure of objects, which is exploited by selector transitions
Object type, ID, and CSS classes
Attribute value that matches the selector attribute of the same name
The declarations part represents property settings on a target object. The target object depends on the way the CSS engine is used. In JViews TGO, the target object is the rendering object associated with the object in the model. JViews TGO provides a default graphic representation for user-defined business classes and predefined business classes. This graphic representation has a set of properties that are used to customize its appearance.
Instead of using the default graphic representation supplied by
JViews TGO, you can define your own rendering object, an
IlvGraphic or a
JComponent. In this case, the declarations change property values on the graphic object that corresponds to the object matched in the model.
How to customize the graphic representation
object."test.Vehicle"[model=sports] {
icon: "sports-car.gif";
}
This example matches the object of the class test.Vehicle with the property model (which has the value sports ) and fixes the property icon of the graphic object associated with this object to sports-car.gif. (The association of the object with the graphic object is defined elsewhere.)
NOTE The enclosing double quotes around test.Vehicle are used so that the dot is not interpreted as a CSS class pattern; that is, an object of type test with CSS class Vehicle.
Property matching can be used to add dynamic behavior. An event that changes attribute values occurring on the model can activate the CSS engine to establish new property values.
How to add dynamic behavior through property matching
object.computer[state=down] {
foreground: gray;
}
This example changes the foreground color whenever an object of CSS class computer has the value of the property state set to down.
The CSS engine in JViews TGO
Describes the role of the CSS engine with respect to graphic objects.
Explains how to use expressions in CSS declarations.
Overview
In JViews TGO, the CSS engine is responsible for creating and customizing graphic objects and renderers when the data is loaded. At run time, the engine customizes the graphic objects according to changes in the model.
The left side of a declaration usually represents a JavaBean™ property of the graphic property. The right side is a literal. If the literal requires type conversion, the method setAsText() is invoked on the property editor associated with the JavaBean property.
Class property
The class property name is a reserved keyword that indicates the class name of the generated graphic object. JViews TGO provides a predefined representation for the objects in all graphic components, which means that the class property is optional. It can be used when you want to replace the predefined representation.
How to use the Class property
The right side of a class declaration could contain:
The class name, loaded with the application context class loader.
For example:
object {
class: ilog.views.sdm.graphic.IlvGeneralNode;
foreground: red;
}
A path name to a file. In fact, the class name is forwarded to the JavaBeans™ library with the method
java.beans.Beans.instantiate(), so a serialized JavaBean is suitable. For example:
object {
class: data.beans.gauge;
foreground: red;
}
The JavaBeans documentation states: “When using the beanName as a serialized object name, we convert the given beanName to a resource path name and add a trailing ‘.ser’ suffix. We then try to load a serialized object from that resource.”
In the example given, the method Beans.instantiate() would try to read a serialized object from the resource data/beans/gauge.ser.
In the network and equipment components, the class declaration is applied only when a creation request occurs. When the model state changes, graphic components are customized by applying only new declarations from the matching rules in the CSS. The class declaration is ignored. To change the class, the object in the model must be removed and then added again.
Model indirection
The right side of a declaration contains a literal that is converted dynamically through a property editor. If the literal is prefixed by @, the remainder of the string is treated as a model attribute name. The declaration expects the attribute value of the object from the model.
How to refer to attribute values of model objects
object."ilog.tgo.model.IltObject" {
label: @name;
}
The label property is set to the value of the attribute named name in the model.
Besides the standard model attributes, JViews TGO also provides the following attributes that you can use when customizing objects and graphic components:
@__ID Returns the object identifier. You can use it to customize objects as illustrated below:
object {
toolTipText: @__ID;
}
@__ADAPTER Returns the component adapter. You can use it to customize graphic components adapters. For more information about component customization using CSS, see the following topics:
Resolving URLs
Sometimes declaration values are URLs relative to the style sheet location. A special construct, standard in CSS level 2, allows you to create a URL from the base URL of the current style sheet. For example, the following declaration extends the path of the current style sheet URL with images/icon.gif.
How to extend the path of the current style sheet
imageURL: url(images/icon.gif);
This feature is very useful for creating style sheets with images located relative to the style sheet itself, since the URL remains valid even when the CSS is cascaded or imported elsewhere.
CSS recursion
You may want to specify a Java object as the value of a declaration. A simple convention allows you to recurse in the style sheet; that is, to define a new Java object which has the same style sheet, but is unrelated to the current model.
Prefix the value with @# to create a new JavaBean dynamically.
How to Create a New JavaBean Dynamically
object."Alarm/creationTime" {
toolTipText: "@#tooltipFormatBean";
label: @creationTime;
}
Subobject#toolTipFormatBean {
class:"ilog.cpl.util.text.IlpSimpleDataFormat";
pattern: "HH:mm:ss z";
}
The @# operator extends the current data model by adding a dummy model object as the child of the current object. The object ID of the dummy object is the remainder of the string, beyond the @# operator. The type of the dummy object is Subobject. The dummy object inherits CSS classes and attributes from its parent.
The CSS engine creates and customizes a new subobject according to the declarations it finds for the dummy object. This means, in particular, that the Java class of the subobject is determined by the value of the class property. The newly created subobject becomes the value of the @# expression. In the declarations for the subobject, attribute references through the @ operator refer to the attributes of the parent object.
Once the subobject is completed, the previous model is restored, so that normal processing is resumed.
In the example, an
IlpSimpleDateFormat object is created, with the pattern property set to
HH:mm:ss z, and is assigned to the
toolTipText property of the object.
There are two refinements to the @#ID operator:
@=ID Using @=ID instead of @#ID shares the instance. The first time the declaration is resolved, the object is created as with the @# operator. But for all subsequent access to the same value, @=ID returns the same instance, the one created the first time and without applying the CSS rules.
@+ID Using @+ID instead of @#ID avoids unnecessary creation of objects. The CSS engine first checks whether the property value corresponding to the declaration is defined and not null. If the property value is defined, this current value is customized directly using the rules for the #ID operator, deliberately ignoring any class declaration. If it is not defined, the operator behaves exactly as with the @# operator. In this case, the operator creates the property value only when required and customizes it in all cases.
The need for these refinements arises from a performance issue. The @# operator creates a new object each time a declaration is resolved. Usually, a declaration is applied when properties change. Under certain circumstances, the creation of objects may lead to expensive processing. These optional mechanisms minimize the creation of objects.
Expressions
The value in a CSS declaration is usually a literal. However, it is possible to write an expression in place of a literal.
If the value begins with @|, then the remainder of the value is processed as an expression.
The syntax of the expressions, after the @| prefix, is close to the Java syntax. The expression type can be arithmetic (type int, long, float, or double ), Boolean, or String. Examples:
@|3+2*5 -> 13
@|true&&(true||!true) -> true
@|start+end -> "startend"
You can use the following regular arithmetic operators, listed here in decreasing precedence:
Unary operators
+,
-,
!Exponentiation operator
^Multiplicative operators
*,
/,
%Additive operators
+,
-Relational operators
==,
!=,
<,
>,
<=,
>=Conditional operators
&&,
||Conditional operator
?:NOTE >> The conditional operator is left-associative, unlike in Java where it is right-associative. In CSS, the expression a ? b : c ? d : e is equivalent to (a ? b : c) ? d : e, whereas in Java it is equivalent to a ? b : (c ? d : e).
In conditional expressions such as A ? B : C, put spaces around the colon because a colon can also be part of a subexpression, for example, when B is @abc.
An expression can refer to model attributes. The syntax is the usual one:
@|@speed/100+@drift -> 1/100 of the value of speed plus the value of drift. speed and drift are attributes of the current object.
'@|"name is: " + @name' -> "name is: Bob", if the value of the current object attribute name is Bob. Note the use of quotation marks to keep the space characters. You could use the backslash (\) character instead, directly preceding the space characters to retain them. The backslash works to quote any character that directly follows it. The use of the backslash character makes sure that the character thus quoted is not interpreted by the expression parser.
For example, when you edit a style sheet directly and you use double quotation marks for the entire declaration value specification, you must use escaped double quotation marks for inner strings of CSS expressions.
node {
name: "@|concat(\"Name is \", @name)" ;
}
Alternatively, you can use quotation marks:
node {
name: '@|concat("Name is ", @name)' ;
}
The standard functions abs(), acos(), asin(), atan(), ceil(), cos(), exp(), floor(), log(), pi, rint(), round(), sin(), sqrt(), and tan() are accepted, as in, for example:
@|3+sin(pi/2) -> 4
The following functions are also available:
Function | Description |
concat(arg1,...,argn) | Returns the concatenation of the arguments arg1,...,argn as strings. |
emptyString() | Returns an empty string. |
messageFormat(format,arg0,arg1,... | Returns a formatted string. The formatting is done through the object MessageFormat corresponding to the first argument. See class java.text.MessageFormat for details. |
decimalFormat(format, arg) | Returns a formatted string. The formatting is done through the object DecimalFormat corresponding to the first argument. See class java.text.DecimalFormat for details. |
simpleDateFormat(format, arg[, locale]) | Returns a formatted string. The formatting is done through the object SimpleDateFormat corresponding to the first argument. See class java.text.SimpleDateFormat for details. |
customFormat(formatBean,arg0,arg1,...) | Returns a formatted string. formatBean must be a Java object of type MessageFormat, NumberFormat, or DateFormat, usually defined using the @#id syntax. |
locale() | Returns the locale of the object being styled or of the current context. |
localized(resourceBundleName, resourceName[, locale]) | Returns the localized value of the designated resource, fetched from a ResourceBundle, as a string. |
id() | Returns the ID of the object being styled. |
type() | Returns the CSS type of the object being styled. |
cast(expr,type) | Casts a value to a type. The second argument can be a fully qualified class name (entered as a string) or a class object. |
double(expr) | Evaluates the argument as an expression. The result is a number of type Double. |
float(expr) | Evaluates the argument as an expression. The result is a number of type Float. |
int(expr) | Evaluates the argument as an expression. The result is a number of type Integer. |
long(expr) | Evaluates the argument as an expression. The result is a number of type Long. |
min(arg0,arg1, ...) | Returns the smallest number among the arguments. All arguments must be numbers. Unless otherwise specified, the arguments are interpreted as numbers of type Double. |
max(arg0,arg1, ...) | Returns the largest number among the arguments. All arguments must be numbers. Unless otherwise specified, the arguments are interpreted as numbers of type Double. |
invoke(obj,methodname,signature,arg...) | Invokes a method on the object by introspection. The signature string specifies the argument types of the method as a comma separated list of (fully qualified) type names. The object and the arguments must be cast accordingly. For example, the specification @|invoke(cast(@val,java.lang.String),substring,"int,int",int(3),int(6)) corresponds to the call ((String)@val).substring(3,6). |
invokeStatic(classname,methodname,signature,arg...) | Invokes a static method on the specified class by introspection. The signature string specifies the argument types of the method as a comma separated list of (fully qualified) type names. The arguments must be cast accordingly. For example, the specification @|invokeStatic("java.lang.Math","atan2","double,double",double(0.6),double(0.4)) corresponds to the call java.lang.Math.atan2(0.6,0.4). |
new(classname,signature,arg...) | Invokes a constructor on the specified class by introspection. The signature string specifies the argument types of the method as a comma separated list of (fully qualified) type names. The arguments must be cast accordingly. For example, the specification @|new("java.util.Date","long",long(1293840000000)) corresponds to the call java.util.Date(1293840000000L). |
random() | Returns a random number between 0 (inclusive) and 1 (exclusive). |
random(n) | Returns a random number between 0 (inclusive) and n (exclusive). |
point(x, y) | Returns a point of type IlvPoint. |
rect(x, y, w, h) | Returns a rectangle of type IlvRect. |
blinkingColor(onColor, offColor) | Returns a blinking color with the timing specified in the IlvBlinkingRenderer. |
blinkingColor(onColor, offColor, onTime, offTime) | Returns a blinking color with the timing onTime and offTime specified in milliseconds. |
brighterColor(color) | Returns a brighter color. Corresponds to Color.brighter. |
darkerColor(color) | Returns a darker color. Corresponds to Color.darker. |
styleSheetURL() | Returns the URL of the current style sheet, if any. |
styleSheetURL(path) | Returns a URL specified by a path relative to the location of the style sheet. |
getGraphicFromId(id) | Returns the graphic object that corresponds to the SDM model object with the specified ID. |
childrenCount() | Returns the number of children in the SDM model for the current node, for instance if the current node is a subgraph. |
childrenCount(tag) | Returns the number of children with a given tag in the SDM model for the current node, for instance if the current node is a subgraph. |
depends(expr, prop1, ...,propn) | Returns the value of the expression argument. The expression is declared to depend on the mode properties prop1 to propn. When these properties change, the expression is re-evaluated. |
JViews TGO Functions
Functions for direct use in CSS files
Functions for direct use in CSS files
Function Name | Description | Class Name | Usage |
image | Retrieves an image from the Image Repository service registered in your application context. | | Parameter: image location Example: @|image("ilog/tgo/ilt_busy.png") |
resource | Retrieves a resource value from a given ResourceBundle. | | Parameters: ResourceBundle name (mandatory) Message identifier (mandatory) Default message value (optional). Returned if the message requested was not found in the given resource bundle. Example: @|resource("ilog.tgo.messages.JTGOMessages", "ilog.tgo.Operational_State") |
valuemap | Retrieves a value from an IlpValueMap object that corresponds to the specified key. | | Parameters: IlpValueMap instance Object key Example: @|valuemap(@#valuemap, @severity); |
format | Applies a format to the given values. | | Parameters: java.text.Format instance Arguments of the Format Example: @|format(@#formatBean, @attribute) |
blinkingcolor | Creates a blinking color. NOTE Blinking colors are not supported in table and tree components. | | Parameters: on color off color on period off period Example: @|blinkingcolor(black, white,1000, 500) |
pattern | Creates a pattern description, IlPattern, which can be used to customize the representation of JViews TGO predefined business objects. | | Parameter: Pattern type, which can have one of the following values: Grid, SkewGrid, Dots, ThinHatching. It can also generate patterns defined in IlvPattern, for example, LIGHT_VERTICAL. Depending on the pattern type, other arguments can be passed to configure the pattern instance. Grid patterns accept two integer arguments: xPeriod and yPeriod. SkewGrid patterns accept two integer arguments: uPeriod and vPeriod. Examples: @|pattern("Grid", 3, 2) @|pattern("SkewGrid", 2, 2) @|pattern("LIGHT_VERTICAL") |
acknowledgedAlarmCount | Returns the number of acknowledged alarms for a given business object. | | Parameter: One of the following possibilities: Default: all raw severities or traps Impact: all impact alarm severities Alarm severity name: for example, Raw.Major, Impact.MajorHigh Examples: label: '@|acknowledgedAlarmCount("Impact")'; label: '@|acknowledgedAlarmCount("Impact.MajorHigh")'; |
acknowledgedAlarmSummary | Returns a summary of acknowledged alarms for a given business object. The returned value is a String listing the number of acknowledged alarms for each chosen severity. | | Parameter: One of the following possibilities: Default: all raw severities or traps Impact: all impact alarm severities Alarm severity name: for example, Raw.Major, Impact.MajorHigh Examples: label: '@|acknowledgedAlarmSummary("Impact")'; label: '@|acknowledgedAlarmSummary("Raw.Major")'; |
alarmCount | Returns the number of outstanding alarms for a given business object. | | Parameter: One of the following possibilities: Default: all raw severities or traps Impact: all impact alarm severities Alarm severity name: for example, Raw.Major, Impact.MajorHigh Examples: label: '@|alarmCount("Impact")'; label: '@|alarmCount("Raw.Major")'; |
alarmSummary | Returns the summary of new and acknowledged alarms for a given business object. | | Parameter: One of the following possibilities: Default: all raw severities or traps Impact: all impact alarm severities Alarm severity name: for example, Raw.Major, Impact.MajorHigh Examples: label: '@|alarmSummary()'; ///Equivalent to "Default" label: '@|alarmSummary("Impact")'; ///Impact alarms label: '@|alarmSummary("Raw.Major")'; ///Consider only raw major alarms |
highestAcknowledgedSeverity | Returns the highest severity of acknowledged alarms for a given business object. | | Parameter: One of the following possibilities: Default: all raw alarm severities or traps Impact: all impact alarm severities Alarm severity name: for example, Raw.Major, Impact.MajorHigh Examples: label: '@|highestAcknowledgedSeverity()'; ///Equivalent to "Default" label: '@|highestAcknowledgedSeverity("Impact")'; ///Impact alarms label: '@|highestAcknowledgedSeverity("Raw.Major")'; ///Consider only raw major alarms |
highestNewSeverity | Returns the highest severity of new alarms for a given business object. | | Parameter: One of the following possibilities: Default: all raw alarm severities or traps Impact: all impact alarm severities Alarm severity name: for example, Raw.Major, Impact.MajorHigh Examples: label: '@|highestNewSeverity()'; ///Equivalent to "Default" label: '@|highestNewSeverity("Impact")'; ///Impact alarms label: '@|highestNewSeverity("Raw.Major")'; ///Consider only raw major alarms |
highestSeverity | Returns the highest severity of outstanding alarms for a given business object. | | Parameter: One of the following possibilities: Default: all raw alarm severities or traps Impact: all impact alarm severities Alarm severity name: for example, Raw.Major, Impact.MajorHigh Examples: label: '@|highestSeverity()'; ///Equivalent to "Default" label: '@|highestSeverity("Impact")'; ///Impact alarms label: '@|highestSeverity("Raw.Major")'; ///Consider only raw major alarms |
newAlarmCount | Returns the number of new alarms for a given business object. | | Parameter: One of the following possibilities: Default: all raw alarm severities or traps Impact: all impact alarm severities Alarm severity name: for example, Raw.Major, Impact.MajorHigh Examples: label: '@|newAlarmCount()'; ///Equivalent to "Default" label: '@|newAlarmCount("Impact")'; ///Impact alarms label: '@|newAlarmCount("Impact.MajorLow")'; ///Consider only raw major alarms |
newAlarmSummary | Returns the summary of new alarms for a given business object. | | Parameter: One of the following possibilities: Default: all raw alarm severities or traps Impact: all impact alarm severities Alarm severity name: for example, Raw.Major, Impact.MajorHigh Examples: label: '@|newAlarmSummary()'; ///Equivalent to "Default" label: '@|newAlarmSummary("Impact")'; ///Impact alarms label: '@|newAlarmSummary("Impact.MajorLow")'; ///Consider only raw major alarms |
primaryStateSummary | Returns the summary of the primary state information for a given business object. | | Example: label: '@|primaryStateSummary()'; |
secondaryStateSummary | Returns the summary of the secondary state information for a given business object. | | Example: label: '@|secondaryStateSummary()'; |
settings | | | Parameter: Setting key Example: icon: '@|settings("Link.Media.Fiber.Icon")'; |
severityColor | Returns the color corresponding to a given alarm severity. | | Parameter: Alarm severity Examples: labelBackgroundColor: '@|severityColor(@|highestNewSeverity())'; labelBackgroundColor: '@|severityColor("Raw.Major")'; |
severityBrightColor | Returns the bright color corresponding to a given alarm severity. | | Parameter: Alarm severity Example: alarmBrightColor: '@|severityBrightColor(@|highestNewSeverity())'; |
severityDarkColor | Returns the dark color corresponding to a given alarm severity. | | Parameter: Alarm severity Example: alarmDarkColor: '@|severityDarkColor(@|highestNewSeverity())'; |
severityIcon | Returns the icon corresponding to a given alarm severity. | | Parameter: IltAlarmSeverity or the String representation of an IltAlarmSeverity. Example: alarmIcon: '@|severityIcon("Raw.Major")'; alarmIcon: '@|severityIcon(@|highestSeverity())'; alarmIcon: '@|severityIcon(@|highestSeverity("Impact"))'; |
tinyImage | Returns an image displaying the tiny representation of a predefined business object. | | Example: icon : '@|tinyImage()'; |
How to create new CSS functions
JViews TGO allows you to create and register new functions to be used in CSS files to customize the representation of your business objects. These functions should implement the interface
IlpCSSFunction. This interface defines the following methods:
Returns the name of the function that is used to identify the function in the CSS files.
Returns the delimiters that are used to identify the parameters of the function; for example, comma ( , ).
Indicates whether the delimiters will also be returned as tokens.
This method is the core of the function, where the value will be computed and returned.
The signature of the main method is:
public Object call (Object[] args,
Class type,
IlpContext appc,
IlpGraphicView view,
IlpRepresentationObject ro,
IlpAttribute attribute);
When a function is evaluated, the parameters are first resolved as subexpressions. Then, the final values of the parameters are passed to the args array.
The parameter type is the expected type of the function when it is known. A null value is possible. The implementation should be careful to return an object of the appropriate type. Otherwise, a simple conversion is applied, if conversion is possible, that is, between primitive types or to a String.
The other parameters provide information about the application context, graphic view, representation object, and attribute at the time when the call is made. Stateless expressions do not need these parameters.
If an error occurs during a call, an exception will be reported and the current property setting will be canceled.
The following application is provided as part of the
JViews TGO demonstration software:
<installdir> /samples/framework/datasource-explorer2. It shows how to implement and register a new function. See file ByteFunction.java.
Functions are registered in the CSS file with one of the following properties:
functionList : lists the functions as a comma-separated list of function names.
functions : an indexed property of function names. Allows you to specify the list of functions according to indices. With this indexed property, you can register functions in a modular way in different CSS files.
How to register a function in a CSS file
StyleSheet {
functionList: "test.function.FirstFunction,test.function.SecondFunction";
}
or
StyleSheet {
functions[0]: "test.function.FirstFunction";
functions[1]: "test.function.SecondFunction";
}
Divergences from CSS2
Java objects are not HTML documents. The differences lead to an adaptation of the CSS, so that its power can be fully exploited. The CSS2 syntax is retained. Therefore, a CSS editor can still be used to create the style sheet.
Cascading
Cascading is explicit. The API provides a means of cascading the style sheets. The !important and inherit tags are not supported. They have not been implemented for the sake of simplicity.
Pseudo-classes and pseudo-elements
Pseudo-classes are minimal building blocks which match model objects according to an external context. The syntax is like a CSS class, but uses a colon (:) instead of a dot (.). For example,
:link-visited matches a link element only if it is already visited. Only the browser can resolve this
pseudoclass at run time.
The pseudo-classes are fully implemented and are used by all JViews TGO renderers. JViews TGO recognizes the pseudo-classes :selected, :focus, and :expanded by default.
A pseudo-class has the same
specificity as a CSS class.
Pseudo-elements are metaclasses like pseudo-classes, but match document structure instead of the browser state; for example, :first-child.
The CSS2 predefined
pseudoelements and pseudo-classes (
:link,
:hover, and so forth) are not implemented: they have no meaning in Java™.
Attribute matching
Each attribute value must be converted to String. This conversion is done using the Type converter specified in your application context.
The attribute pattern in CSS2 checks only the presence [att], equality [att=val], and inclusion [att~=val] of strings. The |= operator is disabled. In Java, numeric comparators >, >=, <>, <=, < have been added, with the usual semantics.
Operators available in the attribute selectors
Operator | Meaning | Applicable To |
A | present | strings |
A=val | equals | strings |
A~val | not equals | strings |
A~=val | contains the word | strings |
A==val | equals | numbers |
A<>val | not equals | numbers |
A<val | less than | numbers |
A<=val | less than or equals | numbers |
A>val | greater than | numbers |
A>=val | greater than or equals | numbers |
Syntax enhancement
CSS for Java requires the use of quotation marks when a token contains special characters such as dot (.), colon (:), commercial at sign (@), hash sign (#), space ( ), and so on. Quotes can be used almost everywhere, in particular to delimit a declaration value, an element type, or a CSS class with reserved characters. The closing semicolon (;) is optional.
Null value
Sometimes it makes sense to specify a null value in a declaration. By convention, null is a zero-length string '' or "".
How to specify a null value
object {
labelBackground: '';
}
The notation '' is also used to denote a null array for properties that expect an array of values.
Empty string
The null syntax does not distinguish the ability to write an empty string in the style sheets. If an empty string is required, it is easy to create it dynamically.
How to create an empty string
object {
label: @#emptyString;
}
Subobject#emptyString {
class: 'java.lang.String';
}
NOTE You can use the sharing mechanism to avoid creating several strings. The @= construct creates the empty string the first time only and reuses the same instance for all other occurrences of @=emptyString.
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.