public final class ExtensibleAttributes extends AbstractAttributeGroup
In DDMS | 2.0 | 3.0 | 3.1 | 4.0.1/4.1 | 5.0 |
No validation or processing of any kind is performed by DDMSence on extensible attributes, other than the base
validation used when loading attributes from an XML file, and a check to confirm that extensible attributes do not
collide with existing attributes. This class merely exposes a getAttributes()
method which returns a
read-only List of XOM Attributes that can be manipulated in business-specific ways.
For example, this ddms:Keyword would have an ExtensibleAttributes instance containing 2 attributes (assuming that the "opensearch" namespace was defined earlier in the file):
<ddms:Keyword ddms:value="xml" opensearch:relevance="95" opensearch:confidence="82" />
XOM attributes can be created as follows:
Attribute attribute = new Attribute("opensearch:relevance", "http://opensearch.namespace/", "95");
Attribute attribute = new Attribute("opensearch:confidence", "http://opensearch.namespace/", "82");
The DDMS documentation does not provide sample HTML/Text output for extensible attributes, so the following approach is used. In general, the output of extensible attributes will be prefixed with the name of the element being marked. For example:
keyword opensearch:relevance: 95
keyword opensearch:confidence: 82
<meta name="subjectCoverage.Subject.keyword.opensearch.relevance" content="95" />
<meta name="subjectCoverage.Subject.keyword.opensearch.confidence" content="82" />
When output as JSON, properties will retain their namespace prefix. Because all values are stored as Strings, no casting is performed to Boolean or Number types.
{"extensibleAttributes":{"opensearch.relevance":"95","opensearch.confidence":"82"}}
Details about the XOM Attribute class can be found at: http://www.xom.nu/apidocs/index.html?nu/xom/Attribute.html
History |
---|
In DDMS 2.0, this attribute group can only decorate In DDMS 3.0 and 3.1, this attribute group can decorate In DDMS 4.0.1 and 4.1, this attribute group was removed from In DDMS 5.0, this attribute group was also removed from |
Nested Elements | |||
---|---|---|---|
|
Attributes | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Validation Rules | |||
---|---|---|---|
|
Modifier and Type | Class and Description |
---|---|
static class |
ExtensibleAttributes.AttributeBuilder
Builder for a XOM attribute.
|
static class |
ExtensibleAttributes.Builder
Builder for these attributes.
|
INCOMPATIBLE_VERSION_MESSAGE
Constructor and Description |
---|
ExtensibleAttributes(nu.xom.Element element)
Base constructor
|
ExtensibleAttributes(List<nu.xom.Attribute> attributes)
Constructor which builds from raw data.
|
Modifier and Type | Method and Description |
---|---|
void |
addTo(nu.xom.Element element)
Convenience method to add these attributes onto an existing XOM Element
|
boolean |
equals(Object obj) |
List<nu.xom.Attribute> |
getAttributes()
Accessor for the attributes.
|
String |
getHTMLTextOutput(OutputFormat format,
String prefix)
Outputs to HTML or Text with a prefix at the beginning of each meta tag or line.
|
com.google.gson.JsonObject |
getJSONObject()
Renders this component as a JSON object, which can either be converted to
a JSON string or inserted into the parent JSON object.
|
String |
getName()
Returns a name that describes this attribute group.
|
static ExtensibleAttributes |
getNonNullInstance(ExtensibleAttributes extensibleAttributes)
Returns a non-null instance of extensible attributes.
|
int |
hashCode() |
boolean |
isEmpty()
Checks if any attributes have been set.
|
protected void |
validate(DDMSVersion version)
Currently, no further validation is performed.
|
addJson, addJson, getNamespace, getValidationWarnings, getWarnings, setNamespace
public ExtensibleAttributes(nu.xom.Element element) throws InvalidDDMSException
Will only load attributes from a different namespace than DDMS (##other) and will also skip any Resource attributes that are reserved.
element
- the XOM element which is decorated with these attributes.InvalidDDMSException
public ExtensibleAttributes(List<nu.xom.Attribute> attributes) throws InvalidDDMSException
attributes
- a list of extensible attributesInvalidDDMSException
- if any required information is missing or malformedpublic static ExtensibleAttributes getNonNullInstance(ExtensibleAttributes extensibleAttributes) throws InvalidDDMSException
extensibleAttributes
- the attributes to return by defaultInvalidDDMSException
- if there are problems creating the empty attributes instancepublic void addTo(nu.xom.Element element) throws InvalidDDMSException
element
- the element to decorateInvalidDDMSException
- if the attribute already existspublic boolean isEmpty()
AbstractAttributeGroup
isEmpty
in class AbstractAttributeGroup
AbstractAttributeGroup.isEmpty()
protected void validate(DDMSVersion version) throws InvalidDDMSException
validate
in class AbstractAttributeGroup
version
- the DDMS version to validate against. This cannot be stored in the attribute group because some
DDMSVersions have the same attribute XML namespace (e.g. XLink, ISM, NTK, GML after DDMS 2.0).InvalidDDMSException
- if any required information is missing or malformedpublic com.google.gson.JsonObject getJSONObject()
AbstractAttributeGroup
I consider this to be an internal method, that unfortunately must be marked as public to allow cross-package access when generating output. Use toJSON() as the formal, public method to generate output.
getJSONObject
in class AbstractAttributeGroup
AbstractAttributeGroup.getJSONObject()
public String getName()
AbstractAttributeGroup
getName
in class AbstractAttributeGroup
AbstractAttributeGroup.getName()
public String getHTMLTextOutput(OutputFormat format, String prefix)
AbstractAttributeGroup
I consider this to be an internal method, that unfortunately must be marked as public to allow cross-package access when generating output. Use toHTML() and toText() as the formal, public methods to generate output.
getHTMLTextOutput
in class AbstractAttributeGroup
format
- the desired format of this outputprefix
- the prefix to addAbstractAttributeGroup.getHTMLTextOutput(OutputFormat, String)
public boolean equals(Object obj)
equals
in class Object
Object.equals(Object)
public int hashCode()
hashCode
in class Object
Object.hashCode()
public List<nu.xom.Attribute> getAttributes()
Copyright 2010 - 2019 by Brian Uri!
Generated on 09/15/2016 12:36 PM
https://ddmsence.urizone.net/