|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fu_berlin.ties.extract.ExtractionContainer
public class ExtractionContainer
A container of Extraction
s of different
classes. Instances of this class are not thread-safe.
Extraction containers can be serialized
(storeEntries(FieldContainer)
), but not deserialized.
Instances of this class are not thread-safe and have to be synchronized externally, if required.
Constructor Summary | |
---|---|
ExtractionContainer(TargetStructure targetStruct)
Creates a new empty instance. |
|
ExtractionContainer(TargetStructure targetStruct,
FieldContainer fContainer)
Creates a new instance from a field container, delegating to restoreEntries(FieldContainer) . |
Method Summary | |
---|---|
void |
add(Extraction extraction)
Adds an extraction to this container. |
TargetStructure |
getTargetStructure()
Returns the target structure specifying the classes to recognize. |
Iterator |
iterator()
Returns an iterator over all extractions in insertion order. |
Iterator<Extraction> |
iterator(String className)
Returns an iterator over the extractions of a specified class, in insertion order. |
Extraction |
last()
Returns the last extraction added to this container. |
List |
lastN(int number)
Returns a list of the last n extractions added to this container. |
List<Extraction> |
lastN(String extractionClass,
int number)
Returns a list of the last n extractions of a specified class added to this container. |
boolean |
remove(Extraction ext)
Removes an extraction from this container, if it is present. |
Extraction |
removeLast()
Removes the last extraction added to this
container. |
void |
restoreEntries(FieldContainer fContainer)
Restores extractions stored in a field container and adds them to this instance. |
void |
storeEntries(FieldContainer fContainer)
Adds all extractions stored in this instance to a field container for serialization. |
String |
toString()
Returns a string representation of this object. |
void |
unsetPositions()
Unsets the positions of all stored extractions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ExtractionContainer(TargetStructure targetStruct)
targetStruct
- the target structure specifying the classes to
recognizepublic ExtractionContainer(TargetStructure targetStruct, FieldContainer fContainer) throws IllegalArgumentException
restoreEntries(FieldContainer)
.
targetStruct
- the target structure specifying the classes to
recognizefContainer
- the field container to read
IllegalArgumentException
- if fContainer
contains
extractions of an unsupported
(@link de.fu_berlin.ties.classify.Prediction#getType())Method Detail |
---|
public void add(Extraction extraction) throws IllegalArgumentException
extraction
- the extraction to add
IllegalArgumentException
- if the type of the extraction
(@link de.fu_berlin.ties.classify.Prediction#getType()) is not
in the set of class names defined by the target structurepublic Iterator iterator()
public Iterator<Extraction> iterator(String className)
className
- the name of the class of extractions to iterate
public TargetStructure getTargetStructure()
public Extraction last()
null
if the container is emptypublic List lastN(int number)
number
- the number of extractions to copy
Extraction
spublic List<Extraction> lastN(String extractionClass, int number)
extractionClass
- the class of extractionsnumber
- the number of extractions to copy
Extraction
s of the given
class; will be empty if there are no extractions of this classpublic boolean remove(Extraction ext)
ext
- the extraction to remove
true
if the container contained the specified
extractionpublic Extraction removeLast() throws IllegalStateException
added
to this
container.
IllegalStateException
- if this method is called while the
container is emptypublic void restoreEntries(FieldContainer fContainer) throws IllegalArgumentException
storeEntries(FieldContainer)
on an extraction container with
identical target structure, or
errors are likely.
restoreEntries
in interface RestorableContainer
fContainer
- the field container to read
IllegalArgumentException
- if fContainer
contains
extractions of an unsupported
(@link de.fu_berlin.ties.classify.Prediction#getType())public void storeEntries(FieldContainer fContainer)
storeEntries
in interface StorableContainer
fContainer
- the field container to fillpublic String toString()
toString
in class Object
public void unsetPositions()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |