public class SourceElementToModelTransformer extends Object implements SourceTransformer
Modifier and Type | Field and Description |
---|---|
static String |
NULL_ATTRIBUTE_FIELD_NAME
The field name in the model which is filled if the attribute name
null appears in the source graph. |
Constructor and Description |
---|
SourceElementToModelTransformer()
Standard constructor.
|
SourceElementToModelTransformer(Class<?> modelRootClass)
Constructor defining the model root class.
|
Modifier and Type | Method and Description |
---|---|
protected static Object |
getInstance(String className,
UnitConfiguration unitConfiguration)
Creates an instance of a class.
|
void |
setIgnoreUnknownAttributes(boolean ignoreUnknownAttributes)
Sets whether to ignore unknown attributes in the source tree.
|
void |
setIgnoreUnknownElements(boolean ignoreUnknownElements)
Sets whether to ignore unknown elements in the source tree.
|
void |
setModelRootClass(String modelRootClass)
Sets the class which the model root must have.
|
Object |
transform(Object modelRoot,
ControllerState controllerState)
Transforms one source root into another source root.
|
public static final String NULL_ATTRIBUTE_FIELD_NAME
null
appears in the source graph.public SourceElementToModelTransformer()
public SourceElementToModelTransformer(Class<?> modelRootClass)
modelRootClass
- the model root class, not null.public void setModelRootClass(String modelRootClass)
modelRootClass
- the class the model root must have,
or null for any classpublic void setIgnoreUnknownAttributes(boolean ignoreUnknownAttributes)
ignoreUnknownAttributes
- true if unknown attributes
should be ignored, false otherwise.public void setIgnoreUnknownElements(boolean ignoreUnknownElements)
ignoreUnknownElements
- true if unknown elements
should be ignored, false otherwise.public Object transform(Object modelRoot, ControllerState controllerState) throws SourceTransformerException
SourceTransformer
transform
in interface SourceTransformer
modelRoot
- the root object to fill, not null.controllerState
- the controller state objectSourceTransformerException
- if filling the source graph fails,
e.g. if an attribute name or element name has no corresponding
field in a model element.Transforms the source graph into the model. This is done by recursively
walking through the source graph and setting the fields corresponding
to the names of the attributes resp. child elements.
protected static Object getInstance(String className, UnitConfiguration unitConfiguration) throws SourceTransformerException
className
- the fully qualified name of the class to instantiate.unitConfiguration
- The configuration of the generation unit, not null.SourceTransformerException
- if the class cannot be instantiated.Copyright © 2000–2020 The Apache Software Foundation. All rights reserved.