public interface Document
Property objects. Map-like functionality is
provided through the findProperty(String) method. In
addition, a method provides the caller with the Set of all property
names, which it can use to iterate over all properties.
Important: a Property object obtained by calling
findProperty(String) may be invalidated by the next
call to findProperty(String). Typically, the caller will
store the current Property in a loop variable, so that it is
clear that this rule is observed; see the example code below. The
caller may request a specific property multiple times with separate calls
to findProperty(String). In such a case, the
implementation must return the same set of values associated with that
property name. If the caller requests a property for which the
Document has no value, null should be returned.
The typical pattern for consuming an object that implements this interface is as follows (disregarding exception handling):
Document doc = ...
Property prop = null;
if ((prop = doc.findProperty(specialPropName1)) != null) {
doSomethingSpecial(prop);
}
if ((prop = doc.findProperty(specialPropName2)) != null) {
doSomethingElseSpecial(prop);
}
... so on for other special properties as needed ...
for (String propName : doc.getPropertyNames()) {
prop = doc.findProperty(propName);
// assert(prop != null);
doSomething(prop);
}
| Modifier and Type | Method and Description |
|---|---|
Property |
findProperty(java.lang.String name)
Finds a
Property by name. |
java.util.Set<java.lang.String> |
getPropertyNames()
Gets the set of names of all
Properties in this
Document. |
Property findProperty(java.lang.String name) throws RepositoryException
Property by name. If the current document has a property
then that property is returned.name - the name of the Property to findProperty, if found; null otherwiseRepositoryException - if a repository access error occursRepositoryDocumentException - if a document has fatal
processing errorsjava.util.Set<java.lang.String> getPropertyNames()
throws RepositoryException
Properties in this
Document.Set of StringsRepositoryException - if a repository access error occursRepositoryDocumentException - if a document has fatal
processing errors