public abstract class PackagePart extends java.lang.Object implements RelationshipSource, java.lang.Comparable<PackagePart>
Modifier and Type | Field and Description |
---|---|
protected OPCPackage |
_container
This part's container.
(这部分的容器。)
|
protected ContentType |
_contentType
The type of content of this part.
(此部分的内容类型。)
|
protected PackagePartName |
_partName
The part name.
(零件名称。)
|
Modifier | Constructor and Description |
---|---|
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.
(构造函数。)
|
Modifier and Type | Method and Description |
---|---|
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()
(通过 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()
Method that gets the input stream for this part.
(获取此部分的输入流的方法。)
|
java.io.OutputStream |
getOutputStream()
Get the output stream of this part.
(获取这部分的输出流。)
|
protected abstract java.io.OutputStream |
getOutputStreamImpl()
Method that gets the output stream for this part.
(获取此部分的输出流的方法。)
|
OPCPackage |
getPackage() |
PackagePartName |
getPartName() |
PackagePart |
getRelatedPart(PackageRelationship rel)
Get the PackagePart that is the target of a relationship.
(获取作为关系目标的 PackagePart。)
|
PackageRelationship |
getRelationship(java.lang.String id)
Retrieves a package relationship from its id.
(从其 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.
(删除由其 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() |
protected OPCPackage _container
protected PackagePartName _partName
protected ContentType _contentType
protected PackagePart(OPCPackage pack, PackagePartName partName, ContentType contentType) throws InvalidFormatException
pack
- Parent package.
(pack - 父包。)
partName
- The part name, relative to the parent Package root.
(partName - 相对于父包根的部件名称。)
contentType
- The content type.
(contentType - 内容类型。)
InvalidFormatException
- If the specified URI is not valid.
(InvalidFormatException - 如果指定的 URI 无效。)
protected PackagePart(OPCPackage pack, PackagePartName partName, ContentType contentType, boolean loadRelationships) throws InvalidFormatException
pack
- Parent package.
(pack - 父包。)
partName
- The part name, relative to the parent Package root.
(partName - 相对于父包根的部件名称。)
contentType
- The content type.
(contentType - 内容类型。)
loadRelationships
- Specify if the relationships will be loaded
(loadRelationships - 指定是否加载关系)
InvalidFormatException
- If the specified URI is not valid.
(InvalidFormatException - 如果指定的 URI 无效。)
public PackagePart(OPCPackage pack, PackagePartName partName, java.lang.String contentType) throws InvalidFormatException
pack
- Parent package.
(pack - 父包。)
partName
- The part name, relative to the parent Package root.
(partName - 相对于父包根的部件名称。)
contentType
- The Multipurpose Internet Mail Extensions (MIME) content type of the part's data stream.
(contentType - 部件数据流的多用途 Internet 邮件扩展 (MIME) 内容类型。)
InvalidFormatException
- If the specified URI is not valid.
(InvalidFormatException - 如果指定的 URI 无效。)
public PackageRelationship findExistingRelation(PackagePart packagePart)
packagePart
- to find the relationship for
(packagePart - 查找关系)
public PackageRelationship addExternalRelationship(java.lang.String target, java.lang.String relationshipType)
addExternalRelationship
in interface
RelationshipSource
(接口RelationshipSource中的addExternalRelationship)
target
- External target of the relationship
(target - 关系的外部目标)
relationshipType
- Type of relationship.
(relationshipType - 关系类型。)
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
RelationshipSource
(接口RelationshipSource中的addExternalRelationship)
target
- External target of the relationship
(target - 关系的外部目标)
relationshipType
- Type of relationship.
(relationshipType - 关系类型。)
id
- Relationship unique id.
(id - 关系唯一 ID。)
RelationshipSource.addExternalRelationship(java.lang.String, java.lang.String)
public PackageRelationship addRelationship(PackagePartName targetPartName, TargetMode targetMode, java.lang.String relationshipType)
addRelationship
in interface
RelationshipSource
(接口RelationshipSource中的addRelationship)
targetPartName
- Name of the target part. This one must be relative to the source root directory of the part.
(targetPartName - 目标部件的名称。这个必须相对于部件的源根目录。)
targetMode
- Mode [Internal|External].
(targetMode - 模式 [内部|外部]。)
relationshipType
- Type of relationship.
(relationshipType - 关系类型。)
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.
(向零件添加关系(关系零件除外)。检查规则 M1.25:Relationships 部分不应与任何其他部分有关系。包实施者应在尝试创建此类关系时强制执行此要求,并将任何此类关系视为无效。)addRelationship
in interface
RelationshipSource
(接口RelationshipSource中的addRelationship)
targetPartName
- Name of the target part. This one must be relative to the source root directory of the part.
(targetPartName - 目标部件的名称。这个必须相对于部件的源根目录。)
targetMode
- Mode [Internal|External].
(targetMode - 模式 [内部|外部]。)
relationshipType
- Type of relationship.
(relationshipType - 关系类型。)
id
- Relationship unique id.
(id - 关系唯一 ID。)
InvalidOperationException
- If a writing operation is done on a read only package or invalid nested relations are created.
(InvalidOperationException - 如果对只读包执行写入操作或创建了无效的嵌套关系。)
java.lang.IllegalArgumentException
- if targetPartName, targetMode or relationshipType are passed as null
(java.lang.IllegalArgumentException - 如果 targetPartName、targetMode 或 relationshipType 作为 null 传递)
RelationshipSource.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.
(targetURI - URI 目标部分。必须相对于部件的源根目录。)
targetMode
- Mode [Internal|External].
(targetMode - 模式 [内部|外部]。)
relationshipType
- Type of relationship.
(relationshipType - 关系类型。)
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.
(向零件添加关系(关系零件除外)。检查规则 M1.25:Relationships 部分不应与任何其他部分有关系。包实施者应在尝试创建此类关系时强制执行此要求,并将任何此类关系视为无效。)targetURI
- URI of the target part. Must be relative to the source root directory of the part.
(targetURI - 目标部分的 URI。必须相对于部件的源根目录。)
targetMode
- Mode [Internal|External].
(targetMode - 模式 [内部|外部]。)
relationshipType
- Type of relationship.
(relationshipType - 关系类型。)
id
- Relationship unique id.
(id - 关系唯一 ID。)
InvalidOperationException
- If the URI point to a relationship part URI.
(InvalidOperationException - 如果 URI 指向关系部分 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
RelationshipSource
(接口RelationshipSource中的clearRelationships)
RelationshipSource.clearRelationships()
public void removeRelationship(java.lang.String id)
removeRelationship
in interface
RelationshipSource
(接口RelationshipSource中的removeRelationship)
id
- The ID identified the part to delete.
(id - 标识要删除的部分的 ID。)
RelationshipSource.removeRelationship(java.lang.String)
public PackageRelationshipCollection getRelationships() throws InvalidFormatException
getRelationships
in interface
RelationshipSource
(接口RelationshipSource中的getRelationships)
InvalidOperationException
- Throws if the package is open en write only mode.
(InvalidOperationException - 如果包以只写模式打开,则抛出。)
InvalidFormatException
(无效格式异常)
RelationshipSource.getRelationships()
public PackageRelationship getRelationship(java.lang.String id)
getRelationship
in interface
RelationshipSource
(接口RelationshipSource中的getRelationship)
id
- ID of the package relationship to retrieve.
(id - 要检索的包关系的 ID。)
RelationshipSource.getRelationship(java.lang.String)
public PackageRelationshipCollection getRelationshipsByType(java.lang.String relationshipType) throws InvalidFormatException
getRelationshipsByType
in interface
RelationshipSource
(接口RelationshipSource中的getRelationshipsByType)
relationshipType
- Relationship type filter.
(relationshipType - 关系类型过滤器。)
InvalidFormatException
- If an error occurs while parsing the part.
(InvalidFormatException - 如果在解析部件时发生错误。)
InvalidOperationException
- If the package is open in write only mode.
(InvalidOperationException - 如果包以只写模式打开。)
RelationshipSource.getRelationshipsByType(java.lang.String)
public boolean hasRelationships()
hasRelationships
in interface
RelationshipSource
(接口RelationshipSource中的hasRelationships)
RelationshipSource.hasRelationships()
public boolean isRelationshipExists(PackageRelationship rel)
isRelationshipExists
in interface
RelationshipSource
(isRelationship存在于接口RelationshipSource中)
rel
- The relationship to check.
(rel - 要检查的关系。)
RelationshipSource.isRelationshipExists(org.apache.poi.openxml4j.opc.PackageRelationship)
public PackagePart getRelatedPart(PackageRelationship rel) throws InvalidFormatException
rel
- A relationship from this part to another one
(rel - 从这部分到另一部分的关系)
InvalidFormatException
- If the specified URI is not valid.
(InvalidFormatException - 如果指定的 URI 无效。)
public java.io.InputStream getInputStream() throws java.io.IOException
null
.
(本部分内容的输入流,否则为null。)
java.io.IOException
- If creating the input-stream fails.
(java.io.IOException - 如果创建输入流失败。)
public java.io.OutputStream getOutputStream()
MemoryPackagePart
public PackagePartName getPartName()
public java.lang.String getContentType()
public ContentType getContentTypeDetails()
public void setContentType(java.lang.String contentType) throws InvalidFormatException
contentType
- the contentType to set
(contentType - 要设置的 contentType)
InvalidFormatException
- Throws if the content type is not valid.
(InvalidFormatException - 如果内容类型无效则抛出。)
InvalidOperationException
- Throws if you try to change the content type whereas this part is already attached to a package.
(InvalidOperationException - 如果您尝试更改内容类型而此部分已附加到包,则抛出该异常。)
public OPCPackage getPackage()
public boolean isRelationshipPart()
public boolean isDeleted()
public void setDeleted(boolean isDeleted)
isDeleted
- the isDeleted to set
(isDeleted - 要设置的 isDeleted)
public long getSize()
public java.lang.String toString()
toString
in class
java.lang.Object
public int compareTo(PackagePart other)
compareTo
in interface
java.lang.Comparable<PackagePart>
(接口 java.lang.Comparable 中的 compareTo
protected abstract java.io.InputStream getInputStreamImpl() throws java.io.IOException
java.io.IOException
- Throws if an IO Exception occur in the implementation method.
(java.io.IOException - 如果在实现方法中发生 IO 异常,则抛出。)
protected abstract java.io.OutputStream getOutputStreamImpl()
public abstract boolean save(java.io.OutputStream zos) throws OpenXML4JException
zos
- Output stream to save this part.
(zos - 输出流以保存这部分。)
POILogger
(如果内容已成功存储,则为 true,否则为 false。有关错误的更多信息可以通过 POILogger 记录)
OpenXML4JException
- If any exception occur.
(OpenXML4JException - 如果发生任何异常。)
public abstract boolean load(java.io.InputStream ios) throws InvalidFormatException
ios
- The input stream of the content to load.
(ios - 要加载的内容的输入流。)
POILogger
(如果内容已成功加载,则为 true,否则为 false。有关错误的更多信息可以通过 POILogger 记录)
InvalidFormatException
- Throws if the content format is invalid.
(InvalidFormatException - 如果内容格式无效则抛出。)
public abstract void close()
public abstract void flush()
public void clear()
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.