Changeset 854


Ignore:
Timestamp:
07/08/09 17:09:15 (3 years ago)
Author:
jharrop
Message:

Remove ContentTypeManager? interface; replace it with implementation.
ContentTypeManager?: change semantics of isContentTypeRegistered, so that it means 'is *default* content type registered'.

Location:
trunk/docx4j/src/main/java/org/docx4j
Files:
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/main/java/org/docx4j/convert/in/FlatOpcXmlImporter.java

    r846 r854  
    4646import org.docx4j.openpackaging.contenttype.ContentType; 
    4747import org.docx4j.openpackaging.contenttype.ContentTypeManager; 
    48 import org.docx4j.openpackaging.contenttype.ContentTypeManagerImpl; 
    4948import org.docx4j.openpackaging.exceptions.Docx4JException; 
    5049import org.docx4j.openpackaging.exceptions.InvalidFormatException; 
     
    116115                //              but only the WordML package exists at present 
    117116                 
    118                 ctm = new ContentTypeManagerImpl(); 
     117                ctm = new ContentTypeManager(); 
    119118                 
    120119                ctm.addDefaultContentType("rels", "application/vnd.openxmlformats-package.relationships+xml"); 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/contenttype/ContentTypeManager.java

    r790 r854  
    8282 * @version 1.0 
    8383 */ 
    84 public class ContentTypeManagerImpl implements ContentTypeManager { 
    85          
    86         // TODO - merge this with interface.  
    87         // There is no value in having a separate implementation. 
    88  
    89         protected static Logger log = Logger.getLogger(ContentTypeManagerImpl.class); 
     84public class ContentTypeManager  { 
     85         
     86        protected static Logger log = Logger.getLogger(ContentTypeManager.class); 
    9087 
    9188        /** 
     
    134131         *             If the content types part content is not valid. 
    135132         */ 
    136         public ContentTypeManagerImpl(Document contentTypes) throws InvalidFormatException { 
     133        public ContentTypeManager(Document contentTypes) throws InvalidFormatException { 
    137134                init(); 
    138135                if (contentTypes != null) { 
     
    148145        } 
    149146 
    150         public ContentTypeManagerImpl()  { 
     147        public ContentTypeManager()  { 
    151148                init(); 
    152149        } 
     
    169166                String extension = partName.getExtension(); 
    170167                if ((extension.length() == 0) 
    171                                 || (this.defaultContentType.containsKey(extension) && !(defaultCTExists = this.defaultContentType 
    172                                                 .containsValue(contentType)))) 
     168                                || (this.defaultContentType.containsKey(extension)  
     169                                                && !(defaultCTExists = this.defaultContentType.containsValue(contentType)))) { 
    173170                        this.addOverrideContentType(partName.getURI(), contentType); 
    174                 else if (!defaultCTExists) 
     171                } else if (!defaultCTExists) { 
    175172                        this.addDefaultContentType(extension, contentType); 
     173                } 
    176174        } 
    177175 
     
    474472 
    475473        /** 
    476          * Check if the specified content type is already register. 
     474         * Check if the specified content type is already registered 
     475         * as a default content type.  We don't currently have a method 
     476         * to check whether its registered as an override content type; 
     477         * getContentType(PartName partName) may suffice for that purpose. 
    477478         *  
    478479         * @param contentType 
    479480         *            The content type to check. 
    480481         * @return <code>true</code> if the specified content type is already 
    481          *         register, then <code>false</code>. 
     482         *         registered, then <code>false</code>. 
    482483         */ 
    483484        public boolean isContentTypeRegistered(String contentType) { 
     
    485486                        throw new IllegalArgumentException("contentType"); 
    486487 
    487                 return (this.defaultContentType.values().contains(contentType) || (this.overrideContentType != null && this.overrideContentType 
    488                                 .values().contains(contentType))); 
     488                return this.defaultContentType.values().contains(contentType);  
     489//                              || (this.overrideContentType != null  
     490//                                              && this.overrideContentType.values().contains(contentType))); 
    489491        } 
    490492 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/io/LoadFromJCR.java

    r819 r854  
    5151import org.docx4j.openpackaging.URIHelper; 
    5252import org.docx4j.openpackaging.contenttype.ContentTypeManager; 
    53 import org.docx4j.openpackaging.contenttype.ContentTypeManagerImpl; 
    5453import org.docx4j.openpackaging.exceptions.InvalidFormatException; 
    5554import org.docx4j.openpackaging.Base; 
     
    119118         
    120119        public LoadFromJCR(NodeMapper nodeMapper) { 
    121                 this(new ContentTypeManagerImpl(), nodeMapper ); 
     120                this(new ContentTypeManager(), nodeMapper ); 
    122121        } 
    123122 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/io/LoadFromZipFile.java

    r819 r854  
    4040import org.docx4j.openpackaging.URIHelper; 
    4141import org.docx4j.openpackaging.contenttype.ContentTypeManager; 
    42 import org.docx4j.openpackaging.contenttype.ContentTypeManagerImpl; 
    4342import org.docx4j.openpackaging.exceptions.Docx4JException; 
    4443import org.docx4j.openpackaging.exceptions.InvalidFormatException; 
     
    8887         
    8988        public LoadFromZipFile() { 
    90                 this(new ContentTypeManagerImpl() ); 
     89                this(new ContentTypeManager() ); 
    9190        } 
    9291 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/io/LoadFromZipNG.java

    r819 r854  
    4545import org.docx4j.openpackaging.URIHelper; 
    4646import org.docx4j.openpackaging.contenttype.ContentTypeManager; 
    47 import org.docx4j.openpackaging.contenttype.ContentTypeManagerImpl; 
    4847import org.docx4j.openpackaging.exceptions.Docx4JException; 
    4948import org.docx4j.openpackaging.exceptions.InvalidFormatException; 
     
    9190         
    9291        public LoadFromZipNG() { 
    93                 this(new ContentTypeManagerImpl() ); 
     92                this(new ContentTypeManager() ); 
    9493        } 
    9594 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/Package.java

    r817 r854  
    2828import org.docx4j.openpackaging.Base; 
    2929import org.docx4j.openpackaging.contenttype.ContentTypeManager; 
    30 import org.docx4j.openpackaging.contenttype.ContentTypeManagerImpl; 
    3130import org.docx4j.openpackaging.exceptions.InvalidFormatException; 
    3231import org.docx4j.openpackaging.parts.CustomXmlDataStoragePart; 
     
    101100                        partName = new PartName("/", false); 
    102101                         
    103                         contentTypeManager = new ContentTypeManagerImpl(); 
     102                        contentTypeManager = new ContentTypeManager(); 
    104103                } catch (Exception e) { 
    105104                        log.error(e.getMessage()); 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/WordprocessingMLPackage.java

    r791 r854  
    4949import org.docx4j.openpackaging.contenttype.ContentType; 
    5050import org.docx4j.openpackaging.contenttype.ContentTypeManager; 
    51 import org.docx4j.openpackaging.contenttype.ContentTypeManagerImpl; 
    5251import org.docx4j.openpackaging.contenttype.ContentTypes; 
    5352import org.docx4j.openpackaging.exceptions.Docx4JException; 
     
    238237                org.docx4j.convert.in.FlatOpcXmlImporter xmlPackage = new org.docx4j.convert.in.FlatOpcXmlImporter( wmlPackageEl);  
    239238                 
    240                 ContentTypeManager ctm = new ContentTypeManagerImpl(); 
     239                ContentTypeManager ctm = new ContentTypeManager(); 
    241240                 
    242241                Part tmpDocPart = xmlPackage.getRawPart(ctm,  "/word/document.xml"); 
Note: See TracChangeset for help on using the changeset viewer.