ilog.rules.xml.util

Class IlrXmlDefaultXomMapper

  • java.lang.Object
    • ilog.rules.xml.util.IlrXmlDefaultXomMapper
  • All Implemented Interfaces:
    IlrXmlXomMapper
    Direct Known Subclasses:
    IlrXmlXomMapperApi6_0


    public class IlrXmlDefaultXomMapper
    extends java.lang.Object
    implements IlrXmlXomMapper
    This class is the default implementation of an XML-XOM mapper. The XML-XOM mapping is described in the XML Binding User's Manual. The XML complex types are mapped onto ilog.rules.xml.IlrXmlObjects.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void addComplexTypeMapping(java.lang.String namespace, java.lang.String complexType, java.lang.Class javaClass)
      Adds a Java mapping to an XML complex type.
      void addForbiddenName(java.lang.String keyword)
      Adds a forbidden keyword.
      IlrXmlDataTypeMapper createDataTypeMapper(IlrObjectModel objectModel)
      Creates a data type mapper.
      java.lang.String formatAnyFieldName(boolean flagIsUnary)
      Formats a XOM field name related to any XML any particle declaration.
      java.lang.String formatClassName(java.lang.String namespace, java.lang.String xmlComplexType, java.lang.String xmlParentElement)
      Formats a XOM dynamic class name related to an XML complex type name.
      java.lang.String formatContentFieldName()
      Formats a XOM field name related to the content of an XML complex type definition.
      java.lang.String formatEnumStaticFieldName(java.lang.String enumLiteral)
      Formats a XOM static field name related to an XML enumeration.
      java.lang.String formatFieldName(java.lang.String namespace, java.lang.String xmlField, boolean flagIsUnary)
      Formats a XOM field name related to an XML declaration, that is an attribute or an element.
      protected java.lang.String formatJavaIdentifier(java.lang.String str, boolean upperCase)
      Formats a Java identifier from a string.
      java.lang.String formatNewIdentifier(java.lang.String identifier, int counter)
      Formats a new unique XOM identifier given a seed identifier and a counter incremented at each attempt.
      java.lang.String formatSimpleTypeName(java.lang.String namespace, java.lang.String xmlSimpleType, java.lang.String xmlParentDeclaration)
      Formats a XOM dynamic simple type name related to an XML simple type identifier.
      java.lang.ClassLoader getXomClassLoader()
      Returns the class loader used by the XOM to resolve inclusion and resource files.
      boolean isFieldDomainGenerated()
      Indicates if fiel domain are generated onto inner XOM classes.
      boolean isForbiddenName(java.lang.String name)
      Determines if a string might be considered as a forbidden.
      boolean isInnerClassGenerated()
      Indicates if XML local type are mapped onto inner XOM class.
      java.lang.Class mapComplexType(java.lang.String namespace, java.lang.String xmlComplexType)
      Returns the Java class mapped on an XML complex type.
      java.lang.reflect.Field mapXomField(IlrAttribute xomField, java.lang.Class parentJavaClass)
      Returns a Java field that will map the XML selected field.
      java.lang.String modifyForbiddenName(java.lang.String forbiddenName)
      Finalizes a name of a component by checking, for example, that is is not a keyword, and potentially modify it.
      void setXomClassLoader(java.lang.ClassLoader xomClassLoader) 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IlrXmlDefaultXomMapper

        public IlrXmlDefaultXomMapper()
        Creates a default XOM mapper. The inner class mode is activated.
      • IlrXmlDefaultXomMapper

        public IlrXmlDefaultXomMapper(java.lang.Class defaultJavaClass)
        Creates a default XOM mapper. The inner class mode is activated.
        Parameters:
        defaultJavaClass - The default Java class related to a complex type.
      • IlrXmlDefaultXomMapper

        public IlrXmlDefaultXomMapper(boolean flagInnerClass)
        Creates a default XOM mapper. The inner class mode activation depends on the parameter.
        Parameters:
        flagInnerClass - true if the inner class generation is activated.
      • IlrXmlDefaultXomMapper

        public IlrXmlDefaultXomMapper(boolean flagInnerClass,
                              boolean fieldDomainGenerated)
        Creates a default XOM mapper. The inner class mode activation depends on the parameter.
        Parameters:
        flagInnerClass - true if the inner class
        fieldDomainGenerated - true if the field's domain are generated generation is activated.
      • IlrXmlDefaultXomMapper

        public IlrXmlDefaultXomMapper(boolean flagInnerClass,
                              boolean fieldDomainGenerated,
                              boolean forbiddenNameDetection)
        Creates a default XOM mapper. The inner class mode activation depends on the parameter.
        Parameters:
        flagInnerClass - true if the inner class
        fieldDomainGenerated - true if the field's domain are generated generation is activated.
    • Method Detail

      • getXomClassLoader

        public java.lang.ClassLoader getXomClassLoader()
        Returns the class loader used by the XOM to resolve inclusion and resource files.
        Specified by:
        getXomClassLoader in interface IlrXmlXomMapper
      • setXomClassLoader

        public void setXomClassLoader(java.lang.ClassLoader xomClassLoader)
      • addForbiddenName

        public void addForbiddenName(java.lang.String keyword)
        Adds a forbidden keyword.
        Parameters:
        keyword - The forbidden keyword to be added.
      • isForbiddenName

        public boolean isForbiddenName(java.lang.String name)
        Determines if a string might be considered as a forbidden. name used in IRL or JOM language for example.
        Specified by:
        isForbiddenName in interface IlrXmlXomMapper
        Parameters:
        name - The string to be checked.
        Returns:
        true if the string is a forbidden keyword.
      • addComplexTypeMapping

        public void addComplexTypeMapping(java.lang.String namespace,
                                 java.lang.String complexType,
                                 java.lang.Class javaClass)
        Adds a Java mapping to an XML complex type.
        Parameters:
        namespace - The complex type namespace (may be null)
        complexType - The complex type local name,
        javaClass - The JAva class mapped on the complex type.
      • formatClassName

        public java.lang.String formatClassName(java.lang.String namespace,
                                       java.lang.String xmlComplexType,
                                       java.lang.String xmlParentElement)
        Formats a XOM dynamic class name related to an XML complex type name.
        Specified by:
        formatClassName in interface IlrXmlXomMapper
        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

        public java.lang.String formatSimpleTypeName(java.lang.String namespace,
                                            java.lang.String xmlSimpleType,
                                            java.lang.String xmlParentDeclaration)
        Formats a XOM dynamic simple type name related to an XML simple type identifier.
        Specified by:
        formatSimpleTypeName in interface IlrXmlXomMapper
        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

        public java.lang.String formatFieldName(java.lang.String namespace,
                                       java.lang.String xmlField,
                                       boolean flagIsUnary)
        Formats a XOM field name related to an XML declaration, that is an attribute or an element.
        Specified by:
        formatFieldName in interface IlrXmlXomMapper
        Parameters:
        namespace - The XML declaration namespace (may be null).
        xmlField - The XML field name (attribute or element).
        flagIsUnary - Indicates if an element declaration is unary (minOccurs<=1, maxOccurs<=1).
        Returns:
        The XOM field name.
      • formatEnumStaticFieldName

        public java.lang.String formatEnumStaticFieldName(java.lang.String enumLiteral)
        Formats a XOM static field name related to an XML enumeration.
        Specified by:
        formatEnumStaticFieldName in interface IlrXmlXomMapper
        Parameters:
        enumLiteral - The XML enumeration literal).
        Returns:
        The XOM field name.
      • formatAnyFieldName

        public java.lang.String formatAnyFieldName(boolean flagIsUnary)
        Formats a XOM field name related to any XML any particle declaration.
        Specified by:
        formatAnyFieldName in interface IlrXmlXomMapper
        Parameters:
        flagIsUnary - Indicates if a declaration is unary (minOccurs<=1, maxOccurs<=1).
        Returns:
        The XOM field name.
      • formatContentFieldName

        public java.lang.String formatContentFieldName()
        Formats a XOM field name related to the content of an XML complex type definition.
        Specified by:
        formatContentFieldName in interface IlrXmlXomMapper
        Returns:
        The XOM field name.
      • formatNewIdentifier

        public final java.lang.String formatNewIdentifier(java.lang.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.
        Specified by:
        formatNewIdentifier in interface IlrXmlXomMapper
        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

        public java.lang.Class mapComplexType(java.lang.String namespace,
                                     java.lang.String xmlComplexType)
        Returns the Java class mapped on an XML complex type. This class MUST inherit from the ilog.rules.xml.IlrXmlObject, be public and declare a public void constructor. If not, a runtime exception may be raised.
        Specified by:
        mapComplexType in interface IlrXmlXomMapper
        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

        public java.lang.reflect.Field mapXomField(IlrAttribute xomField,
                                          java.lang.Class parentJavaClass)
        Returns 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 the mapComplexType with the complex type related tothe XOM field.
        Specified by:
        mapXomField in interface IlrXmlXomMapper
        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

        public boolean isInnerClassGenerated()
        Indicates if XML local type are mapped onto inner XOM class.
        Specified by:
        isInnerClassGenerated in interface IlrXmlXomMapper
        Returns:
        true if inner XOM classes are generated.
      • isFieldDomainGenerated

        public boolean isFieldDomainGenerated()
        Indicates if fiel domain are generated onto inner XOM classes.
        Specified by:
        isFieldDomainGenerated in interface IlrXmlXomMapper
        Returns:
        true if the field domain are generated
      • formatJavaIdentifier

        protected java.lang.String formatJavaIdentifier(java.lang.String str,
                                            boolean upperCase)
        Formats a Java identifier from a string. The Character.isJavaIdentifierPart and isJavaIdentifierStart methods indicate if the string characters could compose a Java identifier. Otherwise, it is dropped and the next character is made uppercase.
        Parameters:
        str - The string to be Java formatted.
        upperCase - Indicates if the first letter must be uppercase.
        Returns:
        The Java formatted identifier.
      • modifyForbiddenName

        public java.lang.String modifyForbiddenName(java.lang.String forbiddenName)
        Finalizes a name of a component by checking, for example, that is is not a keyword, and potentially modify it.
        Parameters:
        forbiddenName - The name to be checked.
        Returns:
        The finalized name.

© Copyright IBM Corp. 1987, 2017