Source Code Cross Referenced for Query.java in  » IDE » tIDE » snow » sortabletable » 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 » tIDE » snow.sortabletable 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package snow.sortabletable;
002:
003:        import java.util.regex.Pattern;
004:
005:        /**
006:         * Describes a search query for the sortable table
007:         *  IMMUTABLE !
008:         */
009:        public class Query {
010:            // existing boolean operators to combine multiple query objects
011:            public static final int OPERATION_AND = 0;
012:            public static final int OPERATION_OR = 1;
013:            public static final int OPERATION_AND_NOT = 2;
014:            public static final int OPERATION_OR_NOT = 3;
015:            //public static final int OPERATION_XOR  = 4;
016:
017:            public final static String[] booleanCombineNames = new String[] {
018:                    "and", "or", "and not", "or not" };
019:
020:            public enum Combine {
021:                And, Or, AndNot, OrNot;
022:                public static Combine forIndex(int i) {
023:                    switch (i) {
024:                    case 0:
025:                        return And;
026:                    case 1:
027:                        return Or;
028:                    case 2:
029:                        return AndNot;
030:                    case 3:
031:                        return OrNot;
032:                    }
033:                    return And;
034:                }
035:            }
036:
037:            public final static String[] comparisonTypeNames = new String[] {
038:                    "contains", "equals", "starts with", "ends with", "regEx" };
039:
040:            public enum Comparison {
041:                Contains, Equals, StartsWith, EndsWith, RegEx;
042:                public static Comparison forIndex(int i) {
043:                    switch (i) {
044:                    case 0:
045:                        return Contains;
046:                    case 1:
047:                        return Equals;
048:                    case 2:
049:                        return StartsWith;
050:                    case 3:
051:                        return EndsWith;
052:                    case 4:
053:                        return RegEx; // matcher matches (fully), case insensitive.
054:                    }
055:                    return RegEx;
056:                }
057:            }
058:
059:            public Comparison comparison = Comparison.Contains;
060:            public final Pattern pattern;
061:            public final int column; // = -1;  // -1 means all columns
062:            public final String searchTxt;
063:            public final Combine boolOp; // = OPERATION_AND;
064:
065:            public Query(int _column, String _searchTxt, Combine _boolOp) {
066:                this (_column, _searchTxt, _boolOp, Comparison.Contains);
067:            }
068:
069:            public Query(int _column, String _searchTxt, Combine _boolOp,
070:                    Comparison _comparison) {
071:                this .column = _column;
072:                this .searchTxt = _searchTxt.toUpperCase();
073:                this .boolOp = _boolOp;
074:                this .comparison = _comparison;
075:
076:                if (_comparison == Comparison.RegEx) {
077:                    // use the arg, NOT the uppercased, because "\s" is NOT "\S" !!!
078:                    pattern = Pattern.compile(_searchTxt,
079:                            Pattern.CASE_INSENSITIVE);
080:                } else {
081:                    pattern = null;
082:                }
083:            }
084:
085:            public boolean isEmpty() {
086:                return searchTxt.length() == 0;
087:            }
088:
089:            public boolean isNegation() {
090:                return boolOp == Combine.AndNot || boolOp == Combine.OrNot;
091:            }
092:
093:            public static Query[] simpleSearchQuery(String txt) {
094:                return new Query[] { new Query(-1, txt, Combine.And,
095:                        Comparison.Contains) };
096:            }
097:
098:            public static Query[] emptySearchQuery() {
099:                return new Query[] { new Query(-1, "", Combine.And,
100:                        Comparison.Contains) };
101:            }
102:
103:            @Override
104:            public final String toString() {
105:                if (this .isEmpty())
106:                    return "Query empty";
107:                StringBuilder sb = new StringBuilder(50);
108:                sb.append("Query '");
109:                sb.append(searchTxt);
110:                sb.append("' in col ");
111:                sb.append(column);
112:                sb.append(" bool ");
113:                sb.append(boolOp);
114:                return sb.toString();
115:            }
116:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.