Class XmlToJson<Xml>

java.lang.Object
org.revapi.configuration.XmlToJson<Xml>
Type Parameters:
Xml - The type of the xml representation used by the calling code.

public final class XmlToJson<Xml> extends Object
A tool to convert some XML representation of the Revapi configuration to JsonNode used by Revapi.
Since:
0.8.0
Author:
Lukas Krejci
  • Constructor Details

  • Method Details

    • fromKnownSchemas

      public static <Xml> XmlToJson<Xml> fromKnownSchemas(Map<String,com.fasterxml.jackson.databind.JsonNode> knownExtensionSchemas, Function<Xml,String> getName, Function<Xml,String> getValue, BiFunction<Xml,String,String> getAttributeValue, Function<Xml,List<Xml>> getChildren)
      Constructs a new XML to JSON converter. To be able to navigate the XML and to convert to JSON data types correctly, the instance needs to know about the schemas used by various extensions.
      Parameters:
      knownExtensionSchemas - the schemas of the known extensions. Keys are extension ids, values are extension schemas
      getName - a function that gets the name of an XML tag
      getValue - a function that gets the textual value of an XML node, e.g. it's textual content.
      getAttributeValue - a function to get a value of an attribute of an XML node
      getChildren - a function that gets the children of an XML node. Note that the returned list MUST NOT contain any text or CDATA nodes - those are to be used in the getValue function. It also MUST NOT contain any comment nodes.
    • fromRevapi

      public static <Xml> XmlToJson<Xml> fromRevapi(Revapi revapi, Function<Xml,String> getName, Function<Xml,String> getValue, BiFunction<Xml,String,String> getAttributeValue, Function<Xml,List<Xml>> getChildren)
      Similar to fromKnownSchemas(Map, Function, Function, BiFunction, Function) but learns the known schemas from the provided Revapi instance.
    • convert

      @Deprecated public org.jboss.dmr.ModelNode convert(Xml xml)
      Deprecated.
      use convertXml(Object) instead
    • convertXml

      public com.fasterxml.jackson.databind.JsonNode convertXml(Xml xml)