Class CssSelectorBuilder
- java.lang.Object
-
- de.xima.fc.css.builder.CssSelectorBuilder
-
public final class CssSelectorBuilder extends Object
Simple builder for creating CSS selector string, e.g..foo[type=input]
- Author:
- XIMA MEDIA GmbH
-
-
Constructor Summary
Constructors Constructor Description CssSelectorBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CssSelectorBuilder
attrContains(Object name, Object value)
[name*=a]
CssSelectorBuilder
attrContainsPart(Object name, Object value)
[lang|=CH]
CssSelectorBuilder
attrContainsWord(Object name, Object value)
[name~=red]
CssSelectorBuilder
attrEndsWith(Object name, Object value)
[name$=bar]
CssSelectorBuilder
attrEquals(Object name, Object value)
[type=input]
CssSelectorBuilder
attrExists(Object name)
[type]
CssSelectorBuilder
attrStartsWith(Object name, Object value)
[name^=foo]
String
build()
CssSelectorBuilder
child()
.foo > .bar
CssSelectorBuilder
clazz(String className)
.my-class
CssSelectorBuilder
custom(String selector)
Appends a custom selector.CssSelectorBuilder
id(String id)
#my-id
CssSelectorBuilder
sibling()
.foo ~ .bar
CssSelectorBuilder
sub()
.foo .bar
CssSelectorBuilder
tagName(String tagName)
input
String
toString()
-
-
-
Method Detail
-
attrContains
public CssSelectorBuilder attrContains(Object name, Object value)
[name*=a]
Appends an attribute selector for matching an attribute that contains the given value.
- Parameters:
name
- Name of the attribute to match.value
- Value to compare against the attribute.- Returns:
- This builder instance for chaining method calls.
-
attrContainsPart
public CssSelectorBuilder attrContainsPart(Object name, Object value)
[lang|=CH]
Appends an attribute selector for matching an attribute that contains a hyphen case part the given value.
Precisely, represents elements with an attribute name whose value can be exactly value or can begin with value immediately followed by a hyphen, - (U+002D). It is often used for language subcode matches.
- Parameters:
name
- Name of the attribute to match.value
- Value to compare against the attribute.- Returns:
- This builder instance for chaining method calls.
-
attrContainsWord
public CssSelectorBuilder attrContainsWord(Object name, Object value)
[name~=red]
Appends an attribute selector for matching an attribute that contains a word the given value.
- Parameters:
name
- Name of the attribute to match.value
- Value to compare against the attribute.- Returns:
- This builder instance for chaining method calls.
-
attrEndsWith
public CssSelectorBuilder attrEndsWith(Object name, Object value)
[name$=bar]
Appends an attribute selector for matching an attribute that ends with the given value.
- Parameters:
name
- Name of the attribute to match.value
- Value to compare against the attribute.- Returns:
- This builder instance for chaining method calls.
-
attrEquals
public CssSelectorBuilder attrEquals(Object name, Object value)
[type=input]
Appends an attribute selector for matching the attribute value exactly.
- Parameters:
name
- Name of the attribute to match.value
- Value to compare against the attribute.- Returns:
- This builder instance for chaining method calls.
-
attrExists
public CssSelectorBuilder attrExists(Object name)
[type]
Appends an attribute selector for matching an element that has an attribute with the given name.
- Parameters:
name
- Name of the attribute to match.- Returns:
- This builder instance for chaining method calls.
-
attrStartsWith
public CssSelectorBuilder attrStartsWith(Object name, Object value)
[name^=foo]
Appends an attribute selector for matching an attribute that starts with the given value.
- Parameters:
name
- Name of the attribute to match.value
- Value to compare against the attribute.- Returns:
- This builder instance for chaining method calls.
-
build
public String build()
- Returns:
- The string representing the CSS selector.
-
child
public CssSelectorBuilder child()
.foo > .bar
Appends a child selector that selects nodes that are direct children of the first element.
- Returns:
- This builder instance for chaining method calls.
-
clazz
public CssSelectorBuilder clazz(String className)
.my-class
Appends a selector for matching elements with the given class name.
- Parameters:
className
- Name of the CSS class.- Returns:
- This builder instance for chaining method calls.
-
custom
public CssSelectorBuilder custom(String selector)
Appends a custom selector.- Parameters:
selector
- Custom selector string to append.- Returns:
- This builder instance for chaining method calls.
-
id
public CssSelectorBuilder id(String id)
#my-id
Appends a selector for matching elements with the given ID.
- Parameters:
id
- Name of the HTML tag.- Returns:
- This builder instance for chaining method calls.
-
sibling
public CssSelectorBuilder sibling()
.foo ~ .bar
Appends a child selector that selects the siblings.
- Returns:
- This builder instance for chaining method calls.
-
sub
public CssSelectorBuilder sub()
.foo .bar
Appends a selector for matching elements in the subtree of the currently matching element.
- Returns:
- This builder instance for chaining method calls.
-
tagName
public CssSelectorBuilder tagName(String tagName)
input
Appends a selector for matching elements with the given tag name.
- Parameters:
tagName
- Name of the HTML tag.- Returns:
- This builder instance for chaining method calls.
-
-