de.topicmapslab.majortom.inmemory.store.internal
Class CharacteristicsStore

java.lang.Object
  extended by de.topicmapslab.majortom.inmemory.store.internal.CharacteristicsStore
All Implemented Interfaces:
IDataStore
Direct Known Subclasses:
VirtualCharacteristicsStore

public class CharacteristicsStore
extends java.lang.Object
implements IDataStore

Author:
Sven Krosse

Field Summary
private  java.util.Map<de.topicmapslab.majortom.model.core.ILocator,java.util.Set<de.topicmapslab.majortom.model.core.IDatatypeAware>> dataTyped
          storage map of datatype mapping
private  java.util.Map<de.topicmapslab.majortom.model.core.IDatatypeAware,de.topicmapslab.majortom.model.core.ILocator> dataTypes
          storage map of datatype mapping
private  int initialCapacity
           
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IName>> names
          storage map of topic-name mapping
private  java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IName>> namesByValue
          reverse map to speed up the literal index
private  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> occurrences
          storage map of topic-occurrence mapping
private  java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> occurrencesByValue
          reverse map to speed up the literal index
private  java.util.Map<de.topicmapslab.majortom.model.core.IConstruct,java.lang.Object> values
          storage map of characteristics-value mapping
private  java.util.Map<de.topicmapslab.majortom.model.core.IName,java.util.Set<de.topicmapslab.majortom.model.core.IVariant>> variants
          storage map of name-variant mapping
private  java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IVariant>> variantsByValue
          reverse map to speed up the literal index
private  de.topicmapslab.majortom.model.core.ILocator xsdString
          the xsd:any locator
 
Constructor Summary
CharacteristicsStore(de.topicmapslab.majortom.model.core.ILocator xsdString, int initialCapacity)
          constructor
 
Method Summary
 void addName(de.topicmapslab.majortom.model.core.ITopic t, de.topicmapslab.majortom.model.core.IName n)
          Add the given name to the internal data store.
 void addOccurrence(de.topicmapslab.majortom.model.core.ITopic t, de.topicmapslab.majortom.model.core.IOccurrence o)
          Add the given occurrence to the internal data store.
 void addVariant(de.topicmapslab.majortom.model.core.IName n, de.topicmapslab.majortom.model.core.IVariant v)
          Add the given variant to the internal data store.
 void close()
          Remove all items from the internal store.
protected  boolean containsDatatype(de.topicmapslab.majortom.model.core.IDatatypeAware aware)
          Checks if the store contains any locator of the given IDatatypeAware.
 java.util.Set<de.topicmapslab.majortom.model.core.ICharacteristics> getCharacteristics()
          Returns the characteristics of all topics.
 java.util.Set<de.topicmapslab.majortom.model.core.ICharacteristics> getCharacteristics(de.topicmapslab.majortom.model.core.ITopic t)
          Returns the characteristics of the given topic.
 de.topicmapslab.majortom.model.core.ILocator getDatatype(de.topicmapslab.majortom.model.core.IDatatypeAware dataTypeAware)
          Returns the data type of the given data-type-aware
 java.util.Set<de.topicmapslab.majortom.model.core.IDatatypeAware> getDatatypeAwares(de.topicmapslab.majortom.model.core.ILocator locator)
          Returns all data-typed items with the given data type.
protected  java.util.Map<de.topicmapslab.majortom.model.core.ILocator,java.util.Set<de.topicmapslab.majortom.model.core.IDatatypeAware>> getDataTypedMap()
           
protected  java.util.Map<de.topicmapslab.majortom.model.core.IDatatypeAware,de.topicmapslab.majortom.model.core.ILocator> getDataTypesMap()
           
 java.util.Set<de.topicmapslab.majortom.model.core.IName> getNames()
          Returns the names of all topics.
 java.util.Set<de.topicmapslab.majortom.model.core.IName> getNames(de.topicmapslab.majortom.model.core.ITopic t)
          Returns the names of the given topic.
 java.util.Set<de.topicmapslab.majortom.model.core.IName> getNamesByValue(java.util.regex.Pattern regExp)
          Returns the names matching the given regular expression.
 java.util.Set<de.topicmapslab.majortom.model.core.IName> getNamesByValue(java.lang.String value, boolean isRegExp)
          Returns the names matching the given value.
protected  java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IName>> getNamesByValueMap()
           
protected  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IName>> getNamesMap()
           
 java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getOccurrences()
          Returns the occurrences of all topics.
 java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getOccurrences(de.topicmapslab.majortom.model.core.ITopic t)
          Returns the occurrences of the given topic.
 java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getOccurrencesByValue(java.util.regex.Pattern regExp)
          Returns the occurrences matching the given regular expression.
 java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getOccurrencesByValue(java.lang.String value, boolean isRegExp)
          Returns the occurrence matching the given value.
protected  java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> getOccurrencesByValueMap()
           
protected  java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> getOccurrencesMap()
           
 java.lang.Object getValue(de.topicmapslab.majortom.model.core.IConstruct obj)
          Returns the value of the given object
 java.lang.String getValueAsString(de.topicmapslab.majortom.model.core.IConstruct obj)
          Returns the value of the given object
protected  java.util.Map<de.topicmapslab.majortom.model.core.IConstruct,java.lang.Object> getValuesMap()
           
 java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getVariants()
          Returns the variants of the all names.
 java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getVariants(de.topicmapslab.majortom.model.core.IName n)
          Returns the variants of the given name.
 java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getVariantsByValue(java.util.regex.Pattern regExp)
          Returns the variants matching the given regular expression.
 java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getVariantsByValue(java.lang.String value, boolean isRegExp)
          Returns the variants matching the given value.
protected  java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IVariant>> getVariantsByValueMap()
           
protected  java.util.Map<de.topicmapslab.majortom.model.core.IName,java.util.Set<de.topicmapslab.majortom.model.core.IVariant>> getVariantsMap()
           
 void removeName(de.topicmapslab.majortom.model.core.IName n)
          Remove the given name from the internal data store.
 void removeOccurrence(de.topicmapslab.majortom.model.core.IOccurrence o)
          Remove the given occurrence from the internal data store.
 void removeTopic(de.topicmapslab.majortom.model.core.ITopic topic)
          Remove the given topic as parent from the internal store
 void removeVariant(de.topicmapslab.majortom.model.core.IVariant v)
          Remove the given occurrence from the internal data store.
 void replace(de.topicmapslab.majortom.model.core.ITopic topic, de.topicmapslab.majortom.model.core.ITopic replacement, de.topicmapslab.majortom.model.revision.IRevision revision)
          Replace each reference of the given topic by the given replacement.
 de.topicmapslab.majortom.model.core.ILocator setDatatype(de.topicmapslab.majortom.model.core.IDatatypeAware dataTypeAware, de.topicmapslab.majortom.model.core.ILocator dataType)
          Modify the data type of the given data-type-aware
 java.lang.Object setValue(de.topicmapslab.majortom.model.core.IConstruct obj, java.lang.Object value)
          Modify the value of the given object
private  void updateReverseValueMapping(de.topicmapslab.majortom.model.core.IName name, java.lang.String oldValue, java.lang.String value)
          Internal method to update the reverse mapping of a value and the constructs
private  void updateReverseValueMapping(de.topicmapslab.majortom.model.core.IOccurrence occurrence, java.lang.String oldValue, java.lang.String value)
          Internal method to update the reverse mapping of a value and the constructs
private  void updateReverseValueMapping(de.topicmapslab.majortom.model.core.IVariant variant, java.lang.String oldValue, java.lang.String value)
          Internal method to update the reverse mapping of a value and the constructs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

names

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IName>> names
storage map of topic-name mapping


occurrences

private java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> occurrences
storage map of topic-occurrence mapping


variants

private java.util.Map<de.topicmapslab.majortom.model.core.IName,java.util.Set<de.topicmapslab.majortom.model.core.IVariant>> variants
storage map of name-variant mapping


dataTypes

private java.util.Map<de.topicmapslab.majortom.model.core.IDatatypeAware,de.topicmapslab.majortom.model.core.ILocator> dataTypes
storage map of datatype mapping


dataTyped

private java.util.Map<de.topicmapslab.majortom.model.core.ILocator,java.util.Set<de.topicmapslab.majortom.model.core.IDatatypeAware>> dataTyped
storage map of datatype mapping


values

private java.util.Map<de.topicmapslab.majortom.model.core.IConstruct,java.lang.Object> values
storage map of characteristics-value mapping


namesByValue

private java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IName>> namesByValue
reverse map to speed up the literal index


occurrencesByValue

private java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> occurrencesByValue
reverse map to speed up the literal index


variantsByValue

private java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IVariant>> variantsByValue
reverse map to speed up the literal index


xsdString

private final de.topicmapslab.majortom.model.core.ILocator xsdString
the xsd:any locator


initialCapacity

private final int initialCapacity
Constructor Detail

CharacteristicsStore

public CharacteristicsStore(de.topicmapslab.majortom.model.core.ILocator xsdString,
                            int initialCapacity)
constructor

Parameters:
xsdString - the xsd:string locator
initialCapacity - the initial capacity
Method Detail

close

public void close()
Remove all items from the internal store.

Specified by:
close in interface IDataStore

getCharacteristics

public java.util.Set<de.topicmapslab.majortom.model.core.ICharacteristics> getCharacteristics(de.topicmapslab.majortom.model.core.ITopic t)
Returns the characteristics of the given topic.

Parameters:
t - the topic
Returns:
the characteristics

getCharacteristics

public java.util.Set<de.topicmapslab.majortom.model.core.ICharacteristics> getCharacteristics()
Returns the characteristics of all topics.

Returns:
the characteristics

getNames

public java.util.Set<de.topicmapslab.majortom.model.core.IName> getNames(de.topicmapslab.majortom.model.core.ITopic t)
Returns the names of the given topic.

Parameters:
t - the topic
Returns:
the names

getNames

public java.util.Set<de.topicmapslab.majortom.model.core.IName> getNames()
Returns the names of all topics.

Returns:
the names

getNamesByValue

public java.util.Set<de.topicmapslab.majortom.model.core.IName> getNamesByValue(java.lang.String value,
                                                                                boolean isRegExp)
Returns the names matching the given value.

Parameters:
value - the value
isRegExp - Flag if the value is a regular expression
Returns:
the names

getNamesByValue

public java.util.Set<de.topicmapslab.majortom.model.core.IName> getNamesByValue(java.util.regex.Pattern regExp)
Returns the names matching the given regular expression.

Parameters:
regExp - a regular expression
Returns:
the names

getOccurrences

public java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getOccurrences(de.topicmapslab.majortom.model.core.ITopic t)
Returns the occurrences of the given topic.

Parameters:
t - the topic
Returns:
the occurrences

getOccurrences

public java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getOccurrences()
Returns the occurrences of all topics.

Returns:
the occurrences

getOccurrencesByValue

public java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getOccurrencesByValue(java.lang.String value,
                                                                                            boolean isRegExp)
Returns the occurrence matching the given value.

Parameters:
value - the value
isRegExp - Flag if the value is a regular expression
Returns:
the occurrences

getOccurrencesByValue

public java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence> getOccurrencesByValue(java.util.regex.Pattern regExp)
Returns the occurrences matching the given regular expression.

Parameters:
regExp - a regular expression
Returns:
the occurrences

getVariants

public java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getVariants(de.topicmapslab.majortom.model.core.IName n)
Returns the variants of the given name.

Parameters:
n - the name
Returns:
the variants

getVariants

public java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getVariants()
Returns the variants of the all names.

Returns:
the variants

getVariantsByValue

public java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getVariantsByValue(java.lang.String value,
                                                                                      boolean isRegExp)
Returns the variants matching the given value.

Parameters:
value - the value
isRegExp - Flag if the value is a regular expression
Returns:
the variants

getVariantsByValue

public java.util.Set<de.topicmapslab.majortom.model.core.IVariant> getVariantsByValue(java.util.regex.Pattern regExp)
Returns the variants matching the given regular expression.

Parameters:
regExp - a regular expression
Returns:
the variants

removeName

public void removeName(de.topicmapslab.majortom.model.core.IName n)
Remove the given name from the internal data store.

Parameters:
n - the name

removeOccurrence

public void removeOccurrence(de.topicmapslab.majortom.model.core.IOccurrence o)
Remove the given occurrence from the internal data store.

Parameters:
o - the occurrence

removeVariant

public void removeVariant(de.topicmapslab.majortom.model.core.IVariant v)
Remove the given occurrence from the internal data store.

Parameters:
v - the variant

addName

public void addName(de.topicmapslab.majortom.model.core.ITopic t,
                    de.topicmapslab.majortom.model.core.IName n)
Add the given name to the internal data store.

Parameters:
t - the parent topic
n - the name

addOccurrence

public void addOccurrence(de.topicmapslab.majortom.model.core.ITopic t,
                          de.topicmapslab.majortom.model.core.IOccurrence o)
Add the given occurrence to the internal data store.

Parameters:
t - the parent topic
n - the occurrence

addVariant

public void addVariant(de.topicmapslab.majortom.model.core.IName n,
                       de.topicmapslab.majortom.model.core.IVariant v)
Add the given variant to the internal data store.

Parameters:
n - the name
v - the variant

getDatatype

public de.topicmapslab.majortom.model.core.ILocator getDatatype(de.topicmapslab.majortom.model.core.IDatatypeAware dataTypeAware)
Returns the data type of the given data-type-aware

Parameters:
dataTypeAware - the data-type-aware
Returns:
the data type

setDatatype

public de.topicmapslab.majortom.model.core.ILocator setDatatype(de.topicmapslab.majortom.model.core.IDatatypeAware dataTypeAware,
                                                                de.topicmapslab.majortom.model.core.ILocator dataType)
Modify the data type of the given data-type-aware

Parameters:
dataTypeAware - the data-type-aware
dataType - the new data type
Returns:
the old data type

getValue

public java.lang.Object getValue(de.topicmapslab.majortom.model.core.IConstruct obj)
Returns the value of the given object

Parameters:
obj - the object
Returns:
the value

getValueAsString

public java.lang.String getValueAsString(de.topicmapslab.majortom.model.core.IConstruct obj)
Returns the value of the given object

Parameters:
obj - the object
Returns:
the value

setValue

public java.lang.Object setValue(de.topicmapslab.majortom.model.core.IConstruct obj,
                                 java.lang.Object value)
Modify the value of the given object

Parameters:
obj - the object
value - the new value
Returns:
the old value

updateReverseValueMapping

private void updateReverseValueMapping(de.topicmapslab.majortom.model.core.IName name,
                                       java.lang.String oldValue,
                                       java.lang.String value)
Internal method to update the reverse mapping of a value and the constructs

Parameters:
name - the name
oldValue - the old value
value - the new value

updateReverseValueMapping

private void updateReverseValueMapping(de.topicmapslab.majortom.model.core.IOccurrence occurrence,
                                       java.lang.String oldValue,
                                       java.lang.String value)
Internal method to update the reverse mapping of a value and the constructs

Parameters:
occurrence - the occurrence
oldValue - the old value
value - the new value

updateReverseValueMapping

private void updateReverseValueMapping(de.topicmapslab.majortom.model.core.IVariant variant,
                                       java.lang.String oldValue,
                                       java.lang.String value)
Internal method to update the reverse mapping of a value and the constructs

Parameters:
variant - the variant
oldValue - the old value
value - the new value

removeTopic

public void removeTopic(de.topicmapslab.majortom.model.core.ITopic topic)
Remove the given topic as parent from the internal store

Parameters:
topic - the topic to remove

replace

public void replace(de.topicmapslab.majortom.model.core.ITopic topic,
                    de.topicmapslab.majortom.model.core.ITopic replacement,
                    de.topicmapslab.majortom.model.revision.IRevision revision)
Replace each reference of the given topic by the given replacement.

Specified by:
replace in interface IDataStore
Parameters:
topic - the topic
replacement - the replacement
revision - the revision

getDatatypeAwares

public java.util.Set<de.topicmapslab.majortom.model.core.IDatatypeAware> getDatatypeAwares(de.topicmapslab.majortom.model.core.ILocator locator)
Returns all data-typed items with the given data type.

Parameters:
locator - the data type
Returns:
a set

containsDatatype

protected final boolean containsDatatype(de.topicmapslab.majortom.model.core.IDatatypeAware aware)
Checks if the store contains any locator of the given IDatatypeAware.

Parameters:
aware - the IDatatypeAware
Returns:
true if any locator of the given IDatatypeAware is stored, false otherwise.

getDataTypedMap

protected java.util.Map<de.topicmapslab.majortom.model.core.ILocator,java.util.Set<de.topicmapslab.majortom.model.core.IDatatypeAware>> getDataTypedMap()
Returns:
the dataTyped

getDataTypesMap

protected java.util.Map<de.topicmapslab.majortom.model.core.IDatatypeAware,de.topicmapslab.majortom.model.core.ILocator> getDataTypesMap()
Returns:
the dataTypes

getValuesMap

protected java.util.Map<de.topicmapslab.majortom.model.core.IConstruct,java.lang.Object> getValuesMap()

getNamesMap

protected java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IName>> getNamesMap()

getOccurrencesMap

protected java.util.Map<de.topicmapslab.majortom.model.core.ITopic,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> getOccurrencesMap()

getVariantsMap

protected java.util.Map<de.topicmapslab.majortom.model.core.IName,java.util.Set<de.topicmapslab.majortom.model.core.IVariant>> getVariantsMap()

getNamesByValueMap

protected java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IName>> getNamesByValueMap()

getOccurrencesByValueMap

protected java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IOccurrence>> getOccurrencesByValueMap()

getVariantsByValueMap

protected java.util.Map<java.lang.String,java.util.Set<de.topicmapslab.majortom.model.core.IVariant>> getVariantsByValueMap()