public class FragmentImpl extends XMLImpl implements Fragment
Constructor and Description |
---|
FragmentImpl() |
Modifier and Type | Method and Description |
---|---|
void |
appendElementSchemeXPointer(java.lang.String expression)
Add an element Scheme XPointer Expression to the metadata.
|
void |
appendID(java.lang.String id)
Add an ID (used in XPointer resolution) to the metadata.
|
java.util.List<Fragment> |
getAllChildren()
Gets all child fragments.
|
java.util.Set<java.lang.String> |
getAllChildrenIndices() |
Fragment |
getAncestorOrSelf(java.lang.String type)
Gets the ancestor (or self) fragment with the specified fragment type.
|
Fragment |
getChild(java.lang.String type,
int index)
Get a specific child fragment.
|
<F extends Fragment> |
getChildren(java.lang.Class<?> requiredClass)
Gets the child fragments with the specified fragment type.
|
<F extends Fragment> |
getChildren(java.lang.String type)
Gets the child fragments with the specified fragment type.
|
java.util.Set<java.lang.String> |
getChildrenIndices(java.lang.String type) |
org.w3c.dom.Element |
getDataRootElement()
Get the root element of the fragment data.
|
java.lang.String |
getElementSchemeXPointerExpression() |
java.lang.String |
getIDXPointerExpression() |
java.util.List<LabelResource> |
getLabels() |
java.util.List<LabelResource> |
getLabels(java.util.List<java.lang.String> languages,
java.util.List<java.lang.String> resourceRoles) |
java.util.List<LabelResource> |
getLabels(java.util.List<java.lang.String> languages,
java.util.List<java.lang.String> labelRoles,
java.util.List<java.lang.String> linkRoles) |
java.util.List<LabelResource> |
getLabelsWithLanguage(java.lang.String language) |
java.util.List<LabelResource> |
getLabelsWithLanguageAndResourceRole(java.lang.String language,
java.lang.String role) |
java.util.List<LabelResource> |
getLabelsWithLanguageAndResourceRoleAndLinkRole(java.lang.String language,
java.lang.String resourceRole,
java.lang.String linkRole) |
java.util.List<LabelResource> |
getLabelsWithResourceRole(java.lang.String resourceRole) |
java.lang.String |
getLanguage() |
java.lang.String |
getLanguage(org.w3c.dom.Node node)
Algorithm is as follows:
If the node is an attribute, redo with the parent node.
If the node is a XBRLAPI metadata element redo with right node in parent fragment.
If the node is an element in the fragment data:
Try to find the XML lang attribute and use its value.
If that fails, redo the search using the parent node.
|
java.lang.String |
getLanguageName(java.util.List<java.lang.String> languages) |
java.lang.String |
getLanguageName(java.lang.String language) |
java.lang.String |
getLocalname()
Get the local name of the fragment's root element
|
java.lang.String |
getLocalnameFromQName(java.lang.String qname)
Returns the local name for a QName
|
java.lang.String |
getNamespace()
Get the namespace of the fragment root element.
|
java.lang.String |
getNamespaceFromQName(java.lang.String qname,
org.w3c.dom.Node node)
Algorithm is as follows:
If the node is an attribute, redo with the parent node.
If the node is a XBRLAPI metadata element redo with right node in parent fragment.
If the node is an element in the fragment data:
Generate namespace declaration attribute name - 'xmlns:...' to search for.
Try to match the QName prefix to the element's prefix to see if the element namespace is appropriate to return.
Try to find the attribute doing the namespace declaration on the element and use that.
If that fails, redo the search using the parent node.
|
Fragment |
getParent()
Get the parent fragment of this fragment or null if there is none.
|
org.w3c.dom.Element |
getParentElement(org.w3c.dom.Element parentDataRootElement)
This method operates as follows:
If the sequence to the parent element indicates that the
data root element is the parent - use that.
Loop through the sequence to the parent element.
|
java.lang.String |
getParentIndex()
Get the index of the parent fragment or null if the fragment
does not have a parent fragment.
|
java.lang.String |
getPrefixFromQName(java.lang.String qname)
Returns the Namespace prefix for a QName
|
java.util.List<ReferenceResource> |
getReferences() |
java.util.List<ReferenceResource> |
getReferencesWithLanguage(java.lang.String language) |
java.util.List<ReferenceResource> |
getReferencesWithLanguageAndResourceRoleAndLinkRole(java.lang.String language,
java.net.URI resourceRole,
java.net.URI linkRole) |
java.util.List<ReferenceResource> |
getReferencesWithLanguageAndRole(java.lang.String language,
java.net.URI role) |
java.util.List<ReferenceResource> |
getReferencesWithResourceRole(java.lang.String role) |
java.util.List<Locator> |
getReferencingLocators()
Retrieves a list of all locators that target this fragment.
|
java.lang.String[] |
getSequenceToParentElement()
Get the sequence of steps through the parent fragment DOM to the parent element.
|
java.lang.String |
getSequenceToParentElementAsString() |
java.util.List<SimpleLink> |
getSimpleLinks() |
java.net.URI |
getURI()
Get the URI of the document containing this fragment.
|
java.lang.String |
getXPath()
Get the XPath to the element in the parent fragment that is the
parent element of this fragment's root element.
|
java.lang.String |
getXPointerExpression() |
boolean |
isAncestorOf(Fragment descendant) |
boolean |
isChild() |
boolean |
isNewFragment()
Tests if a fragment is new in the sense that it does not have a root data element.
|
boolean |
isRoot() |
void |
setParentIndex(java.lang.String index)
Set the index of the parent fragment.
|
void |
setSequenceToParentElement(Fragment parent)
Specifies the set of ancestor elements of the element in the parent
fragment that is the insertion point for this fragment's root element.
|
void |
setURI(java.net.URI uri)
Set the URI of the fragment's document.
|
appendMetadataElement, compareTo, equals, getBuilder, getDocumentNode, getIndex, getMetaAttribute, getMetadataRootElement, getStore, getType, hashCode, hasMetaAttribute, isa, isa, removeMetaAttribute, removeMetadataElement, serialize, serialize, serialize, setBuilder, setIndex, setMetaAttribute, setResource, setStore, updateInStore
getClass, notify, notifyAll, toString, wait, wait, wait
appendMetadataElement, equals, getBuilder, getDocumentNode, getIndex, getMetaAttribute, getMetadataRootElement, getStore, getType, hashCode, hasMetaAttribute, isa, isa, removeMetaAttribute, removeMetadataElement, serialize, serialize, serialize, setBuilder, setIndex, setMetaAttribute, setResource, setStore, updateInStore
public Fragment getAncestorOrSelf(java.lang.String type) throws XBRLException
Fragment
getAncestorOrSelf
in interface Fragment
type
- The required fragment type of the ancestor (or self).XBRLException
- if no such ancestor fragment exists.Fragment.getAncestorOrSelf(String)
public <F extends Fragment> java.util.List<F> getChildren(java.lang.String type) throws XBRLException
Fragment
getChildren
in interface Fragment
type
- The required fragment type of the child.
EG: If a list of
org.xbrlapi.impl.ReferenceArcImpl fragments is required then
this parameter would have a value of "ReferenceArc".
Note that if the parameter contains full stops, then it is used directly
as the value for the fragment type, enabling fragment extensions to exploit this
method without placing fragment implementations in the org.xbrlapi package.XBRLException
Fragment.getChildren(String)
public <F extends Fragment> java.util.List<F> getChildren(java.lang.Class<?> requiredClass) throws XBRLException
Fragment
getChildren
in interface Fragment
requiredClass
- The required fragment class of the child fragments.XBRLException
Fragment.getChildren(Class)
public java.util.Set<java.lang.String> getChildrenIndices(java.lang.String type) throws XBRLException
getChildrenIndices
in interface Fragment
type
- The fragment typeXBRLException
Fragment.getChildrenIndices(String)
public java.util.List<SimpleLink> getSimpleLinks() throws XBRLException
getSimpleLinks
in interface Fragment
XBRLException
Fragment.getSimpleLinks()
public java.util.List<Fragment> getAllChildren() throws XBRLException
Fragment
getAllChildren
in interface Fragment
XBRLException
Fragment.getAllChildren()
public java.util.Set<java.lang.String> getAllChildrenIndices() throws XBRLException
getAllChildrenIndices
in interface Fragment
XBRLException
Fragment.getAllChildrenIndices()
public Fragment getChild(java.lang.String type, int index) throws XBRLException
Fragment
getChild
in interface Fragment
type
- The fragment type of the required childindex
- The index of the required child fragment (among other children of the same type)
with the first child being at index 0.XBRLException
- if the index is out of boundsFragment.getChild(String, int)
public org.w3c.dom.Element getDataRootElement() throws XBRLException
Fragment
getDataRootElement
in interface Fragment
XBRLException
- if the fragment does not have fragment data.Fragment.getDataRootElement()
public boolean isNewFragment() throws XBRLException
Fragment
isNewFragment
in interface Fragment
XBRLException
Fragment.isNewFragment()
public java.net.URI getURI() throws XBRLException
Fragment
getURI
in interface Fragment
XBRLException
Fragment.getURI()
public void setURI(java.net.URI uri) throws XBRLException
Fragment
setURI
in interface Fragment
uri
- The string value of the document's absolute URIXBRLException
Fragment.setURI(URI)
public java.util.List<Locator> getReferencingLocators() throws XBRLException
Fragment
getReferencingLocators
in interface Fragment
XBRLException
Fragment.getReferencingLocators()
public java.util.List<LabelResource> getLabels() throws XBRLException
getLabels
in interface Fragment
XBRLException
Fragment.getLabels()
public java.util.List<LabelResource> getLabelsWithResourceRole(java.lang.String resourceRole) throws XBRLException
getLabelsWithResourceRole
in interface Fragment
resourceRole
- The XLink role valueXBRLException
Fragment.getLabelsWithResourceRole(String)
public java.util.List<LabelResource> getLabels(java.util.List<java.lang.String> languages, java.util.List<java.lang.String> resourceRoles) throws XBRLException
getLabels
in interface Fragment
languages
- the list of language codes in order of preference from most preferred to least
preferred, eventually allowing any language if no explicit preference match.resourceRoles
- the list of label resource roles in order of preference from most preferred
to least preferred, eventually allowing any resource role.XBRLException
Fragment.getLabels(List, List)
public java.util.List<LabelResource> getLabels(java.util.List<java.lang.String> languages, java.util.List<java.lang.String> labelRoles, java.util.List<java.lang.String> linkRoles) throws XBRLException
getLabels
in interface Fragment
languages
- the list of language codes in order of preference from most
preferred to least preferred, eventually allowing any language
if no explicit preference match.labelRoles
- the list of label resource roles in order of preference from
most preferred to least preferred, eventually allowing any
resource role.linkRoles
- the list of extended link roles in order of preference from
most preferred to least preferred, eventually allowing any
link role.XBRLException
Fragment.getLabels(List, List, List)
public java.util.List<ReferenceResource> getReferencesWithResourceRole(java.lang.String role) throws XBRLException
getReferencesWithResourceRole
in interface Fragment
role
- The XLink role valueXBRLException
Fragment.getReferencesWithResourceRole(String)
public java.util.List<LabelResource> getLabelsWithLanguage(java.lang.String language) throws XBRLException
getLabelsWithLanguage
in interface Fragment
language
- The xml:lang language codevalueXBRLException
Fragment.getLabelsWithLanguage(String)
public java.util.List<LabelResource> getLabelsWithLanguageAndResourceRole(java.lang.String language, java.lang.String role) throws XBRLException
getLabelsWithLanguageAndResourceRole
in interface Fragment
language
- The xml:lang language code valuerole
- The XLink role valueXBRLException
Fragment.getLabelsWithLanguageAndResourceRole(String, String)
public java.util.List<LabelResource> getLabelsWithLanguageAndResourceRoleAndLinkRole(java.lang.String language, java.lang.String resourceRole, java.lang.String linkRole) throws XBRLException
getLabelsWithLanguageAndResourceRoleAndLinkRole
in interface Fragment
language
- The xml:lang language code value or null if not used as
a a label selection criterion.resourceRole
- The XLink resource role value on the label or null if not used as
a a label selection criterion.linkRole
- The XLink extended link role value on the
extended link containing the label or null if not used as
a a label selection criterion..XBRLException
Fragment.getLabelsWithLanguageAndResourceRole(String, String)
public java.util.List<ReferenceResource> getReferences() throws XBRLException
getReferences
in interface Fragment
XBRLException
Fragment.getReferences()
public java.util.List<ReferenceResource> getReferencesWithLanguage(java.lang.String language) throws XBRLException
getReferencesWithLanguage
in interface Fragment
language
- The xml:lang language code valueXBRLException
Fragment.getReferencesWithLanguage(String)
public java.util.List<ReferenceResource> getReferencesWithLanguageAndRole(java.lang.String language, java.net.URI role) throws XBRLException
getReferencesWithLanguageAndRole
in interface Fragment
language
- The xml:lang language code valuerole
- The XLink role valueXBRLException
Fragment.getReferencesWithLanguageAndRole(String, URI)
public java.util.List<ReferenceResource> getReferencesWithLanguageAndResourceRoleAndLinkRole(java.lang.String language, java.net.URI resourceRole, java.net.URI linkRole) throws XBRLException
getReferencesWithLanguageAndResourceRoleAndLinkRole
in interface Fragment
language
- The xml:lang language code valueresourceRole
- The XLink resource role value on the referencelinkRole
- The XLink extended link role value on the
extended link containing the reference.XBRLException
Fragment.getReferencesWithLanguageAndResourceRoleAndLinkRole(String, URI, URI)
public java.lang.String getParentIndex() throws XBRLException
Fragment
getParentIndex
in interface Fragment
XBRLException
- if the parent fragment index is not available.Fragment.getParentIndex()
public boolean isChild() throws XBRLException
isChild
in interface Fragment
XBRLException
Fragment.isChild()
public boolean isAncestorOf(Fragment descendant) throws XBRLException
isAncestorOf
in interface Fragment
descendant
- The candidate descendant fragment.XBRLException
Fragment.isAncestorOf(Fragment)
public boolean isRoot() throws XBRLException
isRoot
in interface Fragment
XBRLException
Fragment.isRoot()
public void setParentIndex(java.lang.String index) throws XBRLException
Fragment
setParentIndex
in interface Fragment
index
- The index of the parent fragment.XBRLException
- if the parent fragment index cannot be set.Fragment.setParentIndex(String)
public java.lang.String getXPath() throws XBRLException
Fragment
getXPath
in interface Fragment
XBRLException
Fragment.getXPath()
public void setSequenceToParentElement(Fragment parent) throws XBRLException
Fragment
setSequenceToParentElement
in interface Fragment
parent
- The parent fragment.XBRLException
Fragment.setSequenceToParentElement(Fragment)
public java.lang.String[] getSequenceToParentElement() throws XBRLException
Fragment
getSequenceToParentElement
in interface Fragment
XBRLException
Fragment.getSequenceToParentElement()
public java.lang.String getSequenceToParentElementAsString() throws XBRLException
getSequenceToParentElementAsString
in interface Fragment
XBRLException
Fragment.getSequenceToParentElementAsString()
public void appendID(java.lang.String id) throws XBRLException
Fragment
appendID
in interface Fragment
id
- The value of the ID.XBRLException
TODO Eliminate the ID metadata element given the existence of the xptr elements.
public void appendElementSchemeXPointer(java.lang.String expression) throws XBRLException
Fragment
appendElementSchemeXPointer
in interface Fragment
expression
- The XPointer expressionXBRLException
Fragment.appendElementSchemeXPointer(String)
public java.lang.String getNamespace() throws XBRLException
Fragment
getNamespace
in interface Fragment
XBRLException
- if there is no data element
in the fragment.Fragment.getNamespace()
public java.lang.String getLocalname() throws XBRLException
Fragment
getLocalname
in interface Fragment
XBRLException
Fragment.getLocalname()
public java.lang.String getPrefixFromQName(java.lang.String qname)
Fragment
getPrefixFromQName
in interface Fragment
qname
- The qName value to resolveFragment.getPrefixFromQName(String)
public java.lang.String getNamespaceFromQName(java.lang.String qname, org.w3c.dom.Node node) throws XBRLException
getNamespaceFromQName
in interface Fragment
qname
- The qName value to resolvenode
- The node in the fragment data (as a DOM representation) to start QName resolution from.XBRLException
- if the namespace is not declaredFragment.getNamespaceFromQName(String, Node)
public java.lang.String getLanguage(org.w3c.dom.Node node) throws XBRLException
getLanguage
in interface Fragment
node
- The XML node to get the XML language fragment for.XBRLException
Fragment.getLanguage(Node)
public java.lang.String getLanguage() throws XBRLException
getLanguage
in interface Fragment
XBRLException
Fragment.getLanguage()
,
Fragment.getLanguage(Node)
public java.lang.String getLanguageName(java.lang.String language) throws XBRLException
getLanguageName
in interface Fragment
language
- The language encoding of the language name, available
in the data store in the form of a Language XML resource.XBRLException
Fragment.getLanguageName(String)
public java.lang.String getLanguageName(java.util.List<java.lang.String> languages) throws XBRLException
getLanguageName
in interface Fragment
XBRLException
Fragment.getLanguageName(List)
public Fragment getParent() throws XBRLException
Fragment
getParent
in interface Fragment
XBRLException
Fragment.getParent()
public org.w3c.dom.Element getParentElement(org.w3c.dom.Element parentDataRootElement) throws XBRLException
getParentElement
in interface Fragment
parentDataRootElement
- The root element of the parent fragment's data.XBRLException
Fragment.getParentElement(Element)
public java.lang.String getLocalnameFromQName(java.lang.String qname)
Fragment
getLocalnameFromQName
in interface Fragment
qname
- The qName value to resolveFragment.getLocalnameFromQName(String)
public java.lang.String getXPointerExpression() throws XBRLException
getXPointerExpression
in interface Fragment
XBRLException
Fragment.getXPointerExpression()
public java.lang.String getElementSchemeXPointerExpression() throws XBRLException
getElementSchemeXPointerExpression
in interface Fragment
XBRLException
Fragment.getElementSchemeXPointerExpression()
public java.lang.String getIDXPointerExpression() throws XBRLException
getIDXPointerExpression
in interface Fragment
XBRLException
Fragment.getIDXPointerExpression()