|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jsoup.select.Elements
public class Elements
A list of Elements
, with methods that act on every element in the list
Constructor Summary | |
---|---|
Elements()
|
|
Elements(Collection<Element> elements)
|
|
Elements(Element... elements)
|
|
Elements(List<Element> elements)
|
Method Summary | ||
---|---|---|
boolean |
add(Element element)
|
|
void |
add(int index,
Element element)
|
|
boolean |
addAll(Collection<? extends Element> c)
|
|
boolean |
addAll(int index,
Collection<? extends Element> c)
|
|
Elements |
addClass(String className)
Add the class name to every matched element's class attribute. |
|
String |
attr(String attributeKey)
Get the attribute value of the first matched element. |
|
Elements |
attr(String attributeKey,
String attributeValue)
Set an attribute on all matched elements. |
|
void |
clear()
|
|
boolean |
contains(Object o)
|
|
boolean |
containsAll(Collection<?> c)
|
|
Elements |
eq(int index)
Reduce the matched elements to one element |
|
boolean |
equals(Object o)
|
|
Element |
first()
Get the first matched element. |
|
Element |
get(int index)
|
|
boolean |
hasAttr(String attributeKey)
Checks if any of the matched elements have this attribute set. |
|
boolean |
hasClass(String className)
Determine if any of the matched elements have this class name set in their class attribute. |
|
int |
hashCode()
|
|
boolean |
hasText()
|
|
int |
indexOf(Object o)
|
|
boolean |
is(String query)
Test if any of the matched elements match the supplied query. |
|
boolean |
isEmpty()
|
|
Iterator<Element> |
iterator()
|
|
Element |
last()
Get the last matched element. |
|
int |
lastIndexOf(Object o)
|
|
ListIterator<Element> |
listIterator()
|
|
ListIterator<Element> |
listIterator(int index)
|
|
Element |
remove(int index)
|
|
boolean |
remove(Object o)
|
|
boolean |
removeAll(Collection<?> c)
|
|
Elements |
removeAttr(String attributeKey)
Remove an attribute from every matched element. |
|
Elements |
removeClass(String className)
Remove the class name from every matched element's class attribute, if present. |
|
boolean |
retainAll(Collection<?> c)
|
|
Elements |
select(String query)
Find matching elements within this element list. |
|
Element |
set(int index,
Element element)
|
|
int |
size()
|
|
List<Element> |
subList(int fromIndex,
int toIndex)
|
|
String |
text()
Get the combined text of all the matched elements. |
|
Object[] |
toArray()
|
|
|
toArray(T[] a)
|
|
Elements |
toggleClass(String className)
Toggle the class name on every matched element's class attribute. |
|
Elements |
wrap(String html)
Wrap the supplied HTML around each matched elements. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Elements()
public Elements(Collection<Element> elements)
public Elements(List<Element> elements)
public Elements(Element... elements)
Method Detail |
---|
public String attr(String attributeKey)
attributeKey
- The attribute key.
hasAttr(String)
public boolean hasAttr(String attributeKey)
attributeKey
- attribute key
public Elements attr(String attributeKey, String attributeValue)
attributeKey
- attribute keyattributeValue
- attribute value
public Elements removeAttr(String attributeKey)
attributeKey
- The attribute to remove.
public Elements addClass(String className)
class
attribute.
className
- class name to add
public Elements removeClass(String className)
class
attribute, if present.
className
- class name to remove
public Elements toggleClass(String className)
class
attribute.
className
- class name to add if missing, or remove if present, from every element.
public boolean hasClass(String className)
class
attribute.
className
- class name to check for
public String text()
Note that it is possible to get repeats if the matched elements contain both parent elements and their own children, as the Element.text() method returns the combined text of a parent and all its children.
Element.text()
public boolean hasText()
public Elements wrap(String html)
<p><b>This</b> is <b>Jsoup</b></p>
,
doc.select("b").wrap("<i></i>");
becomes <p><i><b>This</b></i> is <i><b>jsoup</b></i></p>
html
- HTML to wrap around each element, e.g. <div class="head"></div>
. Can be arbitralily deep.
Element.wrap(java.lang.String)
public Elements select(String query)
query
- A selector query
public Elements eq(int index)
index
- the (zero-based) index of the element in the list to retain
public boolean is(String query)
query
- A selector
public Element first()
null
if contents is empty;public Element last()
null
if contents is empty.public int size()
size
in interface Collection<Element>
size
in interface List<Element>
public boolean isEmpty()
isEmpty
in interface Collection<Element>
isEmpty
in interface List<Element>
public boolean contains(Object o)
contains
in interface Collection<Element>
contains
in interface List<Element>
public Iterator<Element> iterator()
iterator
in interface Iterable<Element>
iterator
in interface Collection<Element>
iterator
in interface List<Element>
public Object[] toArray()
toArray
in interface Collection<Element>
toArray
in interface List<Element>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<Element>
toArray
in interface List<Element>
public boolean add(Element element)
add
in interface Collection<Element>
add
in interface List<Element>
public boolean remove(Object o)
remove
in interface Collection<Element>
remove
in interface List<Element>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<Element>
containsAll
in interface List<Element>
public boolean addAll(Collection<? extends Element> c)
addAll
in interface Collection<Element>
addAll
in interface List<Element>
public boolean addAll(int index, Collection<? extends Element> c)
addAll
in interface List<Element>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<Element>
removeAll
in interface List<Element>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<Element>
retainAll
in interface List<Element>
public void clear()
clear
in interface Collection<Element>
clear
in interface List<Element>
public boolean equals(Object o)
equals
in interface Collection<Element>
equals
in interface List<Element>
equals
in class Object
public int hashCode()
hashCode
in interface Collection<Element>
hashCode
in interface List<Element>
hashCode
in class Object
public Element get(int index)
get
in interface List<Element>
public Element set(int index, Element element)
set
in interface List<Element>
public void add(int index, Element element)
add
in interface List<Element>
public Element remove(int index)
remove
in interface List<Element>
public int indexOf(Object o)
indexOf
in interface List<Element>
public int lastIndexOf(Object o)
lastIndexOf
in interface List<Element>
public ListIterator<Element> listIterator()
listIterator
in interface List<Element>
public ListIterator<Element> listIterator(int index)
listIterator
in interface List<Element>
public List<Element> subList(int fromIndex, int toIndex)
subList
in interface List<Element>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |