Package com.android.repository.impl.meta
Class SchemaModuleUtil
- java.lang.Object
-
- com.android.repository.impl.meta.SchemaModuleUtil
-
public class SchemaModuleUtil extends java.lang.ObjectUtilities for working withSchemaModules, including marshalling and unmarshalling with JAXB.
-
-
Constructor Summary
Constructors Constructor Description SchemaModuleUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.w3c.dom.ls.LSResourceResolvercreateResourceResolver(java.util.Set<SchemaModule<?>> modules, ProgressIndicator progress)Create anLSResourceResolverthat will use the suppliedSchemaModules to find an XSD from its namespace.static javax.xml.validation.SchemagetSchema(java.util.Collection<SchemaModule<?>> possibleModules, org.w3c.dom.ls.LSResourceResolver resourceResolver, ProgressIndicator progress)Creates aSchemafrom a collection ofSchemaModules, with a givenLSResourceResolver(probably obtained fromcreateResourceResolver(Set, ProgressIndicator).static voidmarshal(javax.xml.bind.JAXBElement element, java.util.Collection<SchemaModule<?>> possibleModules, java.io.OutputStream out, org.w3c.dom.ls.LSResourceResolver resourceResolver, ProgressIndicator progress)Transform the givenJAXBElementinto xml, using JAXB and the schemas provided by the givenSchemaModules.static java.lang.Objectunmarshal(java.io.InputStream xml, java.util.Collection<SchemaModule<?>> possibleModules, boolean strict, ProgressIndicator progress)Use JAXB to create POJOs from the given XML.
-
-
-
Method Detail
-
createResourceResolver
@Nullable public static org.w3c.dom.ls.LSResourceResolver createResourceResolver(@NonNull java.util.Set<SchemaModule<?>> modules, @NonNull ProgressIndicator progress)Create anLSResourceResolverthat will use the suppliedSchemaModules to find an XSD from its namespace. This must be used when marshalling/unmarshalling if anySchemaModules contain XSDs which import others without specifying a completeschemaLocation.
-
getSchema
@NonNull public static javax.xml.validation.Schema getSchema(java.util.Collection<SchemaModule<?>> possibleModules, @Nullable org.w3c.dom.ls.LSResourceResolver resourceResolver, ProgressIndicator progress)
Creates aSchemafrom a collection ofSchemaModules, with a givenLSResourceResolver(probably obtained fromcreateResourceResolver(Set, ProgressIndicator). Any warnings or errors are logged to the givenProgressIndicator.
-
unmarshal
@Nullable public static java.lang.Object unmarshal(@NonNull java.io.InputStream xml, @NonNull java.util.Collection<SchemaModule<?>> possibleModules, boolean strict, @NonNull ProgressIndicator progress) throws javax.xml.bind.JAXBExceptionUse JAXB to create POJOs from the given XML.- Parameters:
xml- The XML to read. The stream will be closed after being read.possibleModules- TheSchemaModules that are available to parse the XML.progress- For logging.- Returns:
- The unmarshalled object.
- Throws:
javax.xml.bind.JAXBException- if there is an error during unmarshalling.TODO: maybe templatize and return a nicer type.
-
marshal
public static void marshal(@NonNull javax.xml.bind.JAXBElement element, @NonNull java.util.Collection<SchemaModule<?>> possibleModules, @NonNull java.io.OutputStream out, @Nullable org.w3c.dom.ls.LSResourceResolver resourceResolver, @NonNull ProgressIndicator progress)Transform the givenJAXBElementinto xml, using JAXB and the schemas provided by the givenSchemaModules.
-
-