Class SchemaItem
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
SchemaCompositeIndex
,SchemaField
,SchemaObjectType
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The regular expression that all schema item names must match.Fields inherited from class io.permazen.util.AbstractXMLStreaming
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected SchemaItem
clone()
Deep-clone this instance.protected Diffs
differencesFrom
(SchemaItem that) boolean
abstract ItemType
Get theItemType
corresponding to this instance.getName()
Get the name associated with this instance, if any.final SchemaId
Generate a uniqueSchemaId
corresponding to the type and encoding structure of this schema item.int
Get the storage ID associated with this instance.int
hashCode()
final boolean
isLockedDown
(boolean includingStorageIds) Determine whether this instance is locked down.void
Set the name associated with this instance.void
setStorageId
(int storageId) Set the storage ID associated with this instance.abstract String
toString()
final <T extends SchemaItem>
voidvisitSchemaItems
(Class<T> nodeType, Consumer<? super T> visitor) Visit this schema item and all of its descendents matching the given type with the given visitor.void
visitSchemaItems
(Consumer<? super SchemaItem> visitor) Visit allSchemaItem
descendents of this instance with the given visitor.Methods inherited from class io.permazen.util.AbstractXMLStreaming
expect, expectClose, getAttr, getAttr, getBooleanAttr, getBooleanAttr, getIntAttr, getIntAttr, getLongAttr, newInvalidAttributeException, newInvalidInputException, newInvalidInputException, next, skip, writeAttr, writeCData, writeCharacters, writeElement, writeEmptyElement, writeStartElement
-
Field Details
-
NAME_PATTERN
The regular expression that all schema item names must match.This pattern is the same as is required for Java identifiers, with the exception that control characters (i.e.,
0x0000
through0x001f
, plus0x007f
) are disallowed. This restriction ensures that item names are valid in an XML document.- See Also:
-
-
Constructor Details
-
SchemaItem
public SchemaItem()
-
-
Method Details
-
getName
Get the name associated with this instance, if any.All names must match
NAME_PATTERN
.- Returns:
- the name of this instance, or null if it has none
-
setName
Set the name associated with this instance.- Parameters:
name
- name of this instance- Throws:
UnsupportedOperationException
- if this instance is locked down
-
getStorageId
public int getStorageId()Get the storage ID associated with this instance.- Returns:
- the storage ID for this instance, or zero to have one automatically assigned
-
setStorageId
public void setStorageId(int storageId) Set the storage ID associated with this instance.The default value of zero means one should be automatically assigned when the schema is registered into a database.
- Parameters:
storageId
- storage ID for this instance, or zero for automatica assignment- Throws:
UnsupportedOperationException
- if this instance is locked down
-
differencesFrom
-
toString
-
equals
-
hashCode
public int hashCode() -
clone
Deep-clone this instance.The returned instance will not be locked down even if this one is.
-
visitSchemaItems
Visit allSchemaItem
descendents of this instance with the given visitor.If this instance is also a
SchemaItem
, then also visit this instance.The traversal is depth first, pre-order.
- Parameters:
visitor
- visitor for schema items- Throws:
IllegalArgumentException
- ifvisitor
is null
-
visitSchemaItems
public final <T extends SchemaItem> void visitSchemaItems(Class<T> nodeType, Consumer<? super T> visitor) Visit this schema item and all of its descendents matching the given type with the given visitor.The traversal is depth first, post-order.
- Parameters:
nodeType
- node type to includevisitor
- visitor for schema items- Throws:
IllegalArgumentException
- if either parameter is null
-
isLockedDown
public final boolean isLockedDown(boolean includingStorageIds) Determine whether this instance is locked down.- Parameters:
includingStorageIds
- false to test all but storage ID's, true to require storage ID's to be locked down as well- Returns:
- true if instance is locked down, otherwise false
-
getSchemaId
Generate a uniqueSchemaId
corresponding to the type and encoding structure of this schema item.The
SchemaId
does not depend on the storage ID.This instance must be locked down except for storage ID's. Repeated invocations of this method will be very fast, just returning the cached previous result.
- Returns:
- schema ID
- Throws:
IllegalStateException
- if this instance is not locked down- See Also:
-
getItemType
Get theItemType
corresponding to this instance.- Returns:
- schema item type
-