public class PropertySet
extends java.lang.Object
An application that wants to access these metadata should create an instance of this class or one of its subclasses by calling the factory method PropertySetFactory.create(org.apache.poi.poifs.filesystem.DirectoryEntry, java.lang.String)
and then retrieve the information its needs by calling appropriate methods.
PropertySetFactory.create(org.apache.poi.poifs.filesystem.DirectoryEntry, java.lang.String)
does its work by calling one of the constructors PropertySet(InputStream)
or PropertySet(byte[])
. If the constructor's argument is not in the Horrible Property Set Format, i.e. not a property set stream, or if any other error occurs, an appropriate exception is thrown.
A PropertySet
has a list of Section
s, and each Section
has a Property
array. Use getSections()
to retrieve the Section
s, then call Section.getProperties()
for each Section
to get hold of the Property
arrays.
Since the vast majority of PropertySet
s contains only a single Section
, the convenience method getProperties()
returns the properties of a PropertySet
's Section
(throwing a NoSingleSectionException
if the PropertySet
contains more (or less) than exactly one Section
).
Modifier and Type | Field and Description |
---|---|
static int |
OS_MACINTOSH
If the OS version field holds this value the property set stream was created on a Macintosh system.
(如果 OS 版本字段包含此值,则属性集流是在 Macintosh 系统上创建的。)
|
static int |
OS_WIN16
If the OS version field holds this value the property set stream was created on a 16-bit Windows system.
(如果 OS 版本字段包含此值,则属性集流是在 16 位 Windows 系统上创建的。)
|
static int |
OS_WIN32
If the OS version field holds this value the property set stream was created on a 32-bit Windows system.
(如果 OS 版本字段包含此值,则属性集流是在 32 位 Windows 系统上创建的。)
|
Constructor and Description |
---|
PropertySet()
Constructs a
PropertySet instance.
|
PropertySet(byte[] stream)
Creates a
PropertySet instance from a byte array that represents a stream in the Horrible Property Set Format.
|
PropertySet(byte[] stream, int offset, int length)
Creates a
PropertySet instance from a byte array that represents a stream in the Horrible Property Set Format.
|
PropertySet(java.io.InputStream stream)
Creates a
PropertySet instance from an
InputStream in the Horrible Property Set Format.
|
PropertySet(PropertySet ps)
Constructs a
PropertySet by doing a deep copy of an existing
PropertySet .
|
Modifier and Type | Method and Description |
---|---|
void |
addSection(Section section)
Adds a section to this property set.
(向此属性集添加一个部分。)
|
void |
clearSections()
Removes all sections from this property set.
(从此属性集中删除所有部分。)
|
boolean |
equals(java.lang.Object o)
Returns
true if the
PropertySet is equal to the specified parameter, else
false .
(如果 PropertySet 等于指定的参数,则返回 true,否则返回 false。)
|
int |
getByteOrder() |
ClassID |
getClassID() |
Section |
getFirstSection()
Gets the
PropertySet 's first section.
(获取 PropertySet 的第一部分。)
|
int |
getFormat() |
int |
getOSVersion() |
Property[] |
getProperties()
Convenience method returning the
Property array contained in this property set.
(返回此属性集中包含的属性数组的便捷方法。)
|
protected java.lang.Object |
getProperty(int id)
Convenience method returning the value of the property with the specified ID.
(返回具有指定 ID 的属性值的便捷方法。)
|
PropertyIDMap |
getPropertySetIDMap()
The id to name mapping of the properties in this set.
(此集中属性的 id 到名称映射。)
|
static java.lang.String |
getPropertyStringValue(java.lang.Object propertyValue)
Return the string representation of a property value
(返回属性值的字符串表示)
|
int |
getSectionCount() |
java.util.List<Section> |
getSections() |
int |
hashCode() |
boolean |
isDocumentSummaryInformation()
Checks whether this
PropertySet is a Document Summary Information.
(检查此 PropertySet 是否为文档摘要信息。)
|
static boolean |
isPropertySetStream(byte[] src, int offset, int length)
Checks whether a byte array is in the Horrible Property Set Format.
(检查字节数组是否为可怕的属性集格式。)
|
static boolean |
isPropertySetStream(java.io.InputStream stream)
Checks whether an
InputStream is in the Horrible Property Set Format.
(检查 InputStream 是否为可怕的属性集格式。)
|
boolean |
isSummaryInformation()
Checks whether this
PropertySet represents a Summary Information.
(检查此 PropertySet 是否表示摘要信息。)
|
void |
setByteOrder(int byteOrder)
Returns the property set stream's low-level "byte order" field.
(返回属性集流的低级“字节顺序”字段。)
|
void |
setClassID(ClassID classID)
Sets the property set stream's low-level "class ID" field.
(设置属性集流的低级“类 ID”字段。)
|
void |
setFormat(int format)
Sets the property set stream's low-level "format" field.
(设置属性集流的低级“格式”字段。)
|
void |
setOSVersion(int osVersion)
Sets the property set stream's low-level "OS version" field.
(设置属性集流的低级“操作系统版本”字段。)
|
java.io.InputStream |
toInputStream()
Returns the contents of this property set stream as an input stream.
(将此属性集流的内容作为输入流返回。)
|
java.lang.String |
toString() |
boolean |
wasNull()
Checks whether the property which the last call to
getPropertyIntValue(int) or
getProperty(int) tried to access was available or not.
(检查最后一次调用 getPropertyIntValue(int) 或 getProperty(int) 尝试访问的属性是否可用。)
|
void |
write(DirectoryEntry dir, java.lang.String name)
Writes a property set to a document in a POI filesystem directory.
(将属性集写入 POI 文件系统目录中的文档。)
|
void |
write(java.io.OutputStream out)
Writes the property set to an output stream.
(将属性集写入输出流。)
|
public static final int OS_WIN16
public static final int OS_MACINTOSH
public static final int OS_WIN32
public PropertySet()
PropertySet
instance. Its primary task is to initialize the field with their proper values. It also sets fields that might change to reasonable defaults.
(构造一个 PropertySet 实例。它的主要任务是用适当的值初始化字段。它还设置可能更改为合理默认值的字段。)
public PropertySet(java.io.InputStream stream) throws NoPropertySetStreamException, java.io.IOException
PropertySet
instance from an
InputStream
in the Horrible Property Set Format.
The constructor reads the first few bytes from the stream and determines whether it is really a property set stream. If it is, it parses the rest of the stream. If it is not, it resets the stream to its beginning in order to let other components mess around with the data and throws an exception.
(从 Horrible Property Set 格式的 InputStream 创建一个 PropertySet 实例。构造函数从流中读取前几个字节并确定它是否真的是属性集流。如果是,它会解析流的其余部分。如果不是,它会将流重置为其开头,以便让其他组件弄乱数据并引发异常。)stream
- Holds the data making out the property set stream.
(流 - 保存生成属性集流的数据。)
java.io.IOException
- if the
InputStream
cannot be accessed as needed.
(java.io.IOException - 如果无法根据需要访问 InputStream。)
NoPropertySetStreamException
- if the input stream does not contain a property set.
(NoPropertySetStreamException - 如果输入流不包含属性集。)
java.io.UnsupportedEncodingException
- if a character encoding is not supported.
(java.io.UnsupportedEncodingException - 如果不支持字符编码。)
public PropertySet(byte[] stream, int offset, int length) throws NoPropertySetStreamException, java.io.UnsupportedEncodingException
PropertySet
instance from a byte array that represents a stream in the Horrible Property Set Format.
(从表示 Horrible Property Set 格式的流的字节数组创建一个 PropertySet 实例。)
stream
- The byte array holding the stream data.
(stream - 保存流数据的字节数组。)
offset
- The offset in
stream
where the stream data begin. If the stream data begin with the first byte in the array, the
offset
is 0.
(offset - 流数据开始的流中的偏移量。如果流数据从数组中的第一个字节开始,则偏移量为 0。)
length
- The length of the stream data.
(length - 流数据的长度。)
NoPropertySetStreamException
- if the byte array is not a property set stream.
(NoPropertySetStreamException - 如果字节数组不是属性集流。)
java.io.UnsupportedEncodingException
- if the codepage is not supported.
(java.io.UnsupportedEncodingException - 如果代码页不受支持。)
public PropertySet(byte[] stream) throws NoPropertySetStreamException, java.io.UnsupportedEncodingException
PropertySet
instance from a byte array that represents a stream in the Horrible Property Set Format.
(从表示 Horrible Property Set 格式的流的字节数组创建一个 PropertySet 实例。)
stream
- The byte array holding the stream data. The complete byte array contents is the stream data.
(stream - 保存流数据的字节数组。完整的字节数组内容是流数据。)
NoPropertySetStreamException
- if the byte array is not a property set stream.
(NoPropertySetStreamException - 如果字节数组不是属性集流。)
java.io.UnsupportedEncodingException
- if the codepage is not supported.
(java.io.UnsupportedEncodingException - 如果代码页不受支持。)
public PropertySet(PropertySet ps)
PropertySet
by doing a deep copy of an existing
PropertySet
. All nested elements, i.e.
Section
s and
Property
instances, will be their counterparts in the new
PropertySet
.
(通过对现有 PropertySet 进行深层复制来构造 PropertySet。所有嵌套元素,即 Sections 和 Property 实例,将在新的 PropertySet 中成为它们的对应物。)
ps
- The property set to copy
(ps - 要复制的属性集)
public int getByteOrder()
0xFFFE
.
(属性集流的低级“字节顺序”字段。它始终为 0xFFFE。)
public void setByteOrder(int byteOrder)
byteOrder
- The property set stream's low-level "byte order" field.
(byteOrder - 属性集流的低级“字节顺序”字段。)
public int getFormat()
0x0000
.
(属性集流的低级“格式”字段。它始终为 0x0000。)
public void setFormat(int format)
format
- The property set stream's low-level "format" field.
(format - 属性集流的低级“格式”字段。)
public int getOSVersion()
public void setOSVersion(int osVersion)
osVersion
- The property set stream's low-level "OS version" field.
(osVersion - 属性集流的低级“操作系统版本”字段。)
public ClassID getClassID()
public void setClassID(ClassID classID)
classID
- The property set stream's low-level "class ID" field.
(classID - 属性集流的低级“类 ID”字段。)
public int getSectionCount()
Section
s in the property set.
(属性集中的部分数。)
public java.util.List<Section> getSections()
Section
s in the property set.
(属性集中不可修改的部分列表。)
public void addSection(Section section)
section
- The
Section
to add. It will be appended after any sections that are already present in the property set and thus become the last section.
(section - 要添加的部分。它将附加在属性集中已经存在的任何部分之后,因此成为最后一个部分。)
public void clearSections()
public PropertyIDMap getPropertySetIDMap()
null
if not applicable
(此集合中属性的 ID 到名称映射,如果不适用,则为 null)
public static boolean isPropertySetStream(java.io.InputStream stream) throws java.io.IOException
InputStream
is in the Horrible Property Set Format.
(检查 InputStream 是否为可怕的属性集格式。)
stream
- The
InputStream
to check. In order to perform the check, the method reads the first bytes from the stream. After reading, the stream is reset to the position it had before reading. The
InputStream
must support the
InputStream.mark(int)
method.
(stream - 要检查的 InputStream。为了执行检查,该方法从流中读取第一个字节。读取后,流被重置为读取前的位置。 InputStream 必须支持 InputStream.mark(int) 方法。)
true
if the stream is a property set stream, else
false
.
(如果流是属性集流,则为 true,否则为 false。)
java.io.IOException
- if an I/O error occurs
(java.io.IOException - 如果发生 I/O 错误)
public static boolean isPropertySetStream(byte[] src, int offset, int length)
src
- The byte array to check.
(src - 要检查的字节数组。)
offset
- The offset in the byte array.
(offset - 字节数组中的偏移量。)
length
- The significant number of bytes in the byte array. Only this number of bytes will be checked.
(length - 字节数组中的有效字节数。仅检查此字节数。)
true
if the byte array is a property set stream,
false
if not.
(如果字节数组是属性集流,则为 true,否则为 false。)
public void write(java.io.OutputStream out) throws java.io.IOException, WritingNotSupportedException
out
- the output stream to write the section to
(out - 将部分写入的输出流)
java.io.IOException
- if an error when writing to the output stream occurs
(java.io.IOException - 如果写入输出流时发生错误)
WritingNotSupportedException
- if HPSF does not yet support writing a property's variant type.
(WritingNotSupportedException - 如果 HPSF 还不支持写入属性的变体类型。)
public void write(DirectoryEntry dir, java.lang.String name) throws WritingNotSupportedException, java.io.IOException
dir
- The directory in the POI filesystem to write the document to.
(dir - POI 文件系统中要将文档写入的目录。)
name
- The document's name. If there is already a document with the same name in the directory the latter will be overwritten.
(name - 文档的名称。如果目录中已经存在同名文档,则后者将被覆盖。)
WritingNotSupportedException
- if the filesystem doesn't support writing
(WritingNotSupportedException - 如果文件系统不支持写入)
java.io.IOException
- if the old entry can't be deleted or the new entry be written
(java.io.IOException - 如果无法删除旧条目或写入新条目)
public java.io.InputStream toInputStream() throws WritingNotSupportedException, java.io.IOException
PropertySet
only.
(将此属性集流的内容作为输入流返回。例如,后者可用于将属性集写入 POIFS 文档。输入流表示属性集的快照。如果后者在输入流仍在被读取时被修改,修改将不会反映在输入流中,而只会反映在 PropertySet 中。)
WritingNotSupportedException
- if HPSF does not yet support writing of a property's variant type.
(WritingNotSupportedException - 如果 HPSF 还不支持写入属性的变体类型。)
java.io.IOException
- if an I/O exception occurs.
(java.io.IOException - 如果发生 I/O 异常。)
public static java.lang.String getPropertyStringValue(java.lang.Object propertyValue)
propertyValue
- the property value
(propertyValue - 属性值)
public boolean isSummaryInformation()
PropertySet
represents a Summary Information.
(检查此 PropertySet 是否表示摘要信息。)
true
if this
PropertySet
represents a Summary Information, else
false
.
(如果此 PropertySet 表示摘要信息,则为 true,否则为 false。)
public boolean isDocumentSummaryInformation()
PropertySet
is a Document Summary Information.
(检查此 PropertySet 是否为文档摘要信息。)
true
if this
PropertySet
represents a Document Summary Information, else
false
.
(如果此 PropertySet 表示文档摘要信息,则为 true,否则为 false。)
public Property[] getProperties() throws NoSingleSectionException
Property
array contained in this property set. It is a shortcut for getting he
PropertySet
's
Section
s list and then getting the
Property
array from the first
Section
.
(返回此属性集中包含的属性数组的便捷方法。这是获取PropertySet 的Sections 列表然后从第一个Section 中获取Property 数组的快捷方式。)
Section
of this
PropertySet
.
(此 PropertySet 的唯一 Section 的属性。)
NoSingleSectionException
- if the
PropertySet
has more or less than one
Section
.
(NoSingleSectionException - 如果 PropertySet 的 Section 多于或少于一个。)
protected java.lang.Object getProperty(int id) throws NoSingleSectionException
null
is returned and a subsequent call to
wasNull()
will return
true
.
(返回具有指定 ID 的属性值的便捷方法。如果该属性不可用,则返回 null,随后对 wasNull() 的调用将返回 true。)
id
- The property ID
(id - 属性 ID)
NoSingleSectionException
- if the
PropertySet
has more or less than one
Section
.
(NoSingleSectionException - 如果 PropertySet 的 Section 多于或少于一个。)
public boolean wasNull() throws NoSingleSectionException
getPropertyIntValue(int)
or
getProperty(int)
tried to access was available or not. This information might be important for callers of
getPropertyIntValue(int)
since the latter returns 0 if the property does not exist. Using wasNull, the caller can distinguish this case from a property's real value of 0.
(检查最后一次调用 getPropertyIntValue(int) 或 getProperty(int) 尝试访问的属性是否可用。此信息对于 getPropertyIntValue(int) 的调用者可能很重要,因为如果属性不存在,后者将返回 0。使用 wasNull,调用者可以将这种情况与属性的实际值 0 区分开来。)
true
if the last call to
getPropertyIntValue(int)
or
getProperty(int)
tried to access a property that was not available, else
false
.
(如果最后一次调用 getPropertyIntValue(int) 或 getProperty(int) 尝试访问不可用的属性,则为 true,否则为 false。)
NoSingleSectionException
- if the
PropertySet
has more than one
Section
.
(NoSingleSectionException - 如果 PropertySet 有多个部分。)
public Section getFirstSection()
PropertySet
's first section.
(获取 PropertySet 的第一部分。)
PropertySet
's first section.
(PropertySet 的第一部分。)
public boolean equals(java.lang.Object o)
true
if the
PropertySet
is equal to the specified parameter, else
false
.
(如果 PropertySet 等于指定的参数,则返回 true,否则返回 false。)
equals
in class
java.lang.Object
o
- the object to compare this
PropertySet
with
(o - 与此 PropertySet 进行比较的对象)
true
if the objects are equal,
false
if not
(如果对象相等,则为 true,否则为 false)
@NotImplemented public int hashCode()
hashCode
in class
java.lang.Object
Object.hashCode()
public java.lang.String toString()
toString
in class
java.lang.Object
Object.toString()
Copyright 2021 The Apache Software Foundation or its licensors, as applicable.