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.
|
containerListenersconsistencyCheck, 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, removeContainerListeneraddTopicMapListeners, 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, setReadOnlyprotected 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()
TopicMappublic boolean isUseUndo()
public void setUseUndo(boolean useUndo)
throws UndoException
UndoExceptionpublic void setUndoDisabled(boolean value)
public void undo()
throws UndoException
UndoExceptionpublic void redo()
throws UndoException
UndoExceptionprivate 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
TopicMapclearTopicMap in class TopicMapTopicMapExceptionpublic void clearTopicMapIndexes()
throws TopicMapException
TopicMapclearTopicMapIndexes in class TopicMapTopicMapExceptionpublic void clearTopicIndex()
void removeTopicFromIndex(Locator l) throws TopicMapException
TopicMapExceptionvoid addTopicToIndex(LayeredTopic lt) throws TopicMapException
TopicMapExceptionpublic void setConsistencyCheck(boolean value)
throws TopicMapException
TopicMapSet 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 TopicMapTopicMapExceptionTopicMap.checkAssociationConsistency(TopicMapLogger)public boolean getConsistencyCheck()
throws TopicMapException
getConsistencyCheck in class TopicMapTopicMapExceptionpublic void setAmbiguityResolver(AmbiguityResolver resolver)
public void topicRemoved(Topic t) throws TopicMapException
TopicMapListenertopicRemoved in interface TopicMapListenerTopicMapExceptionpublic void associationRemoved(Association a) throws TopicMapException
TopicMapListenerassociationRemoved in interface TopicMapListenerTopicMapExceptionpublic void topicSubjectIdentifierChanged(Topic t, Locator added, Locator removed) throws TopicMapException
TopicMapListenertopicSubjectIdentifierChanged in interface TopicMapListenerTopicMapExceptionpublic void topicBaseNameChanged(Topic t, java.lang.String newName, java.lang.String oldName) throws TopicMapException
TopicMapListenertopicBaseNameChanged in interface TopicMapListenerTopicMapExceptionpublic void topicTypeChanged(Topic t, Topic added, Topic removed) throws TopicMapException
TopicMapListenertopicTypeChanged in interface TopicMapListenerTopicMapExceptionpublic void topicVariantChanged(Topic t, java.util.Collection<Topic> scope, java.lang.String newName, java.lang.String oldName) throws TopicMapException
TopicMapListenertopicVariantChanged in interface TopicMapListenerTopicMapExceptionpublic void topicDataChanged(Topic t, Topic type, Topic version, java.lang.String newValue, java.lang.String oldValue) throws TopicMapException
TopicMapListenertopicDataChanged in interface TopicMapListenerTopicMapExceptionpublic void topicSubjectLocatorChanged(Topic t, Locator newLocator, Locator oldLocator) throws TopicMapException
TopicMapListenertopicSubjectLocatorChanged in interface TopicMapListenerTopicMapExceptionpublic void topicChanged(Topic t) throws TopicMapException
TopicMapListenertopicChanged in interface TopicMapListenerTopicMapExceptionpublic void associationTypeChanged(Association a, Topic newType, Topic oldType) throws TopicMapException
TopicMapListenerassociationTypeChanged in interface TopicMapListenerTopicMapExceptionpublic void associationPlayerChanged(Association a, Topic role, Topic newPlayer, Topic oldPlayer) throws TopicMapException
TopicMapListenerassociationPlayerChanged in interface TopicMapListenerTopicMapExceptionpublic void associationChanged(Association a) throws TopicMapException
TopicMapListenerassociationChanged in interface TopicMapListenerTopicMapExceptionpublic boolean isSelectedReadOnly()
public int getLayerZPos(Layer l)
getLayerZPos in class ContainerTopicMappublic Layer getLayer(java.lang.String layerName)
getLayer in class ContainerTopicMappublic Layer getSelectedLayer()
getSelectedLayer in class ContainerTopicMappublic int getSelectedIndex()
getSelectedIndex in class ContainerTopicMappublic void selectLayer(Layer layer)
selectLayer in class ContainerTopicMappublic java.util.List<Layer> getLayers()
getLayers in class ContainerTopicMappublic java.util.List<Layer> getVisibleLayers()
getVisibleLayers in class ContainerTopicMappublic void notifyLayersChanged()
notifyLayersChanged in class ContainerTopicMappublic java.util.Collection<Topic> getTopicsForLayer(Layer l, Topic t)
getTopicsForLayer in class ContainerTopicMappublic void addLayer(Layer l)
addLayer in class ContainerTopicMappublic void addLayer(Layer l, int pos)
addLayer in class ContainerTopicMappublic void setLayer(Layer l, int pos)
setLayer in class ContainerTopicMappublic boolean removeLayer(Layer l)
removeLayer in class ContainerTopicMappublic void reverseLayerOrder()
reverseLayerOrder in class ContainerTopicMappublic 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
TopicMapExceptionprotected void collectTopics(java.util.Set<Topic> collected, Topic t) throws TopicMapException
TopicMapExceptionLayeredTopic makeLayeredTopic(Topic t) throws TopicMapException
TopicMapExceptionjava.util.Collection<Topic> makeLayeredTopics(java.util.Collection<Topic> ts) throws TopicMapException
TopicMapExceptionLayeredAssociation makeLayeredAssociation(Association a) throws TopicMapException
TopicMapExceptionpublic Topic getTopic(Locator si) throws TopicMapException
TopicMapgetTopic in class TopicMapTopicMapExceptionpublic Topic[] getTopics(java.lang.String[] sis) throws TopicMapException
TopicMapgetTopics in class TopicMapTopicMapExceptionpublic Topic getTopicBySubjectLocator(Locator sl) throws TopicMapException
TopicMapgetTopicBySubjectLocator in class TopicMapTopicMapExceptionpublic Topic createTopic(java.lang.String id) throws TopicMapException
TopicMapcreateTopic in class TopicMapTopicMapExceptionpublic Topic createTopic() throws TopicMapException
TopicMapcreateTopic in class TopicMapTopicMapExceptionpublic Association createAssociation(Topic type) throws TopicMapException
TopicMapcreateAssociation in class TopicMapTopicMapExceptionpublic java.util.Collection<Topic> getTopicsOfType(Topic type) throws TopicMapException
TopicMapgetTopicsOfType in class TopicMapTopicMapExceptionpublic Topic getTopicWithBaseName(java.lang.String name) throws TopicMapException
TopicMapgetTopicWithBaseName in class TopicMapTopicMapExceptionpublic java.util.Iterator<Topic> getTopics() throws TopicMapException
TopicMapgetTopics in class TopicMapTopicMapExceptionpublic java.util.Iterator<Association> getAssociations() throws TopicMapException
TopicMapgetAssociations in class TopicMapTopicMapExceptionLayeredTopic getLayeredTopic(Topic t, java.util.Map<Topic,LayeredTopic> layeredTopics) throws TopicMapException
TopicMapExceptionpublic java.util.Collection<Association> getAssociationsOfType(Topic type) throws TopicMapException
TopicMapgetAssociationsOfType in class TopicMapTopicMapExceptionpublic int getNumTopics()
throws TopicMapException
TopicMapgetNumTopics in class TopicMapTopicMapExceptionpublic int getNumAssociations()
throws TopicMapException
TopicMapgetNumAssociations in class TopicMapTopicMapExceptionpublic Topic copyTopicIn(Topic t, boolean deep) throws TopicMapException
TopicMapcopyTopicIn in class TopicMapTopicMapExceptionpublic Association copyAssociationIn(Association a) throws TopicMapException
TopicMapcopyAssociationIn in class TopicMapTopicMapExceptionpublic void copyTopicAssociationsIn(Topic t) throws TopicMapException
TopicMapcopyTopicAssociationsIn in class TopicMapTopicMapExceptionpublic void importXTM(java.io.InputStream in,
TopicMapLogger logger)
throws java.io.IOException,
TopicMapException
importXTM in class TopicMapjava.io.IOExceptionTopicMapExceptionpublic void importLTM(java.io.InputStream in,
TopicMapLogger logger)
throws java.io.IOException,
TopicMapException
importLTM in class TopicMapjava.io.IOExceptionTopicMapExceptionpublic void importLTM(java.io.File in)
throws java.io.IOException,
TopicMapException
importLTM in class TopicMapjava.io.IOExceptionTopicMapExceptionpublic void mergeIn(TopicMap tm) throws TopicMapException
TopicMapmergeIn in class TopicMapTopicMapExceptionpublic boolean trackingDependent()
trackingDependent in class TopicMappublic void setTrackDependent(boolean v)
TopicMapsetTrackDependent in class TopicMappublic java.util.List<TopicMapListener> getTopicMapListeners()
TopicMapgetTopicMapListeners in class TopicMappublic void addTopicMapListener(TopicMapListener listener)
TopicMapaddTopicMapListener in class TopicMappublic void removeTopicMapListener(TopicMapListener listener)
TopicMapremoveTopicMapListener in class TopicMappublic void disableAllListeners()
disableAllListeners in class TopicMappublic void enableAllListeners()
enableAllListeners in class TopicMappublic boolean resetTopicMapChanged()
throws TopicMapException
resetTopicMapChanged in class TopicMapTopicMapExceptionTopicMap.isTopicMapChanged()public boolean isTopicMapChanged()
throws TopicMapException
TopicMapisTopicMapChanged in class TopicMapTopicMapExceptionpublic java.util.Collection<Topic> search(java.lang.String query, TopicMapSearchOptions options) throws TopicMapException
TopicMapsearch in class TopicMapTopicMapExceptionpublic TopicMapStatData getStatistics(TopicMapStatOptions options) throws TopicMapException
getStatistics in class TopicMapTopicMapExceptionpublic static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.ExceptionCopyright 2004-2015 Wandora Team