com.univocity.parsers.remote
Class Paginator<E extends RemoteEntitySettings,P extends PaginationContext>

java.lang.Object
  extended by com.univocity.parsers.remote.Paginator<E,P>
Type Parameters:
E - type of RemoteEntitySettings of a parser with support for pagination. A paginator is essentially an entity specifically configured and used for the purpose of retrieving more content from a current state (or page), if available.

public abstract class Paginator<E extends RemoteEntitySettings,P extends PaginationContext>
extends Object

An abstract class that allows EntityParserInterface implementations that work with RemoteEntitySettings to access multiple pages of remote content that needs to parsed.

Author:
uniVocity Software Pty Ltd - dev@univocity.com
See Also:
RemoteParserSettings, PaginationContext, NextInputHandler

Field Summary
static String CURRENT_PAGE
          Reserved field name used by the paginator to store the current page matching entity
static String CURRENT_PAGE_NUMBER
          Reserved field name used by the paginator to store the current page number
static String ENTITY_NAME
          Reserved field name used by the paginator to store itself as an entity
protected  E entitySettings
           
static String NEXT_PAGE
          Reserved field name used by the paginator to store the next page matching entity
static String NEXT_PAGE_NUMBER
          Reserved field name used by the paginator to store the next page number
 
Constructor Summary
protected Paginator(RemoteParserSettings parserSettings)
          Creates a new Paginator
 
Method Summary
 Set<String> getFieldNames()
          Returns the name of all fields associated with the paginator.
 int getFollowCount()
          Returns the number of pages this Paginator can go up to.
 NextInputHandler<P> getPaginationHandler()
          Returns the NextInputHandler associated with thie Paginator.
 boolean isUrlTestingEnabled()
          Indicates whether this paginator should test URLs pointing to the next page before actually retrieving it.
protected abstract  E newEntitySettings(RemoteParserSettings parserSettings)
          Internally, the Paginator uses an instance of RemoteEntitySettings that should allow the definition of fields specifically to control the available pagination elements found in the parsed content.
 void setFollowCount(int followCount)
          Sets the number of pages this Paginator can go up to.
 void setPaginationHandler(NextInputHandler<P> paginationHandler)
          Sets the NextInputHandler which is used to prepare the call to the next page when the parser runs.
 void setUrlTestingEnabled(boolean urlTestingEnabled)
          Configures this paginator to test URLs pointing to the next page before actually retrieving it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entitySettings

protected final E extends RemoteEntitySettings entitySettings

ENTITY_NAME

public static final String ENTITY_NAME
Reserved field name used by the paginator to store itself as an entity

See Also:
Constant Field Values

CURRENT_PAGE

public static final String CURRENT_PAGE
Reserved field name used by the paginator to store the current page matching entity

See Also:
Constant Field Values

CURRENT_PAGE_NUMBER

public static final String CURRENT_PAGE_NUMBER
Reserved field name used by the paginator to store the current page number

See Also:
Constant Field Values

NEXT_PAGE

public static final String NEXT_PAGE
Reserved field name used by the paginator to store the next page matching entity

See Also:
Constant Field Values

NEXT_PAGE_NUMBER

public static final String NEXT_PAGE_NUMBER
Reserved field name used by the paginator to store the next page number

See Also:
Constant Field Values
Constructor Detail

Paginator

protected Paginator(RemoteParserSettings parserSettings)
Creates a new Paginator

Parameters:
parserSettings - the parser settings to use
Method Detail

newEntitySettings

protected abstract E newEntitySettings(RemoteParserSettings parserSettings)
Internally, the Paginator uses an instance of RemoteEntitySettings that should allow the definition of fields specifically to control the available pagination elements found in the parsed content.

Parameters:
parserSettings - the parser settings to use in the new Entity settings
Returns:
a new instance of a concrete implementation of RemoteEntitySettings, used to configure all pagination-related elements.

setFollowCount

public final void setFollowCount(int followCount)
Sets the number of pages this Paginator can go up to. Defaults to -1 (no limit)

Parameters:
followCount - the maximum number of pages that should be visited from a given starting point.

getFollowCount

public final int getFollowCount()
Returns the number of pages this Paginator can go up to. Defaults to 0 (no limit)

Returns:
the maximum number of pages that should be visited from a given starting point.

setPaginationHandler

public final void setPaginationHandler(NextInputHandler<P> paginationHandler)
Sets the NextInputHandler which is used to prepare the call to the next page when the parser runs. Users can provide their NextInputHandler to obtain information about the pagination process through a PaginationContext, and if required, to manipulate the remote call used to fetch the next page.

Parameters:
paginationHandler - the NextInputHandler that will be associated with this Paginator

getPaginationHandler

public NextInputHandler<P> getPaginationHandler()
Returns the NextInputHandler associated with thie Paginator. The NextInputHandler is used to prepare the call to the next page when the parser runs. Users can provide their NextInputHandler to obtain information about the pagination process through a PaginationContext, and if required, to manipulate the remote call used to fetch the next page.

Returns:
the NextInputHandler associated with this Paginator

getFieldNames

public final Set<String> getFieldNames()
Returns the name of all fields associated with the paginator. The definition how this Paginator fields are populated is delegated to concrete implementations of this class.

Returns:
a unmodifiable, ordered LinkedHashSet of field names available from this Paginator.

isUrlTestingEnabled

public boolean isUrlTestingEnabled()
Indicates whether this paginator should test URLs pointing to the next page before actually retrieving it. Testing occurs every time RemoteContext.getNextPage() returns content that might be a relative or absolute URL pointing to the next page. URL testing consists of executing a HEAD HttpRequest call to the next page URL. If the response code returned by the remote server is 200 (i.e. HttpURLConnection.HTTP_OK) then the next page URL can be used, otherwise pagination will stop. Defaults to false

Returns:
a flag indicating whether the paginator will test URLs formed to capture the next page before actually attempting to fetch it.

setUrlTestingEnabled

public void setUrlTestingEnabled(boolean urlTestingEnabled)
Configures this paginator to test URLs pointing to the next page before actually retrieving it. Testing occurs every time RemoteContext.getNextPage() returns content that might be a relative or absolute URL pointing to the next page. URL testing consists of executing a HEAD HttpRequest call to the next page URL. If the response code returned by the remote server is 200 (i.e. HttpURLConnection.HTTP_OK) then the next page URL can be used, otherwise pagination will stop. Defaults to false

Parameters:
urlTestingEnabled - flag indicating whether the paginator should test URLs formed to capture the next page before actually attempting to fetch it.


Copyright © 2018 uniVocity Software Pty Ltd. All rights reserved.