Package org.geotools.xml.gml
Class FCBuffer
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Runnable
,FeatureReader<SimpleFeatureType,SimpleFeature>
public class FCBuffer extends Thread implements FeatureReader<SimpleFeatureType,SimpleFeature>
Feature Buffer ... acts as a FeatureReaderby making itself as a seperate thread prior starting execution with the SAX Parser. - Author:
- dzwiers
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FCBuffer.StopException
-
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected SAXException
exception
static int
FINISH
Last feature is in the bufferprotected SimpleFeatureType
ft
protected static Logger
logger
protected int
state
static int
STOP
-
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FCBuffer(URI document, int capacity, int timeout, SimpleFeatureType ft)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
addFeature(SimpleFeature f)
Adds a feature to the buffervoid
close()
Release the underlying resources associated with this stream.int
getCapacity()
static FeatureReader<SimpleFeatureType,SimpleFeature>
getFeatureReader(URI document, int capacity)
The prefered method of using this class, this will return the Feature Reader for the document specified, using the specified buffer capacity.static FeatureReader<SimpleFeatureType,SimpleFeature>
getFeatureReader(URI document, int capacity, int timeout)
static FeatureReader<SimpleFeatureType,SimpleFeature>
getFeatureReader(URI document, int capacity, int timeout, SimpleFeatureType ft)
static FeatureReader<SimpleFeatureType,SimpleFeature>
getFeatureReader(URI document, int capacity, SimpleFeatureType ft)
SimpleFeatureType
getFeatureType()
Return the FeatureType this reader has been configured to create.int
getInternalState()
int
getSize()
int
getTimeout()
boolean
hasNext()
Query whether this FeatureReader has another Feature.protected void
initHints(XMLHandlerHints hints)
Called before parsing the FeatureCollection.SimpleFeature
next()
Reads the next Feature in the FeatureReader.SimpleFeature
peek()
void
resetTimer()
void
run()
-
Methods inherited from class Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
FINISH
public static final int FINISH
Last feature is in the buffer- See Also:
- Constant Field Values
-
STOP
public static final int STOP
- See Also:
- Constant Field Values
-
logger
protected static Logger logger
-
state
protected int state
-
exception
protected SAXException exception
-
ft
protected SimpleFeatureType ft
-
-
Constructor Detail
-
FCBuffer
protected FCBuffer(URI document, int capacity, int timeout, SimpleFeatureType ft)
- Parameters:
ft
- Nullable
-
-
Method Detail
-
getSize
public int getSize()
- Returns:
- The buffer size
-
getCapacity
public int getCapacity()
- Returns:
- The buffer capacity
-
getTimeout
public int getTimeout()
- Returns:
- The buffer capacity
-
addFeature
protected boolean addFeature(SimpleFeature f)
Adds a feature to the buffer- Parameters:
f
- Feature to add- Returns:
- false if unable to add the feature
-
getFeatureReader
public static FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(URI document, int capacity) throws SAXException
The prefered method of using this class, this will return the Feature Reader for the document specified, using the specified buffer capacity.- Parameters:
document
- URL to parse- Throws:
SAXException
-
getFeatureReader
public static FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(URI document, int capacity, SimpleFeatureType ft) throws SAXException
- Throws:
SAXException
-
getFeatureReader
public static FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(URI document, int capacity, int timeout) throws SAXException
- Throws:
SAXException
-
getFeatureReader
public static FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(URI document, int capacity, int timeout, SimpleFeatureType ft) throws SAXException
- Throws:
SAXException
-
getFeatureType
public SimpleFeatureType getFeatureType()
Description copied from interface:FeatureReader
Return the FeatureType this reader has been configured to create.- Specified by:
getFeatureType
in interfaceFeatureReader<SimpleFeatureType,SimpleFeature>
- Returns:
- the FeatureType of the Features this FeatureReader will create.
- See Also:
FeatureReader.getFeatureType()
-
next
public SimpleFeature next() throws IOException, NoSuchElementException
Description copied from interface:FeatureReader
Reads the next Feature in the FeatureReader.- Specified by:
next
in interfaceFeatureReader<SimpleFeatureType,SimpleFeature>
- Returns:
- The next feature in the reader.
- Throws:
IOException
- If an error occurs reading the Feature.NoSuchElementException
- If there are no more Features in the Reader.- See Also:
FeatureReader.next()
-
peek
public SimpleFeature peek() throws IOException, NoSuchElementException
- Throws:
IOException
NoSuchElementException
- See Also:
FeatureReader.next()
-
hasNext
public boolean hasNext() throws IOException
Description copied from interface:FeatureReader
Query whether this FeatureReader has another Feature.- Specified by:
hasNext
in interfaceFeatureReader<SimpleFeatureType,SimpleFeature>
- Returns:
- True if there are more Features to be read. In other words, true if calls to next would return a feature rather than throwing an exception.
- Throws:
IOException
- If an error occurs determining if there are more Features.- See Also:
FeatureReader.hasNext()
-
close
public void close()
Description copied from interface:FeatureReader
Release the underlying resources associated with this stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceFeatureReader<SimpleFeatureType,SimpleFeature>
- See Also:
FeatureReader.close()
-
run
public void run()
- Specified by:
run
in interfaceRunnable
- Overrides:
run
in classThread
- See Also:
Runnable.run()
-
initHints
protected void initHints(XMLHandlerHints hints)
Called before parsing the FeatureCollection. Subclasses may override to set their custom hints.
-
getInternalState
public int getInternalState()
-
resetTimer
public void resetTimer()
-
-