Source Code Cross Referenced for Edit.java in  » Portal » Open-Portal » com » sun » portal » wireless » taglibs » base » 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 » Portal » Open Portal » com.sun.portal.wireless.taglibs.base 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: Edit.java,v 1.4 2003/01/10 02:53:28 rakeshn Exp $
003:         * Copyright 2002 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.wireless.taglibs.base;
014:
015:        import com.sun.portal.desktop.encode.Encoder;
016:        import com.sun.portal.desktop.encode.EncoderException;
017:
018:        public class Edit {
019:
020:            public static final int ESCAPE_STYLE_NONE = 0;
021:            public static final int ESCAPE_STYLE_XML = 1;
022:            public static final int ESCAPE_STYLE_WML = 2;
023:
024:            private int truncation = -1;
025:            private boolean escape = false;
026:            private String from = null;
027:            private int fromLength = 0;
028:            private String to = "";
029:            private int toLength = 0;
030:            private String escapeClassName;
031:
032:            /**
033:             * Edit constructor...
034:             *
035:             */
036:            public Edit(String escapeClassNameParam) {
037:                this .escapeClassName = escapeClassNameParam;
038:            }
039:
040:            /**
041:             * String substitution...
042:             *
043:             */
044:            private String substituteString(String string) {
045:                int matchIndex = string.indexOf(from);
046:
047:                if (matchIndex == -1)
048:                    return string;
049:
050:                return string.substring(0, matchIndex)
051:                        + to
052:                        + substituteString(string.substring(matchIndex
053:                                + fromLength));
054:            }
055:
056:            /**
057:             * Process string according to
058:             * current edit rules.
059:             *
060:             * @return processed string
061:             */
062:            public String editString(String string) {
063:                int length = 0;
064:
065:                if (string != null) {
066:                    length = string.length();
067:                }
068:
069:                if (length > 0) {
070:                    // Perform case conversion
071:                    //
072:                    if (toLower) {
073:                        string = string.toLowerCase();
074:                    } else if (toUpper) {
075:                        string = string.toUpperCase();
076:                    }
077:
078:                    // Perform substitution...
079:                    if (fromLength != 0) {
080:                        string = substituteString(string);
081:                    }
082:
083:                    // Compute truncation...
084:                    length = string.length();
085:                    int trunc = truncation;
086:                    if (trunc < 0) {
087:                        trunc = length;
088:                    } else {
089:                        trunc = (trunc > length) ? length : trunc;
090:                    }
091:
092:                    // Truncate, escape, and output...
093:                    if (escape) {
094:                        try {
095:                            return Encoder.encode(escapeClassName, string
096:                                    .substring(0, trunc));
097:                        } catch (EncoderException ex) {
098:                            return string.substring(0, trunc);
099:                        }
100:                    } else {
101:                        return string.substring(0, trunc);
102:                    }
103:                }
104:
105:                return string;
106:            }
107:
108:            /**
109:             * Get from...
110:             * 
111:             * @return the from value.
112:             */
113:            public String getFrom() {
114:                return from;
115:            }
116:
117:            /**
118:             * Set from...
119:             * 
120:             * @return none
121:             */
122:            public void setFrom(String s) {
123:                from = s;
124:                fromLength = from.length();
125:                return;
126:            }
127:
128:            /**
129:             * Get to...
130:             * 
131:             * @return the from value.
132:             */
133:            public String getTo() {
134:                return to;
135:            }
136:
137:            /**
138:             * Set from...
139:             * 
140:             * @return none
141:             */
142:            public void setTo(String s) {
143:                to = s;
144:                toLength = to.length();
145:                return;
146:            }
147:
148:            /**
149:             * Get truncation...
150:             * 
151:             * @return the truncation value.
152:             */
153:            public int getTruncation() {
154:                return truncation;
155:            }
156:
157:            /**
158:             * Set truncation...
159:             * 
160:             * @return none
161:             */
162:            public void setTruncation(int v) {
163:                truncation = v;
164:            }
165:
166:            /**
167:             * Get escape...
168:             * 
169:             * @return the escape value.
170:             */
171:            public boolean getEscape() {
172:                return escape;
173:            }
174:
175:            /**
176:             * Set escape...
177:             * 
178:             * @return none
179:             */
180:            public void setEscape(boolean b) {
181:                escape = b;
182:            }
183:
184:            /**
185:             * Specify if the property is to be returned upper/lowercase
186:             */
187:
188:            private boolean toLower = false;
189:            private boolean toUpper = false;
190:
191:            /**
192:             * Set the case.
193:             */
194:            public void setCase(String type) {
195:                String caseType = null;
196:
197:                if (type != null) {
198:                    caseType = type.trim();
199:                    if (caseType.equals("")) // throw away empty strings
200:                        caseType = null;
201:                }
202:
203:                if (caseType != null) {
204:                    if (caseType.equalsIgnoreCase("lower"))
205:                        toLower = true;
206:                    else if (caseType.equalsIgnoreCase("upper"))
207:                        toUpper = true;
208:                }
209:            }
210:
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.