javax.xml.bind.helpers


  1. Creating a JAXBContext instance:

    JAXBContext context = JAXBContext.newInstance(MyClass.class);
  2. Creating a Marshaller instance:

    Marshaller marshaller = context.createMarshaller();
  3. Setting Marshaller properties:

    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
  4. Marshalling an object to XML:

    marshaller.marshal(myObject, new File("myFile.xml"));
  5. Creating an Unmarshaller instance:

    Unmarshaller unmarshaller = context.createUnmarshaller();
  6. Setting Unmarshaller properties:

    unmarshaller.setProperty(Unmarshaller.JAXB_VALIDATION_MODE, ValidatorMode.LAX);
  7. Unmarshalling XML to an object:

    MyClass myObject = (MyClass) unmarshaller.unmarshal(new File("myFile.xml"));
  8. Creating a JAXBElement instance:

    JAXBElement<MyClass> jaxbElement = new JAXBElement<>(new QName("myNamespace", "myElement"), MyClass.class, myObject);
  9. Getting the value of a JAXBElement instance:

    MyClass myObject = jaxbElement.getValue();
  10. Creating an XMLStreamReader from a JAXBElement instance:

  1. Creating an XMLStreamWriter from a JAXBElement instance:

  1. Creating a DatatypeConverter instance:

  1. Converting a string to a date:

  1. Converting a date to a string:

  1. Converting a string to a time:

  1. Converting a time to a string:

  1. Converting a string to a date and time:

  1. Converting a date and time to a string:

  1. Converting a string to a duration:

  1. Converting a duration to a string:

  1. Converting a string to a base64 binary:

  1. Converting a base64 binary to a string:

  1. Converting a string to a hex binary:

  1. Converting a hex binary to a string:

  1. Creating a ValidationEventCollector instance:

  1. Registering the ValidationEventCollector with a Marshaller:

  1. Getting validation events from the ValidationEventCollector:

  1. Creating a ValidationEventHandler instance:

  1. Registering the ValidationEventHandler with a Marshaller:

  1. Implementing the handleEvent method of the ValidationEventHandler:

  1. Creating a PropertyChangeSupport instance:

  1. Adding a PropertyChangeListener to the PropertyChangeSupport:

  1. Removing a PropertyChangeListener from the PropertyChangeSupport:

  1. Firing a property change event:

  1. Creating a JAXBIntrospector instance:

  1. Getting the bean class of a JAXBIntrospector instance:

  1. Getting the schema location of a JAXBIntrospector instance:

  1. Getting the root element of a JAXBIntrospector instance:

  1. Getting the property info of a JAXBIntrospector instance:

  1. Getting the value of a property from an object using a JAXBIntrospector instance:

  1. Setting the value of a property on an object using a JAXBIntrospector instance:

  1. Creating a JAXBMarshallable instance:

  1. Implementing the marshal method of the JAXBMarshallable interface:

  1. Creating a JAXBUnmarshallerHandler instance:

  1. Implementing the handleUnmarshallEvent method of the JAXBUnmarshallerHandler interface:

  1. Creating a JAXBElementHandler instance:

  1. Implementing the getJAXBElement method of the JAXBElementHandler interface:

  1. Creating a JAXBMarshallableHandler instance:

  1. Implementing the marshal method of the JAXBMarshallableHandler interface:

  1. Creating a BindingProvider instance: