Package org.apache.poi.ooxml
Class POIXMLDocumentPart
- java.lang.Object
-
- org.apache.poi.ooxml.POIXMLDocumentPart
-
- Direct Known Subclasses:
CalculationChain
,CommentsTable
,ExternalLinksTable
,MapInfo
,POIXMLDocument
,SharedStringsTable
,SingleXmlCells
,StylesTable
,ThemesTable
,org.apache.poi.xddf.usermodel.chart.XDDFChart
,XDGFXMLDocumentPart
,XSLFCommentAuthors
,XSLFComments
,XSLFObjectData
,XSLFPictureData
,XSLFSheet
,XSLFTableStyles
,XSLFTheme
,XSSFDrawing
,XSSFPictureData
,XSSFPivotCache
,XSSFPivotCacheDefinition
,XSSFPivotCacheRecords
,XSSFPivotTable
,XSSFSheet
,XSSFTable
,XSSFVBAPart
,XSSFVMLDrawing
,XWPFAbstractFootnotesEndnotes
,XWPFHeaderFooter
,XWPFNumbering
,XWPFPictureData
,XWPFSettings
,XWPFStyles
public class POIXMLDocumentPart extends Object
Represents an entry of a OOXML package.Each POIXMLDocumentPart keeps a reference to the underlying a
PackagePart
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
POIXMLDocumentPart.RelationPart
The RelationPart is a cached relationship between the document, which contains the RelationPart, and one of its referenced child document parts.
-
Constructor Summary
Constructors Constructor Description POIXMLDocumentPart()
Creates new POIXMLDocumentPart - called by client code to create new parts from scratch.POIXMLDocumentPart(POIXMLDocumentPart parent, PackagePart part)
Creates an POIXMLDocumentPart representing the given package part, relationship and parent Called byread(POIXMLFactory, java.util.Map)
when reading in an existing file.POIXMLDocumentPart(OPCPackage pkg)
Construct POIXMLDocumentPart representing a "core document" package part.POIXMLDocumentPart(OPCPackage pkg, String coreDocumentRel)
Construct POIXMLDocumentPart representing a custom "core document" package part.POIXMLDocumentPart(PackagePart part)
Creates an POIXMLDocumentPart representing the given package part and relationship.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
_invokeOnDocumentRead(POIXMLDocumentPart part)
Deprecated.POIXMLDocumentPart.RelationPart
addRelation(String relId, POIXMLRelation relationshipType, POIXMLDocumentPart part)
Add a new child POIXMLDocumentPartPOIXMLDocumentPart
createRelationship(POIXMLRelation descriptor, POIXMLFactory factory)
Create a new child POIXMLDocumentPartPOIXMLDocumentPart
createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx)
Create a new child POIXMLDocumentPartPOIXMLDocumentPart.RelationPart
createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, boolean noRelation)
Create a new child POIXMLDocumentPartPackagePart
getPackagePart()
Provides access to the underlying PackagePartPOIXMLDocumentPart
getParent()
Returns the parent POIXMLDocumentPart.POIXMLDocumentPart
getRelationById(String id)
Returns the targetPOIXMLDocumentPart
, where aPackageRelationship
is set from thePackagePart
of thisPOIXMLDocumentPart
to thePackagePart
of the targetPOIXMLDocumentPart
with aPackageRelationship.getId()
matching the given parameter value.String
getRelationId(POIXMLDocumentPart part)
Returns the firstPackageRelationship.getId()
of thePackageRelationship
, that sources from thePackagePart
of thisPOIXMLDocumentPart
to thePackagePart
of the given parameter value.POIXMLDocumentPart.RelationPart
getRelationPartById(String id)
Returns the targetPOIXMLDocumentPart.RelationPart
, where aPackageRelationship
is set from thePackagePart
of thisPOIXMLDocumentPart
to thePackagePart
of the targetPOIXMLDocumentPart
with aPackageRelationship.getId()
matching the given parameter value.List<POIXMLDocumentPart.RelationPart>
getRelationParts()
Returns the list of child relations for this POIXMLDocumentPartList<POIXMLDocumentPart>
getRelations()
Returns the list of child relations for this POIXMLDocumentPartboolean
isCommited()
to check whether embedded part is already committedvoid
setCommited(boolean isCommited)
setter method to set embedded part is committedString
toString()
-
-
-
Constructor Detail
-
POIXMLDocumentPart
public POIXMLDocumentPart(OPCPackage pkg)
Construct POIXMLDocumentPart representing a "core document" package part.- Parameters:
pkg
- the OPCPackage containing this document
-
POIXMLDocumentPart
public POIXMLDocumentPart(OPCPackage pkg, String coreDocumentRel)
Construct POIXMLDocumentPart representing a custom "core document" package part.- Parameters:
pkg
- the OPCPackage containing this documentcoreDocumentRel
- the relation type of this document
-
POIXMLDocumentPart
public POIXMLDocumentPart()
Creates new POIXMLDocumentPart - called by client code to create new parts from scratch.
-
POIXMLDocumentPart
public POIXMLDocumentPart(PackagePart part)
Creates an POIXMLDocumentPart representing the given package part and relationship. Called byread(POIXMLFactory, java.util.Map)
when reading in an existing file.- Parameters:
part
- - The package part that holds xml data representing this sheet.- Since:
- POI 3.14-Beta1
- See Also:
read(POIXMLFactory, java.util.Map)
-
POIXMLDocumentPart
public POIXMLDocumentPart(POIXMLDocumentPart parent, PackagePart part)
Creates an POIXMLDocumentPart representing the given package part, relationship and parent Called byread(POIXMLFactory, java.util.Map)
when reading in an existing file.- Parameters:
parent
- - Parent partpart
- - The package part that holds xml data representing this sheet.- Since:
- POI 3.14-Beta1
- See Also:
read(POIXMLFactory, java.util.Map)
-
-
Method Detail
-
isCommited
public boolean isCommited()
to check whether embedded part is already committed- Returns:
- return true if embedded part is committed
-
setCommited
public void setCommited(boolean isCommited)
setter method to set embedded part is committed- Parameters:
isCommited
- boolean value
-
getPackagePart
public final PackagePart getPackagePart()
Provides access to the underlying PackagePart- Returns:
- the underlying PackagePart
-
getRelations
public final List<POIXMLDocumentPart> getRelations()
Returns the list of child relations for this POIXMLDocumentPart- Returns:
- child relations
-
getRelationParts
public final List<POIXMLDocumentPart.RelationPart> getRelationParts()
Returns the list of child relations for this POIXMLDocumentPart- Returns:
- child relations
-
getRelationById
public final POIXMLDocumentPart getRelationById(String id)
Returns the targetPOIXMLDocumentPart
, where aPackageRelationship
is set from thePackagePart
of thisPOIXMLDocumentPart
to thePackagePart
of the targetPOIXMLDocumentPart
with aPackageRelationship.getId()
matching the given parameter value.- Parameters:
id
- The relation id to look for- Returns:
- the target part of the relation, or null, if none exists
-
getRelationPartById
public final POIXMLDocumentPart.RelationPart getRelationPartById(String id)
Returns the targetPOIXMLDocumentPart.RelationPart
, where aPackageRelationship
is set from thePackagePart
of thisPOIXMLDocumentPart
to thePackagePart
of the targetPOIXMLDocumentPart
with aPackageRelationship.getId()
matching the given parameter value.- Parameters:
id
- The relation id to look for- Returns:
- the target relation part, or null, if none exists
- Since:
- 4.0.0
-
getRelationId
public final String getRelationId(POIXMLDocumentPart part)
Returns the firstPackageRelationship.getId()
of thePackageRelationship
, that sources from thePackagePart
of thisPOIXMLDocumentPart
to thePackagePart
of the given parameter value.There can be multiple references to the given
POIXMLDocumentPart
and only the first in the order of creation is returned.- Parameters:
part
- ThePOIXMLDocumentPart
for which the according relation-id shall be found.- Returns:
- The value of the
PackageRelationship.getId()
or null, if parts are not related.
-
addRelation
public final POIXMLDocumentPart.RelationPart addRelation(String relId, POIXMLRelation relationshipType, POIXMLDocumentPart part)
Add a new child POIXMLDocumentPart- Parameters:
relId
- the preferred relation id, when null the next free relation id will be usedrelationshipType
- the package relationship typepart
- the child to add- Returns:
- the new RelationPart
- Since:
- 3.14-Beta1
-
getParent
public final POIXMLDocumentPart getParent()
Returns the parent POIXMLDocumentPart. All parts except root have not-null parent.- Returns:
- the parent POIXMLDocumentPart or
null
for the root element.
-
createRelationship
public final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory)
Create a new child POIXMLDocumentPart- Parameters:
descriptor
- the part descriptorfactory
- the factory that will create an instance of the requested relation- Returns:
- the created child POIXMLDocumentPart
- Throws:
PartAlreadyExistsException
- If rule M1.12 is not verified : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names.
-
createRelationship
public final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx)
Create a new child POIXMLDocumentPart- Parameters:
descriptor
- the part descriptorfactory
- the factory that will create an instance of the requested relationidx
- part number- Returns:
- the created child POIXMLDocumentPart
- Throws:
PartAlreadyExistsException
- If rule M1.12 is not verified : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names.
-
createRelationship
public final POIXMLDocumentPart.RelationPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, boolean noRelation)
Create a new child POIXMLDocumentPart- Parameters:
descriptor
- the part descriptorfactory
- the factory that will create an instance of the requested relationidx
- part numbernoRelation
- if true, then no relationship is added.- Returns:
- the created child POIXMLDocumentPart
- Throws:
PartAlreadyExistsException
- If rule M1.12 is not verified : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names.
-
_invokeOnDocumentRead
@Internal @Deprecated public static void _invokeOnDocumentRead(POIXMLDocumentPart part) throws IOException
Deprecated.Internal method, do not use!This method only exists to allow access to protected
onDocumentRead()
fromXWPFDocument
without reflection. It should be removed.- Parameters:
part
- the part which is to be read- Throws:
IOException
- if the part can't be read
-
-