org.apache.poi
public class POIXMLDocumentPart extends java.lang.Object
Each POIXMLDocumentPart keeps a reference to the underlying a PackagePart
.
Modifier and Type | Field and Description |
---|---|
static XmlOptions |
DEFAULT_XML_OPTIONS |
Constructor and Description |
---|
POIXMLDocumentPart()
Creates new POIXMLDocumentPart - called by client code to create new parts from scratch.
|
POIXMLDocumentPart(OPCPackage pkg)
Construct POIXMLDocumentPart representing a "core document" package part.
|
POIXMLDocumentPart(PackagePart part,
PackageRelationship rel)
Creates an POIXMLDocumentPart representing the given package part and relationship.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addRelation(POIXMLDocumentPart part)
Add a new child POIXMLDocumentPart
|
protected void |
commit()
Save the content in the underlying package part.
|
POIXMLDocumentPart |
createRelationship(POIXMLRelation descriptor,
POIXMLFactory factory)
Create a new child POIXMLDocumentPart
|
POIXMLDocumentPart |
createRelationship(POIXMLRelation descriptor,
POIXMLFactory factory,
int idx) |
protected POIXMLDocumentPart |
createRelationship(POIXMLRelation descriptor,
POIXMLFactory factory,
int idx,
boolean noRelation)
Create a new child POIXMLDocumentPart
|
PackagePart |
getPackagePart()
Provides access to the underlying PackagePart
|
PackageRelationship |
getPackageRelationship()
Provides access to the PackageRelationship that identifies this POIXMLDocumentPart
|
POIXMLDocumentPart |
getParent()
Returns the parent POIXMLDocumentPart.
|
java.util.List<POIXMLDocumentPart> |
getRelations()
Returns the list of child relations for this POIXMLDocumentPart
|
protected void |
onDocumentCreate()
Fired when a new package part is created
|
protected void |
onDocumentRead()
Fired when a package part is read
|
protected void |
onSave(java.util.Set<PackagePart> alreadySaved)
Save changes in the underlying OOXML package.
|
protected void |
read(POIXMLFactory factory,
java.util.Map<PackagePart,POIXMLDocumentPart> context)
Iterate through the underlying PackagePart and create child POIXMLFactory instances
using the specified factory
|
void |
removeRelation(POIXMLDocumentPart part)
Remove the specified part in this package.
|
java.lang.String |
toString() |
public POIXMLDocumentPart(OPCPackage pkg)
public POIXMLDocumentPart()
public POIXMLDocumentPart(PackagePart part, PackageRelationship rel)
read(POIXMLFactory, java.util.Map)
when reading in an exisiting file.part
- - The package part that holds xml data represenring this sheet.rel
- - the relationship of the given package partread(POIXMLFactory, java.util.Map)
public final PackagePart getPackagePart()
public final PackageRelationship getPackageRelationship()
public final java.util.List<POIXMLDocumentPart> getRelations()
protected final void addRelation(POIXMLDocumentPart part)
part
- the child to addpublic final void removeRelation(POIXMLDocumentPart part)
public final POIXMLDocumentPart getParent()
null
for the root element.public java.lang.String toString()
toString
in class java.lang.Object
protected void commit() throws java.io.IOException
protected void commit() throws IOException {
PackagePart part = getPackagePart();
OutputStream out = part.getOutputStream();
XmlObject bean = getXmlBean(); //the "model" which holds changes in memory
bean.save(out, DEFAULT_XML_OPTIONS);
out.close();
}
java.io.IOException
protected final void onSave(java.util.Set<PackagePart> alreadySaved) throws java.io.IOException
commit()
for each package partalreadySaved
- context set containing already visited nodesjava.io.IOException
public final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory)
descriptor
- the part descriptorfactory
- the factory that will create an instance of the requested relationpublic final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx)
protected final POIXMLDocumentPart createRelationship(POIXMLRelation descriptor, POIXMLFactory factory, int idx, boolean noRelation)
descriptor
- the part descriptorfactory
- the factory that will create an instance of the requested relationidx
- part numbernoRelation
- if true, then no relationship is added.protected void read(POIXMLFactory factory, java.util.Map<PackagePart,POIXMLDocumentPart> context) throws OpenXML4JException
factory
- the factory object that creates POIXMLFactory instancescontext
- context map containing already visited noted keyed by targetURIOpenXML4JException
protected void onDocumentCreate() throws java.io.IOException
java.io.IOException
protected void onDocumentRead() throws java.io.IOException
java.io.IOException
Copyright 2014 The Apache Software Foundation or its licensors, as applicable.