Source Code Cross Referenced for StringSegment.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:         *  $RCSfile: StringSegment.java,v $
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:        package com.sun.perseus.model;
027:
028:        /**
029:         * Represents String segment in an animation.
030:         *
031:         * @version $Id: StringSegment.java,v 1.3 2006/06/29 10:47:34 ln156897 Exp $
032:         */
033:        class StringSegment implements  Segment {
034:            /**
035:             * The segment's begin value.
036:             */
037:            String[] start;
038:
039:            /**
040:             * The segment's end value.
041:             */
042:            String[] end;
043:
044:            /**
045:             * @return the start value.
046:             */
047:            public Object[] getStart() {
048:                return start;
049:            }
050:
051:            /**
052:             * @return set end value.
053:             */
054:            public Object[] getEnd() {
055:                return end;
056:            }
057:
058:            /**
059:             * Sets the start value to its notion of 'zero'.
060:             * For a StringSegment, a 'zero' start means empty strings
061:             * on all components.
062:             */
063:            public void setZeroStart() {
064:                for (int i = 0; i < start.length; i++) {
065:                    start[i] = "";
066:                }
067:            }
068:
069:            /**
070:             * Sets the start value. 
071:             *
072:             * @param newStart the new segment start value.
073:             */
074:            public void setStart(Object[] newStart) {
075:                start = (String[]) newStart;
076:            }
077:
078:            /**
079:             * Collapses this segment with the one passed as a parameter.
080:             * Note that if the input segment is not of the same class
081:             * as this one, an IllegalArgumentException is thrown. The 
082:             * method also throws an exception if the input segment's
083:             * end does not have the same number of components as this 
084:             * segment's end.
085:             *
086:             * After this method is called, this segment's end value
087:             * is the one of the input <code>seg</code> parameter.
088:             *
089:             * @param seg the Segment to collapse with this one.
090:             * @param anim the Animation this segment is part of.
091:             */
092:            public void collapse(final Segment seg, final Animation anim) {
093:                StringSegment mseg = (StringSegment) seg;
094:                if (mseg.end.length != end.length) {
095:                    throw new IllegalArgumentException();
096:                }
097:
098:                end = mseg.end;
099:            }
100:
101:            /**
102:             * Adds the input value to this Segment's end value.
103:             * 
104:             * @param by the value to add. Throws IllegalArgumentException if this
105:             * Segment type is not additive or if the input value is incompatible (e.g.,
106:             * different number of components or different number of dimensions on a
107:             * component).
108:             */
109:            public void addToEnd(Object[] by) {
110:                throw new IllegalArgumentException();
111:            }
112:
113:            /**
114:             * @return true if this segment type supports addition. false
115:             * otherwise.
116:             */
117:            public boolean isAdditive() {
118:                return false;
119:            }
120:
121:            /**
122:             * Computes an interpolated value for the given penetration in the 
123:             * segment.
124:             *
125:             * @param p the segment penetration. Should be in the [0, 1] range.
126:             * @return the interpolated value.
127:             */
128:            public String[] compute(final float p) {
129:                if (p == 1) {
130:                    return end;
131:                } else {
132:                    return start;
133:                }
134:            }
135:
136:            /**
137:             * Debug helper.
138:             */
139:            public String toString() {
140:                StringBuffer sb = new StringBuffer();
141:                sb.append("StringSegment[");
142:                if (start == null) {
143:                    sb.append("null");
144:                } else {
145:                    sb.append("start[" + start.length + "] : {");
146:                    for (int ci = 0; ci < start.length; ci++) {
147:                        sb.append("\"" + start[ci] + "\"");
148:                        if (ci < start.length - 1) {
149:                            sb.append(",");
150:                        }
151:                    }
152:                    sb.append("}");
153:                }
154:
155:                if (end == null) {
156:                    sb.append(" null");
157:                } else {
158:                    sb.append(" end[" + end.length + "] : {");
159:                    for (int ci = 0; ci < end.length; ci++) {
160:                        sb.append("\"" + end[ci] + "\"");
161:                        if (ci < end.length - 1) {
162:                            sb.append(",");
163:                        }
164:                    }
165:                    sb.append("}");
166:                }
167:
168:                return sb.toString();
169:            }
170:
171:            /**
172:             * Computes this segment's length. This is always the value
173:             * '1' for a string segment.
174:             */
175:            public final float getLength() {
176:                return 1;
177:            }
178:
179:            /**
180:             * Should be called after the segment's configuration is complete
181:             * to give the segment's implementation a chance to initialize 
182:             * internal data and cache values.
183:             */
184:            public final void initialize() {
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.