javax.xml.bind.helpers

Class AbstractMarshallerImpl

    • Constructor Detail

      • AbstractMarshallerImpl

        public AbstractMarshallerImpl()
    • Method Detail

      • marshal

        public void marshal(Object jaxbElement,
                   File output)
                     throws JAXBException
        Description copied from interface: Marshaller
        Marshal the content tree rooted at jaxbElement into a file.
        Specified by:
        marshal in interface Marshaller
        Parameters:
        jaxbElement - The root of content tree to be marshalled.
        output - File to be written. If this file already exists, it will be overwritten.
        Throws:
        JAXBException - If any unexpected problem occurs during the marshalling.
        MarshalException - If the ValidationEventHandler returns false from its handleEvent method or the Marshaller is unable to marshal obj (or any object reachable from obj). See Marshalling a JAXB element.
      • getNode

        public Node getNode(Object obj)
                     throws JAXBException
        By default, the getNode method is unsupported and throw an UnsupportedOperationException. Implementations that choose to support this method must override this method.
        Specified by:
        getNode in interface Marshaller
        Parameters:
        obj - - JAXB Java representation of XML content
        Returns:
        the DOM tree view of the contentTree
        Throws:
        JAXBException - If any unexpected problem occurs
      • getEncoding

        protected String getEncoding()
        Convenience method for getting the current output encoding.
        Returns:
        the current encoding or "UTF-8" if it hasn't been set.
      • setEncoding

        protected void setEncoding(String encoding)
        Convenience method for setting the output encoding.
        Parameters:
        encoding - a valid encoding as specified in the Marshaller class documentation
      • getSchemaLocation

        protected String getSchemaLocation()
        Convenience method for getting the current schemaLocation.
        Returns:
        the current schemaLocation or null if it hasn't been set
      • setSchemaLocation

        protected void setSchemaLocation(String location)
        Convenience method for setting the schemaLocation.
        Parameters:
        location - the schemaLocation value
      • getNoNSSchemaLocation

        protected String getNoNSSchemaLocation()
        Convenience method for getting the current noNamespaceSchemaLocation.
        Returns:
        the current noNamespaceSchemaLocation or null if it hasn't been set
      • setNoNSSchemaLocation

        protected void setNoNSSchemaLocation(String location)
        Convenience method for setting the noNamespaceSchemaLocation.
        Parameters:
        location - the noNamespaceSchemaLocation value
      • isFormattedOutput

        protected boolean isFormattedOutput()
        Convenience method for getting the formatted output flag.
        Returns:
        the current value of the formatted output flag or false if it hasn't been set.
      • setFormattedOutput

        protected void setFormattedOutput(boolean v)
        Convenience method for setting the formatted output flag.
        Parameters:
        v - value of the formatted output flag.
      • isFragment

        protected boolean isFragment()
        Convenience method for getting the fragment flag.
        Returns:
        the current value of the fragment flag or false if it hasn't been set.
      • setFragment

        protected void setFragment(boolean v)
        Convenience method for setting the fragment flag.
        Parameters:
        v - value of the fragment flag.
      • getJavaEncoding

        protected String getJavaEncoding(String encoding)
                                  throws UnsupportedEncodingException
        Gets the corresponding Java encoding name from an IANA name. This method is a helper method for the derived class to convert encoding names.
        Throws:
        UnsupportedEncodingException - If this implementation couldn't find the Java encoding name.
      • setProperty

        public void setProperty(String name,
                       Object value)
                         throws PropertyException
        Default implementation of the setProperty method handles the four defined properties in Marshaller. If a provider needs to handle additional properties, it should override this method in a derived class.
        Specified by:
        setProperty in interface Marshaller
        Parameters:
        name - the name of the property to be set. This value can either be specified using one of the constant fields or a user supplied string.
        value - the value of the property to be set
        Throws:
        PropertyException - when there is an error processing the given property or value
      • getProperty

        public Object getProperty(String name)
                           throws PropertyException
        Default implementation of the getProperty method handles the four defined properties in Marshaller. If a provider needs to support additional provider specific properties, it should override this method in a derived class.
        Specified by:
        getProperty in interface Marshaller
        Parameters:
        name - the name of the property to retrieve
        Returns:
        the value of the requested property
        Throws:
        PropertyException - when there is an error retrieving the given property or value property name
      • setEventHandler

        public void setEventHandler(ValidationEventHandler handler)
                             throws JAXBException
        Description copied from interface: Marshaller
        Allow an application to register a validation event handler.

        The validation event handler will be called by the JAXB Provider if any validation errors are encountered during calls to any of the marshal API's. If the client application does not register a validation event handler before invoking one of the marshal methods, then validation events will be handled by the default event handler which will terminate the marshal operation after the first error or fatal error is encountered.

        Calling this method with a null parameter will cause the Marshaller to revert back to the default default event handler.

        Specified by:
        setEventHandler in interface Marshaller
        Parameters:
        handler - the validation event handler
        Throws:
        JAXBException - if an error was encountered while setting the event handler
        See Also:
        Marshaller.setEventHandler(ValidationEventHandler)
      • setSchema

        public void setSchema(Schema schema)
        Description copied from interface: Marshaller
        Specify the JAXP 1.3 Schema object that should be used to validate subsequent marshal operations against. Passing null into this method will disable validation.

        This method allows the caller to validate the marshalled XML as it's marshalled.

        Initially this property is set to null.

        Specified by:
        setSchema in interface Marshaller
        Parameters:
        schema - Schema object to validate marshal operations against or null to disable validation
      • getSchema

        public Schema getSchema()
        Description copied from interface: Marshaller
        Get the JAXP 1.3 Schema object being used to perform marshal-time validation. If there is no Schema set on the marshaller, then this method will return null indicating that marshal-time validation will not be performed.
        Specified by:
        getSchema in interface Marshaller
        Returns:
        the Schema object being used to perform marshal-time validation or null if not present.
      • setAdapter

        public <A extends XmlAdapter> void setAdapter(Class<A> type,
                                             A adapter)
        Description copied from interface: Marshaller
        Associates a configured instance of XmlAdapter with this marshaller.

        Every marshaller internally maintains a Map<Class,XmlAdapter>, which it uses for marshalling classes whose fields/methods are annotated with XmlJavaTypeAdapter.

        This method allows applications to use a configured instance of XmlAdapter. When an instance of an adapter is not given, a marshaller will create one by invoking its default constructor.

        Specified by:
        setAdapter in interface Marshaller
        Parameters:
        type - The type of the adapter. The specified instance will be used when XmlJavaTypeAdapter.value() refers to this type.
        adapter - The instance of the adapter to be used. If null, it will un-register the current adapter set for this type.
      • setAttachmentMarshaller

        public void setAttachmentMarshaller(AttachmentMarshaller am)
        Description copied from interface: Marshaller

        Associate a context that enables binary data within an XML document to be transmitted as XML-binary optimized attachment. The attachment is referenced from the XML document content model by content-id URIs(cid) references stored within the xml document.

        Specified by:
        setAttachmentMarshaller in interface Marshaller

Document created the 11/06/2005, last modified the 04/03/2020
Source of the printed document:https://www.gaudry.be/en/java-api-rf-javax/xml/bind/helpers/abstractmarshallerimpl.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : https://docs.oracle.com

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut