Rule
Class
A CSS style rule. A block is created with provided selector(s), which can then have individual key/value rules written to it.
Basic rules can be created with the constructor. Advanced rules can be created via the static methods.
These rules can be written into a style element.
Object
Writable
public
Rule.of(DIV).rule("border-bottom", "2px solid black")
Rule.of(P, Qualifier.ATTRIBUTE_EQUALS.of("blob", "hello")).rule("color", "blue")
new Rule(DIV).rule("background", "red")
Constructors
new Rule (Object...)
ConstructorA rule with multiple selectors.
These will be written as first second third {...}
.
This can accept HTMElement
s or string tag names.
Index | Type | Name |
---|---|---|
1 | Object[] | object |
Rule
public varargs
// Randomly-generated example
final Rule rule = new Rule(object);
rule.toString();
assert rule.write(stream, charset) == null;
rule.rule(key, value, important);
new Rule (String...)
ConstructorA rule with multiple selectors.
These will be written as first second third {...}
.
Index | Type | Name |
---|---|---|
1 | String[] | string |
Rule
public varargs
// Randomly-generated example
final Rule rule = new Rule(string);
rule.toString();
assert rule.write(stream, charset) == null;
rule.rule(key, value, important);
Methods
toString ()
MethodString
public
of (HTMElement, TargetQualifier)
MethodWrites a new selector with an advanced qualifier.
These can be simple tags such as p::before
or advanced attribute selectors
like div[name=bean]
.
These can be written using the Qualifier enum.
Index | Type | Name |
---|---|---|
1 | HTMElement | before |
2 | TargetQualifier | qualifier |
Rule
public static
Rule.of(DIV, ATTRIBUTE_EQUALS.of("name", "hello"))
div[name=hello] {
}
of (HTMElement)
MethodWrites a simple selector for this element's tag.
Index | Type | Name |
---|---|---|
1 | HTMElement | element |
Rule
public static
of (String, TargetQualifier)
MethodWrites a selector for the string tag with a qualifier.
This can be used to build complex selectors.
Index | Type | Name |
---|---|---|
1 | String | before |
2 | TargetQualifier | qualifier |
Rule
public static
of (TargetQualifier)
MethodWrites a selector for a qualifier.
This can be used to select special elements.
Index | Type | Name |
---|---|---|
1 | TargetQualifier | qualifier |
Rule
public static
exact (HTMElement)
MethodWrites an exact selector for the tag, properties and classes of this element.
Index | Type | Name |
---|---|---|
1 | HTMElement | element |
Rule
public static
Rule.exact(DIV
.classes("bean")
.set("blob", "hello")
)
div[blob=hello].bean {
}
before (HTMElement, HTMElement)
MethodWrites a new selector for tags immediately before each other.
Index | Type | Name |
---|---|---|
1 | HTMElement | before |
2 | HTMElement | after |
Rule
public static
Rule.before(UL, P)
p ~ ul {
}
after (HTMElement, HTMElement)
MethodWrites a new selector for tags immediately after each other.
Index | Type | Name |
---|---|---|
1 | HTMElement | before |
2 | HTMElement | after |
Rule
public static
Rule.after(UL, P)
ul + p {
}
child (HTMElement, HTMElement)
MethodWrites a new selector for child tags inside an immediate parent tag.
Index | Type | Name |
---|---|---|
1 | HTMElement | parent |
2 | HTMElement | child |
Rule
public static
Rule.child(DIV, P)
div > p {
}
all (HTMElement...)
MethodWrites a selector for all of the given elements.
Index | Type | Name |
---|---|---|
1 | HTMElement[] | elements |
Rule
public static varargs
Rule.all(UL, P, DIV, BR)
ul, p, div, br {
}
rule (String, String, boolean)
MethodAdds a new rule to the block with the !important
tag.
Index | Type | Name |
---|---|---|
1 | String | key |
2 | String | value |
3 | boolean | important |
Rule
public
new Rule(DIV).rule("background", "red", true)
div {
background: red !important;
}
rule (String, String)
MethodAdds a new rule to the block.
Index | Type | Name |
---|---|---|
1 | String | key |
2 | String | value |
Rule
public
new Rule(DIV).rule("background", "red")
div {
background: red;
}
inside (HTMElement, HTMElement)
MethodWrites a new selector for inner tags inside an outer tag.
Index | Type | Name |
---|---|---|
1 | HTMElement | outer |
2 | HTMElement | inner |
Rule
public static
Rule.inside(DIV, P)
div p {
}
everything ()
MethodWrites a selector for everything.
Rule
public static
Rule.everything()
* {
}