Source Code Cross Referenced for MathMLMathElementImpl.java in  » Science » JSci » JSci » mathml » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » JSci » JSci.mathml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package JSci.mathml;
002:
003:        import org.w3c.dom.*;
004:        import org.w3c.dom.mathml.*;
005:
006:        /**
007:         * Implements a MathML <code>math</code> element.
008:         * @version 1.0
009:         * @author Mark Hale
010:         */
011:        public class MathMLMathElementImpl extends MathMLElementImpl implements 
012:                MathMLMathElement {
013:            /**
014:             * Constructs a MathML <code>math</code> element.
015:             */
016:            public MathMLMathElementImpl(MathMLDocumentImpl owner,
017:                    String qualifiedName) {
018:                super (owner, qualifiedName);
019:            }
020:
021:            public String getMacros() {
022:                return getAttribute("macros");
023:            }
024:
025:            public void setMacros(String macros) {
026:                setAttribute("macros", macros);
027:            }
028:
029:            public String getDisplay() {
030:                return getAttribute("display");
031:            }
032:
033:            public void setDisplay(String display) {
034:                setAttribute("display", display);
035:            }
036:
037:            public int getNArguments() {
038:                return getArgumentsGetLength();
039:            }
040:
041:            public MathMLNodeList getArguments() {
042:                return new MathMLNodeList() {
043:                    public int getLength() {
044:                        return getArgumentsGetLength();
045:                    }
046:
047:                    public Node item(int index) {
048:                        return getArgumentsItem(index);
049:                    }
050:                };
051:            }
052:
053:            public MathMLNodeList getDeclarations() {
054:                return new MathMLNodeList() {
055:                    public int getLength() {
056:                        return getDeclarationsGetLength();
057:                    }
058:
059:                    public Node item(int index) {
060:                        return getDeclarationsItem(index);
061:                    }
062:                };
063:            }
064:
065:            public MathMLElement getArgument(int index) throws DOMException {
066:                Node arg = getArgumentsItem(index - 1);
067:                if (arg == null) {
068:                    throw new DOMException(DOMException.INDEX_SIZE_ERR,
069:                            "Index out of bounds");
070:                }
071:                return (MathMLElement) arg;
072:            }
073:
074:            public MathMLElement setArgument(MathMLElement newArgument,
075:                    int index) throws DOMException {
076:                final int argsLength = getArgumentsGetLength();
077:
078:                if ((index < 1) || (index > argsLength + 1)) {
079:                    throw new DOMException(DOMException.INDEX_SIZE_ERR,
080:                            "Index out of bounds");
081:                }
082:                if (index == argsLength + 1) {
083:                    return (MathMLElement) appendChild(newArgument);
084:                } else {
085:                    return (MathMLElement) replaceChild(newArgument,
086:                            getArgumentsItem(index - 1));
087:                }
088:            }
089:
090:            public MathMLElement insertArgument(MathMLElement newArgument,
091:                    int index) throws DOMException {
092:                final int argsLength = getArgumentsGetLength();
093:
094:                if ((index < 0) || (index > argsLength + 1)) {
095:                    throw new DOMException(DOMException.INDEX_SIZE_ERR,
096:                            "Index out of bounds");
097:                }
098:                if ((index == 0) || (index == argsLength + 1)) {
099:                    return (MathMLElement) appendChild(newArgument);
100:                } else {
101:                    return (MathMLElement) insertBefore(newArgument,
102:                            getArgumentsItem(index - 1));
103:                }
104:            }
105:
106:            public MathMLElement removeArgument(int index) throws DOMException {
107:                Node arg = getArgumentsItem(index - 1);
108:                if (arg == null) {
109:                    throw new DOMException(DOMException.INDEX_SIZE_ERR,
110:                            "Index out of bounds");
111:                }
112:                return (MathMLElement) removeChild(arg);
113:            }
114:
115:            public void deleteArgument(int index) throws DOMException {
116:                removeArgument(index);
117:            }
118:
119:            public MathMLDeclareElement getDeclaration(int index)
120:                    throws DOMException {
121:                Node decl = getDeclarationsItem(index - 1);
122:                if (decl == null) {
123:                    throw new DOMException(DOMException.INDEX_SIZE_ERR,
124:                            "Index out of bounds");
125:                }
126:                return (MathMLDeclareElement) decl;
127:            }
128:
129:            public MathMLDeclareElement setDeclaration(
130:                    MathMLDeclareElement newDeclaration, int index)
131:                    throws DOMException {
132:                final int declsLength = getDeclarationsGetLength();
133:
134:                if ((index < 1) || (index > declsLength + 1)) {
135:                    throw new DOMException(DOMException.INDEX_SIZE_ERR,
136:                            "Index out of bounds");
137:                }
138:                if (index == declsLength + 1) {
139:                    return (MathMLDeclareElement) appendChild(newDeclaration);
140:                } else {
141:                    return (MathMLDeclareElement) replaceChild(newDeclaration,
142:                            getDeclarationsItem(index - 1));
143:                }
144:            }
145:
146:            public MathMLDeclareElement insertDeclaration(
147:                    MathMLDeclareElement newDeclaration, int index)
148:                    throws DOMException {
149:                final int declsLength = getDeclarationsGetLength();
150:
151:                if ((index < 0) || (index > declsLength + 1)) {
152:                    throw new DOMException(DOMException.INDEX_SIZE_ERR,
153:                            "Index out of bounds");
154:                }
155:                if ((index == 0) || (index == declsLength + 1)) {
156:                    return (MathMLDeclareElement) appendChild(newDeclaration);
157:                } else {
158:                    return (MathMLDeclareElement) insertBefore(newDeclaration,
159:                            getDeclarationsItem(index - 1));
160:                }
161:            }
162:
163:            public MathMLDeclareElement removeDeclaration(int index)
164:                    throws DOMException {
165:                Node decl = getDeclarationsItem(index - 1);
166:                if (decl == null) {
167:                    throw new DOMException(DOMException.INDEX_SIZE_ERR,
168:                            "Index out of bounds");
169:                }
170:                return (MathMLDeclareElement) removeChild(decl);
171:            }
172:
173:            public void deleteDeclaration(int index) throws DOMException {
174:                removeDeclaration(index);
175:            }
176:
177:            private int getArgumentsGetLength() {
178:                final int length = getLength();
179:                int numArgs = 0;
180:
181:                for (int i = 0; i < length; i++) {
182:                    if (!(item(i) instanceof  MathMLDeclareElement)) {
183:                        numArgs++;
184:                    }
185:                }
186:                return numArgs;
187:            }
188:
189:            private Node getArgumentsItem(int index) {
190:                final int argsLength = getArgumentsGetLength();
191:
192:                if ((index < 0) || (index >= argsLength))
193:                    return null;
194:
195:                Node node = null;
196:                int n = -1;
197:                for (int i = 0; n < index; i++) {
198:                    node = item(i);
199:                    if (!(node instanceof  MathMLDeclareElement)) {
200:                        n++;
201:                    }
202:                }
203:                return node;
204:            }
205:
206:            private int getDeclarationsGetLength() {
207:                final int length = getLength();
208:                int numDecls = 0;
209:
210:                for (int i = 0; i < length; i++) {
211:                    if (item(i) instanceof  MathMLDeclareElement) {
212:                        numDecls++;
213:                    }
214:                }
215:                return numDecls;
216:            }
217:
218:            private Node getDeclarationsItem(int index) {
219:                final int declLength = getDeclarationsGetLength();
220:
221:                if ((index < 0) || (index >= declLength))
222:                    return null;
223:
224:                Node node = null;
225:                int n = -1;
226:                for (int i = 0; n < index; i++) {
227:                    node = item(i);
228:                    if (node instanceof  MathMLDeclareElement) {
229:                        n++;
230:                    }
231:                }
232:                return node;
233:            }
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.