public abstract class SmallDefinitionStoreBase extends Object implements IDefinitionStore
IDefinitionStore
that use a small number of fields, rather than a map, to store definition sets.Modifier and Type | Field and Description |
---|---|
protected static String[] |
EMPTY_STRING_ARRAY |
Constructor and Description |
---|
SmallDefinitionStoreBase()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(IDefinition definition)
Adds a definition to this store.
|
protected static void |
addBaseNameToList(List<String> list,
IDefinitionSet definitionSet)
If the specified definition set is non-null and contains definitions,
add the base name of those definitions to the specified list.
|
protected static void |
addDefinitionSetToList(List<IDefinitionSet> list,
IDefinitionSet definitionSet)
If the specified definition set is non-null, add it to the specified list.
|
protected static void |
addDefinitionsToList(List<IDefinition> list,
IDefinitionSet definitionSet)
If the specified definition set is non-null and contains definitions,
add those definitions to the specified list.
|
static IDefinitionSet |
addDefinitionToSet(IDefinitionSet oldDefinitionSet,
IDefinition definition)
Adds a new definition to a definition set, possibly creating a new
definition set in the process (if the old definition set was
null or couldn't hold the new definition). |
protected abstract int |
findAvailableIndex()
Returns the index of the first null field where a new definition set
can be stored.
|
protected abstract int |
findIndexForBaseName(String baseName)
Returns the index of the field storing a definition set with the
specified base name, or -1 if there is no such field.
|
protected static String |
getBaseName(IDefinitionSet definitionSet)
Gets the base name of the definitions stored in the specified definition set.
|
abstract int |
getCapacity()
Gets the number of fields for storing definition sets.
|
protected abstract IDefinitionSet |
getDefinitionSet(int i)
Gets the definition set stored in the specified field.
|
abstract IDefinitionSet |
getDefinitionSetByName(String baseName)
Gets the set of definitions in this store that have a specified base name.
|
boolean |
remove(IDefinition definition)
Removes a definition from this store.
|
static boolean |
removeDefinitionFromSet(IDefinitionSet definitionSet,
IDefinition definition)
Removes a definition from a definition set.
|
protected abstract void |
setDefinitionSet(int i,
IDefinitionSet definitionSet)
Sets the specified definition set into the specified field.
|
String |
toString()
For debugging only.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createLargerStore, getAllDefinitions, getAllDefinitionSets, getAllNames, putDefinitionSetByName
protected static final String[] EMPTY_STRING_ARRAY
protected static String getBaseName(IDefinitionSet definitionSet)
definitionSet
- An IDefinitionSet
or null
.null
if the definition set
was null
or empty.public static IDefinitionSet addDefinitionToSet(IDefinitionSet oldDefinitionSet, IDefinition definition)
null
or couldn't hold the new definition).
This method handles the fact that we use different optimized implementations
of IDefinitionSet
for different set sizes.
oldDefinitionSet
- An IDefinitionSet
containing definitions.
This may be null if we are adding the first definition with a particular base name.definition
- The IDefinition
to add to the set.public static boolean removeDefinitionFromSet(IDefinitionSet definitionSet, IDefinition definition)
This method handles the fact that we use different optimized implementations
of IDefinitionSet
for different set sizes.
definitionSet
- An IDefinitionSet
containing definitions.definition
- The IDefinition
to be removed.true
if the definition set is now empty
and must be removed from the store.protected static void addBaseNameToList(List<String> list, IDefinitionSet definitionSet)
This is a helper function used by subclasses to implement IDefinitionStore.getAllNames()
().
Subclasses call this method for each field that can store a definition set.
list
- A list of base names being built up.definitionSet
- An IDefinitionSet
, which may be null or empty.protected static void addDefinitionSetToList(List<IDefinitionSet> list, IDefinitionSet definitionSet)
This is a helper function used by subclasses to implement IDefinitionStore.getAllDefinitionSets()
().
Subclasses call this method for each field that can store a definition set.
The field may be null or may contain an empty definition set.
list
- A list of definition sets being built up.definitionSet
- An IDefinitionSet
, which may be null or empty.protected static void addDefinitionsToList(List<IDefinition> list, IDefinitionSet definitionSet)
This is a helper function used by subclasses to implement IDefinitionStore.getAllDefinitions()
().
Subclasses call this method for each field that can store a definition set.
list
- A list of definitions being built up.definitionSet
- An IDefinitionSet
, which may be null or empty.public boolean add(IDefinition definition)
IDefinitionStore
add
in interface IDefinitionStore
definition
- The IDefinition
to add.IDefinitionStore
have limited storage capacity, as a memory
optimization.public boolean remove(IDefinition definition)
IDefinitionStore
remove
in interface IDefinitionStore
definition
- The IDefinition
to remove.public abstract IDefinitionSet getDefinitionSetByName(String baseName)
IDefinitionStore
This method is called very frequently as part of name resolution. All implementations should be fast and avoid creating temporary objects.
getDefinitionSetByName
in interface IDefinitionStore
baseName
- The base name of the definitions you want to retrieve
from the store.IDefinitionSet
containing the definition with that
base name, or null
if there are none.public abstract int getCapacity()
getCapacity
in interface IDefinitionStore
protected abstract IDefinitionSet getDefinitionSet(int i)
i
- The index of the field.IDefinitionSet
store there.protected abstract void setDefinitionSet(int i, IDefinitionSet definitionSet)
i
- The index of the field.definitionSet
- The IDefinitionSet
to store there.protected abstract int findIndexForBaseName(String baseName)
baseName
- The base name to look for.protected abstract int findAvailableIndex()
Copyright © 2016 The Apache Software Foundation. All rights reserved.