public class LayerStack extends ContainerTopicMap implements TopicMapListener
LayerStack combines several topic maps (called layers) into one topic map. This has the advantage of being able to hide and show parts of the topic map when necessary and keep different kinds of information apart from each other but still be able to view all the information as a single topic map when needed.
All LayeredTopics consist of a collection of topics from all layers. The collection may contain any number of topics for any layer. All methods in LayerStack, LayeredTopic and LayeredAssociation always return layered objects instead of the objects of different layers except for the method where it is specifically stated that return value consists of individual topics. Also all methods expect to receive their parameters as Layered objects instead of objects of individual layers except when something else is specifically stated.
LayerStack has some requirements about the behavior of equals and hashCode methods. Objects representing the same topic in the topic map must be equal when checked with the equals method. Also, the hashCode of of a topic must not change after the creation of the topic. One way to achieve this is to use the default equals and hashCode methods and at any time have at most one object for each topic in the topic map. LayerStack itself doesn't meet these requirements, hashCode of topics will change when the set of topics it contains changes, and thus you cannot use LayerStacks as layers in another LayerStack.
Note:
TopicMapListeners work a bit different in LayerStack than other TopicMap implementations.
Listeners may get changed events even when nothing that is visible using TopicMap interface
methods has changed. For example changing a variant name in any layer will cause topicVariantNameChanged
event even if another layer overrides the name. Also changes to subject identifiers may cause
complex merge or split operations which are reported as a single (or in some cases a few) events.
Modifier and Type | Class and Description |
---|---|
private class |
LayerStack.AssociationsIterator |
class |
LayerStack.TopicAndLayerKeyMaker |
private class |
LayerStack.TopicsIterator |
Modifier and Type | Field and Description |
---|---|
private AmbiguityResolver |
ambiguityResolver |
protected ContainerTopicMapListener |
containerListener |
protected java.util.ArrayList<TopicMapListener> |
disabledListeners |
protected java.lang.Object |
indexLock |
protected java.util.HashMap<TopicMap,Layer> |
layerIndex
Maps the topic maps of each layer to the layer itself.
|
protected java.util.Vector<Layer> |
layers
All layers in the layer stack.
|
protected Layer |
selectedLayer
The selected layer.
|
protected java.util.HashMap<Locator,LayeredTopic> |
topicIndex
Maps subject identifiers to layered topics for fast access in makeLayered.
|
protected java.util.ArrayList<TopicMapListener> |
topicMapListeners |
protected boolean |
trackDependent |
protected boolean |
useTopicIndex |
protected boolean |
useUndo |
protected java.util.Vector<Layer> |
visibleLayers
All layers that are currently visible, in the order they are in the stack.
|
containerListeners
consistencyCheck, consistencyCheckWhenXTMImport, EDITTIME_SI, isReadOnly, logger, parentTopicMap
Constructor and Description |
---|
LayerStack() |
LayerStack(java.lang.String wandoraProjectFilename)
Creates a new instance of LayerStack
|
Modifier and Type | Method and Description |
---|---|
void |
addLayer(Layer l)
Adds a layer at the bottom of the stack.
|
void |
addLayer(Layer l,
int pos)
Inserts a layer at the specified position in the stack.
|
void |
addTopicMapListener(TopicMapListener listener)
Adds a topic map listener.
|
(package private) void |
addTopicToIndex(LayeredTopic lt)
Adds a topic to topicIndex.
|
void |
addUndoMarker(java.lang.String label) |
(package private) void |
ambiguity(java.lang.String s) |
void |
associationChanged(Association a)
A notification used to report general or large changes in association.
|
void |
associationPlayerChanged(Association a,
Topic role,
Topic newPlayer,
Topic oldPlayer)
A notification that a player in an association with a certain role has
been changed.
|
void |
associationRemoved(Association a)
A notification that an association has been completely removed.
|
void |
associationTypeChanged(Association a,
Topic newType,
Topic oldType)
A notification that association type has changed.
|
boolean |
canRedo() |
boolean |
canUndo() |
void |
clearTopicIndex()
Clears topicIndex.
|
void |
clearTopicMap()
Completely clears the topic map.
|
void |
clearTopicMapIndexes()
If the topic map implementation keeps indexes or caches of topics, calling
this method will clear such data structures and cause further methods to
retrieve data directly from the original data source.
|
void |
clearUndoBuffers() |
void |
close()
Close the topic map.
|
protected void |
collectTopics(java.util.Set<Topic> collected,
Topic t)
Collects all topics from all layers that merge with the given topic.
|
protected java.util.Set<Topic> |
collectTopics(Topic t)
Collects all topics from all layers that merge with the given topic.
|
Association |
copyAssociationIn(Association a)
Copies an association of a different topic map in this topic map.
|
void |
copyTopicAssociationsIn(Topic t)
Copies all associations of a topic of a different topic map in this topic
map using copyAssociationIn.
|
Topic |
copyTopicIn(Topic t,
boolean deep)
Copies a topic of different topic map in this topic map.
|
Association |
createAssociation(Topic type)
Creates a new association of the given type without any members.
|
Topic |
createTopic()
Creates a new topic without base name, subject identifier, data or any associations.
|
Topic |
createTopic(java.lang.String id)
Creates a new topic without base name, subject identifier, data or any associations.
|
void |
disableAllListeners() |
void |
enableAllListeners() |
java.util.Iterator<Association> |
getAssociations()
Returns all associations in the topic map.
|
java.util.Collection<Association> |
getAssociationsOfType(Topic type)
Returns all associations in the topic map that are of the given type.
|
boolean |
getConsistencyCheck() |
Layer |
getLayer(java.lang.String layerName)
Gets the layer with the specified name.
|
Layer |
getLayer(Topic t)
Gets the layer a topic belongs to.
|
Layer |
getLayer(TopicMap tm)
Gets the layer of a topic map.
|
(package private) LayeredTopic |
getLayeredTopic(Topic t,
java.util.Map<Topic,LayeredTopic> layeredTopics) |
java.util.List<Layer> |
getLayers()
Gets all layers in the order they are in the stack.
|
int |
getLayerZPos(Layer l)
Gets layer position in the stack.
|
private UndoBuffer |
getNextRedo() |
static Tuples.T2<java.lang.Integer,UndoBuffer> |
getNextRedo(LayerStack lst) |
private UndoBuffer |
getNextUndo() |
static Tuples.T2<java.lang.Integer,UndoBuffer> |
getNextUndo(LayerStack lst) |
int |
getNumAssociations()
Returns the number of associations in topic map.
|
int |
getNumTopics()
Returns the number of topics in topic map.
|
int |
getSelectedIndex()
Gets the selected layer position in the stack.
|
Layer |
getSelectedLayer()
Gets the selected layer.
|
TopicMapStatData |
getStatistics(TopicMapStatOptions options) |
Topic |
getTopic(Locator si)
Gets a topic with subject identifier.
|
Topic |
getTopicBySubjectLocator(Locator sl)
Gets a topic with subject locator.
|
java.util.List<TopicMapListener> |
getTopicMapListeners()
Gets all topic map listeners.
|
java.util.Iterator<Topic> |
getTopics()
Gets all topics in the topic map.
|
Topic[] |
getTopics(java.lang.String[] sis)
Gets the topics whose subject identifiers are given in the array.
|
java.util.Collection<Topic> |
getTopicsForLayer(Layer l,
Topic t) |
java.util.Collection<Topic> |
getTopicsOfType(Topic type)
Gets all topics in the topic map that are of the given type.
|
Topic |
getTopicWithBaseName(java.lang.String name)
Gets a topic with topic base name.
|
java.util.ArrayList<UndoOperation> |
getUndoOperations() |
java.util.List<Layer> |
getVisibleLayers()
Gets all visible layers in the order they are in the stack.
|
void |
importLTM(java.io.File in) |
void |
importLTM(java.io.InputStream in,
TopicMapLogger logger) |
void |
importXTM(java.io.InputStream in,
TopicMapLogger logger) |
boolean |
isSelectedReadOnly()
Checks if the selected layer is in read only mode.
|
boolean |
isTopicMapChanged()
Checks if the topic map has been changed since the last call to resetTopicMapChanged.
|
boolean |
isUseUndo() |
static void |
main(java.lang.String[] args) |
(package private) LayeredAssociation |
makeLayeredAssociation(Association a)
Makes layered association from an individual association.
|
(package private) LayeredTopic |
makeLayeredTopic(Topic t)
Makes a layered topic when given a topic in one of the layers, that is a topic
that isn't yet a LayeredTopic of this LayerStack.
|
(package private) java.util.Collection<Topic> |
makeLayeredTopics(java.util.Collection<Topic> ts)
Makes layered topics for all topics in the collection.
|
void |
mergeAllLayers(int targetLayerIndex)
Merges all layers in the specified layer.
|
void |
mergeIn(TopicMap tm)
Merges the contents of the given topic map in this topic map.
|
void |
mergeLayers(int[] layerIndexes)
Merges some layers.
|
void |
notifyLayersChanged() |
void |
redo() |
boolean |
removeLayer(Layer l)
Removes the specified layer.
|
(package private) void |
removeTopicFromIndex(Locator l)
Removes topic from topicIndex.
|
void |
removeTopicMapListener(TopicMapListener listener)
Removes a topic map listener.
|
boolean |
resetTopicMapChanged() |
AmbiguityResolution |
resolveAmbiguity(java.lang.String event) |
AmbiguityResolution |
resolveAmbiguity(java.lang.String event,
java.lang.String msg) |
void |
reverseLayerOrder()
Moves layers around to reverse layer order.
|
java.util.Collection<Topic> |
search(java.lang.String query,
TopicMapSearchOptions options)
Searches the topic map for the given string.
|
void |
selectLayer(Layer layer)
Makes the specified layer the selected layer.
|
void |
setAmbiguityResolver(AmbiguityResolver resolver) |
void |
setConsistencyCheck(boolean value)
Set consistency check of associations on or off.
|
void |
setLayer(Layer l,
int pos)
Sets layer in the specified position removing old layer at that position.
|
void |
setTrackDependent(boolean v)
NOTE: The two trackDependent methods are mostly deprecated.
|
void |
setUndoDisabled(boolean value) |
void |
setUseUndo(boolean useUndo) |
void |
topicBaseNameChanged(Topic t,
java.lang.String newName,
java.lang.String oldName)
Notification that the base name has been changed.
|
void |
topicChanged(Topic t)
A notification used to report general or large changes in topic, for example when topics are merged.
|
void |
topicDataChanged(Topic t,
Topic type,
Topic version,
java.lang.String newValue,
java.lang.String oldValue)
Notification that topic occurrence has been changed.
|
void |
topicRemoved(Topic t)
Notification that a topic has been completely removed.
|
void |
topicSubjectIdentifierChanged(Topic t,
Locator added,
Locator removed)
Notification that a subject identifier has changed.
|
void |
topicSubjectLocatorChanged(Topic t,
Locator newLocator,
Locator oldLocator)
Notification that the subject locator has been changed.
|
void |
topicTypeChanged(Topic t,
Topic added,
Topic removed)
Notification that a topic type has changed.
|
void |
topicVariantChanged(Topic t,
java.util.Collection<Topic> scope,
java.lang.String newName,
java.lang.String oldName)
Notification that a variant name has been changed.
|
boolean |
trackingDependent() |
void |
undo() |
addContainerListener, addContainerListeners, fireLayerAdded, fireLayerChanged, fireLayerRemoved, fireLayerStructureChanged, fireLayerVisibilityChanged, getContainerListeners, getLeafLayer, getLeafLayers, getLeafLayers, getNumLayers, getSelectedTreeLayer, getTopicForLayer, getTopicForSelectedTreeLayer, getTopicsForAllLeafLayers, getTopicsForSelectedTreeLayer, getTopicsForTreeLayer, getTreeLayer, getTreeLayer, getTreeLayerPath, getTreeLayerPath, getTreeLayers, getTreeLayers, moveLayer, removeContainerListener
addTopicMapListeners, checkAssociationConsistency, checkAssociationConsistency, copyTopicCollectionIn, createLocator, createLocator, escapeXML, exportJTM, exportJTM, exportJTM, exportJTM, exportLTM, exportLTM, exportLTM, exportLTM, exportTopicMap, exportTopicMap, exportXTM, exportXTM, exportXTM, exportXTM, exportXTM10, exportXTM10, exportXTM10, exportXTM20, exportXTM20, forceStop, getLogger, getMergingTopics, getParentTopicMap, getRootTopicMap, getTopic, getTopicBySubjectLocator, getTopics, getTopicsOfType, hlog, importJTM, importJTM, importJTM, importJTM, importJTM, importJTM, importLTM, importLTM, importLTM, importLTM, importTopicMap, importTopicMap, importTopicMap, importXTM, importXTM, importXTM, importXTM, isConnected, isReadOnly, log, log, log, makeJTMString, makeJTMTopicId, makeLTMString, makeLTMTopicId, makeSubjectIndicator, makeSubjectIndicatorAsLocator, mergeIn, setLogger, setLogTitle, setParentTopicMap, setProgress, setProgressMax, setReadOnly
protected boolean useTopicIndex
protected java.lang.Object indexLock
protected java.util.HashMap<Locator,LayeredTopic> topicIndex
protected java.util.Vector<Layer> layers
protected java.util.HashMap<TopicMap,Layer> layerIndex
protected Layer selectedLayer
protected java.util.Vector<Layer> visibleLayers
protected boolean trackDependent
protected java.util.ArrayList<TopicMapListener> topicMapListeners
protected java.util.ArrayList<TopicMapListener> disabledListeners
private AmbiguityResolver ambiguityResolver
protected ContainerTopicMapListener containerListener
protected boolean useUndo
public LayerStack(java.lang.String wandoraProjectFilename)
public LayerStack()
public void close()
TopicMap
public boolean isUseUndo()
public void setUseUndo(boolean useUndo) throws UndoException
UndoException
public void setUndoDisabled(boolean value)
public void undo() throws UndoException
UndoException
public void redo() throws UndoException
UndoException
private UndoBuffer getNextUndo()
public static Tuples.T2<java.lang.Integer,UndoBuffer> getNextUndo(LayerStack lst)
private UndoBuffer getNextRedo()
public static Tuples.T2<java.lang.Integer,UndoBuffer> getNextRedo(LayerStack lst)
public boolean canUndo()
public boolean canRedo()
public void addUndoMarker(java.lang.String label)
public void clearUndoBuffers()
public java.util.ArrayList<UndoOperation> getUndoOperations()
public void clearTopicMap() throws TopicMapException
TopicMap
clearTopicMap
in class TopicMap
TopicMapException
public void clearTopicMapIndexes() throws TopicMapException
TopicMap
clearTopicMapIndexes
in class TopicMap
TopicMapException
public void clearTopicIndex()
void removeTopicFromIndex(Locator l) throws TopicMapException
TopicMapException
void addTopicToIndex(LayeredTopic lt) throws TopicMapException
TopicMapException
public void setConsistencyCheck(boolean value) throws TopicMapException
TopicMap
Set consistency check of associations on or off. This should normally be turned on but you may turn it off before some big batch operations to speed them up. After this operation you need to turn the consistency check back on and manually call checkAssociationConsistency unless you are sure that the operation did not cause any incensistencies with associations.
Note that some implementations may not allow turning consistency check off so getConsistencyCheck may return a different value that the last parameter used for setConsistencyCheck. If turning consistency check off is not supported, then it is also not needed to manually call the checkAssociationConsistency.
setConsistencyCheck
in class TopicMap
TopicMapException
TopicMap.checkAssociationConsistency(TopicMapLogger)
public boolean getConsistencyCheck() throws TopicMapException
getConsistencyCheck
in class TopicMap
TopicMapException
public void setAmbiguityResolver(AmbiguityResolver resolver)
public void topicRemoved(Topic t) throws TopicMapException
TopicMapListener
topicRemoved
in interface TopicMapListener
TopicMapException
public void associationRemoved(Association a) throws TopicMapException
TopicMapListener
associationRemoved
in interface TopicMapListener
TopicMapException
public void topicSubjectIdentifierChanged(Topic t, Locator added, Locator removed) throws TopicMapException
TopicMapListener
topicSubjectIdentifierChanged
in interface TopicMapListener
TopicMapException
public void topicBaseNameChanged(Topic t, java.lang.String newName, java.lang.String oldName) throws TopicMapException
TopicMapListener
topicBaseNameChanged
in interface TopicMapListener
TopicMapException
public void topicTypeChanged(Topic t, Topic added, Topic removed) throws TopicMapException
TopicMapListener
topicTypeChanged
in interface TopicMapListener
TopicMapException
public void topicVariantChanged(Topic t, java.util.Collection<Topic> scope, java.lang.String newName, java.lang.String oldName) throws TopicMapException
TopicMapListener
topicVariantChanged
in interface TopicMapListener
TopicMapException
public void topicDataChanged(Topic t, Topic type, Topic version, java.lang.String newValue, java.lang.String oldValue) throws TopicMapException
TopicMapListener
topicDataChanged
in interface TopicMapListener
TopicMapException
public void topicSubjectLocatorChanged(Topic t, Locator newLocator, Locator oldLocator) throws TopicMapException
TopicMapListener
topicSubjectLocatorChanged
in interface TopicMapListener
TopicMapException
public void topicChanged(Topic t) throws TopicMapException
TopicMapListener
topicChanged
in interface TopicMapListener
TopicMapException
public void associationTypeChanged(Association a, Topic newType, Topic oldType) throws TopicMapException
TopicMapListener
associationTypeChanged
in interface TopicMapListener
TopicMapException
public void associationPlayerChanged(Association a, Topic role, Topic newPlayer, Topic oldPlayer) throws TopicMapException
TopicMapListener
associationPlayerChanged
in interface TopicMapListener
TopicMapException
public void associationChanged(Association a) throws TopicMapException
TopicMapListener
associationChanged
in interface TopicMapListener
TopicMapException
public boolean isSelectedReadOnly()
public int getLayerZPos(Layer l)
getLayerZPos
in class ContainerTopicMap
public Layer getLayer(java.lang.String layerName)
getLayer
in class ContainerTopicMap
public Layer getSelectedLayer()
getSelectedLayer
in class ContainerTopicMap
public int getSelectedIndex()
getSelectedIndex
in class ContainerTopicMap
public void selectLayer(Layer layer)
selectLayer
in class ContainerTopicMap
public java.util.List<Layer> getLayers()
getLayers
in class ContainerTopicMap
public java.util.List<Layer> getVisibleLayers()
getVisibleLayers
in class ContainerTopicMap
public void notifyLayersChanged()
notifyLayersChanged
in class ContainerTopicMap
public java.util.Collection<Topic> getTopicsForLayer(Layer l, Topic t)
getTopicsForLayer
in class ContainerTopicMap
public void addLayer(Layer l)
addLayer
in class ContainerTopicMap
public void addLayer(Layer l, int pos)
addLayer
in class ContainerTopicMap
public void setLayer(Layer l, int pos)
setLayer
in class ContainerTopicMap
public boolean removeLayer(Layer l)
removeLayer
in class ContainerTopicMap
public void reverseLayerOrder()
reverseLayerOrder
in class ContainerTopicMap
public void mergeAllLayers(int targetLayerIndex)
public void mergeLayers(int[] layerIndexes)
void ambiguity(java.lang.String s)
public AmbiguityResolution resolveAmbiguity(java.lang.String event)
public AmbiguityResolution resolveAmbiguity(java.lang.String event, java.lang.String msg)
protected java.util.Set<Topic> collectTopics(Topic t) throws TopicMapException
TopicMapException
protected void collectTopics(java.util.Set<Topic> collected, Topic t) throws TopicMapException
TopicMapException
LayeredTopic makeLayeredTopic(Topic t) throws TopicMapException
TopicMapException
java.util.Collection<Topic> makeLayeredTopics(java.util.Collection<Topic> ts) throws TopicMapException
TopicMapException
LayeredAssociation makeLayeredAssociation(Association a) throws TopicMapException
TopicMapException
public Topic getTopic(Locator si) throws TopicMapException
TopicMap
getTopic
in class TopicMap
TopicMapException
public Topic[] getTopics(java.lang.String[] sis) throws TopicMapException
TopicMap
getTopics
in class TopicMap
TopicMapException
public Topic getTopicBySubjectLocator(Locator sl) throws TopicMapException
TopicMap
getTopicBySubjectLocator
in class TopicMap
TopicMapException
public Topic createTopic(java.lang.String id) throws TopicMapException
TopicMap
createTopic
in class TopicMap
TopicMapException
public Topic createTopic() throws TopicMapException
TopicMap
createTopic
in class TopicMap
TopicMapException
public Association createAssociation(Topic type) throws TopicMapException
TopicMap
createAssociation
in class TopicMap
TopicMapException
public java.util.Collection<Topic> getTopicsOfType(Topic type) throws TopicMapException
TopicMap
getTopicsOfType
in class TopicMap
TopicMapException
public Topic getTopicWithBaseName(java.lang.String name) throws TopicMapException
TopicMap
getTopicWithBaseName
in class TopicMap
TopicMapException
public java.util.Iterator<Topic> getTopics() throws TopicMapException
TopicMap
getTopics
in class TopicMap
TopicMapException
public java.util.Iterator<Association> getAssociations() throws TopicMapException
TopicMap
getAssociations
in class TopicMap
TopicMapException
LayeredTopic getLayeredTopic(Topic t, java.util.Map<Topic,LayeredTopic> layeredTopics) throws TopicMapException
TopicMapException
public java.util.Collection<Association> getAssociationsOfType(Topic type) throws TopicMapException
TopicMap
getAssociationsOfType
in class TopicMap
TopicMapException
public int getNumTopics() throws TopicMapException
TopicMap
getNumTopics
in class TopicMap
TopicMapException
public int getNumAssociations() throws TopicMapException
TopicMap
getNumAssociations
in class TopicMap
TopicMapException
public Topic copyTopicIn(Topic t, boolean deep) throws TopicMapException
TopicMap
copyTopicIn
in class TopicMap
TopicMapException
public Association copyAssociationIn(Association a) throws TopicMapException
TopicMap
copyAssociationIn
in class TopicMap
TopicMapException
public void copyTopicAssociationsIn(Topic t) throws TopicMapException
TopicMap
copyTopicAssociationsIn
in class TopicMap
TopicMapException
public void importXTM(java.io.InputStream in, TopicMapLogger logger) throws java.io.IOException, TopicMapException
importXTM
in class TopicMap
java.io.IOException
TopicMapException
public void importLTM(java.io.InputStream in, TopicMapLogger logger) throws java.io.IOException, TopicMapException
importLTM
in class TopicMap
java.io.IOException
TopicMapException
public void importLTM(java.io.File in) throws java.io.IOException, TopicMapException
importLTM
in class TopicMap
java.io.IOException
TopicMapException
public void mergeIn(TopicMap tm) throws TopicMapException
TopicMap
mergeIn
in class TopicMap
TopicMapException
public boolean trackingDependent()
trackingDependent
in class TopicMap
public void setTrackDependent(boolean v)
TopicMap
setTrackDependent
in class TopicMap
public java.util.List<TopicMapListener> getTopicMapListeners()
TopicMap
getTopicMapListeners
in class TopicMap
public void addTopicMapListener(TopicMapListener listener)
TopicMap
addTopicMapListener
in class TopicMap
public void removeTopicMapListener(TopicMapListener listener)
TopicMap
removeTopicMapListener
in class TopicMap
public void disableAllListeners()
disableAllListeners
in class TopicMap
public void enableAllListeners()
enableAllListeners
in class TopicMap
public boolean resetTopicMapChanged() throws TopicMapException
resetTopicMapChanged
in class TopicMap
TopicMapException
TopicMap.isTopicMapChanged()
public boolean isTopicMapChanged() throws TopicMapException
TopicMap
isTopicMapChanged
in class TopicMap
TopicMapException
public java.util.Collection<Topic> search(java.lang.String query, TopicMapSearchOptions options) throws TopicMapException
TopicMap
search
in class TopicMap
TopicMapException
public TopicMapStatData getStatistics(TopicMapStatOptions options) throws TopicMapException
getStatistics
in class TopicMap
TopicMapException
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
Copyright 2004-2015 Wandora Team