Class ContentTypeManager
java.lang.Object
org.docx4j.openpackaging.contenttype.ContentTypeManager
Manage package content types ([Content_Types].xml ) .
- Version:
- 1.0
- Author:
- Julien Chable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDefaultContentType(String extension, String contentType) voidaddDefaultContentType(String extension, CTDefault contentType) Add a content type associated with the specified extension.voidaddOverrideContentType(URI partUri, String contentType) voidaddOverrideContentType(URI partUri, CTOverride contentType) Add an override content type for a specific part.voidaddOverrideContentType(PartName partName, String contentType) voidclearAll()Clear all content types.voidClear all override content types.CreateCommentsPartObject(String partName) CreateDefaultXmlPartObject(String partName) CreateDocPropsCorePartObject(String partName) CreateDocPropsCustomPartObject(String partName) CreateDocPropsExtendedPartObject(String partName) CreateDocumentSettingsPartObject(String partName) CreateEndnotesPartObject(String partName) CreateFontTablePartObject(String partName) CreateFooterPartObject(String partName) CreateFootnotesPartObject(String partName) CreateGlossaryDocumentPartObject(String partName) CreateHeaderPartObject(String partName) CreateMainDocumentPartObject(String partName) CreateNumberingPartObject(String partName) CreateObfuscatedFontPartObject(String partName) createPackage(String pkgContentType) Return a package of the appropriate type.CreateStyleDefinitionsPartObject(String partName) CreateThemePartObject(String partName) CreateWebSettingsPartObject(String partName) getContentType(PartName partName) Get the content type for the specified part, if any.getPart(String partName, Relationship rel) getPartNameOverridenByContentType(String contentType) booleanisContentEqual(ContentTypeManager other) booleanisContentTypeRegistered(String contentType) Check if the specified content type is already registered as a default content type.booleanisOverrideContentTypeRegistered(String contentType) Check if the specified content type is already registered as a default content type.voidmarshal(OutputStream os) voidnewPartForContentType(String contentType, String partName, Relationship rel) voidparseContentTypesFile(InputStream contentTypes) voidremoveContentType(PartName partName) Deprecated.voidDelete a default content type based on the specified part name.voidremoveOverrideContentType(PartName partName) Delete an override content type based on the specified part name.toString()
-
Field Details
-
log
protected static org.slf4j.Logger log -
CONTENT_TYPES_PART_NAME
Content type part name.- See Also:
-
TYPES_NAMESPACE_URI
Content type namespace- See Also:
-
-
Constructor Details
-
ContentTypeManager
public ContentTypeManager()
-
-
Method Details
-
getDefaultContentType
- Returns:
- the defaultContentType
- Since:
- 2.8.1
-
getOverrideContentType
- Returns:
- the overrideContentType
- Since:
- 2.8.1
-
addOverrideContentType
Add an override content type for a specific part.- Parameters:
partUri- Uri of the part.contentType- Content type of the part.
-
addOverrideContentType
-
getPartNameOverridenByContentType
-
getPart
public Part getPart(String partName, Relationship rel) throws URISyntaxException, PartUnrecognisedException, InvalidFormatException -
newPartForContentType
public Part newPartForContentType(String contentType, String partName, Relationship rel) throws InvalidFormatException, PartUnrecognisedException -
CreateDefaultXmlPartObject
- Throws:
InvalidFormatException
-
CreateMainDocumentPartObject
- Throws:
InvalidFormatException
-
CreateStyleDefinitionsPartObject
- Throws:
InvalidFormatException
-
CreateDocumentSettingsPartObject
- Throws:
InvalidFormatException
-
CreateWebSettingsPartObject
- Throws:
InvalidFormatException
-
CreateFontTablePartObject
- Throws:
InvalidFormatException
-
CreateThemePartObject
- Throws:
InvalidFormatException
-
CreateDocPropsCorePartObject
- Throws:
InvalidFormatException
-
CreateDocPropsExtendedPartObject
- Throws:
InvalidFormatException
-
CreateDocPropsCustomPartObject
- Throws:
InvalidFormatException
-
CreateCommentsPartObject
- Throws:
InvalidFormatException
-
CreateCustomXmlDataStoragePropertiesPartObject
public Part CreateCustomXmlDataStoragePropertiesPartObject(String partName) throws InvalidFormatException - Throws:
InvalidFormatException
-
CreateEndnotesPartObject
- Throws:
InvalidFormatException
-
CreateFootnotesPartObject
- Throws:
InvalidFormatException
-
CreateGlossaryDocumentPartObject
- Throws:
InvalidFormatException
-
CreateHeaderPartObject
- Throws:
InvalidFormatException
-
CreateNumberingPartObject
- Throws:
InvalidFormatException
-
CreateObfuscatedFontPartObject
- Throws:
InvalidFormatException
-
addDefaultContentType
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.
-
addDefaultContentType
-
addOverrideContentType
- Parameters:
partName-contentType-- Since:
- 6.1.0
-
removeContentType
Deprecated.Delete a content type based on the specified part name. If the specified part name is registered with an override content type, then this content type is removed, else the content type is removed in the default content type list if it exists. Deprecated since you'd typically NOT want to accidentally remove *.xml or *.rels from the default Content type list- Parameters:
partUri- The part URI associated with the override content type to delete.
-
removeOverrideContentType
Delete an override content type based on the specified part name.- Parameters:
partUri- The part URI associated with the override content type to delete.- Since:
- 6.1.0
-
removeDefaultContentType
Delete a default content type based on the specified part name. Note that you'd typically NOT want to remove *.xml or *.rels from the default Content type list- Parameters:
partUri- The part URI associated with the override content type to delete.- Since:
- 6.1.0
-
isContentTypeRegistered
Check if the specified content type is already registered as a default content type. We don't currently have a method to check whether its registered as an override content type; getContentType(PartName partName) may suffice for that purpose.- Parameters:
contentType- The content type to check.- Returns:
trueif the specified content type is already registered, thenfalse.
-
isOverrideContentTypeRegistered
Check if the specified content type is already registered as a default content type. We don't currently have a method to check whether its registered as an override content type; getContentType(PartName partName) may suffice for that purpose.- Parameters:
contentType- The content type to check.- Returns:
trueif the specified content type is already registered, thenfalse.- Since:
- 6.1.0
-
getContentType
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.
-
clearAll
public void clearAll()Clear all content types. -
clearOverrideContentTypes
public void clearOverrideContentTypes()Clear all override content types. -
parseContentTypesFile
- Throws:
InvalidFormatException
-
marshal
- Throws:
jakarta.xml.bind.JAXBException
-
marshal
- Throws:
jakarta.xml.bind.JAXBException
-
createPackage
Return a package of the appropriate type. Used when loading an existing Package, with an already populated [Content_Types].xml. When creating a new Package, start with the new WordprocessingMLPackage constructor.- Throws:
InvalidFormatException
-
isContentEqual
- Throws:
Docx4JException
-
toString
-