Package org.revapi.configuration
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 toJsonNode
used by Revapi.- Since:
- 0.8.0
- Author:
- Lukas Krejci
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
XmlToJson.JSONPointer
Deprecated.use Jackson's impl
-
Constructor Summary
Constructors Constructor Description XmlToJson(Map<String,org.jboss.dmr.ModelNode> knownExtensionSchemas, Function<Xml,String> getName, Function<Xml,String> getValue, BiFunction<Xml,String,String> getAttributeValue, Function<Xml,List<Xml>> getChildren)
Deprecated.use the Jackson-based variantXmlToJson(Revapi revapi, Function<Xml,String> getName, Function<Xml,String> getValue, BiFunction<Xml,String,String> getAttributeValue, Function<Xml,List<Xml>> getChildren)
Deprecated.use #fromRevapi
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description org.jboss.dmr.ModelNode
convert(Xml xml)
Deprecated.useconvertXml(Object)
insteadcom.fasterxml.jackson.databind.JsonNode
convertXml(Xml xml)
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.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)
-
-
-
Constructor Detail
-
XmlToJson
@Deprecated public XmlToJson(Revapi revapi, Function<Xml,String> getName, Function<Xml,String> getValue, BiFunction<Xml,String,String> getAttributeValue, Function<Xml,List<Xml>> getChildren)
Deprecated.use #fromRevapiA convenience constructor to create an instance using the extension schemas known to the provided Revapi instance.
-
XmlToJson
@Deprecated public XmlToJson(Map<String,org.jboss.dmr.ModelNode> knownExtensionSchemas, Function<Xml,String> getName, Function<Xml,String> getValue, BiFunction<Xml,String,String> getAttributeValue, Function<Xml,List<Xml>> getChildren)
Deprecated.use the Jackson-based variantConstructs 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 schemasgetName
- a function that gets the name of an XML taggetValue
- 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 nodegetChildren
- 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 thegetValue
function. It also MUST NOT contain any comment nodes.
-
-
Method Detail
-
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 schemasgetName
- a function that gets the name of an XML taggetValue
- 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 nodegetChildren
- 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 thegetValue
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)
-
convert
@Deprecated public org.jboss.dmr.ModelNode convert(Xml xml)
Deprecated.useconvertXml(Object)
instead
-
convertXml
public com.fasterxml.jackson.databind.JsonNode convertXml(Xml xml)
-
-