com.endeca.navigation.analytics
Class AnalyticsQuery

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList
          extended by com.endeca.navigation.analytics.AnalyticsQuery
All Implemented Interfaces:
QueryNode, Iterable, Collection, List

public class AnalyticsQuery
extends AbstractList
implements List, QueryNode

An AnalyticsQuery is an ordered list of Statement objects. The AnalyticsQuery object is then set in an ENEQuery object via the ENEQuery.setAnalyticsQuery() method.

When the query is executed on the Endeca MDEX Engine, each Statement transforms an input set of records into a resulting stream of aggregated records. Each Statement operates on the record set produced by some previous Statement, or on the records in the Navigation State or on all the records in the MDEX Engine. Note that each Statement in the AnalyticsQuery must have a unique name.

Users can construct an AnalyticsQuery with either the programmatic interface or a text-based syntax. The following is a programmatic example of retrieving the Statement objects from an AnalyticsQuery:

// Retrieve ENEQuery from the current request
ENEQuery usq = (ENEQuery)request.getAttribute("eneQuery");
// Get the AnalyticsQuery object from the ENEQuery
AnalyticsQuery aq = usq.getAnalyticsQuery();
// Return an iterator with the Statements in this list
Iterator it_aq = aq.iterator();
// Get the Statement objects from the iterator
while(it_aq.hasNext()) {
   Statement st = (Statement)it_aq.next();
   ...
}
Much of the text-based syntax is based on a subset of the SQL language. Use the parseQuery(String) parser method to create an AnalyticsQuery from the String representation of the query. For example, if str is a String that has been initialized to a valid query, then the statement:
AnalyticsQuery analytics = AnalyticsQuery.parseQuery(str);
creates an AnalyticsQuery when the str query is parsed.


Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
AnalyticsQuery()
          Construct a new, empty AnalyticsQuery.
 
Method Summary
 void add(int index, Object obj)
          Inserts a Statement object at position index.
 Object get(int index)
          Gets the Statement object at position index.
static AnalyticsQuery parseQuery(String query)
          Parses a String form of a Statement query and returns an instance of AnalyticsQuery if the query is well-formed.
 Object remove(int index)
          Removes the Statement object at the specified position in this AnalyticsQuery.
 Object set(int index, Object obj)
          Replaces the Statement object at position index with the the Statement object specified by obj.
 int size()
          Returns the number of Statement objects in this list.
 String toString()
          Returns the string form of the syntax tree rooted at this AnalyticsQuery.
 String toWire()
          Returns the wire form of the query.
 void validateSyntax()
          Validates an AnalyticsQuery.
 
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, retainAll, subList, toArray, toArray
 

Constructor Detail

AnalyticsQuery

public AnalyticsQuery()
Construct a new, empty AnalyticsQuery.

Method Detail

get

public Object get(int index)
Gets the Statement object at position index.

Specified by:
get in interface List
Specified by:
get in class AbstractList
Parameters:
index - offset of the Statement object.
Returns:
Statement object at position index.
Throws:
IndexOutOfBoundsException - if index is out of range.

size

public int size()
Returns the number of Statement objects in this list.

Specified by:
size in interface Collection
Specified by:
size in interface List
Specified by:
size in class AbstractCollection
Returns:
Number of Statement objects in this AnalyticsQuery.

set

public Object set(int index,
                  Object obj)
Replaces the Statement object at position index with the the Statement object specified by obj.

Specified by:
set in interface List
Overrides:
set in class AbstractList
Parameters:
index - offset of the Statement to be replaced.
obj - the Statement to be stored.
Returns:
the Statement object previously at position index.
Throws:
IndexOutOfBoundsException - if index is out of range.
IllegalArgumentException - if obj is not a Statement.

add

public void add(int index,
                Object obj)
Inserts a Statement object at position index. Shifts the Statement element currently at that position (if any) and any subsequent Statement elements to the right (adds one to their indices).

Specified by:
add in interface List
Overrides:
add in class AbstractList
Parameters:
index - offset at which the Statement is to be inserted.
obj - the Statement to be inserted.
Throws:
IndexOutOfBoundsException - if index is out of range.
IllegalArgumentException - if obj is not a Statement object.

remove

public Object remove(int index)
Removes the Statement object at the specified position in this AnalyticsQuery. Shifts any subsequent Statement objects to the left (subtracts one from their indices). Returns the Statement object that was removed from the list.

Specified by:
remove in interface List
Overrides:
remove in class AbstractList
Parameters:
index - offset of the Statement object to be removed.
Returns:
Statement object previously at position index.
Throws:
IndexOutOfBoundsException - if index is out of range.

toString

public String toString()
Returns the string form of the syntax tree rooted at this AnalyticsQuery. Semicolons will delimit multiple Statement objects.

Specified by:
toString in interface QueryNode
Overrides:
toString in class AbstractCollection
Returns:
String form of the syntax tree.

toWire

public String toWire()
Returns the wire form of the query. This method is not intended for public use because the wire format is subject to change.

Specified by:
toWire in interface QueryNode

validateSyntax

public void validateSyntax()
                    throws SyntaxException
Validates an AnalyticsQuery. The AnalyticsQuery is valid if it contains at least one Statement, and all its Statement objects are themselves valid.

Specified by:
validateSyntax in interface QueryNode
Throws:
SyntaxException - if the AnalyticsQuery does not contain at least one Statement object.

parseQuery

public static AnalyticsQuery parseQuery(String query)
                                 throws SyntaxException
Parses a String form of a Statement query and returns an instance of AnalyticsQuery if the query is well-formed.

Parameters:
query - a Statement in a String text-based syntax.
Throws:
SyntaxException - if the query is malformed or null.


© 2003, 2012 Oracle and/or its affiliates. All rights reserved.
Oracle and/or its affiliates Confidential