package org.xmlsmartdoc.SmartDoc.mathml.rParts;
import org.w3c.dom.*;
/**
* <b>MMath</b> is generated by Relaxer based on MathML.rlx.
* This class is derived from:
*
* <!-- for programmer
* <elementRule role="math">
* <choice occurs="*">
* <ref label="mi"/>
* <ref label="mn"/>
* <ref label="mo"/>
* <ref label="mtext"/>
* <ref label="ms"/>
* <ref label="mspace"/>
* <ref label="mrow"/>
* <ref label="mfrac"/>
* <ref label="msqrt"/>
* <ref label="mroot"/>
* <ref label="mstyle"/>
* <ref label="merror"/>
* <ref label="mpadded"/>
* <ref label="mphantom"/>
* <ref label="mfenced"/>
* <ref label="msub"/>
* <ref label="msup"/>
* <ref label="msubsup"/>
* <ref label="munder"/>
* <ref label="mover"/>
* <ref label="munderover"/>
* <ref label="mmultiscripts"/>
* <ref label="mtable"/>
* <ref label="mtr"/>
* <ref label="mtd"/>
* <ref label="maligngroup"/>
* <ref label="malignmark"/>
* <ref label="maction"/>
* <ref label="ci"/>
* <ref label="cn"/>
* <ref label="apply"/>
* <ref label="fn"/>
* <ref label="lambda"/>
* <ref label="reln"/>
* <ref label="interval"/>
* <ref label="list"/>
* <ref label="matrix"/>
* <ref label="matrixrow"/>
* <ref label="set"/>
* <ref label="vector"/>
* <ref label="semantics"/>
* </choice>
* </elementRule>
*
* <tag name="math">
* <attribute name="class" type="string"/>
* <attribute name="style" type="string"/>
* <attribute name="id" type="ID"/>
* <attribute name="other" type="string"/>
* <attribute name="macros" type="string"/>
* <attribute name="mode" type="string"/>
* <attribute name="type" type="string"/>
* <attribute name="name" type="string"/>
* <attribute name="height" type="string"/>
* <attribute name="width" type="string"/>
* <attribute name="baseline" type="string"/>
* <attribute name="overflow" type="NMTOKEN">
* <enumeration value="scroll"/>
* <enumeration value="elide"/>
* <enumeration value="truncate"/>
* <enumeration value="scale"/>
* </attribute>
* <attribute name="altimg" type="string"/>
* <attribute name="alttext" type="string"/>
* </tag>
* -->
* <!-- for javadoc -->
* <pre> <elementRule role="math">
* <choice occurs="*">
* <ref label="mi"/>
* <ref label="mn"/>
* <ref label="mo"/>
* <ref label="mtext"/>
* <ref label="ms"/>
* <ref label="mspace"/>
* <ref label="mrow"/>
* <ref label="mfrac"/>
* <ref label="msqrt"/>
* <ref label="mroot"/>
* <ref label="mstyle"/>
* <ref label="merror"/>
* <ref label="mpadded"/>
* <ref label="mphantom"/>
* <ref label="mfenced"/>
* <ref label="msub"/>
* <ref label="msup"/>
* <ref label="msubsup"/>
* <ref label="munder"/>
* <ref label="mover"/>
* <ref label="munderover"/>
* <ref label="mmultiscripts"/>
* <ref label="mtable"/>
* <ref label="mtr"/>
* <ref label="mtd"/>
* <ref label="maligngroup"/>
* <ref label="malignmark"/>
* <ref label="maction"/>
* <ref label="ci"/>
* <ref label="cn"/>
* <ref label="apply"/>
* <ref label="fn"/>
* <ref label="lambda"/>
* <ref label="reln"/>
* <ref label="interval"/>
* <ref label="list"/>
* <ref label="matrix"/>
* <ref label="matrixrow"/>
* <ref label="set"/>
* <ref label="vector"/>
* <ref label="semantics"/>
* </choice>
* </elementRule>
* <tag name="math">
* <attribute name="class" type="string"/>
* <attribute name="style" type="string"/>
* <attribute name="id" type="ID"/>
* <attribute name="other" type="string"/>
* <attribute name="macros" type="string"/>
* <attribute name="mode" type="string"/>
* <attribute name="type" type="string"/>
* <attribute name="name" type="string"/>
* <attribute name="height" type="string"/>
* <attribute name="width" type="string"/>
* <attribute name="baseline" type="string"/>
* <attribute name="overflow" type="NMTOKEN">
* <enumeration value="scroll"/>
* <enumeration value="elide"/>
* <enumeration value="truncate"/>
* <enumeration value="scale"/>
* </attribute>
* <attribute name="altimg" type="string"/>
* <attribute name="alttext" type="string"/>
* </tag>
* </pre>
*
* @version MathML.rlx 1.0 (Sat Sep 09 10:48:40 JST 2000)
* @author Relaxer 0.11b (by ASAMI@Yokohama)
*/
public class MMath implements java.io.Serializable, IRVisitable, IRNode {
private String classValue;
private String style;
private String id;
private String other;
private String macros;
private String mode;
private String type;
private String name;
private String height;
private String width;
private String baseline;
private String overflow;
private String altimg;
private String alttext;
// List<IMMathContent>
private java.util.List content = new java.util.ArrayList();
private IRNode parentRNode;
/**
* Creates a <code>MMath</code>.
*
*/
public MMath() {
}
/**
* Creates a <code>MMath</code> by the Stack <code>stack</code>
* that contains Elements.
* This constructor is supposed to be used internally
* by the Relaxer system.
*
* @param stack
*/
public MMath(RStack stack) {
setup(stack);
}
/**
* Creates a <code>MMath</code> by the Document <code>doc</code>.
*
* @param doc
*/
public MMath(Document doc) {
setup(doc.getDocumentElement());
}
/**
* Creates a <code>MMath</code> by the Element <code>element</code>.
*
* @param element
*/
public MMath(Element element) {
setup(element);
}
/**
* Initializes the <code>MMath</code> by the Document <code>doc</code>.
*
* @param doc
*/
public void setup(Document doc) {
setup(doc.getDocumentElement());
}
/**
* Initializes the <code>MMath</code> by the Element <code>element</code>.
*
* @param element
*/
public void setup(Element element) {
init(element);
}
/**
* Initializes the <code>MMath</code> by the Stack <code>stack</code>
* that contains Elements.
* This constructor is supposed to be used internally
* by the Relaxer system.
*
* @param stack
*/
public void setup(RStack stack) {
setup(stack.popElement());
}
/**
* @param element
*/
private void init(Element element) {
RStack stack = new RStack(element);
classValue = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "class");
style = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "style");
id = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "id");
other = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "other");
macros = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "macros");
mode = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "mode");
type = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "type");
name = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "name");
height = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "height");
width = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "width");
baseline = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "baseline");
overflow = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "overflow");
altimg = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "altimg");
alttext = URelaxer2.getAttributePropertyAsString(element, "http://www.w3.org/1998/Math/MathML", "alttext");
content.clear();
while (!stack.isEmptyElement()) {
if (MMi.isMatch(stack)) {
addContent(new MMi(stack));
} else if (MMn.isMatch(stack)) {
addContent(new MMn(stack));
} else if (MMo.isMatch(stack)) {
addContent(new MMo(stack));
} else if (MMtext.isMatch(stack)) {
addContent(new MMtext(stack));
} else if (MMs.isMatch(stack)) {
addContent(new MMs(stack));
} else if (MMspace.isMatch(stack)) {
addContent(new MMspace(stack));
} else if (MMrow.isMatch(stack)) {
addContent(new MMrow(stack));
} else if (MMfrac.isMatch(stack)) {
addContent(new MMfrac(stack));
} else if (MMsqrt.isMatch(stack)) {
addContent(new MMsqrt(stack));
} else if (MMroot.isMatch(stack)) {
addContent(new MMroot(stack));
} else if (MMstyle.isMatch(stack)) {
addContent(new MMstyle(stack));
} else if (MMerror.isMatch(stack)) {
addContent(new MMerror(stack));
} else if (MMpadded.isMatch(stack)) {
addContent(new MMpadded(stack));
} else if (MMphantom.isMatch(stack)) {
addContent(new MMphantom(stack));
} else if (MMfenced.isMatch(stack)) {
addContent(new MMfenced(stack));
} else if (MMsub.isMatch(stack)) {
addContent(new MMsub(stack));
} else if (MMsup.isMatch(stack)) {
addContent(new MMsup(stack));
} else if (MMsubsup.isMatch(stack)) {
addContent(new MMsubsup(stack));
} else if (MMunder.isMatch(stack)) {
addContent(new MMunder(stack));
} else if (MMover.isMatch(stack)) {
addContent(new MMover(stack));
} else if (MMunderover.isMatch(stack)) {
addContent(new MMunderover(stack));
} else if (MMmultiscripts.isMatch(stack)) {
addContent(new MMmultiscripts(stack));
} else if (MMtable.isMatch(stack)) {
addContent(new MMtable(stack));
} else if (MMtr.isMatch(stack)) {
addContent(new MMtr(stack));
} else if (MMtd.isMatch(stack)) {
addContent(new MMtd(stack));
} else if (MMaligngroup.isMatch(stack)) {
addContent(new MMaligngroup(stack));
} else if (MMalignmark.isMatch(stack)) {
addContent(new MMalignmark(stack));
} else if (MMaction.isMatch(stack)) {
addContent(new MMaction(stack));
} else if (MCi.isMatch(stack)) {
addContent(new MCi(stack));
} else if (MCn.isMatch(stack)) {
addContent(new MCn(stack));
} else if (MApply.isMatch(stack)) {
addContent(new MApply(stack));
} else if (MFn.isMatch(stack)) {
addContent(new MFn(stack));
} else if (MLambda.isMatch(stack)) {
addContent(new MLambda(stack));
} else if (MReln.isMatch(stack)) {
addContent(new MReln(stack));
} else if (MInterval.isMatch(stack)) {
addContent(new MInterval(stack));
} else if (MList.isMatch(stack)) {
addContent(new MList(stack));
} else if (MMatrix.isMatch(stack)) {
addContent(new MMatrix(stack));
} else if (MMatrixrow.isMatch(stack)) {
addContent(new MMatrixrow(stack));
} else if (MSet.isMatch(stack)) {
addContent(new MSet(stack));
} else if (MVector.isMatch(stack)) {
addContent(new MVector(stack));
} else if (MSemantics.isMatch(stack)) {
addContent(new MSemantics(stack));
} else {
break;
}
}
}
/**
* Creates a DOM representation of the object.
* Result is appended to the Node <code>parent</code>.
*
* @param parent
*/
public void makeElement(Node parent) {
Document doc;
if (parent instanceof Document) {
doc = (Document)parent;
} else {
doc = parent.getOwnerDocument();
}
Element element = doc.createElement("math");
int size;
if (classValue != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "class", classValue);
}
if (style != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "style", style);
}
if (id != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "id", id);
}
if (other != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "other", other);
}
if (macros != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "macros", macros);
}
if (mode != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "mode", mode);
}
if (type != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "type", type);
}
if (name != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "name", name);
}
if (height != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "height", height);
}
if (width != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "width", width);
}
if (baseline != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "baseline", baseline);
}
if (overflow != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "overflow", overflow);
}
if (altimg != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "altimg", altimg);
}
if (alttext != null) {
URelaxer2.setAttributePropertyByString(element, "http://www.w3.org/1998/Math/MathML", "alttext", alttext);
}
size = content.size();
for (int i = 0;i < size;i++) {
IMMathContent value = (IMMathContent)this.content.get(i);
value.makeElement(element);
}
parent.appendChild(element);
}
/**
* Gets the String property <b>classValue</b>.
*
* @return String
*/
public final String getClassValue() {
return (classValue);
}
/**
* Sets the String property <b>classValue</b>.
*
* @param classValue
*/
public final void setClassValue(String classValue) {
this.classValue = classValue;
}
/**
* Gets the String property <b>style</b>.
*
* @return String
*/
public final String getStyle() {
return (style);
}
/**
* Sets the String property <b>style</b>.
*
* @param style
*/
public final void setStyle(String style) {
this.style = style;
}
/**
* Gets the String property <b>id</b>.
*
* @return String
*/
public final String getId() {
return (id);
}
/**
* Sets the String property <b>id</b>.
*
* @param id
*/
public final void setId(String id) {
this.id = id;
}
/**
* Gets the String property <b>other</b>.
*
* @return String
*/
public final String getOther() {
return (other);
}
/**
* Sets the String property <b>other</b>.
*
* @param other
*/
public final void setOther(String other) {
this.other = other;
}
/**
* Gets the String property <b>macros</b>.
*
* @return String
*/
public final String getMacros() {
return (macros);
}
/**
* Sets the String property <b>macros</b>.
*
* @param macros
*/
public final void setMacros(String macros) {
this.macros = macros;
}
/**
* Gets the String property <b>mode</b>.
*
* @return String
*/
public final String getMode() {
return (mode);
}
/**
* Sets the String property <b>mode</b>.
*
* @param mode
*/
public final void setMode(String mode) {
this.mode = mode;
}
/**
* Gets the String property <b>type</b>.
*
* @return String
*/
public final String getType() {
return (type);
}
/**
* Sets the String property <b>type</b>.
*
* @param type
*/
public final void setType(String type) {
this.type = type;
}
/**
* Gets the String property <b>name</b>.
*
* @return String
*/
public final String getName() {
return (name);
}
/**
* Sets the String property <b>name</b>.
*
* @param name
*/
public final void setName(String name) {
this.name = name;
}
/**
* Gets the String property <b>height</b>.
*
* @return String
*/
public final String getHeight() {
return (height);
}
/**
* Sets the String property <b>height</b>.
*
* @param height
*/
public final void setHeight(String height) {
this.height = height;
}
/**
* Gets the String property <b>width</b>.
*
* @return String
*/
public final String getWidth() {
return (width);
}
/**
* Sets the String property <b>width</b>.
*
* @param width
*/
public final void setWidth(String width) {
this.width = width;
}
/**
* Gets the String property <b>baseline</b>.
*
* @return String
*/
public final String getBaseline() {
return (baseline);
}
/**
* Sets the String property <b>baseline</b>.
*
* @param baseline
*/
public final void setBaseline(String baseline) {
this.baseline = baseline;
}
/**
* Gets the String property <b>overflow</b>.
*
* @return String
*/
public final String getOverflow() {
return (overflow);
}
/**
* Sets the String property <b>overflow</b>.
*
* @param overflow
*/
public final void setOverflow(String overflow) {
this.overflow = overflow;
}
/**
* Gets the String property <b>altimg</b>.
*
* @return String
*/
public final String getAltimg() {
return (altimg);
}
/**
* Sets the String property <b>altimg</b>.
*
* @param altimg
*/
public final void setAltimg(String altimg) {
this.altimg = altimg;
}
/**
* Gets the String property <b>alttext</b>.
*
* @return String
*/
public final String getAlttext() {
return (alttext);
}
/**
* Sets the String property <b>alttext</b>.
*
* @param alttext
*/
public final void setAlttext(String alttext) {
this.alttext = alttext;
}
/**
* Gets the IMMathContent property <b>content</b>.
*
* @return IMMathContent[]
*/
public final IMMathContent[] getContent() {
IMMathContent[] array = new IMMathContent[content.size()];
return ((IMMathContent[])content.toArray(array));
}
/**
* Sets the IMMathContent property <b>content</b>.
*
* @param content
*/
public final void setContent(IMMathContent[] content) {
this.content.clear();
this.content.addAll(java.util.Arrays.asList(content));
for (int i = 0;i < content.length;i++) {
content[i].setParentRNode(this);
}
}
/**
* Sets the IMMathContent property <b>content</b>.
*
* @param content
*/
public final void setContent(IMMathContent content) {
this.content.clear();
this.content.add(content);
content.setParentRNode(this);
}
/**
* Adds the IMMathContent property <b>content</b>.
*
* @param content
*/
public final void addContent(IMMathContent content) {
this.content.add(content);
content.setParentRNode(this);
}
/**
* Accepts the Visitor for enter behavior.
*
* @param visitor
*/
public void enter(IRVisitor visitor) {
visitor.enter(this);
}
/**
* Accepts the Visitor for leave behavior.
*
* @param visitor
*/
public void leave(IRVisitor visitor) {
visitor.leave(this);
}
/**
* Gets the IRNode property <b>parentRNode</b>.
*
* @return IRNode
*/
public final IRNode getParentRNode() {
return (parentRNode);
}
/**
* Sets the IRNode property <b>parentRNode</b>.
*
* @param parentRNode
*/
public final void setParentRNode(IRNode parentRNode) {
this.parentRNode = parentRNode;
}
/**
* Gets child RNodes.
*
* @return IRNode[]
*/
public IRNode[] getRNodes() {
java.util.List classNodes = new java.util.ArrayList();
classNodes.addAll(content);
IRNode[] nodes = new IRNode[classNodes.size()];
return ((IRNode[])classNodes.toArray(nodes));
}
/**
* Tests if a Element <code>element</code> is valid
* for the <code>MMath</code>.
*
* @param element
* @return boolean
*/
public static boolean isMatch(Element element) {
if (!URelaxer2.isTargetElement(element, "http://www.w3.org/1998/Math/MathML", "math")) {
return (false);
}
RStack target = new RStack(element);
Element child;
while (!target.isEmptyElement()) {
if (MMi.isMatchHungry(target)) {
} else if (MMn.isMatchHungry(target)) {
} else if (MMo.isMatchHungry(target)) {
} else if (MMtext.isMatchHungry(target)) {
} else if (MMs.isMatchHungry(target)) {
} else if (MMspace.isMatchHungry(target)) {
} else if (MMrow.isMatchHungry(target)) {
} else if (MMfrac.isMatchHungry(target)) {
} else if (MMsqrt.isMatchHungry(target)) {
} else if (MMroot.isMatchHungry(target)) {
} else if (MMstyle.isMatchHungry(target)) {
} else if (MMerror.isMatchHungry(target)) {
} else if (MMpadded.isMatchHungry(target)) {
} else if (MMphantom.isMatchHungry(target)) {
} else if (MMfenced.isMatchHungry(target)) {
} else if (MMsub.isMatchHungry(target)) {
} else if (MMsup.isMatchHungry(target)) {
} else if (MMsubsup.isMatchHungry(target)) {
} else if (MMunder.isMatchHungry(target)) {
} else if (MMover.isMatchHungry(target)) {
} else if (MMunderover.isMatchHungry(target)) {
} else if (MMmultiscripts.isMatchHungry(target)) {
} else if (MMtable.isMatchHungry(target)) {
} else if (MMtr.isMatchHungry(target)) {
} else if (MMtd.isMatchHungry(target)) {
} else if (MMaligngroup.isMatchHungry(target)) {
} else if (MMalignmark.isMatchHungry(target)) {
} else if (MMaction.isMatchHungry(target)) {
} else if (MCi.isMatchHungry(target)) {
} else if (MCn.isMatchHungry(target)) {
} else if (MApply.isMatchHungry(target)) {
} else if (MFn.isMatchHungry(target)) {
} else if (MLambda.isMatchHungry(target)) {
} else if (MReln.isMatchHungry(target)) {
} else if (MInterval.isMatchHungry(target)) {
} else if (MList.isMatchHungry(target)) {
} else if (MMatrix.isMatchHungry(target)) {
} else if (MMatrixrow.isMatchHungry(target)) {
} else if (MSet.isMatchHungry(target)) {
} else if (MVector.isMatchHungry(target)) {
} else if (MSemantics.isMatchHungry(target)) {
} else {
break;
}
}
if (!target.isEmptyElement()) {
return (false);
}
return (true);
}
/**
* Tests if elements contained in a Stack <code>stack</code>
* is valid for the <code>MMath</code>.
* This mehtod is supposed to be used internally
* by the Relaxer system.
*
* @param stack
* @return boolean
*/
public static boolean isMatch(RStack stack) {
Element element = stack.peekElement();
if (element == null) {
return (false);
}
return (isMatch(element));
}
/**
* Tests if elements contained in a Stack <code>stack</code>
* is valid for the <code>MMath</code>.
* This method consumes the stack contents during matching operation.
* This mehtod is supposed to be used internally
* by the Relaxer system.
*
* @param stack
* @return boolean
*/
public static boolean isMatchHungry(RStack stack) {
Element element = stack.peekElement();
if (element == null) {
return (false);
}
if (isMatch(element)) {
stack.popElement();
return (true);
} else {
return (false);
}
}
}