package org.xmlsmartdoc.SmartDoc.mathml.rParts; import org.w3c.dom.*; /** * <b>MMerror</b> is generated by Relaxer based on MathML.rlx. * This class is derived from: * * <!-- for programmer * <elementRule role="merror"> * <choice occurs="*"> * <ref label="mi"/> * <ref label="mn"/> * <ref label="mo"/> * <ref label="mtext"/> * <ref label="ms"/> * <ref label="mspace"/> * <ref label="mprescripts"/> * <ref label="none"/> * <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="merror"> * <attribute name="class" type="string"/> * <attribute name="style" type="string"/> * <attribute name="id" type="ID"/> * <attribute name="other" type="string"/> * </tag> * --> * <!-- for javadoc --> * <pre> <elementRule role="merror"> * <choice occurs="*"> * <ref label="mi"/> * <ref label="mn"/> * <ref label="mo"/> * <ref label="mtext"/> * <ref label="ms"/> * <ref label="mspace"/> * <ref label="mprescripts"/> * <ref label="none"/> * <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="merror"> * <attribute name="class" type="string"/> * <attribute name="style" type="string"/> * <attribute name="id" type="ID"/> * <attribute name="other" type="string"/> * </tag> * </pre> * * @version MathML.rlx 1.0 (Sat Sep 09 10:48:42 JST 2000) * @author Relaxer 0.11b (by ASAMI@Yokohama) */ public class MMerror implements java.io.Serializable, IMMerrorContent, IMMpaddedContent, IMMphantomContent, IMMfencedContent, IMMsubContent, IMMsupContent, IMMsubsupContent, IMMunderContent, IMMoverContent, IMMunderoverContent, IMMmultiscriptsContent, IMMtableContent, IMMtrContent, IMMtdContent, IMMactionContent, IMCiPCDATA, IMCnPCDATA, IMFnContent, IMLogbaseContent, IMDegreeContent, IMBvarContent, IMUplimitContent, IMLowlimitContent, IMVectorContent, IMSetContent, IMMatrixrowContent, IMMatrixContent, IMListContent, IMIntervalContent, IMAnnotationXmlContent, IMSemanticsContent, IMDeclareContent, IMConditionContent, IMLambdaContent, IMRelnContent, IMApplyContent, IRVisitable, IRNode, IMMstyleContent, IMMrootContent, IMMsqrtContent, IMMfracContent, IMMrowContent, IMMathContent { private String classValue; private String style; private String id; private String other; // List<IMMerrorContent> private java.util.List content = new java.util.ArrayList(); private IRNode parentRNode; /** * Creates a <code>MMerror</code>. * */ public MMerror() { } /** * Creates a <code>MMerror</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 MMerror(RStack stack) { setup(stack); } /** * Creates a <code>MMerror</code> by the Document <code>doc</code>. * * @param doc */ public MMerror(Document doc) { setup(doc.getDocumentElement()); } /** * Creates a <code>MMerror</code> by the Element <code>element</code>. * * @param element */ public MMerror(Element element) { setup(element); } /** * Initializes the <code>MMerror</code> by the Document <code>doc</code>. * * @param doc */ public void setup(Document doc) { setup(doc.getDocumentElement()); } /** * Initializes the <code>MMerror</code> by the Element <code>element</code>. * * @param element */ public void setup(Element element) { init(element); } /** * Initializes the <code>MMerror</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"); 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 (MMprescripts.isMatch(stack)) { addContent(new MMprescripts(stack)); } else if (MNone.isMatch(stack)) { addContent(new MNone(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("merror"); 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); } size = content.size(); for (int i = 0;i < size;i++) { IMMerrorContent value = (IMMerrorContent)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 IMMerrorContent property <b>content</b>. * * @return IMMerrorContent[] */ public final IMMerrorContent[] getContent() { IMMerrorContent[] array = new IMMerrorContent[content.size()]; return ((IMMerrorContent[])content.toArray(array)); } /** * Sets the IMMerrorContent property <b>content</b>. * * @param content */ public final void setContent(IMMerrorContent[] 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 IMMerrorContent property <b>content</b>. * * @param content */ public final void setContent(IMMerrorContent content) { this.content.clear(); this.content.add(content); content.setParentRNode(this); } /** * Adds the IMMerrorContent property <b>content</b>. * * @param content */ public final void addContent(IMMerrorContent 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>MMerror</code>. * * @param element * @return boolean */ public static boolean isMatch(Element element) { if (!URelaxer2.isTargetElement(element, "http://www.w3.org/1998/Math/MathML", "merror")) { 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 (MMprescripts.isMatchHungry(target)) { } else if (MNone.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>MMerror</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>MMerror</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); } } }