|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgroovy.lang.GroovyObjectSupport
groovy.lang.Binding
groovy.util.FactoryBuilderSupport
groovy.util.ObjectGraphBuilder
groovytools.builder.MetaObjectGraphBuilder
public class MetaObjectGraphBuilder
This class is the workhorse behind MetaBuilder. It is responsible for building object hierarchies according
to the schemas given to it. It is not intended to be used independently of MetaBuilder.
| Nested Class Summary | |
|---|---|
class |
MetaObjectGraphBuilder.FactoryClassNameResolver
Overrides the default implementation in MetaObjectGraphBuilder.FactoryClassNameResolver in order to support
resolution of the class name using the factory schema attribute. |
| Field Summary |
|---|
| Fields inherited from class groovy.util.ObjectGraphBuilder |
|---|
NODE_CLASS, NODE_NAME, OBJECT_ID |
| Fields inherited from class groovy.util.FactoryBuilderSupport |
|---|
CURRENT_FACTORY, CURRENT_NAME, CURRENT_NODE, OWNER, PARENT_CONTEXT, PARENT_FACTORY, PARENT_NAME, PARENT_NODE |
| Constructor Summary | |
|---|---|
MetaObjectGraphBuilder(MetaBuilder metaBuilder,
SchemaNode defaultSchema,
Factory defaultFactory)
Constructs a MetaObjectGraphBuilder. |
|
MetaObjectGraphBuilder(MetaBuilder metaBuilder,
SchemaNode defaultSchema,
Factory defaultFactory,
Closure objectVisitor)
Constructs a MetaObjectGraphBuilder. |
|
| Method Summary | |
|---|---|
protected void |
checkCollections(SchemaNode currentSchema,
Object node)
|
protected void |
checkNode(SchemaNode schema,
Object node)
Execute check against node, if one exists. |
protected void |
checkPropertyValue(SchemaNode schema,
Object val)
Check value against a propertySchema's check attribute, if it exists. |
protected ObjectGraphBuilder.ClassNameResolver |
createClassNameResolver()
Override to modify the MetaObjectGraphBuilder.FactoryClassNameResolver behavior. |
protected ObjectGraphBuilder.IdentifierResolver |
createIdentifierResolver()
Override to modify the ObjectGraphBuilder.IdentifierResolver behavior. |
protected Object |
createNode(Object name,
Map attributes,
Object value)
Overrides in order to construct nodes based on the current schema definition. |
protected SchemaNode |
findCollectionSchema(SchemaNode parentSchema,
String containerName,
String name)
|
protected SchemaNode |
findSchema(SchemaNode parentSchema,
String containerName,
String name)
Finds and returns a child schema with the given name, in the specified container or null if not found. |
protected Object |
findSchemaAttribute(SchemaNode parentSchema,
String name)
|
Map |
getCurrentProperties()
|
SchemaNode |
getCurrentSchema()
|
protected SchemaNode |
getMergedCollections(SchemaNode schema)
Return a shallow set of merged collections by searching for all collections of schema and its parents, in a depth first manner. |
protected SchemaNode |
getMergedProperties(SchemaNode schema)
Return a shallow set of merged properties by searching for all properties of schema and its parents, in a depth first manner. |
MetaBuilder |
getMetaBuilder()
|
protected Comparable |
getMinMaxValComp(SchemaNode schema,
String name,
Object val)
Returns a Comparable object that can be used with the min and max constraints. |
Closure |
getObjectVisitor()
|
protected void |
handleUnsetProperties(SchemaNode currentSchema,
Object node)
|
protected void |
nodeCompleted(Object parent,
Object node)
Overrides the default implementation to: sync the schema with the current node handle unset properties check collections execute any check on the node iteself |
Map |
popProperties()
|
SchemaNode |
popSchema()
|
void |
pushProperties(Map properties)
|
void |
pushProperties(SchemaNode propertiesSchema)
|
void |
pushSchema(SchemaNode schema)
|
protected Factory |
resolveFactory(Object name,
Map attributes,
Object value)
Overrides the default implementation to support lookup of a factory defined in a schema attribute. |
protected SchemaNode |
resolveSchemaRef(Object schemaRef)
Returns the schema referenced by name. |
protected void |
setNodeAttributes(Object node,
Map attributesMap)
Sets properties on the node based on the current schema. |
void |
setObjectVisitor(Closure objectVisitor)
|
protected void |
setParent(Object parent,
Object child)
Overrides the default implementation in order set the parent using the current schema definition. |
protected void |
setProperty(Object node,
Object value,
SchemaNode propertySchema)
Sets a node's property value, allowing for property renaming. |
void |
setVariable(Object node,
SchemaNode schema,
String name,
Object value)
Sets the given node's property value by name referencing the given schema. |
void |
setVariable(String name,
Object value)
Sets thet node's property value by name referencing the current schema. |
| Methods inherited from class groovy.lang.Binding |
|---|
getProperty, getVariable, getVariables, setProperty |
| Methods inherited from class groovy.lang.GroovyObjectSupport |
|---|
getMetaClass, setMetaClass |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MetaObjectGraphBuilder(MetaBuilder metaBuilder,
SchemaNode defaultSchema,
Factory defaultFactory)
MetaObjectGraphBuilder.
metaBuilder - the MetaBuilder providing the build contextdefaultSchema - defaultFactory -
public MetaObjectGraphBuilder(MetaBuilder metaBuilder,
SchemaNode defaultSchema,
Factory defaultFactory,
Closure objectVisitor)
MetaObjectGraphBuilder.
metaBuilder - the MetaBuilder providing the build contextdefaultSchema - defaultFactory - objectVisitor - | Method Detail |
|---|
public MetaBuilder getMetaBuilder()
public void pushProperties(SchemaNode propertiesSchema)
public void pushProperties(Map properties)
public Map popProperties()
public Map getCurrentProperties()
public void pushSchema(SchemaNode schema)
public SchemaNode popSchema()
public SchemaNode getCurrentSchema()
public Closure getObjectVisitor()
public void setObjectVisitor(Closure objectVisitor)
protected SchemaNode resolveSchemaRef(Object schemaRef)
schemaRef - the schema reference
protected SchemaNode findSchema(SchemaNode parentSchema,
String containerName,
String name)
parentSchema - the parent schemacontainerName - the name of a container of child schemas, e.g. collections, propertiesname - the name of the child schema
protected SchemaNode findCollectionSchema(SchemaNode parentSchema,
String containerName,
String name)
protected Object findSchemaAttribute(SchemaNode parentSchema,
String name)
protected Object createNode(Object name,
Map attributes,
Object value)
createNode in class FactoryBuilderSupportname - the name of the nodeattributes - optional attributes of the current nodevalue - optional value of the current node
public void setVariable(String name,
Object value)
setVariable in class Bindingname - the property namevalue - the property valuesetVariable(Object, SchemaNode, String, Object)
public void setVariable(Object node,
SchemaNode schema,
String name,
Object value)
node - the property ownerschema - the property owner's schemaname - the property namevalue - the property value
protected void nodeCompleted(Object parent,
Object node)
nodeCompleted in class FactoryBuilderSupportparent - the parent nodenode - the node that is being completed
protected void checkCollections(SchemaNode currentSchema,
Object node)
protected void handleUnsetProperties(SchemaNode currentSchema,
Object node)
protected ObjectGraphBuilder.IdentifierResolver createIdentifierResolver()
ObjectGraphBuilder.IdentifierResolver behavior.
protected ObjectGraphBuilder.ClassNameResolver createClassNameResolver()
MetaObjectGraphBuilder.FactoryClassNameResolver behavior.
protected Factory resolveFactory(Object name,
Map attributes,
Object value)
Factory is resolved as follows:
Factory, then it is returned.factory which is an instance of Factory,
then the attribute value is returned.factory which is an instance of Closure,
then the Closure will be returned, wrapped by ClosureFactoryAdapterfactory which is an instance of String
or Class, then the corresponding class will be instantiated and returned.
resolveFactory in class ObjectGraphBuildername - attributes - value -
protected SchemaNode getMergedProperties(SchemaNode schema)
schema - the owner of the properties
protected SchemaNode getMergedCollections(SchemaNode schema)
schema - the owner of the collections
protected void setNodeAttributes(Object node,
Map attributesMap)
setNodeAttributes in class FactoryBuilderSupportnode - attributesMap - setProperty(java.lang.Object, java.lang.Object, groovytools.builder.SchemaNode)
protected void checkPropertyValue(SchemaNode schema,
Object val)
value against a propertySchema's check attribute, if it exists.
schema - see aboveval - the value
protected void checkNode(SchemaNode schema,
Object node)
node, if one exists.
schema - see abovenode - the node
protected Comparable getMinMaxValComp(SchemaNode schema,
String name,
Object val)
Comparable object that can be used with the min and max constraints.
schema - the property owner (used to report errors)name - the property name (used to report errors)val - the property value
protected void setProperty(Object node,
Object value,
SchemaNode propertySchema)
property attribute, if any, else the property node name is used by default.
node - the current nodevalue - the value of the propertypropertySchema - the property's property attribute or name
protected void setParent(Object parent,
Object child)
setParent in class FactoryBuilderSupportparent - child -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||