ModeShape Distribution 3.0.0.Beta4

org.modeshape.jcr.query.model
Class Limit

java.lang.Object
  extended by org.modeshape.jcr.query.model.Limit
All Implemented Interfaces:
Serializable, Limit, LanguageObject, Visitable

@Immutable
public class Limit
extends Object
implements LanguageObject, Limit

A specification of the limit placed on a query, detailing the a maximum number of result rows and an offset for the first row in the results.

See Also:
Serialized Form

Field Summary
static Limit NONE
           
 
Constructor Summary
Limit(int rowLimit)
          Create a limit on the number of rows.
Limit(int rowLimit, int offset)
          Create a limit on the number of rows and the number of initial rows to skip.
 
Method Summary
 void accept(Visitor visitor)
          Accept the supplied visitor, which should call back to the visitor to complete the double-dispatch operation.
 boolean equals(Object obj)
           
 int getOffset()
          Get the number of rows skipped before the results begin.
 int getRowLimit()
          Get the maximum number of rows that are to be returned.
 int hashCode()
           
 boolean hasRowLimited()
          Determine whether this limit clause defines a maximum limit
 boolean isLimitedToSingleRowWithNoOffset()
           
 boolean isOffset()
          Determine whether this limit clause defines an offset.
 boolean isUnlimited()
          Determine whether this limit clause is necessary.
 String toString()
           
 Limit withOffset(int offset)
          Create a new Limit object that contains the same maximum row count as this object but a new offset.
 Limit withRowLimit(int rowLimit)
          Create a new Limit object that contains the same offset as this object but a new maximum row count.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final Limit NONE
Constructor Detail

Limit

public Limit(int rowLimit)
Create a limit on the number of rows.

Parameters:
rowLimit - the maximum number of rows
Throws:
IllegalArgumentException - if the row limit is negative

Limit

public Limit(int rowLimit,
             int offset)
Create a limit on the number of rows and the number of initial rows to skip.

Parameters:
rowLimit - the maximum number of rows
offset - the number of rows to skip before beginning the results
Throws:
IllegalArgumentException - if the row limit is negative, or if the offset is negative
Method Detail

getOffset

public final int getOffset()
Description copied from interface: Limit
Get the number of rows skipped before the results begin.

Specified by:
getOffset in interface Limit
Returns:
the offset; always 0 or a positive number

getRowLimit

public final int getRowLimit()
Description copied from interface: Limit
Get the maximum number of rows that are to be returned.

Specified by:
getRowLimit in interface Limit
Returns:
the maximum number of rows; always positive, or equal to Integer.MAX_VALUE if there is no limit

isUnlimited

public final boolean isUnlimited()
Description copied from interface: Limit
Determine whether this limit clause is necessary.

Specified by:
isUnlimited in interface Limit
Returns:
true if the number of rows is not limited and there is no offset, or false otherwise

hasRowLimited

public final boolean hasRowLimited()
Determine whether this limit clause defines a maximum limit

Returns:
true if the number of rows are limited, or false if there is no limit to the number of rows

isLimitedToSingleRowWithNoOffset

public final boolean isLimitedToSingleRowWithNoOffset()

isOffset

public final boolean isOffset()
Description copied from interface: Limit
Determine whether this limit clause defines an offset.

Specified by:
isOffset in interface Limit
Returns:
true if there is an offset, or false if there is no offset

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

accept

public void accept(Visitor visitor)
Description copied from interface: Visitable
Accept the supplied visitor, which should call back to the visitor to complete the double-dispatch operation.

Specified by:
accept in interface Visitable
Parameters:
visitor - the visitor; never null

withRowLimit

public Limit withRowLimit(int rowLimit)
Create a new Limit object that contains the same offset as this object but a new maximum row count.

Parameters:
rowLimit - the maximum row count for the new Limit object
Returns:
the new Limit object

withOffset

public Limit withOffset(int offset)
Create a new Limit object that contains the same maximum row count as this object but a new offset.

Parameters:
offset - the offset for the new Limit object
Returns:
the new Limit object

ModeShape Distribution 3.0.0.Beta4

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.