Source Code Cross Referenced for CamelUtil.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » quickaccess » 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 » IDE Eclipse » ui workbench » org.eclipse.ui.internal.quickaccess 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         ******************************************************************************/package org.eclipse.ui.internal.quickaccess;
011:
012:        import java.util.ArrayList;
013:        import java.util.List;
014:
015:        /**
016:         * Utility methods for camel case style matching.
017:         *  
018:         * @since 3.3
019:         * 
020:         */
021:        public class CamelUtil {
022:
023:            /**
024:             * Returns a lowercase string consisting of all initials of the words in the
025:             * given String. Words are separated by whitespace and other special
026:             * characters, or by uppercase letters in a word like CamelCase.
027:             * 
028:             * @param s
029:             *            the string
030:             * @return a lowercase string containing the first character of every wordin
031:             *         the given string.
032:             */
033:            public static String getCamelCase(String s) {
034:                StringBuffer result = new StringBuffer();
035:                if (s.length() > 0) {
036:                    int index = 0;
037:                    while (index != -1) {
038:                        result.append(s.charAt(index));
039:                        index = getNextCamelIndex(s, index + 1);
040:                    }
041:                }
042:                return result.toString().toLowerCase();
043:            }
044:
045:            /**
046:             * Return an array with start/end indices for the characters used for camel
047:             * case matching, ignoring the first (start) many camel case characters.
048:             * For example, getCamelCaseIndices("some CamelCase", 1, 2) will return
049:             * {{5,5},{10,10}}.
050:             * 
051:             * @param s the source string
052:             * @param start how many characters of getCamelCase(s) should be ignored
053:             * @param length for how many characters should indices be returned 
054:             * @return an array of length start
055:             */
056:            public static int[][] getCamelCaseIndices(String s, int start,
057:                    int length) {
058:                List result = new ArrayList();
059:                int index = 0;
060:                while (start > 0) {
061:                    index = getNextCamelIndex(s, index + 1);
062:                    start--;
063:                }
064:                while (length > 0) {
065:                    result.add(new int[] { index, index });
066:                    index = getNextCamelIndex(s, index + 1);
067:                    length--;
068:                }
069:                return (int[][]) result.toArray(new int[result.size()][]);
070:            }
071:
072:            /**
073:             * Returns the next index to be used for camel case matching.
074:             * 
075:             * @param s the string
076:             * @param index the index
077:             * @return the next index, or -1 if not found
078:             */
079:            public static int getNextCamelIndex(String s, int index) {
080:                char c;
081:                while (index < s.length()
082:                        && !(isSeparatorForCamelCase(c = s.charAt(index)))
083:                        && Character.isLowerCase(c)) {
084:                    index++;
085:                }
086:                while (index < s.length()
087:                        && isSeparatorForCamelCase(c = s.charAt(index))) {
088:                    index++;
089:                }
090:                if (index >= s.length()) {
091:                    index = -1;
092:                }
093:                return index;
094:            }
095:
096:            /**
097:             * Returns true if the given character is to be considered a separator
098:             * for camel case matching purposes.
099:             * 
100:             * @param c the character
101:             * @return true if the character is a separator
102:             */
103:            public static boolean isSeparatorForCamelCase(char c) {
104:                return !Character.isLetterOrDigit(c);
105:            }
106:
107:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.