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 CssSelectorBuilderattrContains(Object name, Object value)[name*=a]CssSelectorBuilderattrContainsPart(Object name, Object value)[lang|=CH]CssSelectorBuilderattrContainsWord(Object name, Object value)[name~=red]CssSelectorBuilderattrEndsWith(Object name, Object value)[name$=bar]CssSelectorBuilderattrEquals(Object name, Object value)[type=input]CssSelectorBuilderattrExists(Object name)[type]CssSelectorBuilderattrStartsWith(Object name, Object value)[name^=foo]Stringbuild()CssSelectorBuilderchild().foo > .barCssSelectorBuilderclazz(String className).my-classCssSelectorBuildercustom(String selector)Appends a custom selector.CssSelectorBuilderid(String id)#my-idCssSelectorBuildersibling().foo ~ .barCssSelectorBuildersub().foo .barCssSelectorBuildertagName(String tagName)inputStringtoString()
-
-
-
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 > .barAppends 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-classAppends 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-idAppends 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 ~ .barAppends a child selector that selects the siblings.
- Returns:
- This builder instance for chaining method calls.
-
sub
public CssSelectorBuilder sub()
.foo .barAppends 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)
inputAppends 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.
-
-