Source Code Cross Referenced for Set.java in  » 6.0-JDK-Modules » j2me » com » sun » perseus » model » 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 » 6.0 JDK Modules » j2me » com.sun.perseus.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:
027:        package com.sun.perseus.model;
028:
029:        import com.sun.perseus.util.SVGConstants;
030:
031:        import org.w3c.dom.DOMException;
032:
033:        /**
034:         * <code>Set</code> represents an SVG Tiny <code>&lt;set&gt;</code>
035:         * element.
036:         *
037:         * @version $Id: Set.java,v 1.5 2006/06/29 10:47:34 ln156897 Exp $
038:         */
039:        public final class Set extends Animation {
040:            /**
041:             * Required Set traits
042:             */
043:            static final String[] REQUIRED_TRAITS = { SVGConstants.SVG_ATTRIBUTE_NAME_ATTRIBUTE };
044:
045:            /**
046:             * The target Set value.
047:             */
048:            String[] to = new String[1];
049:
050:            /**
051:             * The RefValues corresponding to this &lt;set&gt; element. A &lt;set&gt;
052:             * element has a single segment with the same begin and end value.
053:             */
054:            RefValues refValues = null;
055:
056:            /**
057:             * The trait's qualified name.
058:             */
059:            String traitQName = null;
060:
061:            /**
062:             * Builds a new Set element that belongs to the given
063:             * document. This <code>Set</code> will belong 
064:             * to the <code>DocumentNode</code>'s time container.
065:             *
066:             * @param ownerDocument the document this node belongs to.
067:             * @throws IllegalArgumentException if the input ownerDocument is null
068:             */
069:            public Set(final DocumentNode ownerDocument) {
070:                super (ownerDocument, SVGConstants.SVG_SET_TAG);
071:            }
072:
073:            /**
074:             * Used by <code>DocumentNode</code> to create a new instance from
075:             * a prototype <code>TimedElementNode</code>.
076:             *
077:             * @param doc the <code>DocumentNode</code> for which a new node is
078:             *        should be created.
079:             * @return a new <code>TimedElementNode</code> for the requested document.
080:             */
081:            public ElementNode newInstance(final DocumentNode doc) {
082:                return new Set(doc);
083:            }
084:
085:            /**
086:             * Supported traits: to, attributeName
087:             *
088:             * @param traitName the name of the trait which the element may support.
089:             * @return true if this element supports the given trait in one of the
090:             *         trait accessor methods.
091:             */
092:            boolean supportsTrait(final String traitName) {
093:                if (SVGConstants.SVG_TO_ATTRIBUTE == traitName
094:                        || SVGConstants.SVG_ATTRIBUTE_NAME_ATTRIBUTE == traitName) {
095:                    return true;
096:                } else {
097:                    return super .supportsTrait(traitName);
098:                }
099:            }
100:
101:            /**
102:             * @return an array of traits that are required by this element.
103:             */
104:            public String[] getRequiredTraits() {
105:                return REQUIRED_TRAITS;
106:            }
107:
108:            /**
109:             * Set supports the to and attributeName traits.
110:             *
111:             * Returns the trait value as String. In SVG Tiny only certain traits can be
112:             * obtained as a String value. Syntax of the returned String matches the
113:             * syntax of the corresponding attribute. This element is exactly equivalent
114:             * to {@link org.w3c.dom.svg.SVGElement#getTraitNS getTraitNS} with
115:             * namespaceURI set to null.
116:             *
117:             * The method is meant to be overridden by derived classes. The 
118:             * implementation pattern is that derived classes will override the method 
119:             * and call their super class' implementation. If the ElementNode 
120:             * implementation is called, it means that the trait is either not supported
121:             * or that it cannot be seen as a String.
122:             *
123:             * @param name the requested trait name.
124:             * @return the trait value.
125:             *
126:             * @throws DOMException with error code NOT_SUPPORTED_ERROR if the requested
127:             * trait is not supported on this element or null.
128:             * @throws DOMException with error code TYPE_MISMATCH_ERR if requested
129:             * trait's computed value cannot be converted to a String (SVG Tiny only).
130:             */
131:            public String getTraitImpl(final String name) throws DOMException {
132:                if (SVGConstants.SVG_TO_ATTRIBUTE == name) {
133:                    return to[0];
134:                } else if (SVGConstants.SVG_ATTRIBUTE_NAME_ATTRIBUTE == name) {
135:                    return traitQName;
136:                } else {
137:                    return super .getTraitImpl(name);
138:                }
139:            }
140:
141:            /**
142:             * Set supports the attributeName and to traits.
143:             *
144:             * @param name the trait's name.
145:             * @param value the trait's value.
146:             *
147:             * @throws DOMException with error code NOT_SUPPORTED_ERR if the requested
148:             * trait is not supported on this element or null.
149:             * @throws DOMException with error code TYPE_MISMATCH_ERR if the requested
150:             * trait's value cannot be specified as a String
151:             * @throws DOMException with error code INVALID_ACCESS_ERR if the input
152:             * value is an invalid value for the given trait or null.
153:             * @throws DOMException with error code NO_MODIFICATION_ALLOWED_ERR: if
154:             * attempt is made to change readonly trait.
155:             */
156:            public void setTraitImpl(final String name, final String value)
157:                    throws DOMException {
158:                if (SVGConstants.SVG_TO_ATTRIBUTE == name) {
159:                    checkWriteLoading(name);
160:                    if (value == null) {
161:                        throw illegalTraitValue(name, value);
162:                    }
163:                    to[0] = value;
164:                } else if (SVGConstants.SVG_ATTRIBUTE_NAME_ATTRIBUTE == name) {
165:                    checkWriteLoading(name);
166:
167:                    if (value == null) {
168:                        throw illegalTraitValue(name, value);
169:                    }
170:
171:                    // Now, if this is a QName, we need to use the namespace prefix map.
172:                    int i = value.indexOf(':');
173:                    if (i == -1) {
174:                        this .traitName = value.intern();
175:                        this .traitQName = value.intern();
176:                    } else {
177:                        if (i == value.length() - 1) {
178:                            // ':' is the last character, this is invalid.
179:                            throw illegalTraitValue(name, value);
180:                        }
181:
182:                        String prefix = value.substring(0, i);
183:                        String tName = value.substring(i + 1);
184:
185:                        String ns = ownerDocument.toNamespace(prefix, this );
186:                        if (ns == null) {
187:                            throw illegalTraitValue(name, value);
188:                        }
189:
190:                        traitName = tName.intern();
191:                        traitNamespace = ns.intern();
192:                        traitQName = value;
193:                    }
194:                } else {
195:                    super .setTraitImpl(name, value);
196:                }
197:            }
198:
199:            /**
200:             * This is the Set element's animation function. It is very
201:             * simple as it simply returns the 'to' value, no matter
202:             * what time t is.
203:             *
204:             * @param t the animation's simple time.
205:             */
206:            Object[] f(final long t) {
207:                return refValues.getSegment(0).getStart();
208:            }
209:
210:            /**
211:             * Validating a Set consists in:
212:             * a) Setting its target element. If there was no idRef, then targetElement
213:             *    is still null and will be positioned to the parent node.
214:             * b) Validating the to value with the targetElement, using the target trait
215:             *    name, namespace and value.
216:             *
217:             * @throws DOMException if there is a validation error, for example if the
218:             *         to value is incompatible with the target trait or if the target
219:             *         trait is not animatable.
220:             */
221:            void validate() throws DOMException {
222:                // a) Set the target element.
223:                if (targetElement == null) {
224:                    targetElement = (ElementNode) parent;
225:                }
226:
227:                // b) Validate the to value with the target element.
228:                traitAnim = targetElement.getSafeTraitAnimNS(traitNamespace,
229:                        traitName);
230:
231:                if (to[0] != null) {
232:                    refValues = traitAnim.toRefValues(this , to, null,
233:                            SVGConstants.SVG_TO_ATTRIBUTE);
234:                } else {
235:                    hasNoEffect = true;
236:                }
237:            }
238:
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.