Changeset 530
- Timestamp:
- 08/12/08 05:55:50 (3 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/CommentsPart.java
r301 r530 21 21 package org.docx4j.openpackaging.parts.WordprocessingML; 22 22 23 import javax.xml.bind.JAXBException; 24 import javax.xml.bind.Unmarshaller; 25 23 26 import org.docx4j.openpackaging.exceptions.InvalidFormatException; 24 import org.docx4j.openpackaging.parts.Dom4jXmlPart;25 27 import org.docx4j.openpackaging.parts.Part; 26 28 import org.docx4j.openpackaging.parts.PartName; 27 29 import org.docx4j.openpackaging.parts.relationships.Namespaces; 28 30 29 import org.do m4j.Document;31 import org.docx4j.openpackaging.parts.JaxbXmlPart; 30 32 31 33 32 34 33 public final class CommentsPart extends Dom4jXmlPart {35 public final class CommentsPart extends JaxbXmlPart { 34 36 35 37 public CommentsPart(PartName partName) throws InvalidFormatException { 36 38 super(partName); 37 39 init(); 40 } 41 42 public CommentsPart() throws InvalidFormatException { 43 super(new PartName("/word/comments.xml")); 44 init(); 45 } 46 47 public void init() { 38 48 // Used if this Part is added to [Content_Types].xml 39 49 setContentType(new org.docx4j.openpackaging.contenttype.ContentType( … … 45 55 } 46 56 47 @Override 48 public Document getDocument() { 49 return document; 50 } 51 57 /** 58 * Unmarshal XML data from the specified InputStream and return the 59 * resulting content tree. Validation event location information may 60 * be incomplete when using this form of the unmarshal API. 61 * 62 * <p> 63 * Implements <a href="#unmarshalGlobal">Unmarshal Global Root Element</a>. 64 * 65 * @param is the InputStream to unmarshal XML data from 66 * @return the newly created root object of the java content tree 67 * 68 * @throws JAXBException 69 * If any unexpected errors occur while unmarshalling 70 */ 71 public Object unmarshal( java.io.InputStream is ) throws JAXBException { 72 73 try { 74 75 // if (jc==null) { 76 // setJAXBContext(Context.jc); 77 // } 78 79 Unmarshaller u = jc.createUnmarshaller(); 80 81 //u.setSchema(org.docx4j.jaxb.WmlSchema.schema); 82 u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler()); 83 84 System.out.println("unmarshalling " + this.getClass().getName() + " \n\n" ); 85 86 jaxbElement = u.unmarshal( is ); 87 88 89 System.out.println("\n\n" + this.getClass().getName() + " unmarshalled \n\n" ); 90 91 } catch (Exception e ) { 92 e.printStackTrace(); 93 } 94 95 return jaxbElement; 96 97 } 52 98 }
