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 classFCBuffer.StopException-
Nested classes/interfaces inherited from class Thread
Thread.State, Thread.UncaughtExceptionHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected SAXExceptionexceptionstatic intFINISHLast feature is in the bufferprotected SimpleFeatureTypeftprotected static Loggerloggerprotected intstatestatic intSTOP-
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFCBuffer(URI document, int capacity, int timeout, SimpleFeatureType ft)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanaddFeature(SimpleFeature f)Adds a feature to the buffervoidclose()Release the underlying resources associated with this stream.intgetCapacity()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)SimpleFeatureTypegetFeatureType()Return the FeatureType this reader has been configured to create.intgetInternalState()intgetSize()intgetTimeout()booleanhasNext()Query whether this FeatureReader has another Feature.protected voidinitHints(XMLHandlerHints hints)Called before parsing the FeatureCollection.SimpleFeaturenext()Reads the next Feature in the FeatureReader.SimpleFeaturepeek()voidresetTimer()voidrun()-
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:FeatureReaderReturn the FeatureType this reader has been configured to create.- Specified by:
getFeatureTypein 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:FeatureReaderReads the next Feature in the FeatureReader.- Specified by:
nextin 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:
IOExceptionNoSuchElementException- See Also:
FeatureReader.next()
-
hasNext
public boolean hasNext() throws IOExceptionDescription copied from interface:FeatureReaderQuery whether this FeatureReader has another Feature.- Specified by:
hasNextin 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:FeatureReaderRelease the underlying resources associated with this stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceFeatureReader<SimpleFeatureType,SimpleFeature>- See Also:
FeatureReader.close()
-
run
public void run()
- Specified by:
runin interfaceRunnable- Overrides:
runin 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()
-
-