|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gdata.model.MetadataRegistry
public final class MetadataRegistry
A mutable, thread-safe registry for metadata. This should be used
to construct the default metadata for elements and attributes, the transforms
on those default metadata instances, and any adaptations on the element
types. The createSchema()
method can be called to construct an
immutable Schema
from this builder.
Thread safety is guaranteed by always guarding access to the element and attribute maps by synchronizing on the builder itself. The individual element and attribute registries are also thread safe.
Constructor Summary | |
---|---|
MetadataRegistry()
Constructs a new empty metadata registry. |
|
MetadataRegistry(MetadataRegistry source)
Copy constructor, creates a copy of the given metadata registry. |
Method Summary | ||
---|---|---|
|
adapt(ElementKey<D,E> source,
java.lang.String kind,
ElementKey<? extends D,? extends E> adaptation)
Adapts from the source type to the adaptation type on the given kind. |
|
ElementCreator |
build(ElementKey<?,?> element)
Builds element metadata for the given key. |
|
AttributeCreator |
build(ElementKey<?,?> parent,
AttributeKey<?> attribute)
Builds the metadata for the attribute inside the parent. |
|
AttributeCreator |
build(ElementKey<?,?> parent,
AttributeKey<?> attribute,
MetadataContext context)
Builds the metadata for the attribute inside the parent, during the context. |
|
ElementCreator |
build(ElementKey<?,?> parent,
ElementKey<?,?> element)
Builds metadata for when the key is inside the parent . |
|
ElementCreator |
build(ElementKey<?,?> parent,
ElementKey<?,?> element,
MetadataContext context)
Builds metadata for when the key is inside the parent and
used in a context compatible with context . |
|
ElementCreator |
build(ElementKey<?,?> element,
MetadataContext context)
Builds metadata for when the key is used in a context compatible
with context . |
|
Schema |
createSchema()
Creates a Schema out of this registry. |
|
boolean |
isRegistered(ElementKey<?,?> key)
Returns true if the given key has already been registered. |
|
MetadataRegistry |
merge(MetadataRegistry other)
Merges another metadata registry into this metadata registry. |
|
MetadataRegistry |
register(ElementKey<?,?> key)
Registers the metadata for an element key. |
|
MetadataRegistry |
registerClass(java.lang.Class<? extends Element> clazz)
Registers the metadata from an element subclass using its "registerMetadata" method through reflection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MetadataRegistry()
public MetadataRegistry(MetadataRegistry source)
new MetadataRegistry().merge(source)
.
Method Detail |
---|
public MetadataRegistry merge(MetadataRegistry other)
public MetadataRegistry register(ElementKey<?,?> key)
Element
subclass that the key
refers to, if it refers to a subclass. If it refers to Element directly
it will just build the key.
java.lang.IllegalArgumentException
- if the element type does not support a
registration method.public MetadataRegistry registerClass(java.lang.Class<? extends Element> clazz)
public Schema createSchema()
Schema
out of this registry. Will return a cached
instance if the registry has not changed since last time create() was
called.
public boolean isRegistered(ElementKey<?,?> key)
true
if the given key has already been registered. This
is used to prevent reentrant metadata registration (and cycles).
public ElementCreator build(ElementKey<?,?> element)
public ElementCreator build(ElementKey<?,?> parent, ElementKey<?,?> element)
key
is inside the parent
.
Note that this will not declare the element as part of the parent element,
that must be done using ElementCreator.addElement(ElementKey)
or
ElementCreator.replaceElement(ElementKey)
.
public ElementCreator build(ElementKey<?,?> element, MetadataContext context)
key
is used in a context compatible
with context
.
public ElementCreator build(ElementKey<?,?> parent, ElementKey<?,?> element, MetadataContext context)
key
is inside the parent
and
used in a context compatible with context
. Note that this will not
declare the element as part of the parent element, that must be done using
ElementCreator.addElement(ElementKey)
or
ElementCreator.replaceElement(ElementKey)
.
This will also guarantee that any element types that are referenced have been registered in this registry.
public AttributeCreator build(ElementKey<?,?> parent, AttributeKey<?> attribute)
ElementCreator.addAttribute(AttributeKey)
or
ElementCreator.replaceAttribute(AttributeKey)
.
public AttributeCreator build(ElementKey<?,?> parent, AttributeKey<?> attribute, MetadataContext context)
ElementCreator.addAttribute(AttributeKey)
or
ElementCreator.replaceAttribute(AttributeKey)
.
public <D,E extends Element> void adapt(ElementKey<D,E> source, java.lang.String kind, ElementKey<? extends D,? extends E> adaptation)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |