public void serialize(XMLDocument xmlDocument, OutputStream outputStream, Object options)
     throws IOException {
   XMLMarshaller xmlMarshaller = getXmlMarshaller();
   XMLAttachmentMarshaller attachmentMarshaller = xmlMarshaller.getAttachmentMarshaller();
   // temporarily null out the attachment marshaller as it should not be used during serialization
   xmlMarshaller.setAttachmentMarshaller(null);
   OutputStreamWriter writer = new OutputStreamWriter(outputStream, xmlMarshaller.getEncoding());
   save(xmlDocument, writer, xmlMarshaller);
   xmlMarshaller.setAttachmentMarshaller(attachmentMarshaller);
 }
 /**
  * Saves the DataObject as an XML document with the specified root element. Same as
  * save(createDocument(dataObject, rootElementURI, rootElementName), outputStream, null);
  *
  * @param dataObject specifies DataObject to be saved
  * @param rootElementURI the Target Namespace URI of the root XML element
  * @param rootElementName the Name of the root XML element
  * @param outputStream specifies the OutputStream to write to.
  * @throws IOException for stream exceptions.
  * @throws IllegalArgumentException if the dataObject tree is not closed or has no container.
  */
 public void save(
     DataObject dataObject,
     String rootElementURI,
     String rootElementName,
     OutputStream outputStream)
     throws XMLMarshalException, IOException {
   XMLMarshaller xmlMarshaller = getXmlMarshaller(null);
   OutputStreamWriter writer = new OutputStreamWriter(outputStream, xmlMarshaller.getEncoding());
   save(dataObject, rootElementURI, rootElementName, writer, xmlMarshaller);
 }
 /**
  * Serializes an XMLDocument as an XML document into the outputStream. If the DataObject's Type
  * was defined by an XSD, the serialization will follow the XSD. Otherwise the serialization will
  * follow the format as if an XSD were generated as defined by the SDO specification. The
  * OutputStream will be flushed after writing. Does not perform validation to ensure compliance
  * with an XSD.
  *
  * @param xmlDocument specifies XMLDocument to be saved
  * @param outputStream specifies the OutputStream to write to.
  * @param options implementation-specific options.
  * @throws IOException for stream exceptions.
  * @throws IllegalArgumentException if the dataObject tree is not closed or has no container.
  */
 public void save(XMLDocument xmlDocument, OutputStream outputStream, Object options)
     throws IOException {
   if (xmlDocument == null) {
     throw new IllegalArgumentException(
         SDOException.cannotPerformOperationWithNullInputParameter("save", "xmlDocument"));
   }
   XMLMarshaller xmlMarshaller = getXmlMarshaller(options);
   String encoding = xmlMarshaller.getEncoding();
   if (xmlDocument.getEncoding() != null) {
     encoding = xmlDocument.getEncoding();
   }
   OutputStreamWriter writer = new OutputStreamWriter(outputStream, encoding);
   save(xmlDocument, writer, xmlMarshaller);
 }
 /**
  * Get a property from the JAXBMarshaller. Attempting to get any unsupported property will result
  * in a javax.xml.bind.PropertyException
  *
  * @see org.eclipse.persistence.jaxb.MarshallerProperties
  */
 public Object getProperty(String key) throws PropertyException {
   if (key == null) {
     throw new IllegalArgumentException();
   } else if (JAXB_FORMATTED_OUTPUT.equals(key)) {
     return xmlMarshaller.isFormattedOutput();
   } else if (JAXB_ENCODING.equals(key)) {
     return xmlMarshaller.getEncoding();
   } else if (JAXB_SCHEMA_LOCATION.equals(key)) {
     return xmlMarshaller.getSchemaLocation();
   } else if (JAXB_NO_NAMESPACE_SCHEMA_LOCATION.equals(key)) {
     return xmlMarshaller.getNoNamespaceSchemaLocation();
   } else if (Constants.JAXB_FRAGMENT.equals(key)) {
     return xmlMarshaller.isFragment();
   } else if (MarshallerProperties.MEDIA_TYPE.equals(key)) {
     return xmlMarshaller.getMediaType();
   } else if (MarshallerProperties.NAMESPACE_PREFIX_MAPPER.equals(key)) {
     return xmlMarshaller.getNamespacePrefixMapper();
   } else if (MarshallerProperties.INDENT_STRING.equals(key)
       || SUN_INDENT_STRING.equals(key)
       || SUN_JSE_INDENT_STRING.equals(key)) {
     return xmlMarshaller.getIndentString();
   } else if (MarshallerProperties.CHARACTER_ESCAPE_HANDLER.equals(key)) {
     return xmlMarshaller.getCharacterEscapeHandler();
   } else if (XML_DECLARATION.equals(key)) {
     return !xmlMarshaller.isFragment();
   } else if (XML_HEADERS.equals(key)) {
     return xmlMarshaller.getXmlHeader();
   } else if (OBJECT_IDENTITY_CYCLE_DETECTION.equals(key)) {
     return xmlMarshaller.isEqualUsingIdenity();
   } else if (MarshallerProperties.JSON_ATTRIBUTE_PREFIX.equals(key)) {
     return xmlMarshaller.getAttributePrefix();
   } else if (MarshallerProperties.JSON_INCLUDE_ROOT.equals(key)) {
     return xmlMarshaller.isIncludeRoot();
   } else if (MarshallerProperties.JSON_VALUE_WRAPPER.equals(key)) {
     return xmlMarshaller.getValueWrapper();
   } else if (MarshallerProperties.JSON_NAMESPACE_SEPARATOR.equals(key)) {
     return xmlMarshaller.getNamespaceSeparator();
   } else if (MarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME.equals(key)) {
     return xmlMarshaller.isWrapperAsCollectionName();
   } else if (SUN_CHARACTER_ESCAPE_HANDLER.equals(key)
       || SUN_JSE_CHARACTER_ESCAPE_HANDLER.equals(key)) {
     if (xmlMarshaller.getCharacterEscapeHandler() instanceof CharacterEscapeHandlerWrapper) {
       CharacterEscapeHandlerWrapper wrapper =
           (CharacterEscapeHandlerWrapper) xmlMarshaller.getCharacterEscapeHandler();
       return wrapper.getHandler();
     }
     return xmlMarshaller.getCharacterEscapeHandler();
   } else if (SUN_NAMESPACE_PREFIX_MAPPER.equals(key)
       || SUN_JSE_NAMESPACE_PREFIX_MAPPER.equals(key)) {
     NamespacePrefixMapperWrapper wrapper =
         (NamespacePrefixMapperWrapper) xmlMarshaller.getNamespacePrefixMapper();
     if (wrapper == null) {
       return null;
     }
     return wrapper.getPrefixMapper();
   } else if (MarshallerProperties.OBJECT_GRAPH.equals(key)) {
     Object graph = xmlMarshaller.getMarshalAttributeGroup();
     if (graph instanceof CoreAttributeGroup) {
       return new ObjectGraphImpl((CoreAttributeGroup) graph);
     }
     return graph;
   }
   throw new PropertyException(key);
 }