Class XmlConverter

java.lang.Object
com.aquima.interactions.profile.xml.XmlConverter

public class XmlConverter extends Object
Utility class to export a profile to XML, and to fill a profile with the values from an (exported) XML.
Since:
5.0
Author:
O. Kerpershoek
  • Constructor Details

    • XmlConverter

      public XmlConverter(IMetaModel model)
      Constructs a profile XML converter for the specified meta model using the default XML delegate.
      Parameters:
      model - The meta model definition for the XML converter (mandatory).
      See Also:
    • XmlConverter

      public XmlConverter(IMetaModel model, IXmlDelegate xmlDelegate)
      Constructs a profile XML converter for the specified meta model and XML delegate.
      Parameters:
      model - The meta model definition for the XML converter (mandatory).
      xmlDelegate - The XML delegate that should be used in the import and export methods (mandatory).
  • Method Details

    • exportXml

      public String exportXml(IProfile profile, String typeId)
      This method converts the profile to an XML string (UTF-8 encoded with header). An optional type-id parameter may be provided to identify the profile XML. When the type id parameter is provided, an additional event tag will be included in the XML with this value.
      Parameters:
      profile - The profile that should be converted to XML.
      typeId - Optional parameter that can be used to specify the type of the profile XML.
      Returns:
      String containing the XML representation of the profile contents.
      Throws:
      AppException - This exception is thrown when the export failed due to a definition error (for instance an unknown entity).
    • exportXmlElement

      public IXmlElement exportXmlElement(IProfile profile, String typeId)
      This method converts the profile to an XML element. An optional type-id parameter may be provided to identify the profile XML. When the type id parameter is provided, an additional event tag will be included in the XML with this value.
      Parameters:
      profile - The profile that should be converted to XML.
      typeId - Optional parameter that can be used to specify the type of the profile XML.
      Returns:
      IXMLElement containing the XML representation of the profile contents.
      Throws:
      AppException - This exception is thrown when the export failed due to a definition error (for instance an unknown entity).
    • exportInstance

      protected XmlNewElement exportInstance(IEntityInstance instance)
    • exportAttribute

      protected XmlNewElement exportAttribute(IAttributeValue attributeValue)
    • importXml

      public void importXml(IProfile profile, String xml)
      This method parses the xml file passed, and imports the instance and values definitions into the profile. An empty xml file passed to this method will be ignored.
      Parameters:
      profile - The profile that should be used to import the xml in (mandatory).
      xml - The string containing a profile export (optional).
      Throws:
      AppException - This exception is thrown when the import failed due to a definition error (for instance an unknown entity).
    • importXml

      public void importXml(IProfile profile, IXmlNode profileNode)
      This method uses the XML node passed to it, and imports the instance and values definitions into the profile.
      Parameters:
      profile - The profile that should be used to import the xml in (mandatory).
      profileNode - The XML node containing a profile export (mandatory).
      Throws:
      AppException - This exception is thrown when the import failed due to a definition error (for instance an unknown entity).
    • importInstance

      protected void importInstance(Map<String,com.aquima.interactions.profile.xml.XmlConverter.XmlEntityInstance> instanceLookupMap, com.aquima.interactions.profile.xml.XmlConverter.XmlEntityInstance xmlInstance)
    • getValue

      protected IValue getValue(Map<String,com.aquima.interactions.profile.xml.XmlConverter.XmlEntityInstance> instanceLookupMap, IAttributeDefinition attrDefinition, IXmlNode attributeNode)
    • convertValue

      protected IPrimitiveValue convertValue(Map<String,com.aquima.interactions.profile.xml.XmlConverter.XmlEntityInstance> instanceLookupMap, IAttributeDefinition attrDefinition, String strValue)
    • createInstances

      protected List<com.aquima.interactions.profile.xml.XmlConverter.XmlEntityInstance> createInstances(IProfile profile, IXmlNode[] entityNodes, Map<String,com.aquima.interactions.profile.xml.XmlConverter.XmlEntityInstance> instancesLookup)
    • acquireInstance

      protected com.aquima.interactions.profile.xml.XmlConverter.XmlEntityInstance acquireInstance(IProfile profile, IXmlNode entityNode)
    • isSingletonInstance

      protected boolean isSingletonInstance(IntegerValue instanceId)