KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > mathml > MathMLUnderOverElementImpl


1 package JSci.mathml;
2
3 import org.w3c.dom.DOMException JavaDoc;
4 import org.w3c.dom.mathml.*;
5
6 /**
7  * Implements a MathML under-over element.
8  * @version 1.0
9  * @author Mark Hale
10  */

11 public class MathMLUnderOverElementImpl extends MathMLElementImpl implements MathMLUnderOverElement {
12         /**
13          * Constructs a MathML under-over element.
14          */

15         public MathMLUnderOverElementImpl(MathMLDocumentImpl owner, String JavaDoc qualifiedName) {
16                 super(owner, qualifiedName);
17         }
18
19         public String JavaDoc getAccentunder() {
20                 if (getLocalName().equals("mover")) {
21                         return null;
22                 }
23                 return getAttribute("accentunder");
24         }
25         public void setAccentunder(String JavaDoc accentunder) {
26                 setAttribute("accentunder", accentunder);
27         }
28
29         public String JavaDoc getAccent() {
30                 if (getLocalName().equals("munder")) {
31                         return null;
32                 }
33                 return getAttribute("accent");
34         }
35         public void setAccent(String JavaDoc accent) {
36                 setAttribute("accent", accent);
37         }
38
39         public MathMLElement getBase() {
40                 return (MathMLElement) getFirstChild();
41         }
42         public void setBase(MathMLElement base) {
43                 replaceChild(base, getFirstChild());
44         }
45
46         public MathMLElement getUnderscript() {
47                 if (getLocalName().equals("mover")) {
48                         return null;
49                 }
50                 return (MathMLElement) item(1);
51         }
52         public void setUnderscript(MathMLElement underscript) throws DOMException JavaDoc {
53                 if (getLocalName().equals("mover")) {
54                         throw new DOMException JavaDoc(DOMException.HIERARCHY_REQUEST_ERR, "Cannot set a subscript for msup");
55                 }
56                 replaceChild(underscript, item(1));
57         }
58
59         public MathMLElement getOverscript() {
60                 if (getLocalName().equals("munder")) {
61                         return null;
62                 }
63                 if (getLocalName().equals("mover")) {
64                         return (MathMLElement) item(1);
65                 } else {
66                         return (MathMLElement) item(2);
67                 }
68         }
69         public void setOverscript(MathMLElement overscript) throws DOMException JavaDoc {
70                 if (getLocalName().equals("munder")) {
71                         throw new DOMException JavaDoc(DOMException.HIERARCHY_REQUEST_ERR, "Cannot set a superscript for msub");
72                 }
73                 if(getLocalName().equals("mover")) {
74                         replaceChild(overscript, item(1));
75                 } else {
76                         replaceChild(overscript, item(2));
77                 }
78         }
79 }
80
81
Popular Tags