public class LayeredTopic extends Topic
A LayeredTopic is a collection of topics in different layers that together merge with each other. Note that the collection may contain two topics which do not directly merge with each other but with the addition to some other topics, they all merge together. These topics are stored in an ordered collection with topics of top layers first and bottom layers last. Topics of same layer are ordered according to the smallest (lexicographically) subject identifier. This is somewhat arbitrary but will give a consistent ordering instead of random order.
When information is queried, the collection with all the individual topics is iterated and depending on the data being queried, either the first non null value is restored or all values are combined. Example of the former case is getting the base name and example for the latter case is getting subject identifiers. In general methods that return a collection of something combine the results from all individual topics (removing duplicates) and methods that return a single value return the first non null value encountered. Because topics are ordered in the topic collection, information from top layers is returned before information of bottom layers when only one non null value is returned.
Methods that modify a LayeredTopic actually modify one of the individual topics. The topic to be modified is chosen to be a topic of the selected layer of the layer stack. If such a topic does not exist one is generated in the layer. In case there are several such topics, one of them is chosen. Also the parameters to the modifying methods might not exist in the layer, in which case stubs of them are automatically generated.
Modifier and Type | Class and Description |
---|---|
(package private) class |
LayeredTopic.LayerOrderComparator
Comparator used to order the topics LayeredTopic consists of.
|
static class |
LayeredTopic.TopicKeyMaker |
Modifier and Type | Field and Description |
---|---|
private int |
hashCode |
protected LayerStack |
layerStack
The layer stack for this topic
|
protected java.util.Vector<Topic> |
topics
The topics this LayeredTopic consists of
|
Constructor and Description |
---|
LayeredTopic(java.util.Collection<Topic> topics,
LayerStack layerStack)
Creates a new instance of LayeredTopic.
|
LayeredTopic(Topic t,
LayerStack layerStack)
Creates a new instance of LayeredTopic.
|
Modifier and Type | Method and Description |
---|---|
private void |
_addAssociations(java.util.HashSet<Association> associations,
KeyedHashMap<LayeredTopic,java.util.Vector<LayeredTopic>> players,
java.util.Vector<LayeredTopic> roles,
java.util.Vector<LayeredTopic> chosen,
LayeredTopic type)
Adds LayeredAssociations into associations set based on the possible players
for each role given in the players map.
|
void |
addSubjectIdentifier(Locator l)
Adds a subject identifier for the topic.
|
void |
addType(Topic type)
Adds a topic type.
|
protected void |
ambiguity(java.lang.String s) |
Topic |
copyStubTo(TopicMap tm)
Copies a stub of this topic to the given topic map.
|
protected java.util.Set<Topic> |
createScope(java.util.Set<Topic> layeredScope,
Layer l)
Creates a scope from a collection of LayeredTopics that can be used for the
given layer.
|
protected java.util.Set<Topic> |
createScope(java.util.Set<Topic> layeredScope,
Layer l,
boolean copyTopics)
Creates a scope from a collection of LayeredTopics that can be used for the
given layer.
|
boolean |
equals(java.lang.Object o)
Two LayeredTopics are equal if their topics collections are equal.
|
java.util.Collection<Association> |
getAssociations()
Returns associations of this topic.
|
java.util.Collection<Association> |
getAssociations(Topic type)
See notes in getAssociations().
|
java.util.Collection<Association> |
getAssociations(Topic type,
Topic role)
See notes in getAssociations().
|
java.util.Collection<Association> |
getAssociationsWithRole()
Gets associations that have this topic as role.
|
java.util.Collection<Association> |
getAssociationsWithType()
Gets associations that have this topic as type.
|
java.lang.String |
getBaseName()
Gets the topic base name or null if no base name has been set.
|
Topic |
getBaseNameSource()
Returns the layer that is being used to get the base name for this topic.
|
java.util.Hashtable<Topic,java.lang.String> |
getData(Topic type)
Returns a Hashtable mapping data versions to data content.
|
java.lang.String |
getData(Topic type,
Topic version)
Gets data with the specified type and version.
|
Tuples.T3<Topic,Topic,Topic> |
getDataSource(Topic type,
Topic version)
Returns the topic that is used to get data with specified type and version and
the type and version topics for the source topic layer.
|
java.util.Collection<Topic> |
getDataTypes()
Gets all used data types.
|
long |
getDependentEditTime() |
long |
getEditTime() |
java.lang.String |
getID()
Returns the id of the first topic in the topics collection with layer name
hash code as prefix.
|
LayerStack |
getLayerStack() |
java.util.Set<Topic> |
getScopeOfLayeredScope(Topic t,
java.util.Set<Topic> layeredScope)
Tries to find a variant scope in the given (non layered) topic that matches
the scope consisting of LayeredTopics.
|
java.util.Collection<Locator> |
getSubjectIdentifiers()
Gets all the subject identifiers of all the topics that this layered topic
consists of.
|
Locator |
getSubjectLocator()
Gets the topic subject locator or null if it has not been set.
|
Topic |
getSubjectLocatorSource() |
Topic |
getTopicForLayer(Layer l)
Gets one of the topics of given layer that is part of this layered
topic or null if no such topic exists.
|
Topic |
getTopicForSelectedLayer()
Gets one of the topics of the selected layer that is part of this layered
topic or null if no such topic exists.
|
TopicMap |
getTopicMap()
Gets the topic map this topic belongs to.
|
java.util.Collection<Topic> |
getTopicsForAllLayers()
Get all topics this layered topic consists of in the order they appear
in layers.
|
java.util.Collection<Topic> |
getTopicsForLayer(Layer l)
Get all topics of the given layer that are part of this LayeredTopic.
|
java.util.Collection<Topic> |
getTopicsForSelectedLayer()
Get all topics of selected layer that are part of this LayeredTopic.
|
java.util.Collection<Topic> |
getTopicsWithDataType()
Gets topics which have data with this topic as type.
|
java.util.Collection<Topic> |
getTopicsWithDataVersion()
Gets topics which have data with this topic as version.
|
java.util.Collection<Topic> |
getTopicsWithVariantScope()
Gets topics which have variants with this topic in scope.
|
java.util.Collection<Topic> |
getTypes()
Gets all topic types.
|
java.lang.String |
getVariant(java.util.Set<Topic> scope)
Gets a variant with the specified scope.
|
java.util.Set<java.util.Set<Topic>> |
getVariantScopes()
Gets the scopes of all variant names.
|
Tuples.T2<Topic,java.util.Set<Topic>> |
getVariantSource(java.util.Set<Topic> scope)
Returns the layer that is used to get the variant for the given scope.
|
int |
hashCode() |
boolean |
isDeleteAllowed()
Returns true if and only if remove() can be called without it throwing TopicInUseException.
|
boolean |
isOfType(Topic type)
Checks if this topic is of the specified type.
|
boolean |
isRemoved()
Returns true if this topic has been removed from the topic map it belonged to.
|
private java.util.HashSet<java.lang.String> |
makeKeySet(java.util.Collection<Topic> topics)
Makes a set having one key for each topic in the given collection.
|
boolean |
mergesWithTopic(Topic topic)
Checks if this topic would merge with the topic given as parameter.
|
void |
remakeLayered()
Remakes the collection of topics this layered topic consists of.
|
void |
remakeLayered(Topic t)
Remake this LayeredTopic using the given topic as the base.
|
void |
remove()
Removes this topic.
|
void |
removeData(Topic type)
Removes all data with the specified type.
|
void |
removeData(Topic type,
Topic version)
Removes data with specified type and version.
|
void |
removeSubjectIdentifier(Locator l)
Removes a subject identifier.
|
void |
removeType(Topic type)
Removes a topic type.
|
void |
removeVariant(java.util.Set<Topic> scope)
Removes a variant name with the specified scope.
|
void |
reorderLayers()
Sort the topics collection.
|
protected AmbiguityResolution |
resolveAmbiguity(java.lang.String event) |
protected AmbiguityResolution |
resolveAmbiguity(java.lang.String event,
java.lang.String msg) |
void |
setBaseName(java.lang.String name)
Sets the topic base name.
|
void |
setData(Topic type,
java.util.Hashtable<Topic,java.lang.String> versionData)
Sets several data values.
|
void |
setData(Topic type,
Topic version,
java.lang.String value)
Sets data with specified type and version.
|
void |
setDependentEditTime(long time) |
void |
setEditTime(long time) |
void |
setSubjectLocator(Locator l)
Sets the topic subject locator overwriting possible previous value.
|
void |
setVariant(java.util.Set<Topic> scope,
java.lang.String name)
Sets the variant with the specified scope.
|
getData, getDisplayName, getDisplayName, getFirstSubjectIdentifier, getName, getOneSubjectIdentifier, getSortName, setDisplayName, toString
protected java.util.Vector<Topic> topics
protected LayerStack layerStack
private int hashCode
public LayeredTopic(java.util.Collection<Topic> topics, LayerStack layerStack)
public LayeredTopic(Topic t, LayerStack layerStack)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
protected void ambiguity(java.lang.String s)
protected AmbiguityResolution resolveAmbiguity(java.lang.String event)
protected AmbiguityResolution resolveAmbiguity(java.lang.String event, java.lang.String msg)
public void remakeLayered() throws TopicMapException
TopicMapException
remakeLayered(Topic)
private java.util.HashSet<java.lang.String> makeKeySet(java.util.Collection<Topic> topics)
public void remakeLayered(Topic t) throws TopicMapException
TopicMapException
public java.util.Collection<Topic> getTopicsForSelectedLayer()
public java.util.Collection<Topic> getTopicsForLayer(Layer l)
public java.util.Collection<Topic> getTopicsForAllLayers()
public Topic getTopicForSelectedLayer()
public Topic getTopicForLayer(Layer l)
public void reorderLayers()
public java.lang.String getID() throws TopicMapException
getID
in class Topic
TopicMapException
public java.util.Collection<Locator> getSubjectIdentifiers() throws TopicMapException
getSubjectIdentifiers
in class Topic
TopicMapException
public Topic copyStubTo(TopicMap tm) throws TopicMapException
TopicMapException
public void addSubjectIdentifier(Locator l) throws TopicMapException
Topic
addSubjectIdentifier
in class Topic
TopicMapException
public void removeSubjectIdentifier(Locator l) throws TopicMapException
Topic
removeSubjectIdentifier
in class Topic
TopicMapException
public Topic getBaseNameSource() throws TopicMapException
TopicMapException
public java.lang.String getBaseName() throws TopicMapException
Topic
getBaseName
in class Topic
TopicMapException
public void setBaseName(java.lang.String name) throws TopicMapException
Topic
setBaseName
in class Topic
TopicMapException
public java.util.Collection<Topic> getTypes() throws TopicMapException
Topic
getTypes
in class Topic
TopicMapException
public void addType(Topic type) throws TopicMapException
Topic
addType
in class Topic
TopicMapException
public void removeType(Topic type) throws TopicMapException
Topic
removeType
in class Topic
TopicMapException
public boolean isOfType(Topic type) throws TopicMapException
Topic
isOfType
in class Topic
TopicMapException
protected java.util.Set<Topic> createScope(java.util.Set<Topic> layeredScope, Layer l) throws TopicMapException
TopicMapException
protected java.util.Set<Topic> createScope(java.util.Set<Topic> layeredScope, Layer l, boolean copyTopics) throws TopicMapException
TopicMapException
public java.util.Set<Topic> getScopeOfLayeredScope(Topic t, java.util.Set<Topic> layeredScope) throws TopicMapException
TopicMapException
public Tuples.T2<Topic,java.util.Set<Topic>> getVariantSource(java.util.Set<Topic> scope) throws TopicMapException
TopicMapException
public java.lang.String getVariant(java.util.Set<Topic> scope) throws TopicMapException
Topic
getVariant
in class Topic
TopicMapException
public void setVariant(java.util.Set<Topic> scope, java.lang.String name) throws TopicMapException
Topic
setVariant
in class Topic
TopicMapException
public java.util.Set<java.util.Set<Topic>> getVariantScopes() throws TopicMapException
Topic
getVariantScopes
in class Topic
TopicMapException
public void removeVariant(java.util.Set<Topic> scope) throws TopicMapException
Topic
removeVariant
in class Topic
TopicMapException
public Tuples.T3<Topic,Topic,Topic> getDataSource(Topic type, Topic version) throws TopicMapException
TopicMapException
public java.lang.String getData(Topic type, Topic version) throws TopicMapException
Topic
getData
in class Topic
TopicMapException
public java.util.Hashtable<Topic,java.lang.String> getData(Topic type) throws TopicMapException
Topic
getData
in class Topic
TopicMapException
public java.util.Collection<Topic> getDataTypes() throws TopicMapException
Topic
getDataTypes
in class Topic
TopicMapException
public void setData(Topic type, java.util.Hashtable<Topic,java.lang.String> versionData) throws TopicMapException
Topic
setData
in class Topic
TopicMapException
public void setData(Topic type, Topic version, java.lang.String value) throws TopicMapException
Topic
setData
in class Topic
TopicMapException
public void removeData(Topic type, Topic version) throws TopicMapException
Topic
removeData
in class Topic
TopicMapException
public void removeData(Topic type) throws TopicMapException
Topic
removeData
in class Topic
TopicMapException
public Topic getSubjectLocatorSource() throws TopicMapException
TopicMapException
public Locator getSubjectLocator() throws TopicMapException
Topic
getSubjectLocator
in class Topic
TopicMapException
public void setSubjectLocator(Locator l) throws TopicMapException
Topic
setSubjectLocator
in class Topic
TopicMapException
public TopicMap getTopicMap()
Topic
getTopicMap
in class Topic
public LayerStack getLayerStack()
private void _addAssociations(java.util.HashSet<Association> associations, KeyedHashMap<LayeredTopic,java.util.Vector<LayeredTopic>> players, java.util.Vector<LayeredTopic> roles, java.util.Vector<LayeredTopic> chosen, LayeredTopic type) throws TopicMapException
TopicMapException
public java.util.Collection<Association> getAssociations() throws TopicMapException
getAssociations
in class Topic
TopicMapException
public java.util.Collection<Association> getAssociations(Topic type) throws TopicMapException
getAssociations
in class Topic
TopicMapException
public java.util.Collection<Association> getAssociations(Topic type, Topic role) throws TopicMapException
getAssociations
in class Topic
TopicMapException
public void remove() throws TopicMapException
Topic
remove
in class Topic
TopicMapException
public long getEditTime() throws TopicMapException
getEditTime
in class Topic
TopicMapException
public void setEditTime(long time) throws TopicMapException
setEditTime
in class Topic
TopicMapException
public long getDependentEditTime() throws TopicMapException
getDependentEditTime
in class Topic
TopicMapException
public void setDependentEditTime(long time) throws TopicMapException
setDependentEditTime
in class Topic
TopicMapException
public boolean isRemoved() throws TopicMapException
Topic
isRemoved
in class Topic
TopicMapException
public boolean isDeleteAllowed() throws TopicMapException
Topic
isDeleteAllowed
in class Topic
TopicMapException
public java.util.Collection<Topic> getTopicsWithDataType() throws TopicMapException
Topic
getTopicsWithDataType
in class Topic
TopicMapException
public java.util.Collection<Association> getAssociationsWithType() throws TopicMapException
Topic
getAssociationsWithType
in class Topic
TopicMapException
public java.util.Collection<Association> getAssociationsWithRole() throws TopicMapException
Topic
getAssociationsWithRole
in class Topic
TopicMapException
public java.util.Collection<Topic> getTopicsWithDataVersion() throws TopicMapException
Topic
getTopicsWithDataVersion
in class Topic
TopicMapException
public java.util.Collection<Topic> getTopicsWithVariantScope() throws TopicMapException
Topic
getTopicsWithVariantScope
in class Topic
TopicMapException
public boolean mergesWithTopic(Topic topic) throws TopicMapException
Topic
mergesWithTopic
in class Topic
TopicMapException
Copyright 2004-2015 Wandora Team