Package org.apache.sis.xml
Class XLink
java.lang.Object
org.apache.sis.xml.XLink
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Anchor
The XML attributes defined by OGC in the
xlink schema.
The allowed combinations of any one attribute depend on the value of the special
When
type attribute. Following is a summary of the element types
(columns) on which the global attributes (rows) are allowed, with an indication
of whether a value is required (R) or optional (O)
(Source: W3C):
simple |
extended |
locator |
arc |
resource |
title |
|
|---|---|---|---|---|---|---|
type | R | R | R | R | R | R |
href | O | R | ||||
role | O | O | O | O | ||
arcrole | O | O | ||||
title | O | O | O | O | O | |
show | O | O | ||||
actuate | O | O | ||||
label | O | O | ||||
from | O | |||||
to | O |
xlink attributes are found at unmarshalling time instead of an object definition,
those attributes are given to the ReferenceResolver.resolve(MarshalContext, Class, XLink)
method. Users can override that method in order to fetch an instance in some catalog for the given
xlink values.- Since:
- 0.3
- Version:
- 0.3
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumCommunicates the desired timing of traversal from the starting resource to the ending resource.static enumCommunicates the desired presentation of the ending resource on traversal from the starting resource.static enumThe type of axlink. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate XLink.ActuateCommunicates the desired timing of traversal from the starting resource to the ending resource.private URIA URI reference for some description of the arc role.private StringThe starting resource.private intThe cached hash code value, computed only if thisXLinkis unmodifiable.private URIA URN to an external resources, or to another part of a XML document, or an identifier.private StringIdentifies the target of afromortoattribute.private URIA URI reference for some description of the arc role.private static final longFor cross-version compatibility.private XLink.ShowCommunicates the desired presentation of the ending resource on traversal from the starting resource.private org.opengis.util.InternationalStringJust as with resources, this is simply a human-readable string with a short description for the arc.private StringThe ending resource.private XLink.TypeThe type of link. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidappend(StringBuilder buffer, String label, Object value) Appends the given attribute in the given buffer if the attribute value is not null.private voidChecks if the given attribute can be set.booleanCompares thisXLinkwith the given object for equality.private intReturns a mask of fields for which a non-null value has been defined.voidfreeze()Marks thisxlinkas unmodifiable.Returns the desired timing of traversal from the starting resource to the ending resource.Returns a URI reference for some description of the arc role.getFrom()Returns the starting resource.getHRef()Returns a URN to an external resources, or to another part of a XML document, or an identifier.getLabel()Returns an identification of the target of afromortoattribute.getRole()Returns a URI reference for some description of the arc role.getShow()Returns the desired presentation of the ending resource on traversal from the starting resource.org.opengis.util.InternationalStringgetTitle()Returns a human-readable string with a short description for the arc.getTo()Returns the ending resource.getType()Returns the type of link.private inthash()Computes the hash code now.inthashCode()Returns a hash code value for this XLink.voidsetActuate(XLink.Actuate actuate) Sets the desired timing of traversal from the starting resource to the ending resource.voidsetArcRole(URI arcrole) Sets a URI reference for some description of the arc role.voidSets the starting resource.voidSets the URN to a resources.voidSets an identification of the target of afromortoattribute.voidSets the URI reference for some description of the arc role.voidsetShow(XLink.Show show) Sets the desired presentation of the ending resource on traversal from the starting resource.voidsetTitle(org.opengis.util.InternationalString title) Sets a human-readable string with a short description for the arc.voidSets the ending resource.voidsetType(XLink.Type type) Sets the type of link.toString()Returns a string representation of this object.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
type
The type of link. Ifnull, then the type will be inferred bygetType().- See Also:
-
href
A URN to an external resources, or to another part of a XML document, or an identifier.- See Also:
-
role
A URI reference for some description of the arc role.- See Also:
-
arcrole
A URI reference for some description of the arc role.- See Also:
-
title
private org.opengis.util.InternationalString titleJust as with resources, this is simply a human-readable string with a short description for the arc.- See Also:
-
show
Communicates the desired presentation of the ending resource on traversal from the starting resource.- See Also:
-
actuate
Communicates the desired timing of traversal from the starting resource to the ending resource.- See Also:
-
label
Identifies the target of afromortoattribute.- See Also:
-
from
The starting resource. The value must correspond to the same value for somelabelattribute.- See Also:
-
to
The ending resource. The value must correspond to the same value for somelabelattribute.- See Also:
-
hashCode
private int hashCodeThe cached hash code value, computed only if thisXLinkis unmodifiable. Otherwise, this field is left to zero. This field is computed when thefreeze()method has been invoked.
-
-
Constructor Details
-
XLink
public XLink()Creates a new link. The initial value of all attributes isnull. -
XLink
Creates a new link as a copy of the given link.- Parameters:
link- The link to copy, ornullif none.
-
-
Method Details
-
fieldMask
private int fieldMask()Returns a mask of fields for which a non-null value has been defined. The bit values are defined in thefieldMask()javadoc. -
getType
Returns the type of link. May have one of the following values:- simple: a simple link
- extended: an extended, possibly multi-resource, link
- locator: a pointer to an external resource
- resource: an internal resource
- arc: a traversal rule between resources
- title: a descriptive title for another linking element
null. If thesetType(XLink.Type)method has been invoked with theAUTOenum, then this method will infer a type from the attributes having a non-null value.- Returns:
- the type of link, or
null.
-
setType
Sets the type of link. Any value different thanType.AUTO(includingnull) will overwrite the value inferred automatically bygetType(). AAUTOvalue will enable automatic type detection.- Parameters:
type- the new type of link, ornullif none.
-
canWrite
Checks if the given attribute can be set.- Parameters:
field- the attribute code, as documented infieldMask().- Throws:
UnsupportedOperationException- if thisxlinkis unmodifiable.IllegalStateException- if the given field cannot be set for this kind ofxlink.
-
getHRef
Returns a URN to an external resources, or to another part of a XML document, or an identifier.- Returns:
- a URN to a resources, or
nullif none.
-
setHRef
Sets the URN to a resources.- Parameters:
href- a URN to a resources, ornullif none.- Throws:
UnsupportedOperationException- if thisxlinkis unmodifiable.IllegalStateException- if the link type has been explicitly set. and that type does not allow the"href"attribute.
-
getRole
Returns a URI reference for some description of the arc role.- Returns:
- a URI reference for some description of the arc role, or
nullif none.
-
setRole
Sets the URI reference for some description of the arc role.- Parameters:
role- a URI reference for some description of the arc role, ornullif none.- Throws:
UnsupportedOperationException- if thisxlinkis unmodifiable.IllegalStateException- if the link type has been explicitly set. and that type does not allow the"role"attribute.
-
getArcRole
Returns a URI reference for some description of the arc role.- Returns:
- a URI reference for some description of the arc role, or
nullif none.
-
setArcRole
Sets a URI reference for some description of the arc role.- Parameters:
arcrole- a URI reference for some description of the arc role, ornullif none.- Throws:
UnsupportedOperationException- if thisxlinkis unmodifiable.IllegalStateException- if the link type has been explicitly set. and that type does not allow the"arcrole"attribute.
-
getTitle
public org.opengis.util.InternationalString getTitle()Returns a human-readable string with a short description for the arc.- Returns:
- a human-readable string with a short description for the arc, or
nullif none.
-
setTitle
Sets a human-readable string with a short description for the arc.- Parameters:
title- a human-readable string with a short description for the arc, ornullif none.- Throws:
UnsupportedOperationException- if thisxlinkis unmodifiable.IllegalStateException- if the link type has been explicitly set. and that type does not allow the"title"attribute.
-
getShow
Returns the desired presentation of the ending resource on traversal from the starting resource. It's value should be treated as follows:- new: load ending resource in a new window, frame, pane, or other presentation context
- replace: load the resource in the same window, frame, pane, or other presentation context
- embed: load ending resource in place of the presentation of the starting resource
- other: behavior is unconstrained; examine other markup in the link for hints
- none: behavior is unconstrained
- Returns:
- the desired presentation of the ending resource, or
nullif unspecified.
-
setShow
Sets the desired presentation of the ending resource on traversal from the starting resource.- Parameters:
show- the desired presentation of the ending resource, ornullif unspecified.- Throws:
UnsupportedOperationException- if thisxlinkis unmodifiable.IllegalStateException- if the link type has been explicitly set. and that type does not allow the"show"attribute.
-
getActuate
Returns the desired timing of traversal from the starting resource to the ending resource. It's value should be treated as follows:- onLoad: traverse to the ending resource immediately on loading the starting resource
- onRequest: traverse from the starting resource to the ending resource only on a post-loading event triggered for this purpose
- other: behavior is unconstrained; examine other markup in link for hints
- none: behavior is unconstrained
- Returns:
- the desired timing of traversal from the starting resource to the ending resource,
or
nullif unspecified.
-
setActuate
Sets the desired timing of traversal from the starting resource to the ending resource.- Parameters:
actuate- the desired timing of traversal from the starting resource to the ending resource, ornullif unspecified.- Throws:
UnsupportedOperationException- if thisxlinkis unmodifiable.IllegalStateException- if the link type has been explicitly set. and that type does not allow the"actuate"attribute.
-
getLabel
Returns an identification of the target of afromortoattribute.- Returns:
- an identification of the target of a
fromortoattribute, ornull.
-
setLabel
Sets an identification of the target of afromortoattribute.- Parameters:
label- an identification of the target of afromortoattribute, ornull.- Throws:
UnsupportedOperationException- if thisxlinkis unmodifiable.IllegalStateException- if the link type has been explicitly set. and that type does not allow the"label"attribute.
-
getFrom
Returns the starting resource. The value must correspond to the same value for somelabelattribute.- Returns:
- the starting resource, or
null.
-
setFrom
Sets the starting resource. The value must correspond to the same value for somelabelattribute.- Parameters:
from- the starting resource, ornull.- Throws:
UnsupportedOperationException- if thisxlinkis unmodifiable.IllegalStateException- if the link type has been explicitly set. and that type does not allow the"from"attribute.
-
getTo
Returns the ending resource. The value must correspond to the same value for somelabelattribute.- Returns:
- the ending resource, or
null.
-
setTo
Sets the ending resource. The value must correspond to the same value for somelabelattribute.- Parameters:
to- the ending resource, ornull.- Throws:
UnsupportedOperationException- if thisxlinkis unmodifiable.IllegalStateException- if the link type has been explicitly set. and that type does not allow the"to"attribute.
-
freeze
public void freeze()Marks thisxlinkas unmodifiable. After this method call, any call to a setter method will throw anUnsupportedOperationException.After the first call to this method, any subsequent calls have no effect.
-
equals
Compares thisXLinkwith the given object for equality. -
hashCode
public int hashCode()Returns a hash code value for this XLink. -
hash
private int hash()Computes the hash code now. This method is guaranteed to return a value different than zero, in order to allow us to use 0 as a sentinel value for modifiable xlink. -
toString
Returns a string representation of this object. The default implementation returns the simple class name followed by non-null attributes, as in the example below: -
append
Appends the given attribute in the given buffer if the attribute value is not null. If the given value is an attribute, the XML name will be used rather than the Java field name.
-