|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectContentState
public class ContentState
The state of an entry in a datastore, maintained on a per-transaction basis.
State is maintained on a per transaction basis (see ContentEntry
}.
State maintained includes cached values such as:
getFeatureType()
getCount()
getBounds()
.
This class is a "data object" and is not thread safe. It is up to clients of this class to ensure that values are set in a thread-safe / synchronized manner. For example:
ContentState state = ...;
//get the count
int count = state.getCount();
if ( count == -1 ) {
synchronized ( state ) {
count = calculateCount();
state.setCount( count );
}
}
This class may be extended. Subclasses may extend (not override) the following methods:
Subclasses should also overridecopy()
.
Field Summary | |
---|---|
protected BatchFeatureEvent |
batchFeatureEvent
Even used for batch notification; used to collect the bounds and feature ids generated over the course of a transaction. |
protected ReferencedEnvelope |
bounds
cached bounds of features |
protected int |
count
cached number of features |
protected ContentEntry |
entry
entry maintaining the state |
protected SimpleFeatureType |
featureType
cached feature type |
protected List<FeatureListener> |
listeners
observers |
protected Transaction |
tx
Transaction the state works from. |
Constructor Summary | |
---|---|
|
ContentState(ContentEntry entry)
Creates a new state. |
protected |
ContentState(ContentState state)
Creates a new state from a previous one. |
Method Summary | |
---|---|
void |
addListener(FeatureListener listener)
Adds a listener for collection events. |
void |
close()
Clears all state. |
ContentState |
copy()
Copies the state. |
void |
fireBatchFeatureEvent(boolean isCommit)
Notifies all waiting listeners that a commit has been issued; this notification is also sent to our |
void |
fireFeatureAdded(FeatureSource<?,?> source,
Feature feature)
Used to issue a Type.ADDED FeatureEvent indicating a new feature being created |
void |
fireFeatureEvent(FeatureEvent event)
Used to issue a single FeatureEvent. |
void |
fireFeatureRemoved(FeatureSource<?,?> source,
Feature feature)
|
void |
fireFeatureUpdated(FeatureSource<?,?> source,
Feature feature,
ReferencedEnvelope before)
|
void |
flush()
Clears cached state. |
ReferencedEnvelope |
getBounds()
The cached spatial extent. |
int |
getCount()
The cached number of features. |
ContentEntry |
getEntry()
The entry which maintains the state. |
SimpleFeatureType |
getFeatureType()
The cached feature type. |
Transaction |
getTransaction()
The transaction associated with the state. |
boolean |
hasListener()
Used to quickly test if any listeners are available. |
void |
removeListener(FeatureListener listener)
Removes a listener for collection events. |
void |
setBounds(ReferencedEnvelope bounds)
Sets the cached spatial extent. |
void |
setCount(int count)
Sets the cached number of features. |
void |
setFeatureType(SimpleFeatureType featureType)
Sets the cached feature type. |
void |
setTransaction(Transaction tx)
Sets the transaction associatred with the state. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Transaction tx
protected SimpleFeatureType featureType
protected int count
protected ReferencedEnvelope bounds
protected ContentEntry entry
protected BatchFeatureEvent batchFeatureEvent
protected List<FeatureListener> listeners
Constructor Detail |
---|
public ContentState(ContentEntry entry)
entry
- The entry for the state.protected ContentState(ContentState state)
All state from the specified state is copied. Therefore subclasses extending this constructor should clone all mutable objects.
state
- The existing state.Method Detail |
---|
public ContentEntry getEntry()
public Transaction getTransaction()
public void setTransaction(Transaction tx)
public final SimpleFeatureType getFeatureType()
public final void setFeatureType(SimpleFeatureType featureType)
public final int getCount()
public final void setCount(int count)
public final ReferencedEnvelope getBounds()
public final void setBounds(ReferencedEnvelope bounds)
public final void addListener(FeatureListener listener)
listener
- The listener to addpublic final void removeListener(FeatureListener listener)
listener
- The listener to removepublic final boolean hasListener()
public void fireFeatureUpdated(FeatureSource<?,?> source, Feature feature, ReferencedEnvelope before)
public final void fireFeatureAdded(FeatureSource<?,?> source, Feature feature)
source
- feature
- public void fireFeatureRemoved(FeatureSource<?,?> source, Feature feature)
public final void fireFeatureEvent(FeatureEvent event)
If this content state is used for Transaction.AUTO_COMMIT the notification will be passed to all interested parties.
If not this event will be recored as part of a BatchFeatureEvent that will to be issued using issueBatchFeatureEvent()
event
- public final void fireBatchFeatureEvent(boolean isCommit)
public void flush()
This method does not affect any non-cached state. This method may be extended by subclasses, but not overiden.
public void close()
Any resources that the state holds onto (like a database connection) should be closed or disposes when this method is called. This method may be extended by subclasses, but not overiden.
public ContentState copy()
Subclasses shold override this method. Any mutable state objects should be cloned.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |