|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.poi.openxml4j.opc.PackagePart
public abstract class PackagePart
Provides a base class for parts stored in a Package.
| Field Summary | |
|---|---|
protected OPCPackage |
_container
This part's container. |
protected ContentType |
_contentType
The type of content of this part. |
protected PackagePartName |
_partName
The part name. |
| Constructor Summary | |
|---|---|
protected |
PackagePart(OPCPackage pack,
PackagePartName partName,
ContentType contentType)
Constructor. |
protected |
PackagePart(OPCPackage pack,
PackagePartName partName,
ContentType contentType,
boolean loadRelationships)
Constructor. |
|
PackagePart(OPCPackage pack,
PackagePartName partName,
java.lang.String contentType)
Constructor. |
| Method Summary | |
|---|---|
PackageRelationship |
addExternalRelationship(java.lang.String target,
java.lang.String relationshipType)
Adds an external relationship to a part (except relationships part). |
PackageRelationship |
addExternalRelationship(java.lang.String target,
java.lang.String relationshipType,
java.lang.String id)
Adds an external relationship to a part (except relationships part). |
PackageRelationship |
addRelationship(PackagePartName targetPartName,
TargetMode targetMode,
java.lang.String relationshipType)
Add a relationship to a part (except relationships part). |
PackageRelationship |
addRelationship(PackagePartName targetPartName,
TargetMode targetMode,
java.lang.String relationshipType,
java.lang.String id)
Add a relationship to a part (except relationships part). |
PackageRelationship |
addRelationship(java.net.URI targetURI,
TargetMode targetMode,
java.lang.String relationshipType)
Add a relationship to a part (except relationships part). |
PackageRelationship |
addRelationship(java.net.URI targetURI,
TargetMode targetMode,
java.lang.String relationshipType,
java.lang.String id)
Add a relationship to a part (except relationships part). |
void |
clear()
Allows sub-classes to clean up before new data is added. |
void |
clearRelationships()
Delete all the relationships attached to this. |
abstract void |
close()
Close this part : flush this part, close the input stream and output stream. |
int |
compareTo(PackagePart other)
Compare based on the package part name, using a natural sort order |
PackageRelationship |
findExistingRelation(PackagePart packagePart)
Check if the new part was already added before via PackagePart.addRelationship() |
abstract void |
flush()
Flush the content of this part. |
java.lang.String |
getContentType()
|
ContentType |
getContentTypeDetails()
|
java.io.InputStream |
getInputStream()
Get the input stream of this part to read its content. |
protected abstract java.io.InputStream |
getInputStreamImpl()
Abstract method that get the input stream of this part. |
java.io.OutputStream |
getOutputStream()
Get the output stream of this part. |
protected abstract java.io.OutputStream |
getOutputStreamImpl()
Abstract method that get the output stream of this part. |
OPCPackage |
getPackage()
|
PackagePartName |
getPartName()
|
PackagePart |
getRelatedPart(PackageRelationship rel)
Get the PackagePart that is the target of a relationship. |
PackageRelationship |
getRelationship(java.lang.String id)
Retrieves a package relationship from its id. |
PackageRelationshipCollection |
getRelationships()
Retrieve all the relationships attached to this part. |
PackageRelationshipCollection |
getRelationshipsByType(java.lang.String relationshipType)
Retrieve all relationships attached to this part which have the specified type. |
long |
getSize()
|
boolean |
hasRelationships()
Knows if the part have any relationships. |
boolean |
isDeleted()
|
boolean |
isRelationshipExists(PackageRelationship rel)
Checks if the specified relationship is part of this package part. |
boolean |
isRelationshipPart()
|
abstract boolean |
load(java.io.InputStream ios)
Load the content of this part. |
void |
removeRelationship(java.lang.String id)
Delete the relationship specified by its id. |
abstract boolean |
save(java.io.OutputStream zos)
Save the content of this part and the associated relationships part (if this part own at least one relationship) into the specified output stream. |
void |
setContentType(java.lang.String contentType)
Set the content type. |
void |
setDeleted(boolean isDeleted)
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected OPCPackage _container
protected PackagePartName _partName
protected ContentType _contentType
| Constructor Detail |
|---|
protected PackagePart(OPCPackage pack,
PackagePartName partName,
ContentType contentType)
throws InvalidFormatException
pack - Parent package.partName - The part name, relative to the parent Package root.contentType - The content type.
InvalidFormatException - If the specified URI is not valid.
protected PackagePart(OPCPackage pack,
PackagePartName partName,
ContentType contentType,
boolean loadRelationships)
throws InvalidFormatException
pack - Parent package.partName - The part name, relative to the parent Package root.contentType - The content type.loadRelationships - Specify if the relationships will be loaded
InvalidFormatException - If the specified URI is not valid.
public PackagePart(OPCPackage pack,
PackagePartName partName,
java.lang.String contentType)
throws InvalidFormatException
pack - Parent package.partName - The part name, relative to the parent Package root.contentType - The Multipurpose Internet Mail Extensions (MIME) content type
of the part's data stream.
InvalidFormatException| Method Detail |
|---|
public PackageRelationship findExistingRelation(PackagePart packagePart)
packagePart - to find the relationship for
public PackageRelationship addExternalRelationship(java.lang.String target,
java.lang.String relationshipType)
addExternalRelationship in interface RelationshipSourcetarget - External target of the relationshiprelationshipType - Type of relationship.
RelationshipSource.addExternalRelationship(java.lang.String,
java.lang.String)
public PackageRelationship addExternalRelationship(java.lang.String target,
java.lang.String relationshipType,
java.lang.String id)
addExternalRelationship in interface RelationshipSourcetarget - External target of the relationshiprelationshipType - Type of relationship.id - Relationship unique id.
RelationshipSource.addExternalRelationship(java.lang.String,
java.lang.String)
public PackageRelationship addRelationship(PackagePartName targetPartName,
TargetMode targetMode,
java.lang.String relationshipType)
addRelationship in interface RelationshipSourcetargetPartName - Name of the target part. This one must be relative to the
source root directory of the part.targetMode - Mode [Internal|External].relationshipType - Type of relationship.
RelationshipSource.addRelationship(org.apache.poi.openxml4j.opc.PackagePartName,
org.apache.poi.openxml4j.opc.TargetMode, java.lang.String)
public PackageRelationship addRelationship(PackagePartName targetPartName,
TargetMode targetMode,
java.lang.String relationshipType,
java.lang.String id)
Check rule M1.25: The Relationships part shall not have relationships to any other part. Package implementers shall enforce this requirement upon the attempt to create such a relationship and shall treat any such relationship as invalid.
addRelationship in interface RelationshipSourcetargetPartName - Name of the target part. This one must be relative to the
source root directory of the part.targetMode - Mode [Internal|External].relationshipType - Type of relationship.id - Relationship unique id.
InvalidOperationException - If a writing operation is done on a read only package or
invalid nested relations are created.
java.lang.IllegalArgumentException - if targetPartName, targetMode
or relationshipType are passed as nullRelationshipSource.addRelationship(org.apache.poi.openxml4j.opc.PackagePartName,
org.apache.poi.openxml4j.opc.TargetMode, java.lang.String, java.lang.String)
public PackageRelationship addRelationship(java.net.URI targetURI,
TargetMode targetMode,
java.lang.String relationshipType)
targetURI - URI the target part. Must be relative to the source root
directory of the part.targetMode - Mode [Internal|External].relationshipType - Type of relationship.
RelationshipSource.addRelationship(org.apache.poi.openxml4j.opc.PackagePartName,
org.apache.poi.openxml4j.opc.TargetMode, java.lang.String)
public PackageRelationship addRelationship(java.net.URI targetURI,
TargetMode targetMode,
java.lang.String relationshipType,
java.lang.String id)
Check rule M1.25: The Relationships part shall not have relationships to any other part. Package implementers shall enforce this requirement upon the attempt to create such a relationship and shall treat any such relationship as invalid.
targetURI - URI of the target part. Must be relative to the source root
directory of the part.targetMode - Mode [Internal|External].relationshipType - Type of relationship.id - Relationship unique id.
InvalidOperationException - If the URI point to a relationship part URI.RelationshipSource.addRelationship(org.apache.poi.openxml4j.opc.PackagePartName,
org.apache.poi.openxml4j.opc.TargetMode, java.lang.String, java.lang.String)public void clearRelationships()
RelationshipSource
clearRelationships in interface RelationshipSourceRelationshipSource.clearRelationships()public void removeRelationship(java.lang.String id)
removeRelationship in interface RelationshipSourceid - The ID identified the part to delete.RelationshipSource.removeRelationship(java.lang.String)
public PackageRelationshipCollection getRelationships()
throws InvalidFormatException
getRelationships in interface RelationshipSourceInvalidOperationException - Throws if the package is open en write only mode.
InvalidFormatExceptionRelationshipSource.getRelationships()public PackageRelationship getRelationship(java.lang.String id)
getRelationship in interface RelationshipSourceid - ID of the package relationship to retrieve.
RelationshipSource.getRelationship(java.lang.String)
public PackageRelationshipCollection getRelationshipsByType(java.lang.String relationshipType)
throws InvalidFormatException
getRelationshipsByType in interface RelationshipSourcerelationshipType - Relationship type filter.
InvalidFormatException - If an error occurs while parsing the part.
InvalidOperationException - If the package is open in write only mode.RelationshipSource.getRelationshipsByType(java.lang.String)public boolean hasRelationships()
hasRelationships in interface RelationshipSourceRelationshipSource.hasRelationships()public boolean isRelationshipExists(PackageRelationship rel)
isRelationshipExists in interface RelationshipSourcerel - The relationship to check.
RelationshipSource.isRelationshipExists(org.apache.poi.openxml4j.opc.PackageRelationship)
public PackagePart getRelatedPart(PackageRelationship rel)
throws InvalidFormatException
rel - A relationship from this part to another one
InvalidFormatException
public java.io.InputStream getInputStream()
throws java.io.IOException
null.
java.io.IOException - If creating the input-stream fails.public java.io.OutputStream getOutputStream()
MemoryPackagePartpublic PackagePartName getPartName()
public java.lang.String getContentType()
public ContentType getContentTypeDetails()
public void setContentType(java.lang.String contentType)
throws InvalidFormatException
contentType - the contentType to set
InvalidFormatException - Throws if the content type is not valid.
InvalidOperationException - Throws if you try to change the content type whereas this
part is already attached to a package.public OPCPackage getPackage()
public boolean isRelationshipPart()
public boolean isDeleted()
public void setDeleted(boolean isDeleted)
isDeleted - the isDeleted to setpublic long getSize()
public java.lang.String toString()
toString in class java.lang.Objectpublic int compareTo(PackagePart other)
compareTo in interface java.lang.Comparable<PackagePart>
protected abstract java.io.InputStream getInputStreamImpl()
throws java.io.IOException
java.io.IOException - Throws if an IO Exception occur in the implementation
method.protected abstract java.io.OutputStream getOutputStreamImpl()
public abstract boolean save(java.io.OutputStream zos)
throws OpenXML4JException
zos - Output stream to save this part.
OpenXML4JException - If any exception occur.
public abstract boolean load(java.io.InputStream ios)
throws InvalidFormatException
ios - The input stream of the content to load.
InvalidFormatException - Throws if the content format is invalid.public abstract void close()
public abstract void flush()
public void clear()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||