You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by wa...@apache.org on 2002/03/08 10:51:51 UTC
cvs commit: jakarta-slide/src/share/org/apache/slide/search/basic BasicQuery.java
wam 02/03/08 01:51:50
Modified: src/share/org/apache/slide/search/basic BasicQuery.java
Log:
adjust tab settings
Revision Changes Path
1.2 +168 -168 jakarta-slide/src/share/org/apache/slide/search/basic/BasicQuery.java
Index: BasicQuery.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/BasicQuery.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BasicQuery.java 14 Feb 2002 17:02:46 -0000 1.1
+++ BasicQuery.java 8 Mar 2002 09:51:50 -0000 1.2
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/BasicQuery.java,v 1.1 2002/02/14 17:02:46 wam Exp $
- * $Revision: 1.1 $
- * $Date: 2002/02/14 17:02:46 $
+ * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/basic/BasicQuery.java,v 1.2 2002/03/08 09:51:50 wam Exp $
+ * $Revision: 1.2 $
+ * $Date: 2002/03/08 09:51:50 $
*
* ====================================================================
*
@@ -92,7 +92,7 @@
* BasicSearchExpressions.
*
* @author <a href="mailto:martin.wallmer@softwareag.com">Martin Wallmer</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class BasicQuery extends SearchQuery {
@@ -120,232 +120,232 @@
/** the top level expression in the <WHERE> clause */
private BasicExpression rootExpression;
-
-
- // TODO: <ORDERBY>
+
+
+ // TODO: <ORDERBY>
/**
- * Constructs a query from the queryString. queryString is an XML
- * document according to the DASL basicsearch specfication.
- *
- * @parameter queryString the search query
- *
- * @throws BadQueryException
- */
+ * Constructs a query from the queryString. queryString is an XML
+ * document according to the DASL basicsearch specfication.
+ *
+ * @parameter queryString the search query
+ *
+ * @throws BadQueryException
+ */
BasicQuery (String queryString, SearchToken token) throws BadQueryException {
- this.searchToken = token;
- try {
- Document doc =
- new SAXBuilder ().build (new StringReader (queryString));
-
- Element root = doc.getRootElement();
- parseQueryElement (root);
- }
- catch (org.jdom.JDOMException e) {
- e.printStackTrace();
- throw new BadQueryException (e.getMessage());
- }
+ this.searchToken = token;
+ try {
+ Document doc =
+ new SAXBuilder ().build (new StringReader (queryString));
+
+ Element root = doc.getRootElement();
+ parseQueryElement (root);
+ }
+ catch (org.jdom.JDOMException e) {
+ e.printStackTrace();
+ throw new BadQueryException (e.getMessage());
+ }
}
// BasicQuery (String queryString) throws BadQueryException {
-// this (queryString, Integer.MAX_VALUE);
+// this (queryString, Integer.MAX_VALUE);
// }
/**
- * Constructs a query from queryElement. queryElement is a DOM
- * element <searchrequest> according to the DASL basicsearch
- * specfication.
- *
- * @parameter queryString the search query
- *
- * @throws BadQueryException
- */
+ * Constructs a query from queryElement. queryElement is a DOM
+ * element <searchrequest> according to the DASL basicsearch
+ * specfication.
+ *
+ * @parameter queryString the search query
+ *
+ * @throws BadQueryException
+ */
BasicQuery (org.w3c.dom.Element basicSearchElementDOM, SearchToken token) throws BadQueryException {
- this.searchToken = token;
+ this.searchToken = token;
- org.jdom.Element basicSearchElementJDom =
- new DOMBuilder ().build (basicSearchElementDOM);
+ org.jdom.Element basicSearchElementJDom =
+ new DOMBuilder ().build (basicSearchElementDOM);
- parseQueryElement (basicSearchElementJDom);
+ parseQueryElement (basicSearchElementJDom);
}
-
+
/**
- * Constructs a query from queryElement. queryElement is a DOM
- * element <searchrequest> according to the DASL basicsearch
- * specfication.
- *
- * @parameter queryString the search query
- *
- * @throws BadQueryException
- */
+ * Constructs a query from queryElement. queryElement is a DOM
+ * element <searchrequest> according to the DASL basicsearch
+ * specfication.
+ *
+ * @parameter queryString the search query
+ *
+ * @throws BadQueryException
+ */
BasicQuery (Element basicSearchElementJDOM, SearchToken token) throws BadQueryException {
- this.searchToken = token;
- parseQueryElement (basicSearchElementJDOM);
+ this.searchToken = token;
+ parseQueryElement (basicSearchElementJDOM);
}
-
+
/**
- * Executes a request. A store specific implementation should overwrite
- * this to optimize the execution.
- *
- * @return a SearchQueryResult
- *
- * @throws ServiceAccessException
- *
- */
+ * Executes a request. A store specific implementation should overwrite
+ * this to optimize the execution.
+ *
+ * @return a SearchQueryResult
+ *
+ * @throws ServiceAccessException
+ *
+ */
public SearchQueryResult execute () throws ServiceAccessException {
- SearchQueryResult result = null;
-
- try {
- requestedResources =
- new RequestedResourcesPoolImpl (searchToken, scope);
-
- Set pool = requestedResources.getPool (); // !!!!
- // from where we get our root pool?
- // Set rootPool = propertyResolver.getPool();
-
- //
- rootExpression.resolve (pool);
- if (rootExpression.isResolved ()) {
- result = new SearchQueryResult (rootExpression.getResultSet());
-
- }
- }
-
- catch (BadQueryException e) { // TODO: correct exception handling!
- e.printStackTrace();
- }
-
- return result;
+ SearchQueryResult result = null;
+
+ try {
+ requestedResources =
+ new RequestedResourcesPoolImpl (searchToken, scope);
+
+ Set pool = requestedResources.getPool (); // !!!!
+ // from where we get our root pool?
+ // Set rootPool = propertyResolver.getPool();
+
+ //
+ rootExpression.resolve (pool);
+ if (rootExpression.isResolved ()) {
+ result = new SearchQueryResult (rootExpression.getResultSet());
+
+ }
+ }
+
+ catch (BadQueryException e) { // TODO: correct exception handling!
+ e.printStackTrace();
+ }
+
+ return result;
}
/**
- * Method getScope
- *
- * @return a Scope
- *
- */
+ * Method getScope
+ *
+ * @return a Scope
+ *
+ */
QueryScope getScope () {
- return scope;
+ return scope;
}
/**
- * Method getSelectedProperties
- *
- * @return a SelectedPropertyList
- */
+ * Method getSelectedProperties
+ *
+ * @return a SelectedPropertyList
+ */
public RequestedProperties requestedProperties () {
- return requestedProperties;
+ return requestedProperties;
}
BasicExpression getExpression () {
- return rootExpression;
+ return rootExpression;
}
/**
- * Method isLimitDefined
- *
- * @return true if <limit> was specified
- */
+ * Method isLimitDefined
+ *
+ * @return true if <limit> was specified
+ */
boolean isLimitDefined () {
- return limitDefined;
+ return limitDefined;
}
/**
- * Method getLimit
- *
- * @return the value of <limit>
- */
+ * Method getLimit
+ *
+ * @return the value of <limit>
+ */
int getLimit () {
- return limit;
+ return limit;
}
/**
- * builds the internal structure out of the JDOM tree
- *
- * @param root an Element
- *
- * @throws BadQueryException
- */
+ * builds the internal structure out of the JDOM tree
+ *
+ * @param root an Element
+ *
+ * @throws BadQueryException
+ */
private void parseQueryElement (Element basicSearchElement)
- throws BadQueryException
+ throws BadQueryException
{
- if (basicSearchElement == null)
- throw new BadQueryException ("No query element");
-
- namespace = basicSearchElement.getNamespace();
-
- Element selectElement = basicSearchElement.getChild
- (Literals.SELECT, namespace);
-
- // SELECT is mandatory
- if (selectElement == null)
- throw new BadQueryException ("required element <select> not supplied");
-
- Element fromElement = basicSearchElement.getChild
- (Literals.FROM, namespace);
-
- // FROM is mandatory
- if (fromElement == null)
- throw new BadQueryException ("required element <from> not supplied");
-
- Element whereElement = basicSearchElement.getChild
- (Literals.WHERE, namespace);
-
- Element orderByElement = basicSearchElement.getChild
- (Literals.ORDERBY, namespace);
-
- Element limitElement = basicSearchElement.getChild
- (Literals.LIMIT, namespace);
-
-
- scope = new BasicQueryScope (fromElement);
- requestedProperties = new RequestedPropertiesImpl
- (selectElement.getChild (Literals.PROP, namespace));
-
- // TODO orderby...
-
- // if no where clause is supplied, use a dummy expression
- List expressionList = whereElement.getChildren();
-
- rootExpression = BasicExpression.createExpression
- ((Element) expressionList.get (0));
-
- if (limitElement != null) {
- limit = new Integer (limitElement.getTextTrim()).intValue();
- limitDefined = true;
- }
+ if (basicSearchElement == null)
+ throw new BadQueryException ("No query element");
+
+ namespace = basicSearchElement.getNamespace();
+
+ Element selectElement = basicSearchElement.getChild
+ (Literals.SELECT, namespace);
+
+ // SELECT is mandatory
+ if (selectElement == null)
+ throw new BadQueryException ("required element <select> not supplied");
+
+ Element fromElement = basicSearchElement.getChild
+ (Literals.FROM, namespace);
+
+ // FROM is mandatory
+ if (fromElement == null)
+ throw new BadQueryException ("required element <from> not supplied");
+
+ Element whereElement = basicSearchElement.getChild
+ (Literals.WHERE, namespace);
+
+ Element orderByElement = basicSearchElement.getChild
+ (Literals.ORDERBY, namespace);
+
+ Element limitElement = basicSearchElement.getChild
+ (Literals.LIMIT, namespace);
+
+
+ scope = new BasicQueryScope (fromElement);
+ requestedProperties = new RequestedPropertiesImpl
+ (selectElement.getChild (Literals.PROP, namespace));
+
+ // TODO orderby...
+
+ // if no where clause is supplied, use a dummy expression
+ List expressionList = whereElement.getChildren();
+
+ rootExpression = BasicExpression.createExpression
+ ((Element) expressionList.get (0));
+
+ if (limitElement != null) {
+ limit = new Integer (limitElement.getTextTrim()).intValue();
+ limitDefined = true;
+ }
}
/**
- * For debugging purpose.
- *
- * @return this query in string representation
- *
- */
+ * For debugging purpose.
+ *
+ * @return this query in string representation
+ *
+ */
public String toString () {
-
- return
- "SELECT [" + requestedProperties + "] FROM [" + scope
- + "] WHERE [" + rootExpression + "]";
-
+
+ return
+ "SELECT [" + requestedProperties + "] FROM [" + scope
+ + "] WHERE [" + rootExpression + "]";
+
}
// for testing
public void setPropertyResolver (RequestedResourcesPool propertyResolver) {
- this.requestedResources = propertyResolver;
+ this.requestedResources = propertyResolver;
}
public RequestedResourcesPool getPropertyResolver() {
- return requestedResources;
+ return requestedResources;
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>