Package ilog.rules.xml.util
Interface IlrXmlXomMapper
-
- All Known Implementing Classes:
IlrXmlDefaultXomMapper,IlrXmlXomMapperApi6_0
public interface IlrXmlXomMapperThis interface aims at defining the XML-XOM mapping behavior of the XML data driver. It must be implemented and declared to the driver by using the configuration file when creating the driver.The interface is composed of a set of methods describing how XML symbols are mapped into Java identifiers. The
mapComplexTypemethod defines on which Java class a complex type is mapped. This class must inherit fromilog.rules.xml.IlrXmlObject.The XML-XOM name mapping follows two steps.
- Firstly, a XOM identifier seed is found from the XML identifier without trying to ensure the uniqueness of that name inside its XOM namespace.
- Secondly, given this XOM seed name, its uniqueness is checked in its
namespace. If the symbol is already defined, the
formatNewIdentifieris called with the seed name as a parameter. A counter is incremented until an identifier is found.
- See Also:
IlrXmlHelper,IlrXmlDefaultXomMapper
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description IlrXmlDataTypeMappercreateDataTypeMapper(IlrObjectModel objectModel)Creates a data type mapper.StringformatAnyFieldName(boolean flagIsUnary)Formats a XOM field name related to any XML any particle declaration.StringformatClassName(String namespace, String xmlComplexType, String xmlParentElement)Formats a XOM dynamic class name related to an XML complex type name.StringformatContentFieldName()Formats a XOM field name related to the content of an XML complex type definition.StringformatEnumStaticFieldName(String enumLiteral)Formats a static field name from the XML enumeration literal.StringformatFieldName(String namespace, String xmlDeclaration, boolean flagIsUnary)Formats a XOM field name related to an XML declaration, that is an attribute or an element.StringformatNewIdentifier(String identifier, int counter)Formats a new unique XOM identifier given a seed identifier and a counter incremented at each attempt.StringformatSimpleTypeName(String namespace, String xmlSimpleType, String xmlParentDeclaration)Formats a XOM dynamic simple type name related to an XML simple type identifier.ClassLoadergetXomClassLoader()Returns the class loader used by the XOM to resolve inclusion and resource files.booleanisFieldDomainGenerated()Indicates if fiel domain are generated onto inner XOM classes.booleanisForbiddenName(String name)Determines if a string might be considered as a forbidden name used in IRL or JOM language for example.booleanisInnerClassGenerated()Indicates if XML local types are mapped onto inner XOM classes.ClassmapComplexType(String namespace, String xmlComplexType)Returns the Java class mapped on an XML complex type.FieldmapXomField(IlrAttribute xomField, Class parentJavaClass)Return a Java field that will map the XML selected field.
-
-
-
Method Detail
-
formatClassName
String formatClassName(String namespace, String xmlComplexType, String xmlParentElement)
Formats a XOM dynamic class name related to an XML complex type name.- Parameters:
namespace- The XML type namespace (may be null).xmlComplexType- The XML complex type name (may be null).xmlParentElement- The name of the element in which the type is declared (may be null in case of root type definition).- Returns:
- The dynamic class identifier.
-
formatSimpleTypeName
String formatSimpleTypeName(String namespace, String xmlSimpleType, String xmlParentDeclaration)
Formats a XOM dynamic simple type name related to an XML simple type identifier.- Parameters:
namespace- The XML type namespace (may be null).xmlSimpleType- The XML simple type name (may be null).xmlParentDeclaration- The name of the declaration (XML attribute, XML element or content ) in which the type is declared (may be null).- Returns:
- The dynamic simple type name.
-
formatFieldName
String formatFieldName(String namespace, String xmlDeclaration, boolean flagIsUnary)
Formats a XOM field name related to an XML declaration, that is an attribute or an element.- Parameters:
namespace- The XML declaration namespace (may be null).xmlDeclaration- The XML declaration name (attribute or element).flagIsUnary- Indicates if an element declaration is unary (minOccurs<=1, maxOccurs<=1).- Returns:
- The XOM field name.
-
formatEnumStaticFieldName
String formatEnumStaticFieldName(String enumLiteral)
Formats a static field name from the XML enumeration literal.- Parameters:
enumLiteral- The enumeration literal.- Returns:
- The XOM field name. It may be
null.
-
formatAnyFieldName
String formatAnyFieldName(boolean flagIsUnary)
Formats a XOM field name related to any XML any particle declaration.- Parameters:
flagIsUnary- Indicates if a declaration is unary (minOccurs<=1, maxOccurs<=1).- Returns:
- The XOM field name.
-
formatContentFieldName
String formatContentFieldName()
Formats a XOM field name related to the content of an XML complex type definition.- Returns:
- The XOM field name.
-
formatNewIdentifier
String formatNewIdentifier(String identifier, int counter)
Formats a new unique XOM identifier given a seed identifier and a counter incremented at each attempt. For example, this method might append a suffix to the given identifier depending on the counter value ("myIdentifier_1"). The result should be different for different values of the counter. If not, it may induce a dead-loop during the processing of the mapping.- Parameters:
identifier- The seed name.counter- The counter used to generate a new identifier.- Returns:
- A new identifier formatted from an initial identifier and a counter.
-
mapComplexType
Class mapComplexType(String namespace, String xmlComplexType)
Returns the Java class mapped on an XML complex type. This class MUST inherits from theilog.rules.xml.IlrXmlObject, be public and declare a public void constructor. If not, a runtime exception may be raised.- Parameters:
namespace- The namespace of the complex type (may be null).xmlComplexType- The complex type name (may be null).- Returns:
- The related Java class.
-
mapXomField
Field mapXomField(IlrAttribute xomField, Class parentJavaClass)
Return a Java field that will map the XML selected field. A postcondition is that the return field belongs to the parentJavaClass class. Another constraint is that paentJavaClass is equals to the result of calling themapComplexTypewith the complex type related tothe XOM field.- Parameters:
xomField- The field to be mapped.parentJavaClass- The Java class mapped to the complex type defining the origin XML structure of the Xom field.- Returns:
- The field that maps the XML field. A NULL value indicates that the mapping is purely dynamic and related to no Java field.
-
isInnerClassGenerated
boolean isInnerClassGenerated()
Indicates if XML local types are mapped onto inner XOM classes.- Returns:
- true if inner XOM classes are generated.
-
isFieldDomainGenerated
boolean isFieldDomainGenerated()
Indicates if fiel domain are generated onto inner XOM classes.- Returns:
- true if the field domain are generated
-
isForbiddenName
boolean isForbiddenName(String name)
Determines if a string might be considered as a forbidden name used in IRL or JOM language for example.- Parameters:
name- The string to be checked.- Returns:
trueif the string is a forbidden keyword
-
getXomClassLoader
ClassLoader getXomClassLoader()
Returns the class loader used by the XOM to resolve inclusion and resource files.
-
createDataTypeMapper
IlrXmlDataTypeMapper createDataTypeMapper(IlrObjectModel objectModel)
Creates a data type mapper.- Parameters:
objectModel- The object model.- Returns:
- The data type mapper.
-
-