org.mmbase.bridge.util.xml.query
Class QueryReader

java.lang.Object
  extended by org.mmbase.bridge.util.xml.query.QueryReader

public abstract class QueryReader
extends Object

This class contains static methods related to creating a Query object using a (fragment of an) XML.

Since:
MMBase-1.8
Version:
$Id: QueryReader.java 41048 2010-02-15 23:05:30Z michiel $
Author:
Pierre van Rooden

Field Summary
static String NAMESPACE_SEARCHQUERY
          most recent version
static String NAMESPACE_SEARCHQUERY_1_0
           
static String XSD_SEARCHQUERY_1_0
           
 
Constructor Summary
QueryReader()
           
 
Method Summary
protected static void addConstraint(Element constraintElement, QueryDefinition queryDefinition, CompositeConstraint parentConstraint)
           
protected static void addDistinct(Element distinctElement, QueryDefinition queryDefinition)
           
protected static void addField(Element fieldElement, QueryDefinition queryDefinition, QueryConfigurer configurer)
           
protected static void addSortOrder(Element sortOrderElement, QueryDefinition queryDefinition)
           
protected static Constraint getAgeConstraint(Element constraintElement, QueryDefinition queryDefinition)
           
protected static Integer getAlias(Cloud cloud, String name)
           
protected static Constraint getAliasConstraint(Element constraintElement, QueryDefinition queryDefinition)
           
protected static SortedSet<Integer> getAliases(Cloud cloud, List<String> names)
           
static String getAttribute(Element element, String localName)
          Returns the value of a certain attribute, either an unqualified attribute or an attribute that fits in the searchquery namespace
protected static Constraint getCompositeConstraint(Element constraintElement, QueryDefinition queryDefinition)
           
protected static Constraint getConstraint(Element constraintElement, QueryDefinition queryDefinition)
           
protected static int getDayMark(Cloud cloud, int age)
           
protected static String getFullFieldName(QueryDefinition queryDefinition, String fieldName)
           
protected static SortedSet<Integer> getOTypes(Cloud cloud, List<String> names, boolean descendants)
           
protected static Constraint getTypeConstraint(Element constraintElement, QueryDefinition queryDefinition)
           
static boolean hasAttribute(Element element, String localName)
          Returns whether an element has a certain attribute, either an unqualified attribute or an attribute that fits in the searchquery namespace
static QueryDefinition parseQuery(Element queryElement, Cloud cloud, String relateFrom)
          As parseQuery(Element, QueryConfigurer, Cloud, String), but with default QueryConfigurer
static QueryDefinition parseQuery(Element queryElement, QueryConfigurer configurer, Cloud cloud, String relateFrom)
          Creates a Query object from an Element.
static void registerSystemIDs()
          Register the namespace and XSD used by QueryReader This method is called by EntityResolver.
protected static Object resolveVariables(String s, QueryDefinition queryDefinition)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XSD_SEARCHQUERY_1_0

public static final String XSD_SEARCHQUERY_1_0
See Also:
Constant Field Values

NAMESPACE_SEARCHQUERY_1_0

public static final String NAMESPACE_SEARCHQUERY_1_0
See Also:
Constant Field Values

NAMESPACE_SEARCHQUERY

public static final String NAMESPACE_SEARCHQUERY
most recent version

See Also:
Constant Field Values
Constructor Detail

QueryReader

public QueryReader()
Method Detail

registerSystemIDs

public static void registerSystemIDs()
Register the namespace and XSD used by QueryReader This method is called by EntityResolver.


hasAttribute

public static boolean hasAttribute(Element element,
                                   String localName)
Returns whether an element has a certain attribute, either an unqualified attribute or an attribute that fits in the searchquery namespace


getAttribute

public static String getAttribute(Element element,
                                  String localName)
Returns the value of a certain attribute, either an unqualified attribute or an attribute that fits in the searchquery namespace


getFullFieldName

protected static String getFullFieldName(QueryDefinition queryDefinition,
                                         String fieldName)

addField

protected static void addField(Element fieldElement,
                               QueryDefinition queryDefinition,
                               QueryConfigurer configurer)

resolveVariables

protected static Object resolveVariables(String s,
                                         QueryDefinition queryDefinition)
Since:
MMBase-1.9.1

getConstraint

protected static Constraint getConstraint(Element constraintElement,
                                          QueryDefinition queryDefinition)

getDayMark

protected static int getDayMark(Cloud cloud,
                                int age)

getAgeConstraint

protected static Constraint getAgeConstraint(Element constraintElement,
                                             QueryDefinition queryDefinition)

getAlias

protected static Integer getAlias(Cloud cloud,
                                  String name)

getAliases

protected static SortedSet<Integer> getAliases(Cloud cloud,
                                               List<String> names)

getAliasConstraint

protected static Constraint getAliasConstraint(Element constraintElement,
                                               QueryDefinition queryDefinition)

getOTypes

protected static SortedSet<Integer> getOTypes(Cloud cloud,
                                              List<String> names,
                                              boolean descendants)

getTypeConstraint

protected static Constraint getTypeConstraint(Element constraintElement,
                                              QueryDefinition queryDefinition)

getCompositeConstraint

protected static Constraint getCompositeConstraint(Element constraintElement,
                                                   QueryDefinition queryDefinition)
                                            throws SearchQueryException
Throws:
SearchQueryException

addConstraint

protected static void addConstraint(Element constraintElement,
                                    QueryDefinition queryDefinition,
                                    CompositeConstraint parentConstraint)
                             throws SearchQueryException
Throws:
SearchQueryException

addDistinct

protected static void addDistinct(Element distinctElement,
                                  QueryDefinition queryDefinition)

addSortOrder

protected static void addSortOrder(Element sortOrderElement,
                                   QueryDefinition queryDefinition)

parseQuery

public static QueryDefinition parseQuery(Element queryElement,
                                         Cloud cloud,
                                         String relateFrom)
                                  throws SearchQueryException
As parseQuery(Element, QueryConfigurer, Cloud, String), but with default QueryConfigurer

Throws:
SearchQueryException

parseQuery

public static QueryDefinition parseQuery(Element queryElement,
                                         QueryConfigurer configurer,
                                         Cloud cloud,
                                         String relateFrom)
                                  throws SearchQueryException
Creates a Query object from an Element. The query is wrapped in a QueryDefinition and you can simply access the QueryDefinition.query member to have the actual Query.

Parameters:
queryElement - Any XML element which query sub-tags and attributes.
configurer - The configure which is responsible for instantiating the QueryDefinition
cloud - Cloud, needed to make Query objects.
relateFrom - (optional) name of a node manager which can be used to base the query on, as the first element of the path (can be null)
Throws:
SearchQueryException


MMBase 2.0-SNAPSHOT - null