com.softwareag.tamino.db.api.response
Class TXMLObjectIteratorImpl

java.lang.Object
  extended by com.softwareag.tamino.db.api.response.TXMLObjectIteratorImpl
All Implemented Interfaces:
TXMLObjectIterator
Direct Known Subclasses:
TXMLObjectFetchingIterator, TXMLObjectIteratorTimeLoggingImpl

public class TXMLObjectIteratorImpl
extends java.lang.Object
implements TXMLObjectIterator

TXMLObjectIteratorImpl is the implementation class for TXMLObjectIterator. TXMLObjectIteratorImpl sits on top of a response query content and can be used for bidirectional iteration.

Version:
$Revision: 1.29 $
Author:
Marcus Schreyer

Field Summary
protected static int START_AT_BEGIN
          An indicator for the iteration start at the beginning of a sequence.
protected static int START_AT_END
          An indicator for the iteration start at the ending of a sequence.
 
Constructor Summary
TXMLObjectIteratorImpl()
          Initializes the default (empty) TXMLObjectIteratorImpl.
TXMLObjectIteratorImpl(TResponseQueryContent responseQueryContent)
          Initializes the TXMLObjectIteratorImpl with the given TResponseQueryContent.
 
Method Summary
 boolean canMoveBy(int offset)
          Indicates if this iterator can be moved by the given offset.
 void close()
          Invalidate this iterator.
 int getCount()
          Gets the query count as an int.
protected  int getCurrentIndex()
          Return the current index.
 java.util.Locale getLocale()
          Gets the locale.
protected  TResponseQueryContent getResponseQueryContent()
          Gets the current response query content.
 boolean hasCount()
          Indicates if the response of Tamino contained the query count.
 boolean hasNext()
          Indicates if iterator has a next TXMLObject instance.
 boolean hasPrevious()
          Indicates if this iterator has a previous TXMLObject instance.
protected  void initIndex(int startAt)
          Internal method for initializing the index.
 void moveBy(int offset)
          Moves the iterator by the given offset.
 TXMLObject next()
          Returns the next TXMLObject in the underlying sequence.
 TXMLObject previous()
          Returns the previous TXMLObject in the list.
 void reset()
          Resets the iterator to its initial state as it has been constructed.
protected  void setCurrentIndex(int newIndex)
          Set the current index.
 void setLocale(java.util.Locale locale)
          Sets the locale.
protected  void setResponseQueryContent(java.util.Iterator iterator, int proceedIteration)
          Sets a new response query content on the iterator and moves the iterator to either the beginning or ending of the content sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

START_AT_BEGIN

protected static final int START_AT_BEGIN
An indicator for the iteration start at the beginning of a sequence.

See Also:
Constant Field Values

START_AT_END

protected static final int START_AT_END
An indicator for the iteration start at the ending of a sequence.

See Also:
Constant Field Values
Constructor Detail

TXMLObjectIteratorImpl

public TXMLObjectIteratorImpl()
Initializes the default (empty) TXMLObjectIteratorImpl.


TXMLObjectIteratorImpl

public TXMLObjectIteratorImpl(TResponseQueryContent responseQueryContent)
Initializes the TXMLObjectIteratorImpl with the given TResponseQueryContent.

Parameters:
responseQueryContent - denotes the query content over which can be iterated.
Method Detail

hasNext

public boolean hasNext()
Indicates if iterator has a next TXMLObject instance.

Specified by:
hasNext in interface TXMLObjectIterator
Returns:
true if next element is given, false otherwise.

next

public TXMLObject next()
                throws TNoSuchXMLObjectException,
                       TIteratorException
Returns the next TXMLObject in the underlying sequence. This method may be called repeatedly to iterate through the list, or intermixed with calls to previous to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)

Specified by:
next in interface TXMLObjectIterator
Returns:
The next XmlObject.
Throws:
java.util.NoSuchElementException - if iteration has no more elements.
TIteratorException - if iteration failed because of an underlying Tamino problem.
TNoSuchXMLObjectException - the if iteration has no next TXMLObject instance.

hasPrevious

public boolean hasPrevious()
Indicates if this iterator has a previous TXMLObject instance.

Specified by:
hasPrevious in interface TXMLObjectIterator
Returns:
true if previous TXMLObject is given, false otherwise.

previous

public TXMLObject previous()
                    throws TNoSuchXMLObjectException,
                           TIteratorException
Returns the previous TXMLObject in the list. This method may be called repeatedly to iterate backwards through the list of given TXMLObject instances.

Specified by:
previous in interface TXMLObjectIterator
Returns:
The previous TXMLObject.
Throws:
java.util.NoSuchElementException - if iteration has no more elements.
TIteratorException - if iteration failed because of an underlying Tamino problem.
TNoSuchXMLObjectException - if the iteration has no previous TXMLObject instance.

hasCount

public boolean hasCount()
Indicates if the response of Tamino contained the query count.

Specified by:
hasCount in interface TXMLObjectIterator
Returns:
true if the response of Tamino contained the query count, false otherwise.

getCount

public int getCount()
Gets the query count as an int. The query count is the total number of resulting objects for a query issued against Tamino. This value is independent from the quantity specified in the query method. The query count is only available for queries that have been issued using the query method specifying a quantity (i.e. when the Tamino cursoring mechanism is being used). Furthermore it is not available for xqueries. Tamino only returns a query count in case its calculation does not require the creation of the result set as a whole. In other words, Tamino only returns a query count if it is not expensive to calculate.

Specified by:
getCount in interface TXMLObjectIterator
Returns:
the query count as an int, if available. Otherwise, -1 is returned.

canMoveBy

public boolean canMoveBy(int offset)
                  throws TIteratorException
Indicates if this iterator can be moved by the given offset.

Specified by:
canMoveBy in interface TXMLObjectIterator
Parameters:
offset - the positive or negative amount to move the iterator
Returns:
true if move is possible, false otherwise.
Throws:
TIteratorException - if iteration failed because of an underlying Tamino problem.

moveBy

public void moveBy(int offset)
            throws TNoSuchXMLObjectException,
                   TIteratorException
Moves the iterator by the given offset.

Specified by:
moveBy in interface TXMLObjectIterator
Parameters:
offset - the positive or negative amount to move the iterator
Throws:
TNoSuchXMLObjectException - if the new position is out of bounds.
TIteratorException - if iteration failed because of an underlying Tamino problem.

reset

public void reset()
           throws TIteratorException
Resets the iterator to its initial state as it has been constructed.

Specified by:
reset in interface TXMLObjectIterator
Throws:
TIteratorException - if iteration failed because of an underlying Tamino problem.

getCurrentIndex

protected final int getCurrentIndex()
Return the current index.


setCurrentIndex

protected final void setCurrentIndex(int newIndex)
Set the current index.


close

public void close()
           throws TIteratorException
Invalidate this iterator. Closing the iterator releases any resources which a iterator may hold. After closing a iterator it is no longer usable.

Specified by:
close in interface TXMLObjectIterator
Throws:
TIteratorException - if iteration failed because of an underlying Tamino problem.

setResponseQueryContent

protected void setResponseQueryContent(java.util.Iterator iterator,
                                       int proceedIteration)
Sets a new response query content on the iterator and moves the iterator to either the beginning or ending of the content sequence.

Parameters:
iterator - points to underyling TXMLObject instances.
proceedIteration - indicates where the iterator should proceed with iterations, either START_AT_BEGIN or START_AT_END can be used here. The latter only makes sense once this iterator is capable for backward iterations.

setLocale

public void setLocale(java.util.Locale locale)
Sets the locale.


getLocale

public java.util.Locale getLocale()
Gets the locale.

Returns:
the locale.

getResponseQueryContent

protected TResponseQueryContent getResponseQueryContent()
Gets the current response query content.

Returns:
the current response query content.

initIndex

protected void initIndex(int startAt)
Internal method for initializing the index.



Copyright (c) 2013 Software AG. All Rights Reserved.