Source Code Cross Referenced for StringTraitAnim.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 org.w3c.dom.DOMException;
030:
031:        /**
032:         * @version $Id: StringTraitAnim.java,v 1.2 2006/04/21 06:38:55 st125089 Exp $
033:         */
034:        final class StringTraitAnim extends TraitAnim {
035:            /**
036:             * The trait's base value.
037:             */
038:            String[] baseValue = new String[1];
039:
040:            /**
041:             * Constructs a new StringTraitAnim for a given ElementNode trait
042:             * in the given namespace.
043:             *
044:             * @param targetElement the ElementNode whose trait is animated.
045:             * @param targetNamespace the target trait's namespace. Should not 
046:             *        be null. The per-element partition namespace should be 
047:             *        represented by the ElementNode.NULL_NS value.
048:             * @param targetTrait the name of the animated trait.
049:             */
050:            public StringTraitAnim(final ElementNode targetElement,
051:                    final String traitNamespace, final String traitName) {
052:                super (targetElement, traitNamespace, traitName,
053:                        ElementNode.TRAIT_TYPE_STRING);
054:            }
055:
056:            /**
057:             * @return the trait's value, as a String.
058:             */
059:            protected String getTraitImpl() {
060:                // This returns the computed trait value, using the specified 
061:                // trait value.
062:                return targetElement
063:                        .validateTraitNS(traitNamespace, traitName,
064:                                getSpecifiedTraitNS(), targetElement
065:                                        .getNamespaceURI(), targetElement
066:                                        .getLocalName(), traitNamespace,
067:                                traitName);
068:            }
069:
070:            /**
071:             * Sets the trait's base value, as a String.
072:             * 
073:             * @param value the new trait base value.
074:             *
075:             * @throws DOMException with error code INVALID_ACCESS_ERR if the input
076:             * value is an invalid value for the given trait or null.
077:             */
078:            void setTraitImpl(String value) throws DOMException {
079:                // Validate on set so that we do not get an error later.
080:                // However, we keep the specified value around, for properties 
081:                // that may have relative or inherited values.
082:                targetElement.validateTraitNS(traitNamespace, traitName, value,
083:                        targetElement.getNamespaceURI(), targetElement
084:                                .getLocalName(), traitNamespace, traitName);
085:                specifiedTraitValue = value;
086:            }
087:
088:            /**
089:             * Returns the BaseValue as an array of objects.
090:             *
091:             * @return the base value as an object array. The dimensions of the
092:             *         returned array depend on the trait.
093:             * @see com.sun.perseus.model.BaseValue
094:             */
095:            public Object[] getBaseValue() {
096:                baseValue[0] = getTraitImpl();
097:                return baseValue;
098:            }
099:
100:            /**
101:             * Applies the animation effect. The implementation makes sure it 
102:             * implements the sandwich model by 'pulling' values from the 
103:             * root animation (i.e., the animation with the highest priority).
104:             */
105:            void apply() {
106:                String value = (String) rootAnim.compute()[0];
107:
108:                if (traitNamespace == ElementNode.NULL_NS) {
109:                    targetElement.setTraitImpl(traitName, value);
110:                } else {
111:                    targetElement.setTraitNSImpl(traitNamespace, traitName,
112:                            value);
113:                }
114:            }
115:
116:            /**
117:             * Converts the input values set to a RefValues object.
118:             *
119:             * @param anim the <code>Animation</code> for which the values should be
120:             *        converted.
121:             * @param values a semi-colon seperated list of values which need to be
122:             * validated.
123:             * @param reqTraitNamespace the namespace of the trait which has the values
124:             *        value on the requesting element.
125:             * @param reqTraitName the name of the trait which has the values value on 
126:             *        the requesting element.
127:             * @throws DOMException with error code INVALID_ACCESS_ERR if the input
128:             * value is incompatible with the given trait.
129:             * @throws NullPointerException if values is null.
130:             */
131:            RefValues toRefValues(final Animation anim, String[] values,
132:                    final String reqTraitNamespace, final String reqTraitName)
133:                    throws DOMException {
134:                StringRefValues refValues = new StringRefValues();
135:
136:                if (values.length < 1) {
137:                    throw new IllegalArgumentException();
138:                }
139:
140:                if (values.length == 1) {
141:                    String[] tmpValues = new String[2];
142:                    tmpValues[0] = values[0];
143:                    tmpValues[1] = values[0];
144:                    values = tmpValues;
145:                }
146:
147:                int nSegments = values.length - 1;
148:                refValues.segments = new StringSegment[nSegments];
149:
150:                // Build the first segment.
151:                refValues.segments[0] = new StringSegment();
152:                refValues.segments[0].start = new String[] { values[0] };
153:                refValues.segments[0].end = new String[] { values[1] };
154:
155:                targetElement.validateTraitNS(anim.traitNamespace,
156:                        anim.traitName, refValues.segments[0].start[0], anim
157:                                .getNamespaceURI(), anim.getLocalName(),
158:                        reqTraitNamespace, reqTraitName);
159:
160:                targetElement.validateTraitNS(anim.traitNamespace,
161:                        anim.traitName, refValues.segments[0].end[0], anim
162:                                .getNamespaceURI(), anim.getLocalName(),
163:                        reqTraitNamespace, reqTraitName);
164:
165:                StringSegment prevSegment = refValues.segments[0];
166:
167:                for (int i = 1; i < nSegments; i++) {
168:                    refValues.segments[i] = new StringSegment();
169:                    refValues.segments[i].start = prevSegment.end;
170:                    refValues.segments[i].end = new String[] { values[i + 1] };
171:                    targetElement.validateTraitNS(anim.traitNamespace,
172:                            anim.traitName, refValues.segments[i].end[0], anim
173:                                    .getNamespaceURI(), anim.getLocalName(),
174:                            reqTraitNamespace, reqTraitName);
175:                    prevSegment = refValues.segments[i];
176:                }
177:
178:                return refValues;
179:            }
180:
181:            /**
182:             * Used to sum two animated trait values. Because String traits cannot 
183:             * be summed, this always returns the second parameter value.
184:             *
185:             * @param valueA the base value. May be null.
186:             * @param valueB the value to add to the base value. If the baseValue 
187:             */
188:            public Object[] sum(Object[] valueA, Object[] valueB) {
189:                // String animations do not support additive behavior.
190:                throw new Error();
191:            }
192:
193:            /**
194:             * Used to multiply an animated trait value by a number of iterations.
195:             *
196:             * @param value the animated trait value to multiply.
197:             * @param iter the number of iteration to account for.
198:             * @return the multiply result.
199:             */
200:            public Object[] multiply(Object[] value, int iter) {
201:                // String animations do not support additive behavior.
202:                throw new Error();
203:            }
204:
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.