Source Code Cross Referenced for Strings.java in  » Database-DBMS » db4o-6.4 » com » db4o » db4ounit » util » 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 » Database DBMS » db4o 6.4 » com.db4o.db4ounit.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (C) 2004 - 2007  db4objects Inc.  http://www.db4o.com
002:
003:        This file is part of the db4o open source object database.
004:
005:        db4o is free software; you can redistribute it and/or modify it under
006:        the terms of version 2 of the GNU General Public License as published
007:        by the Free Software Foundation and as clarified by db4objects' GPL 
008:        interpretation policy, available at
009:        http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010:        Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011:        Suite 350, San Mateo, CA 94403, USA.
012:
013:        db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014:        WARRANTY; without even the implied warranty of MERCHANTABILITY or
015:        FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
016:        for more details.
017:
018:        You should have received a copy of the GNU General Public License along
019:        with this program; if not, write to the Free Software Foundation, Inc.,
020:        59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */
021:        package com.db4o.db4ounit.util;
022:
023:        /**
024:         * @sharpen.ignore
025:         */
026:        public class Strings {
027:
028:            private static final char DATESEPARATOR = '-';
029:            private static final char TIMESEPARATOR = ':';
030:            private static final char DATETIMESEPARATOR = ' ';
031:
032:            private String _string;
033:
034:            private Strings() {
035:            }
036:
037:            public Strings(String str) {
038:                this ();
039:                _string = str;
040:            }
041:
042:            public Strings(char a_char, int a_count) {
043:                char[] chars = new char[a_count];
044:                for (int i = 0; i < a_count; chars[i++] = a_char)
045:                    ;
046:                _string = new String(chars);
047:            }
048:
049:            public Strings(int i) {
050:                _string = "" + i;
051:            }
052:
053:            public Strings(long l) {
054:                _string = "" + l;
055:            }
056:
057:            public Strings(char c) {
058:                _string = "" + c;
059:            }
060:
061:            public void clear() {
062:                _string = "";
063:            }
064:
065:            public String getString() {
066:                return _string;
067:            }
068:
069:            protected String joinDate(String year, String month, String day) {
070:                _string = year + DATESEPARATOR + month + DATESEPARATOR + day;
071:                return _string;
072:            }
073:
074:            protected String joinTime(String hours, String minutes,
075:                    String seconds) {
076:                _string = hours + TIMESEPARATOR + minutes + TIMESEPARATOR
077:                        + seconds;
078:                return _string;
079:            }
080:
081:            protected String joinDateTime(String date, String time) {
082:                _string = date + DATETIMESEPARATOR + time;
083:                return _string;
084:            }
085:
086:            public static String _left(String a_String, int a_chars) {
087:                return new Strings(a_String).left(a_chars);
088:            }
089:
090:            public String left(int a_chars) {
091:                if (a_chars > _string.length()) {
092:                    a_chars = _string.length();
093:                } else {
094:                    if (a_chars < 0) {
095:                        a_chars = 0;
096:                    }
097:                }
098:                return _string.substring(0, a_chars);
099:            }
100:
101:            public static boolean _left(String ofString, String isString) {
102:                return new Strings(ofString).left(isString);
103:            }
104:
105:            public boolean left(String compareString) {
106:                return left(compareString.length()).toUpperCase().equals(
107:                        compareString.toUpperCase());
108:            }
109:
110:            public String padLeft(char a_char, int a_length) {
111:                return new Strings(new Strings(a_char, a_length).getString()
112:                        + _string).right(a_length);
113:            }
114:
115:            public String PadRight(char a_char, int a_length) {
116:                return (_string + new Strings(a_char, a_length).getString())
117:                        .substring(0, a_length);
118:            }
119:
120:            public void replace(String a_Replace, String a_With) {
121:                replace(a_Replace, a_With, 0);
122:            }
123:
124:            public static String replace(String source, String replace,
125:                    String with) {
126:                Strings s = new Strings(source);
127:                s.replace(replace, with);
128:                return s.getString();
129:            }
130:
131:            private void replace(String replace, String with, int start) {
132:                int pos = 0;
133:                while ((pos = _string.indexOf(replace, start)) > -1) {
134:                    _string = _string.substring(0, pos) + with
135:                            + _string.substring(pos + replace.length());
136:                }
137:            }
138:
139:            public void replace(String begin, String end, String with, int start) {
140:                int from = _string.indexOf(begin, start);
141:                if (from > -1) {
142:                    int to = _string.indexOf(end, from + 1);
143:                    if (to > -1) {
144:                        _string = _string.substring(0, from) + with
145:                                + _string.substring(to + end.length());
146:                        replace(begin, end, with, to);
147:                    }
148:                }
149:            }
150:
151:            public static String _right(String ofString, int isChar) {
152:                return new Strings(ofString).right(isChar);
153:            }
154:
155:            public String right(int a_chars) {
156:                int l_take = _string.length() - a_chars;
157:                if (l_take < 0) {
158:                    l_take = 0;
159:                }
160:                return _string.substring(l_take);
161:            }
162:
163:            public static boolean _right(String ofString, String compareString) {
164:                return new Strings(ofString).right(compareString);
165:            }
166:
167:            public boolean right(String compareString) {
168:                int l_take = _string.length() - compareString.length();
169:                if (l_take < 0) {
170:                    l_take = 0;
171:                }
172:                String right = _string.substring(l_take).toUpperCase();
173:                return right.equals(compareString.toUpperCase());
174:            }
175:
176:            public static String _splitRight(String a_String, String a_Splitter) {
177:                return new Strings(a_String).splitRight(a_Splitter);
178:            }
179:
180:            public String splitRight(String a_Splitter) {
181:                String l_Return = "";
182:                int l_pos = _string.lastIndexOf(a_Splitter);
183:                if (l_pos > 0) {
184:                    l_Return = _string.substring(l_pos + a_Splitter.length());
185:                    _string = _string.substring(0, l_pos);
186:                }
187:                return l_Return;
188:            }
189:
190:            public String toString() {
191:                return _string;
192:            }
193:
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.