@Nonnull protected <T> JAXBElement <T> createJAXBElement (@Nonnull final T aValue) { return new JAXBElement <> (new QName (m_aDocType.getNamespaceURI (), m_aDocType.getLocalName ()), GenericReflection.uncheckedCast (aValue.getClass ()), null, aValue); } }
public AbstractJAXBBuilder (@Nonnull final IJAXBDocumentType aDocType) { m_aDocType = ValueEnforcer.notNull (aDocType, "DocType"); // By default this class loader of the type to be marshalled should be used // This is important for OSGI application containers and ANT tasks m_aClassLoader = new WeakReference <> (aDocType.getImplementationClass ().getClassLoader ()); }
@Nonnull public static ValidationExecutorXSD create (@Nonnull final IJAXBDocumentType aDocType) { ValueEnforcer.notNull (aDocType, "DocType"); return new ValidationExecutorXSD (new ValidationArtefact (EValidationType.XSD, aDocType.getImplementationClass ().getClassLoader (), aDocType.getAllXSDResources ().getLast ()), aDocType::getSchema); }
public EbInterfaceWriter (@Nonnull final EEbInterfaceDocumentType eDocType) { super (eDocType); // Create a default namespace context for the passed document type final MapBasedNamespaceContext aNSContext = new MapBasedNamespaceContext (); aNSContext.setMapping ("eb", m_aDocType.getNamespaceURI ()); setNamespaceContext (aNSContext); }
/** * @return The XML schema to be used for validating instances. May be * <code>null</code> if no XSDs are present. Also <code>null</code> if */ @Nullable protected final Schema getSchema () { if (m_bUseSchema) return m_aDocType.getSchema (); return null; }
public UBL21WriterBuilder (@Nonnull final EUBL21DocumentType eDocType) { super (eDocType); // Create a special namespace context for the passed document type final MapBasedNamespaceContext aNSContext = UBL21NamespaceContext.getInstance ().getClone (); aNSContext.addDefaultNamespaceURI (m_aDocType.getNamespaceURI ()); setNamespaceContext (aNSContext); }
/** * Validate the passed XML instance against the XML Schema of this document * type using the default class loader. * * @param aXML * The XML resource to be validated. May not be <code>null</code>. * @return A group of validation errors. Is empty if no error occurred. * <code>null</code> is returned if this document type has no XSDs * assigned and therefore not validation can take place. */ @Nullable default IErrorList validateXML (@Nonnull final IReadableResource aXML) { final Schema aSchema = getSchema (); return aSchema == null ? null : XMLSchemaValidationHelper.validate (aSchema, aXML); } }
public UBL22WriterBuilder (@Nonnull final EUBL22DocumentType eDocType) { super (eDocType); // Create a special namespace context for the passed document type final MapBasedNamespaceContext aNSContext = UBL22NamespaceContext.getInstance ().getClone (); aNSContext.addDefaultNamespaceURI (m_aDocType.getNamespaceURI ()); setNamespaceContext (aNSContext); }
public JAXBReaderBuilder (@Nonnull final IJAXBDocumentType aDocType) { this (aDocType, GenericReflection.uncheckedCast (aDocType.getImplementationClass ())); }
/** * @param aLocale * The locale to use for error message creation. May be * <code>null</code> to use the system locale. * @return The compiled {@link Validator} object retrieved from the schema to * be obtained from {@link #getSchema()}. If this document type has no * XML Schema that no {@link Validator} can be created and the return * value is <code>null</code>. * @since 9.0.1 */ @Nullable default Validator getValidator (@Nullable final Locale aLocale) { final Schema aSchema = getSchema (); if (aSchema != null) { final Validator aValidator = aSchema.newValidator (); if (aValidator != null) { if (aLocale != null) EXMLParserProperty.GENERAL_LOCALE.applyTo (aValidator, aLocale); return aValidator; } } return null; }
public UBL20WriterBuilder (@Nonnull final EUBL20DocumentType eDocType) { super (eDocType); // Create a special namespace context for the passed document type final MapBasedNamespaceContext aNSContext = UBL20NamespaceContext.getInstance ().getClone (); aNSContext.addDefaultNamespaceURI (m_aDocType.getNamespaceURI ()); setNamespaceContext (aNSContext); }
@Nonnull @OverrideOnDemand protected JAXBContext getJAXBContext () throws JAXBException { if (m_bUseJAXBContextCache) { // Since creating the JAXB context is quite cost intensive this is done // only once! return JAXBContextCache.getInstance ().getFromCache (m_aDocType.getImplementationClass (), getClassLoader ()); } // Create a new JAXBContext - inefficient return JAXBContext.newInstance (m_aDocType.getImplementationClass ().getPackage ().getName (), getClassLoader ()); }
public GenericodeWriter (@Nonnull final EGenericodeDocumentType eDocType) { super (eDocType); // Create a special namespace context for the passed document type final MapBasedNamespaceContext aNSContext = new MapBasedNamespaceContext (); aNSContext.addMapping ("gc", m_aDocType.getNamespaceURI ()); aNSContext.addDefaultNamespaceURI (""); setNamespaceContext (aNSContext); }
@Nonnull final String sBuilderClass) final String sType = ClassHelper.getClassLocalName (e.getImplementationClass ()); final String sName = StringHelper.trimEnd (sType, "Type"); final String sBuilderMethodName = Character.toLowerCase (sName.charAt (0)) + sName.substring (1);
public UBL20WriterBuilder (@Nonnull final EUBL20DocumentType eDocType) { super (eDocType); // Create a special namespace context for the passed document type final MapBasedNamespaceContext aNSContext = UBL20NamespaceContext.getInstance ().getClone (); aNSContext.addDefaultNamespaceURI (m_aDocType.getNamespaceURI ()); setNamespaceContext (aNSContext); }
if (!m_aDocType.getImplementationClass ().getPackage ().equals (aJAXBDocument.getClass ().getPackage ())) m_aDocType.getImplementationClass ().getPackage ().getName ());
public UBL21WriterBuilder (@Nonnull final EUBL21DocumentType eDocType) { super (eDocType); // Create a special namespace context for the passed document type final MapBasedNamespaceContext aNSContext = UBL21NamespaceContext.getInstance ().getClone (); aNSContext.addDefaultNamespaceURI (m_aDocType.getNamespaceURI ()); setNamespaceContext (aNSContext); }
@Nonnull final String sBuilderClass) final String sType = ClassHelper.getClassLocalName (e.getImplementationClass ()); final String sName = StringHelper.trimEnd (sType, "Type"); final String sBuilderMethodName = Character.toLowerCase (sName.charAt (0)) + sName.substring (1);
public UBL22WriterBuilder (@Nonnull final EUBL22DocumentType eDocType) { super (eDocType); // Create a special namespace context for the passed document type final MapBasedNamespaceContext aNSContext = UBL22NamespaceContext.getInstance ().getClone (); aNSContext.addDefaultNamespaceURI (m_aDocType.getNamespaceURI ()); setNamespaceContext (aNSContext); }
if (!m_aDocType.getImplementationClass ().getPackage ().equals (aJAXBDocument.getClass ().getPackage ())) aJAXBDocument.getClass () + "' as a " + m_aDocType.getImplementationClass ().getPackage ().getName ()); return ESuccess.FAILURE;