Ignore:
Timestamp:
09/06/10 21:40:42 (17 months ago)
Author:
jharrop
Message:

Avoid things of the form:

extends JaxbXmlPart?<JAXBElement<xyz>>

Location:
trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/DrawingML/Chart.java

    r1201 r1203  
    1212import org.xlsx4j.sml.CTStylesheet; 
    1313 
    14 public class Chart  extends JaxbDmlPart<JAXBElement<CTChartSpace>> { 
     14public class Chart  extends JaxbDmlPart<CTChartSpace> { 
    1515        // This part uses a JAXB content model from dml, 
    1616        // so we need to use that context. 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/DrawingML/Drawing.java

    r1201 r1203  
    1212import org.xlsx4j.sml.CTStylesheet; 
    1313 
    14 public class Drawing extends JaxbDmlPart<JAXBElement<CTDrawing>> { 
     14public class Drawing extends JaxbDmlPart<CTDrawing> { 
    1515        // This part uses a JAXB content model from dml, 
    1616        // so we need to use that context. 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/JaxbXmlPart.java

    r949 r1203  
    2626import javax.xml.bind.Unmarshaller; 
    2727 
     28import org.docx4j.XmlUtils; 
    2829import org.docx4j.jaxb.Context; 
    2930import org.docx4j.jaxb.NamespacePrefixMapperUtils; 
     
    214215 
    215216                        log.debug("unmarshalling " + this.getClass().getName() );                                                                                                                        
    216                         jaxbElement = (E) u.unmarshal( is );                                             
     217                        jaxbElement = (E) XmlUtils.unwrap( 
     218                                        u.unmarshal( is ));                                              
    217219                        log.debug( this.getClass().getName() + " unmarshalled" );                                                                        
    218220 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/DocumentPart.java

    r1032 r1203  
    172172                        // Word seems to add an endnotes part when it adds a footnotes part, 
    173173                        // so existence of part is not determinative 
    174                         CTEndnotes endnotes = wmlPackage.getMainDocumentPart().getEndNotesPart().getJaxbElement().getValue(); 
     174                        CTEndnotes endnotes = wmlPackage.getMainDocumentPart().getEndNotesPart().getJaxbElement(); 
    175175                         
    176176                        if (endnotes.getEndnote().size()<3) { 
     
    203203        public static Node getFootnote(WordprocessingMLPackage wmlPackage, String id) {  
    204204                 
    205                 CTFootnotes footnotes = wmlPackage.getMainDocumentPart().getFootnotesPart().getJaxbElement().getValue(); 
     205                CTFootnotes footnotes = wmlPackage.getMainDocumentPart().getFootnotesPart().getJaxbElement(); 
    206206                int pos = Integer.parseInt(id); 
    207207                 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/DocumentSettingsPart.java

    r947 r1203  
    5959                                 
    6060        } 
    61          
    62         @Override 
    63         public Object getJaxbElement() {         
    6461                 
    65                 if (jaxbElement instanceof JAXBElement) { 
    66                         if (((JAXBElement)jaxbElement).getName().getLocalPart().equals("settings")) { 
    67                                 return (CTSettings)((JAXBElement)jaxbElement).getValue();                                
    68                         } else { 
    69                                 log.error("Unexpected " + XmlUtils.JAXBElementDebug((JAXBElement)jaxbElement) );                                 
    70                                 return jaxbElement; 
    71                         } 
    72                 } else if (jaxbElement instanceof CTSettings){ 
    73                         return jaxbElement;                      
    74                 } else { 
    75                         log.error( "Unexpected" + jaxbElement.getClass().getName() ); 
    76                         return jaxbElement; 
    77                 } 
    78         } 
    79          
    8062} 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/EndnotesPart.java

    r887 r1203  
    3131 
    3232 
    33 public final class EndnotesPart extends JaxbXmlPart<JAXBElement<CTEndnotes>> { 
     33public final class EndnotesPart extends JaxbXmlPart<CTEndnotes> { 
    3434         
    3535        public EndnotesPart(PartName partName) throws InvalidFormatException { 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/FootnotesPart.java

    r887 r1203  
    3131 
    3232 
    33 public final class FootnotesPart extends JaxbXmlPart<JAXBElement<CTFootnotes>> { 
     33public final class FootnotesPart extends JaxbXmlPart<CTFootnotes> { 
    3434         
    3535        public FootnotesPart(PartName partName) throws InvalidFormatException { 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/GlossaryDocumentPart.java

    r887 r1203  
    5959        } 
    6060                 
    61     /** 
    62      * Unmarshal XML data from the specified InputStream and return the  
    63      * resulting content tree.  Validation event location information may 
    64      * be incomplete when using this form of the unmarshal API. 
    65      * 
    66      * <p> 
    67      * Implements <a href="#unmarshalGlobal">Unmarshal Global Root Element</a>. 
    68      *  
    69      * @param is the InputStream to unmarshal XML data from 
    70      * @return the newly created root object of the java content tree  
    71      * 
    72      * @throws JAXBException  
    73      *     If any unexpected errors occur while unmarshalling 
    74      */ 
    75         @Override 
    76     public GlossaryDocument unmarshal( java.io.InputStream is ) throws JAXBException { 
    77          
    78                 try { 
    79                                      
    80                         Unmarshaller u = jc.createUnmarshaller(); 
    81  
    82                         //u.setSchema(org.docx4j.jaxb.WmlSchema.schema);                         
    83                         u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler()); 
    84                          
    85 //                      JAXBElement<?> root = (JAXBElement<?>)u.unmarshal( is );                         
    86 //                      jaxbElement = (org.docx4j.wml.Document)root.getValue(); 
    87                          
    88                         jaxbElement =  (GlossaryDocument) u.unmarshal( is ); 
    89                         return jaxbElement; 
    90                          
    91                         //System.out.println("\n\n" + this.getClass().getName() + " unmarshalled \n\n" );                                                                        
    92  
    93                 } catch (Exception e ) { 
    94                         e.printStackTrace(); 
    95                         return null; 
    96                 } 
    97          
    98          
    99     } 
    10061         
    10162} 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/MainDocumentPart.java

    r1166 r1203  
    412412                if (this.getEndNotesPart()!=null) { 
    413413                        log.debug("Looking at endnotes"); 
    414                         CTEndnotes endnotes= this.getEndNotesPart().getJaxbElement().getValue(); 
     414                        CTEndnotes endnotes= this.getEndNotesPart().getJaxbElement(); 
    415415                        traverseMainDocumentRecursive(endnotes.getEndnote(), null, stylesInUse);                         
    416416                } 
    417417                if (this.getFootnotesPart()!=null) { 
    418418                        log.debug("Looking at footnotes"); 
    419                         CTFootnotes footnotes= this.getFootnotesPart().getJaxbElement().getValue(); 
     419                        CTFootnotes footnotes= this.getFootnotesPart().getJaxbElement(); 
    420420                        traverseMainDocumentRecursive(footnotes.getFootnote(), null, stylesInUse);                       
    421421                } 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/parts/WordprocessingML/StyleDefinitionsPart.java

    r1096 r1203  
    7373         
    7474         
    75     /** 
    76      * Unmarshal XML data from the specified InputStream and return the  
    77      * resulting content tree.  Validation event location information may 
    78      * be incomplete when using this form of the unmarshal API. 
    79      * 
    80      * <p> 
    81      * Implements <a href="#unmarshalGlobal">Unmarshal Global Root Element</a>. 
    82      *  
    83      * @param is the InputStream to unmarshal XML data from 
    84      * @return the newly created root object of the java content tree  
    85      * 
    86      * @throws JAXBException  
    87      *     If any unexpected errors occur while unmarshalling 
    88      */ 
    89         @Override 
    90     public Styles unmarshal( java.io.InputStream is ) throws JAXBException { 
    91          
    92                 try { 
    93                          
    94 //                      if (jc==null) { 
    95 //                              setJAXBContext(Context.jc);                              
    96 //                      } 
    97                                      
    98                         Unmarshaller u = jc.createUnmarshaller(); 
    99                          
    100                         //u.setSchema(org.docx4j.jaxb.WmlSchema.schema); 
    101                         u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler()); 
    102  
    103                         log.info("unmarshalling " + this.getClass().getName() + " \n\n" );                                                                       
    104                                                  
    105                         jaxbElement = (Styles) u.unmarshal( is ); 
    106                          
    107                         log.info("\n\n" + this.getClass().getName() + " unmarshalled \n\n" );                                                                    
    108  
    109                 } catch (Exception e ) { 
    110                         e.printStackTrace(); 
    111                 } 
    112          
    113                 return jaxbElement; 
    114          
    115     } 
    11675     
    11776        @Override 
Note: See TracChangeset for help on using the changeset viewer.