|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jdom.Content
org.jdom.Element
org.activemath.omdocjdom.OJElement
public class OJElement
Objects of these classes are any XML element of an OMdoc. It stores almost no field but has mostly utility methods that represent the informations one can retrieve from such an element. This class is not very optimized, caching of some results (like the containgTheoryIDstring) might help.
This class mostly cannot contain any write methods as it is too generic.
Future of this class might include a "comparison" utility.
| Field Summary | |
|---|---|
protected static boolean |
DEBUG
|
protected ID |
id
A buffer to store the id of the element for the first time it is computed. |
protected Object |
info
|
protected static org.apache.commons.logging.Log |
log
|
| Fields inherited from class org.jdom.Element |
|---|
additionalNamespaces, name, namespace |
| Fields inherited from class org.jdom.Content |
|---|
parent |
| Constructor Summary | |
|---|---|
protected |
OJElement()
Constructs an OJElement whose namespace is the OMDoc Namespace. |
|
OJElement(String name)
Constructs an OJElement whose namespace is the OMDoc Namespace and name is specified. |
|
OJElement(String name,
Namespace namespace)
Constructs an OJElement whose namespace and name is given. |
| Method Summary | |
|---|---|
void |
addContentMaybeCloning(Comment child)
Adds the indicated child into this element possibly Element.clone()ing it
if needs be (that is if the element has a parent or has a document) |
void |
addContentMaybeCloning(Element child)
Adds the indicated child into this element possibly Element.clone()ing it
if needs be (that is if the element has a parent or has a document) |
void |
addContentMaybeCloning(EntityRef child)
Adds the indicated child into this element possibly Element.clone()ing it
if needs be (that is if the element has a parent or has a document) |
void |
addContentMaybeCloning(ProcessingInstruction child)
Adds the indicated child into this element possibly Element.clone()ing it
if needs be (that is if the element has a parent or has a document) |
void |
addContentMaybeCloning(Text child)
Adds the indicated child into this element possibly Element.clone()ing it
if needs be (that is if the element has a parent or has a document) |
OJElement |
addDCmetadata(String name,
String role,
String language,
String value)
Creates the metadata element if need be and insert
the indicated Dublin-Core metadata element at the end of it. |
void |
addProperlyIndented(int pos,
OJElement elt)
Adds with correct indenting the element elt after the element at the pos position among the children |
void |
addProperlyIndented(OJElement elt)
Adds the given element with correct indenting at the end of the this element. |
void |
clearExtraNamespaces()
|
OJElement |
findChildWithID(OJElement elt,
ID searchedID)
A method to find back id-ed elements. |
String |
getAnyTitle()
|
String |
getAnyTitle(String defaultValue)
Return any title, or the supplied default string if there is none. |
List |
getChildrenRefs()
Create a list with "xref" ids of all content items ("omd:ref") |
OJElement |
getCompleteDCMetadata()
Walks all the parents collecting all metadata informations of namespace OJConstants.DC_NAMESPACE,
returns a new node which has no parent. |
OJItem |
getContainingItem()
Checks recursively the ancestors of the given node and returns the first implementing OJItem. |
OJElement |
getContainingTheory()
Checks first if an attribute "theory" exists, if yes returns it, otherwise checks the ancestors of the given node and returns the first of the parents whose name is theory. |
String |
getContainingTheoryIDstring()
Covers all the cases in providing the theory attached to this element. |
String |
getCreator()
|
ID |
getEnclosingID()
Walks till the root element to find a parent of this element that has an id attribute (including itself)
and returns its id. |
OJElement |
getFirstDCMetadata(String metadataName)
Climbs from here through the parents to return the first found child of the metadata
element with the given name. |
ID |
getID()
Returns an ID object associated to this node, the buffered one,
or recomputes it from its parents,
storing it in a local variable which will at later calls to this method. |
String |
getIndentOfElementWithNL()
Returns the string representing the whitespace between this tag and the start of line. |
Object |
getInfo()
|
String |
getLanguage()
Returns the value of the xml:lang attribute
of the first ancestor of the element that has one. |
String |
getNL()
|
OJElement |
getOrMakeMetadata()
|
OJElement |
getorMakeMetadataExtradata()
A utility method to return the extradata child of the item
and create it, if it is missing. |
OJElement |
getParentOJElement()
|
List |
getRealContent()
Deprecated. Since jdom-b8 is in, this method is not needed as all the lists and iterators are now properly behaving to removals or additions. |
String |
getTitle(String preferredLanguage)
Returns the name in the given preferred-language (as displayed in the OMdoc DTD). |
Map |
getTitleMap()
Returns a map of all titles with key the two letter-language code. |
Map |
getTitleMapAsJdomElts()
Returns a map associating language two-characters-strings to content of Title or commonname JDOM-elements suitable for transformation for example. |
Map |
getTitleMapAsJdomNodeList()
|
Map |
getTitleMapAsXmlString()
|
List |
getUnionOfDCMetadataEntries(String metadataName)
Climbs through the ancestors of the element and gathers the metadata children with the given name. |
Iterator |
listItems()
Provides an iterator of all the OJItems in the document. |
void |
setID(ID id)
Makes this element believe his id is the given one. |
void |
setID(String name)
|
void |
setInfo(Object i)
|
Element |
setNamespace(Namespace ns)
|
String |
toString()
|
| Methods inherited from class org.jdom.Content |
|---|
detach, equals, getDocument, getParent, getParentElement, hashCode, setParent |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.activemath.omdocjdom.OJNode |
|---|
getDocument, getParent |
| Methods inherited from interface org.jdom.Parent |
|---|
getDocument, getParent |
| Field Detail |
|---|
protected static org.apache.commons.logging.Log log
protected static boolean DEBUG
protected ID id
protected Object info
| Constructor Detail |
|---|
protected OJElement()
public OJElement(String name,
Namespace namespace)
public OJElement(String name)
| Method Detail |
|---|
public Element setNamespace(Namespace ns)
setNamespace in class Elementpublic OJElement getParentOJElement()
public List getRealContent()
Please note that this content can be null when no children are in yet.
public OJElement getContainingTheory()
Note that this does not cover the possible declaration theory= for a given parent.
For more safety, you should use and compare getContainingTheoryIDstring().
public String getContainingTheoryIDstring()
public OJItem getContainingItem()
OJItem.
For this to work, the document must have been built
with OJItem implementing object where there should
be items (i.e. where the name is in the array OJConstants.ITEM_NAMES.
#returns null>/code> if there is no such parent
public String getLanguage()
xml:lang attribute
of the first ancestor of the element that has one.
public String getTitle(String preferredLanguage)
This is in accordance with the possibility that the language is only given in an enclosing element, e.g. for a single-language document like the ones QMath generates.
public String getAnyTitle()
public String getAnyTitle(String defaultValue)
public Map getTitleMapAsXmlString()
public Map getTitleMapAsJdomElts()
Title or commonname JDOM-elements suitable for transformation for example.
public Map getTitleMapAsJdomNodeList()
public Map getTitleMap()
public List getChildrenRefs()
public List getUnionOfDCMetadataEntries(String metadataName)
public OJElement getFirstDCMetadata(String metadataName)
metadata
element with the given name.
This looks like an appropriate procedure for Date
and possibly Contributor, or Title.
Note that this method performs a dirty fallback: it supposes it can happen that the elment is not in the Dublin-Core namespace and returns this element as well.
public OJElement getCompleteDCMetadata()
OJConstants.DC_NAMESPACE,
returns a new node which has no parent.
public void setID(ID id)
getID() will return this object unless null in which
case it will try to recompute it.
This does not, however, set the attributes accordingly.
public ID getID()
ID object associated to this node, the buffered one,
or recomputes it from its parents,
storing it in a local variable which will at later calls to this method.
This is built using the id attribute of the given
element plus the id attribute of the possibly enclosing
theory element and the collection of the enclosing
document.
Alternatively, if the id attribute starts with mbase://
then it is considered an absolute id and is only used.
public ID getEnclosingID()
id attribute (including itself)
and returns its id.
This method requires all parent of this element to be of class
OJElement.
null no suitable one was found.
public OJElement findChildWithID(OJElement elt,
ID searchedID)
The current method goes through the whole tree stopping
at OMOBJ elements' depth until it finds the given ID.
At each node, it requests the ID (using getID())
and compares it to this one.
public Iterator listItems()
OJItems in the document.
These are read along the next() method so any change in the
underlying structure might create concurrency exceptions.
public void addContentMaybeCloning(Element child)
Element.clone()ing it
if needs be (that is if the element has a parent or has a document)
public void addContentMaybeCloning(Text child)
Element.clone()ing it
if needs be (that is if the element has a parent or has a document)
public void addContentMaybeCloning(ProcessingInstruction child)
Element.clone()ing it
if needs be (that is if the element has a parent or has a document)
public void addContentMaybeCloning(Comment child)
Element.clone()ing it
if needs be (that is if the element has a parent or has a document)
public void addContentMaybeCloning(EntityRef child)
Element.clone()ing it
if needs be (that is if the element has a parent or has a document)
public void setInfo(Object i)
setInfo in interface Infoablepublic Object getInfo()
getInfo in interface Infoablepublic OJElement getOrMakeMetadata()
public OJElement getorMakeMetadataExtradata()
extradata child of the item
and create it, if it is missing.
public OJElement addDCmetadata(String name,
String role,
String language,
String value)
metadata element if need be and insert
the indicated Dublin-Core metadata element at the end of it.
public void addProperlyIndented(OJElement elt)
elt - the element to introduce
public void addProperlyIndented(int pos,
OJElement elt)
pos - the child index after which it needs to be insertedelt - that needs to be inserted.public void setID(String name)
public String getCreator()
public void clearExtraNamespaces()
public String getNL()
public String getIndentOfElementWithNL()
public String toString()
toString in class Element
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||