com.amazon.carbonado.qe
Class EmptyQuery<S extends Storable>

java.lang.Object
  extended by com.amazon.carbonado.qe.AbstractQuery<S>
      extended by com.amazon.carbonado.qe.EmptyQuery<S>
All Implemented Interfaces:
Query<S>, Appender

public final class EmptyQuery<S extends Storable>
extends AbstractQuery<S>

Special query implementation that fetches nothing.

Author:
Brian S O'Neill

Constructor Summary
EmptyQuery(QueryFactory<S> factory, OrderingList<S> ordering)
           
EmptyQuery(QueryFactory<S> factory, String... orderings)
           
EmptyQuery(QueryFactory<S> factory, String ordering)
           
 
Method Summary
<T extends S>
Query<S>
after(T start)
          Returns a query which fetches results for this query after a given starting point, which is useful for re-opening a cursor.
 Query<S> and(Filter<S> filter)
          Always throws an IllegalStateException.
 void appendTo(Appendable app)
          Append the string representation of this object to the given Appendable.
 long count()
          Always returns zero.
 void deleteAll()
          Does nothing.
 void deleteOne()
          Always throws PersistNoneException.
 boolean equals(Object obj)
           
 boolean exists()
          Always returns false.
 Cursor<S> fetch()
          Always returns an EmptyCursor.
 Cursor<S> fetchSlice(long from, Long to)
          Always returns an EmptyCursor.
 int getBlankParameterCount()
          Always returns zero.
 Filter<S> getFilter()
          Always returns a ClosedFilter.
 FilterValues<S> getFilterValues()
          Always returns null.
 Class<S> getStorableType()
          Returns the specific type of Storable managed by this object.
 int hashCode()
           
 Query<S> not()
          Returns a query that fetches everything, possibly in a specified order.
 Query<S> or(Filter<S> filter)
          Returns a new query which has another filter logically "or"ed to this, potentially increasing the amount of results.
 Query<S> orderBy(String... properties)
          Returns a copy of this query ordered by specific property values.
 Query<S> orderBy(String property)
          Returns a copy of this query ordered by a specific property value.
 boolean printNative(Appendable app, int indentLevel)
          Always returns false.
 boolean printPlan(Appendable app, int indentLevel)
          Always returns false.
 boolean tryDeleteOne()
          Always returns false.
 Query<S> with(boolean value)
          Always throws an IllegalStateException.
 Query<S> with(byte value)
          Always throws an IllegalStateException.
 Query<S> with(char value)
          Always throws an IllegalStateException.
 Query<S> with(double value)
          Always throws an IllegalStateException.
 Query<S> with(float value)
          Always throws an IllegalStateException.
 Query<S> with(int value)
          Always throws an IllegalStateException.
 Query<S> with(long value)
          Always throws an IllegalStateException.
 Query<S> with(Object value)
          Always throws an IllegalStateException.
 Query<S> with(short value)
          Always throws an IllegalStateException.
 Query<S> withValues(Object... values)
          Throws an IllegalStateException unless no values passed in.
 
Methods inherited from class com.amazon.carbonado.qe.AbstractQuery
and, checkSliceArguments, fetchAfter, loadOne, or, printNative, printNative, printPlan, printPlan, toString, tryLoadOne
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EmptyQuery

public EmptyQuery(QueryFactory<S> factory,
                  OrderingList<S> ordering)
Parameters:
factory - required query factory, used by 'or' and 'not' methods
ordering - optional order-by properties

EmptyQuery

public EmptyQuery(QueryFactory<S> factory,
                  String ordering)
Parameters:
factory - required query factory, used by 'or' and 'not' methods
ordering - optional order-by property

EmptyQuery

public EmptyQuery(QueryFactory<S> factory,
                  String... orderings)
Parameters:
factory - required query factory, used by 'or' and 'not' methods
orderings - optional order-by properties
Method Detail

getStorableType

public Class<S> getStorableType()
Description copied from interface: Query
Returns the specific type of Storable managed by this object.


getFilter

public Filter<S> getFilter()
Always returns a ClosedFilter.


getFilterValues

public FilterValues<S> getFilterValues()
Always returns null.


getBlankParameterCount

public int getBlankParameterCount()
Always returns zero.


with

public Query<S> with(int value)
Always throws an IllegalStateException.

Parameters:
value - parameter value to fill in

with

public Query<S> with(long value)
Always throws an IllegalStateException.

Parameters:
value - parameter value to fill in

with

public Query<S> with(float value)
Always throws an IllegalStateException.

Parameters:
value - parameter value to fill in

with

public Query<S> with(double value)
Always throws an IllegalStateException.

Parameters:
value - parameter value to fill in

with

public Query<S> with(boolean value)
Always throws an IllegalStateException.

Parameters:
value - parameter value to fill in

with

public Query<S> with(char value)
Always throws an IllegalStateException.

Parameters:
value - parameter value to fill in

with

public Query<S> with(byte value)
Always throws an IllegalStateException.

Parameters:
value - parameter value to fill in

with

public Query<S> with(short value)
Always throws an IllegalStateException.

Parameters:
value - parameter value to fill in

with

public Query<S> with(Object value)
Always throws an IllegalStateException.

Parameters:
value - parameter value to fill in

withValues

public Query<S> withValues(Object... values)
Throws an IllegalStateException unless no values passed in.

Parameters:
values - parameter values to fill in; if null or empty, this Query instance is returned

and

public Query<S> and(Filter<S> filter)
Always throws an IllegalStateException.

Parameters:
filter - query filter

or

public Query<S> or(Filter<S> filter)
                             throws FetchException
Description copied from interface: Query
Returns a new query which has another filter logically "or"ed to this, potentially increasing the amount of results.

Parameters:
filter - query filter
Throws:
FetchException - if storage layer throws an exception

not

public Query<S> not()
                              throws FetchException
Returns a query that fetches everything, possibly in a specified order.

Throws:
FetchException - if storage layer throws an exception

orderBy

public Query<S> orderBy(String property)
                                  throws FetchException
Description copied from interface: Query
Returns a copy of this query ordered by a specific property value. The property name may be prefixed with '+' or '-' to indicate ascending or descending order. If the prefix is omitted, ascending order is assumed.

Note: Specification of ordering properties is not cumulative. Calling this method will first remove any previous ordering properties.

Parameters:
property - name of property to order by
Throws:
FetchException - if storage layer throws an exception

orderBy

public Query<S> orderBy(String... properties)
                                  throws FetchException
Description copied from interface: Query
Returns a copy of this query ordered by specific property values. The property names may be prefixed with '+' or '-' to indicate ascending or descending order. If the prefix is omitted, ascending order is assumed.

Note: Specification of ordering properties is not cumulative. Calling this method will first remove any previous ordering properties.

Parameters:
properties - names of properties to order by
Throws:
FetchException - if storage layer throws an exception

after

public <T extends S> Query<S> after(T start)
Description copied from interface: Query
Returns a query which fetches results for this query after a given starting point, which is useful for re-opening a cursor. This is only effective when query has been given an explicit ordering. If not a total ordering, then query may start at an earlier position.

Note: The returned query can be very expensive to fetch from repeatedly, if the query needs to perform a sort operation. Ideally, the query ordering should match the natural ordering of an index or key.

Parameters:
start - storable to attempt to start after; if null, this query is returned

fetch

public Cursor<S> fetch()
Always returns an EmptyCursor.

Returns:
fetch results
See Also:
Repository.enterTransaction(IsolationLevel)

fetchSlice

public Cursor<S> fetchSlice(long from,
                            Long to)
Always returns an EmptyCursor.

Parameters:
from - zero-based from record number, inclusive
to - optional zero-based to record number, exclusive
Returns:
fetch results

deleteOne

public void deleteOne()
               throws PersistNoneException
Always throws PersistNoneException.

Specified by:
deleteOne in interface Query<S extends Storable>
Overrides:
deleteOne in class AbstractQuery<S extends Storable>
Throws:
PersistNoneException - if no matching record found

tryDeleteOne

public boolean tryDeleteOne()
Always returns false.

Returns:
true if record existed and was deleted, or false if no match

deleteAll

public void deleteAll()
Does nothing.


count

public long count()
Always returns zero.

Returns:
count of matches

exists

public boolean exists()
Always returns false.

Returns:
true if any matches

appendTo

public void appendTo(Appendable app)
              throws IOException
Description copied from interface: Appender
Append the string representation of this object to the given Appendable.

Parameters:
app - Appendable object to receive string representation
Throws:
IOException - if thrown from given Appendable

printNative

public boolean printNative(Appendable app,
                           int indentLevel)
Always returns false.

Parameters:
app - append results here
indentLevel - amount to indent text, zero for none
Returns:
false if not implemented

printPlan

public boolean printPlan(Appendable app,
                         int indentLevel)
Always returns false.

Parameters:
app - append results here
indentLevel - amount to indent text, zero for none
Returns:
false if not implemented

hashCode

public int hashCode()
Specified by:
hashCode in interface Query<S extends Storable>
Specified by:
hashCode in class AbstractQuery<S extends Storable>

equals

public boolean equals(Object obj)
Specified by:
equals in interface Query<S extends Storable>
Specified by:
equals in class AbstractQuery<S extends Storable>


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.