tigase.jaxmpp.core.client.criteria
Class ElementCriteria

java.lang.Object
  extended by tigase.jaxmpp.core.client.criteria.ElementCriteria
All Implemented Interfaces:
Criteria

public class ElementCriteria
extends Object
implements Criteria

Simple implementation of Criteria to check element name and its attributes..


Field Summary
protected  HashMap<String,String> attrs
           
protected  String name
           
protected  Criteria nextCriteria
           
 
Constructor Summary
ElementCriteria(String name, String[] attname, String[] attValue)
          Construct criteria.
 
Method Summary
 Criteria add(Criteria criteria)
          Adds restriction for deeper level of elements.
static ElementCriteria empty()
          Makes criteria object what accepts all elements.
 boolean match(Element element)
          This method checks if element match to conditions.
static ElementCriteria name(String name)
          Makes criteria object to check name of element.
static ElementCriteria name(String name, String xmlns)
          Makes criteria object to check name of element and its namespace.
static ElementCriteria name(String name, String[] attNames, String[] attValues)
           
static ElementCriteria xmlns(String xmlns)
          Makes criteria checking only xmlns attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attrs

protected HashMap<String,String> attrs

name

protected String name

nextCriteria

protected Criteria nextCriteria
Constructor Detail

ElementCriteria

public ElementCriteria(String name,
                       String[] attname,
                       String[] attValue)
Construct criteria.

Parameters:
name - name of element. If null then any elements name will be accepted;
attname - names of required attributes
attValue - value of requird attrivutes
Method Detail

empty

public static final ElementCriteria empty()
Makes criteria object what accepts all elements.

Returns:
criteria

name

public static final ElementCriteria name(String name)
Makes criteria object to check name of element.

Parameters:
name - expected element name.
Returns:
criteria

name

public static final ElementCriteria name(String name,
                                         String xmlns)
Makes criteria object to check name of element and its namespace.

Parameters:
name - expected name of element.
xmlns - expected xmlns
Returns:
criteria

name

public static final ElementCriteria name(String name,
                                         String[] attNames,
                                         String[] attValues)

xmlns

public static final ElementCriteria xmlns(String xmlns)
Makes criteria checking only xmlns attribute.

Parameters:
xmlns - expected xmlns
Returns:
criteria

add

public Criteria add(Criteria criteria)
Adds restriction for deeper level of elements.

For example:
If you have structure of elements: <A><B></B></A>
then, to check elements A and B you should use construction like this: critToCheckA.add(critToCheckB);

Specified by:
add in interface Criteria
Parameters:
criteria - restriction to add
Returns:

match

public boolean match(Element element)
              throws XMLException
This method checks if element match to conditions.

Specified by:
match in interface Criteria
Parameters:
element - element to check
Returns:
true if element match.
Throws:
XMLException


Copyright © 2006-2012 Tigase. All Rights Reserved.