Class SourceElementToModelTransformer
java.lang.Object
org.apache.torque.generator.source.transform.SourceElementToModelTransformer
- All Implemented Interfaces:
SourceTransformer
A Source transformer transforming a SourceElement graph to a typed model.
- Version:
- $Id: $
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe field name in the model which is filled if the attribute namenullappears in the source graph. -
Constructor Summary
ConstructorsConstructorDescriptionStandard constructor.SourceElementToModelTransformer(Class<?> modelRootClass) Constructor defining the model root class. -
Method Summary
Modifier and TypeMethodDescriptionprotected static ObjectgetInstance(String className, UnitConfiguration unitConfiguration) Creates an instance of a class.voidsetIgnoreUnknownAttributes(boolean ignoreUnknownAttributes) Sets whether to ignore unknown attributes in the source tree.voidsetIgnoreUnknownElements(boolean ignoreUnknownElements) Sets whether to ignore unknown elements in the source tree.voidsetModelRootClass(String modelRootClass) Sets the class which the model root must have.transform(Object modelRoot, ControllerState controllerState) Transforms one source root into another source root.
-
Field Details
-
NULL_ATTRIBUTE_FIELD_NAME
The field name in the model which is filled if the attribute namenullappears in the source graph.- See Also:
-
-
Constructor Details
-
SourceElementToModelTransformer
public SourceElementToModelTransformer()Standard constructor. -
SourceElementToModelTransformer
Constructor defining the model root class.- Parameters:
modelRootClass- the model root class, not null.
-
-
Method Details
-
setModelRootClass
Sets the class which the model root must have.- Parameters:
modelRootClass- the class the model root must have, or null for any class
-
setIgnoreUnknownAttributes
public void setIgnoreUnknownAttributes(boolean ignoreUnknownAttributes) Sets whether to ignore unknown attributes in the source tree.- Parameters:
ignoreUnknownAttributes- true if unknown attributes should be ignored, false otherwise.
-
setIgnoreUnknownElements
public void setIgnoreUnknownElements(boolean ignoreUnknownElements) Sets whether to ignore unknown elements in the source tree.- Parameters:
ignoreUnknownElements- true if unknown elements should be ignored, false otherwise.
-
transform
public Object transform(Object modelRoot, ControllerState controllerState) throws SourceTransformerException Description copied from interface:SourceTransformerTransforms one source root into another source root. It is allowed to modify the toTransformRoot tree and return the same tree.- Specified by:
transformin interfaceSourceTransformer- Parameters:
modelRoot- the root object to fill, not null.controllerState- the controller state object- Returns:
- the transformed source root, not null.
- Throws:
SourceTransformerException- if filling the source graph fails, e.g. if an attribute name or element name has no corresponding field in a model element.- See Also:
-
getInstance
protected static Object getInstance(String className, UnitConfiguration unitConfiguration) throws SourceTransformerException Creates an instance of a class.- Parameters:
className- the fully qualified name of the class to instantiate.unitConfiguration- The configuration of the generation unit, not null.- Returns:
- the instance of the class
- Throws:
SourceTransformerException- if the class cannot be instantiated.
-