public abstract class AbstractRecordSource extends Object implements RecordSource
RecordSource
. Provides
implementations for all methods except RecordSource.getCurrentRecord()
.
As implemented, this source supports no positioning operations. All supportsXXX methods
return false. All hasXXX methods forward the call to supportsXXX.
All positioning methods throw UnsupportedOperationException.
A typical subclass that supports a certain subset of access modes will only need to override
methods corresponding to those modes. For example, a simple sequential access source
with no rewind capability will override supportsNext()
, hasNext()
, next()
,
and possibly size()
if the number of records in the source is known.
Constructor and Description |
---|
AbstractRecordSource() |
AbstractRecordSource(String name) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the record source and release any associated resources.
|
void |
current()
Reloads the current record.
|
long |
getCurrentIndex()
Returns the index of the current record.
|
RecordTag |
getCurrentTag()
Returns the tag of the current record.
|
long |
getEstimatedSize()
Returns the estimated number of records in this source.
|
String |
getName()
Returns the name of this source.
|
Class<?> |
getRecordClass()
Returns the Class object that is guaranteed to be a superclass of all records in this source.
|
List<RecordTag> |
getTags()
Returns a list of tags for events in this source.
|
boolean |
hasCurrent()
Returns true if this source can reload the current record.
|
boolean |
hasIndex(long index)
Returns true if this source has a record with the specified index.
|
boolean |
hasNext()
Returns true if this source can load the next record.
|
boolean |
hasPrevious()
Returns true if this source can load the previous record.
|
boolean |
hasRewind()
Returns true if this source in its current state can be rewound.
|
boolean |
hasShift(long numberOfRecords)
Returns true if this source can shift by numberOfRecords records.
|
boolean |
hasTag(RecordTag tag)
Returns true if this source has a record with the specified tag.
|
void |
jump(long index)
Loads the record specified by the index.
|
void |
jump(RecordTag tag)
Loads the record specified by the tag.
|
void |
jump(String tagName)
Loads the record specified by name.
|
void |
next()
Loads the next record.
|
RecordTag |
parseTag(String s)
Returns a tag corresponding to the specified string.
|
void |
previous()
Loads the previous record.
|
void |
releaseRecord()
Releases any resources associated with the current record.
|
void |
rewind()
Positions the cursor of this source before the first record.
|
void |
setName(String name) |
void |
shift(long numberOfRecords)
Loads the record specified by the offset with respect to the current cursor position.
|
long |
size()
Returns the number of records in this source.
|
boolean |
supportsCurrent()
Returns true if this source supports reloading current record.
|
boolean |
supportsIndex()
Returns true if this source supports selecting records by index.
|
boolean |
supportsNext()
Returns true if this source supports loading next record.
|
boolean |
supportsPrevious()
Returns true if this source supports loading previous record.
|
boolean |
supportsRewind()
Returns true if this source supports rewind operation.
|
boolean |
supportsShift()
Returns true if this source supports selecting records by offset with respect to the current record.
|
boolean |
supportsTag()
Returns true if this source supports selecting records by tag.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCurrentRecord
public AbstractRecordSource()
public AbstractRecordSource(String name)
public void setName(String name)
public String getName()
getName
in interface RecordSource
public Class<?> getRecordClass()
Implemented to return Object.class.
getRecordClass
in interface RecordSource
public long size()
Implemented to throw UnsupportedOperationException.
size
in interface RecordSource
public long getEstimatedSize()
Implemented to forward the call to size().
getEstimatedSize
in interface RecordSource
public List<RecordTag> getTags()
Implemented to throw UnsupportedOperationException.
getTags
in interface RecordSource
public long getCurrentIndex()
Implemented to throw UnsupportedOperationException.
getCurrentIndex
in interface RecordSource
public RecordTag getCurrentTag()
Implemented to throw UnsupportedOperationException.
getCurrentTag
in interface RecordSource
public void releaseRecord()
Implemented to do nothing.
releaseRecord
in interface RecordSource
public boolean supportsCurrent()
supportsCurrent
in interface RecordSource
public boolean supportsNext()
supportsNext
in interface RecordSource
public boolean supportsPrevious()
supportsPrevious
in interface RecordSource
public boolean supportsIndex()
supportsIndex
in interface RecordSource
public boolean supportsTag()
supportsTag
in interface RecordSource
public boolean supportsShift()
supportsShift
in interface RecordSource
public boolean hasCurrent()
hasCurrent
in interface RecordSource
public boolean hasNext()
hasNext
in interface RecordSource
public boolean hasPrevious()
hasPrevious
in interface RecordSource
public boolean hasIndex(long index)
hasIndex
in interface RecordSource
public boolean hasTag(RecordTag tag)
hasTag
in interface RecordSource
public boolean hasShift(long numberOfRecords)
hasShift
in interface RecordSource
public void current() throws IOException, NoSuchRecordException
current
in interface RecordSource
IOException
- if reloading of the current record fails.NoSuchRecordException
- if there is no current record.public void next() throws IOException, NoSuchRecordException
next
in interface RecordSource
IOException
- if loading of the next record fails.NoSuchRecordException
- if there is no next record.public void previous() throws IOException, NoSuchRecordException
previous
in interface RecordSource
IOException
- if loading of the previous record fails.NoSuchRecordException
- if there is no previous record.public void jump(long index) throws IOException, NoSuchRecordException
jump
in interface RecordSource
IOException
- if loading of the requested record fails.NoSuchRecordException
- if this source does not have a record with the specified index.public void jump(RecordTag tag) throws IOException, NoSuchRecordException
jump
in interface RecordSource
IOException
- if loading of the requested record fails.NoSuchRecordException
- if this source does not have a record with the specified tag.public void shift(long numberOfRecords) throws IOException, NoSuchRecordException
shift
in interface RecordSource
IOException
- if loading of the requested record fails.NoSuchRecordException
- if this source does not have a record with the specified offset.public void jump(String tagName) throws IOException, NoSuchRecordException
parseTag(String)
.IOException
NoSuchRecordException
public boolean supportsRewind()
supportsRewind
in interface RecordSource
public boolean hasRewind()
hasRewind
in interface RecordSource
public void rewind() throws IOException
rewind
in interface RecordSource
IOException
- if rewinding fails for any reason.public void close() throws IOException
Implemented to do nothing.
close
in interface RecordSource
IOException
- if closing fails.public RecordTag parseTag(String s)
Implemented to return an instance of DefaultRecordTag
with the specified name.
parseTag
in interface RecordSource
Copyright © 2000-2012 FreeHEP. All Rights Reserved.