Package org.docx4j.openpackaging
Class Base
java.lang.Object
org.docx4j.openpackaging.Base
- Direct Known Subclasses:
OpcPackage,Part
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ContentTypeprotected static org.slf4j.LoggerDeprecated.relationships - the package and each part can have one of these See eg 11. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddTargetPart(Part targetpart) Convenience method to add a part to this Part's relationships.addTargetPart(Part targetpart, String proposedRelId) Convenience method to add a part to this Part's relationships.addTargetPart(Part targetpart, RelationshipsPart.AddPartBehaviour mode) Convenience method to add a part to this Part's relationships.addTargetPart(Part targetpart, RelationshipsPart.AddPartBehaviour mode, String proposedRelId) Convenience method to add a part to this Part's relationships.abstract OpcPackageGet the relationship part.getRelationshipsPart(boolean createIfAbsent) Get the relationship part.getUserData(String key) voidreset()Reinit fields so this pkg object can be re-used.voidsetContentType(ContentType contentType) voidsetPartName(PartName partName) abstract booleansetPartShortcut(Part part, String relationshipType) Tell the source Part about this target Part, so the source can use this part via a convenience method.voidsetRelationships(RelationshipsPart relationships) voidsetUserData(String key, Object value) An object allowing the user of the docx4j API to associate arbitrary data with this package/part while the package is in memory.
-
Field Details
-
log
protected static org.slf4j.Logger log -
relationships
relationships - the package and each part can have one of these See eg 11. WordprocessingML [11.2 Package Structure]. (Each Part is also the _target_ of a RelationshipPart, so see Part for definition of a corresponding field.) -
contentType
-
partName
Deprecated.The part name. (required by the specification [M1.1]) You should use the getter/setter, rather than accessing this field directly! Note that in docx4J, part names should be resolved, before being set, so that they are absolute (ie start with '/'). We will assume the Package has a part name of "/"
-
-
Constructor Details
-
Base
public Base()
-
-
Method Details
-
getPackage
-
getUserData
- Parameters:
key-- Returns:
-
setUserData
An object allowing the user of the docx4j API to associate arbitrary data with this package/part while the package is in memory. Note that the data is not saved when the package is saved.- Parameters:
key-value-
-
getRelationshipsPart
Get the relationship part. From 2.7.1, the part will be created if it doesn't exist. (SaveToZipFile will only save it if it contains rels)- Returns:
- The relationship part name.
-
getRelationshipsPart
Get the relationship part.- Parameters:
create- whether to create it if it doesn't exist- Returns:
- Since:
- 2.7.1
-
setRelationships
-
getContentType
-
setContentType
-
setPartName
- Parameters:
partName-- Since:
- 3.2.0
-
getPartName
- Returns:
- the uri
-
setPartShortcut
Tell the source Part about this target Part, so the source can use this part via a convenience method.- Parameters:
part-relationshipType-- Returns:
- true if the source Part does use the target Part in a convenience method.
-
addTargetPart
public Relationship addTargetPart(Part targetpart, RelationshipsPart.AddPartBehaviour mode) throws InvalidFormatException Convenience method to add a part to this Part's relationships. The package must be set on this part in order for this to work.- Parameters:
targetpart- The part to add to this part's relationshipsmode- whether to overwrite, rename or abort if the part name already existsproposedRelId-- Returns:
- Throws:
InvalidFormatException- Since:
- 2.7.1
-
addTargetPart
Convenience method to add a part to this Part's relationships. The package must be set on this part in order for this to work. The added part will replace any existing part with the same name (ie same target in the rels part). In other words, if you want to use the one image as the target of 2 rels, don't use this method.- Parameters:
targetpart- The part to add to this part's relationships- Throws:
InvalidFormatException
-
addTargetPart
public Relationship addTargetPart(Part targetpart, String proposedRelId) throws InvalidFormatException Convenience method to add a part to this Part's relationships. The package must be set on this part in order for this to work. The added part will replace any existing part with the same name (ie same target in the rels part). In other words, if you want to use the one image as the target of 2 rels, don't use this method.- Parameters:
targetpart- The part to add to this part's relationships- Throws:
InvalidFormatException
-
addTargetPart
public Relationship addTargetPart(Part targetpart, RelationshipsPart.AddPartBehaviour mode, String proposedRelId) throws InvalidFormatException Convenience method to add a part to this Part's relationships. The package must be set on this part in order for this to work. Whether the added part will replace any existing part with the same name depends on AddPartBehaviour setting.- Parameters:
targetpart- The part to add to this part's relationshipsmode- whether to overwrite, rename or abort if the part name already existsproposedRelId-- Returns:
- Throws:
InvalidFormatException- Since:
- 2.7.1
-
reset
public void reset()Reinit fields so this pkg object can be re-used.- Since:
- 3.3.7
-