org.docx4j.openpackaging.contenttype
Interface ContentTypeManager

All Known Implementing Classes:
ContentTypeManagerImpl

public interface ContentTypeManager


Field Summary
static java.lang.String CONTENT_TYPE_ATTRIBUTE_NAME
           
static java.lang.String CONTENT_TYPES_PART_NAME
          Content type part name.
static java.lang.String DEFAULT_TAG_NAME
           
static java.lang.String EXTENSION_ATTRIBUTE_NAME
           
static java.lang.String OVERRIDE_TAG_NAME
           
static java.lang.String PART_NAME_ATTRIBUTE_NAME
           
static java.lang.String TYPES_NAMESPACE_URI
          Content type namespace
static java.lang.String TYPES_TAG_NAME
           
 
Method Summary
 void addContentType(PartName partName, java.lang.String contentType)
          Build association extention-> content type (will be stored in [Content_Types].xml) for example ContentType="image/png" Extension="png"
 void addDefaultContentType(java.lang.String extension, java.lang.String contentType)
          Add a content type associated with the specified extension.
 void addOverrideContentType(java.net.URI partUri, java.lang.String contentType)
          Add an override content type for a specific part.
 void clearAll()
          Clear all content types.
 void clearOverrideContentTypes()
          Clear all override content types.
 Part CreateCommentsPartObject(java.lang.String partName)
           
 Part CreateCustomXmlPropertiesPartObject(java.lang.String partName)
           
 Part CreateDefaultPartObject(java.lang.String partName)
           
 Part CreateDocPropsCorePartObject(java.lang.String partName)
           
 Part CreateDocPropsCustomPartObject(java.lang.String partName)
           
 Part CreateDocPropsExtendedPartObject(java.lang.String partName)
           
 Part CreateDocumentSettingsPartObject(java.lang.String partName)
           
 Part CreateEndnotesPartObject(java.lang.String partName)
           
 Part CreateFontTablePartObject(java.lang.String partName)
           
 Part CreateFooterPartObject(java.lang.String partName)
           
 Part CreateFootnotesPartObject(java.lang.String partName)
           
 Part CreateGlossaryDocumentPartObject(java.lang.String partName)
           
 Part CreateHeaderPartObject(java.lang.String partName)
           
 Part CreateMainDocumentPartObject(java.lang.String partName)
           
 Part CreateNumberingPartObject(java.lang.String partName)
           
 Part CreateObfuscatedFontPartObject(java.lang.String partName)
           
 Package createPackage()
           
 Part CreateStyleDefinitionsPartObject(java.lang.String partName)
           
 Part CreateThemePartObject(java.lang.String partName)
           
 Part CreateWebSettingsPartObject(java.lang.String partName)
           
 java.lang.String getContentType(PartName partName)
          Get the content type for the specified part, if any.
 org.dom4j.Document getDocument()
          Generates the XML for the contents type part.
 Part getPart(java.lang.String partName)
           
 java.net.URI getPartNameOverridenByContentType(java.lang.String contentType)
           
 boolean isContentTypeRegistered(java.lang.String contentType)
          Check if the specified content type is already register.
 Part newPartForContentType(java.lang.String contentType, java.lang.String partName)
           
 void parseContentTypesFile(org.dom4j.Document xmlContentTypetDoc)
          Parse the content types part.
 void removeContentType(PartName partName)
          Delete a content type based on the specified part name.
 

Field Detail

CONTENT_TYPE_ATTRIBUTE_NAME

static final java.lang.String CONTENT_TYPE_ATTRIBUTE_NAME
See Also:
Constant Field Values

CONTENT_TYPES_PART_NAME

static final java.lang.String CONTENT_TYPES_PART_NAME
Content type part name.

See Also:
Constant Field Values

DEFAULT_TAG_NAME

static final java.lang.String DEFAULT_TAG_NAME
See Also:
Constant Field Values

EXTENSION_ATTRIBUTE_NAME

static final java.lang.String EXTENSION_ATTRIBUTE_NAME
See Also:
Constant Field Values

OVERRIDE_TAG_NAME

static final java.lang.String OVERRIDE_TAG_NAME
See Also:
Constant Field Values

PART_NAME_ATTRIBUTE_NAME

static final java.lang.String PART_NAME_ATTRIBUTE_NAME
See Also:
Constant Field Values

TYPES_NAMESPACE_URI

static final java.lang.String TYPES_NAMESPACE_URI
Content type namespace

See Also:
Constant Field Values

TYPES_TAG_NAME

static final java.lang.String TYPES_TAG_NAME
See Also:
Constant Field Values
Method Detail

addContentType

void addContentType(PartName partName,
                    java.lang.String contentType)
Build association extention-> content type (will be stored in [Content_Types].xml) for example ContentType="image/png" Extension="png"

Parameters:
partUri - the uri that will be stored

addDefaultContentType

void addDefaultContentType(java.lang.String extension,
                           java.lang.String contentType)
Add a content type associated with the specified extension.

Parameters:
extension - The part name extension to bind to a content type.
contentType - The content type associated with the specified extension.

addOverrideContentType

void addOverrideContentType(java.net.URI partUri,
                            java.lang.String contentType)
Add an override content type for a specific part.

Parameters:
partUri - Uri of the part.
contentType - Content type of the part.

clearAll

void clearAll()
Clear all content types.


clearOverrideContentTypes

void clearOverrideContentTypes()
Clear all override content types.


CreateCommentsPartObject

Part CreateCommentsPartObject(java.lang.String partName)
                              throws InvalidFormatException
Throws:
InvalidFormatException

CreateCustomXmlPropertiesPartObject

Part CreateCustomXmlPropertiesPartObject(java.lang.String partName)
                                         throws InvalidFormatException
Throws:
InvalidFormatException

CreateDefaultPartObject

Part CreateDefaultPartObject(java.lang.String partName)
                             throws InvalidFormatException
Throws:
InvalidFormatException

CreateDocPropsCorePartObject

Part CreateDocPropsCorePartObject(java.lang.String partName)
                                  throws InvalidFormatException
Throws:
InvalidFormatException

CreateDocPropsCustomPartObject

Part CreateDocPropsCustomPartObject(java.lang.String partName)
                                    throws InvalidFormatException
Throws:
InvalidFormatException

CreateDocPropsExtendedPartObject

Part CreateDocPropsExtendedPartObject(java.lang.String partName)
                                      throws InvalidFormatException
Throws:
InvalidFormatException

CreateDocumentSettingsPartObject

Part CreateDocumentSettingsPartObject(java.lang.String partName)
                                      throws InvalidFormatException
Throws:
InvalidFormatException

CreateEndnotesPartObject

Part CreateEndnotesPartObject(java.lang.String partName)
                              throws InvalidFormatException
Throws:
InvalidFormatException

CreateFontTablePartObject

Part CreateFontTablePartObject(java.lang.String partName)
                               throws InvalidFormatException
Throws:
InvalidFormatException

CreateFooterPartObject

Part CreateFooterPartObject(java.lang.String partName)
                            throws InvalidFormatException
Throws:
InvalidFormatException

CreateFootnotesPartObject

Part CreateFootnotesPartObject(java.lang.String partName)
                               throws InvalidFormatException
Throws:
InvalidFormatException

CreateGlossaryDocumentPartObject

Part CreateGlossaryDocumentPartObject(java.lang.String partName)
                                      throws InvalidFormatException
Throws:
InvalidFormatException

CreateHeaderPartObject

Part CreateHeaderPartObject(java.lang.String partName)
                            throws InvalidFormatException
Throws:
InvalidFormatException

CreateMainDocumentPartObject

Part CreateMainDocumentPartObject(java.lang.String partName)
                                  throws InvalidFormatException
Throws:
InvalidFormatException

CreateNumberingPartObject

Part CreateNumberingPartObject(java.lang.String partName)
                               throws InvalidFormatException
Throws:
InvalidFormatException

CreateObfuscatedFontPartObject

Part CreateObfuscatedFontPartObject(java.lang.String partName)
                                    throws InvalidFormatException
Throws:
InvalidFormatException

createPackage

Package createPackage()
                      throws InvalidFormatException
Throws:
InvalidFormatException

CreateStyleDefinitionsPartObject

Part CreateStyleDefinitionsPartObject(java.lang.String partName)
                                      throws InvalidFormatException
Throws:
InvalidFormatException

CreateThemePartObject

Part CreateThemePartObject(java.lang.String partName)
                           throws InvalidFormatException
Throws:
InvalidFormatException

CreateWebSettingsPartObject

Part CreateWebSettingsPartObject(java.lang.String partName)
                                 throws InvalidFormatException
Throws:
InvalidFormatException

getContentType

java.lang.String getContentType(PartName partName)
Get the content type for the specified part, if any.

Parameters:
partUri - The URI part to check.
Returns:
The content type associated with the URI (in case of an override content type) or the extension (in case of default content type), else null.

getDocument

org.dom4j.Document getDocument()
Generates the XML for the contents type part.

Parameters:
outStream - The output stream use to save the XML content of the content types part.
Returns:
true if the operation success, else false.

getPart

Part getPart(java.lang.String partName)
             throws java.net.URISyntaxException,
                    InvalidFormatException
Throws:
java.net.URISyntaxException
InvalidFormatException

getPartNameOverridenByContentType

java.net.URI getPartNameOverridenByContentType(java.lang.String contentType)

isContentTypeRegistered

boolean isContentTypeRegistered(java.lang.String contentType)
Check if the specified content type is already register.

Parameters:
contentType - The content type to check.
Returns:
true if the specified content type is already register, then false.

newPartForContentType

Part newPartForContentType(java.lang.String contentType,
                           java.lang.String partName)
                           throws InvalidFormatException
Throws:
InvalidFormatException

parseContentTypesFile

void parseContentTypesFile(org.dom4j.Document xmlContentTypetDoc)
                           throws InvalidFormatException
Parse the content types part.

Throws:
InvalidFormatException - Throws if the content type doesn't exist or the XML format is invalid.

removeContentType

void removeContentType(PartName partName)
Delete a content type based on the specified part name. If the specified part name is register with an override content type, then this content type is remove, else the content type is remove in the default content type list if it exists.

Parameters:
partUri - The part URI associated with the override content type to delete.