KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > mathml > MathMLScriptElementImpl


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

11 public class MathMLScriptElementImpl extends MathMLElementImpl implements MathMLScriptElement {
12         /**
13          * Constructs a MathML script element.
14          */

15         public MathMLScriptElementImpl(MathMLDocumentImpl owner, String JavaDoc qualifiedName) {
16                 super(owner, qualifiedName);
17         }
18
19         public String JavaDoc getSubscriptshift() {
20                 if (getLocalName().equals("msup")) {
21                         return null;
22                 }
23                 return getAttribute("subscriptshift");
24         }
25         public void setSubscriptshift(String JavaDoc subscriptshift) {
26                 setAttribute("subscriptshift", subscriptshift);
27         }
28
29         public String JavaDoc getSuperscriptshift() {
30                 if (getLocalName().equals("msub")) {
31                         return null;
32                 }
33                 return getAttribute("superscriptshift");
34         }
35         public void setSuperscriptshift(String JavaDoc superscriptshift) {
36                 setAttribute("superscriptshift", superscriptshift);
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 getSubscript() {
47                 if (getLocalName().equals("msup")) {
48                         return null;
49                 }
50                 return (MathMLElement) item(1);
51         }
52         public void setSubscript(MathMLElement subscript) throws DOMException JavaDoc {
53                 if (getLocalName().equals("msup")) {
54                         throw new DOMException JavaDoc(DOMException.HIERARCHY_REQUEST_ERR, "Cannot set a subscript for msup");
55                 }
56                 replaceChild(subscript, item(1));
57         }
58
59         public MathMLElement getSuperscript() {
60                 if (getLocalName().equals("msub")) {
61                         return null;
62                 }
63                 if (getLocalName().equals("msup")) {
64                         return (MathMLElement) item(1);
65                 } else {
66                         return (MathMLElement) item(2);
67                 }
68         }
69         public void setSuperscript(MathMLElement superscript) throws DOMException JavaDoc {
70                 if (getLocalName().equals("msub")) {
71                         throw new DOMException JavaDoc(DOMException.HIERARCHY_REQUEST_ERR, "Cannot set a superscript for msub");
72                 }
73                 if(getLocalName().equals("msup")) {
74                         replaceChild(superscript, item(1));
75                 } else {
76                         replaceChild(superscript, item(2));
77                 }
78         }
79 }
80
81
Popular Tags