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


001:        /**
002:         * $Id: ABSearchTerm.java,v 1.6 2003/03/28 19:32:18 dpolla 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 iPlanet
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.addressbook;
014:
015:        import java.util.Vector;
016:        import java.util.Properties;
017:        import java.util.Enumeration;
018:
019:        /**
020:         * Address Book Filter Search Term represents a search term like "ln=doe". 
021:         * The search terms can be nested in a tree structure and combined with 
022:         * an 'and' or an 'or' e.g. "ln=doe & (fn=john | fn=joe)".
023:         *
024:         */
025:        public abstract class ABSearchTerm {
026:
027:            /**
028:             * Values for operators
029:             */
030:            public static final int NO_OP = -1;
031:
032:            public static final int NOT = 0;
033:            public static final int OR = 1;
034:            public static final int AND = 2;
035:
036:            /** 
037:             * Name of the attribute to search on.
038:             */
039:            protected String name = null;
040:
041:            /** 
042:             * Value of the attribute to search.
043:             */
044:            protected String value = null;
045:
046:            /** 
047:             * Default search is carried out as an exact search. Can be set to 
048:             * 'contains' search like '*str*' in ldap by setting exact to false.
049:             */
050:            protected boolean exact = true;
051:
052:            /**
053:             *  Boolean indicating the relationship between name and value
054:             */
055:            protected boolean not = false;
056:
057:            /** 
058:             * ABSearchTerm array which stores the recursive ABSearchTerms. 
059:             */
060:            protected ABSearchTerm[] terms = null;
061:
062:            /** 
063:             * Operator binding the recursive searchTerms in this instance of ABSearchTerm.
064:             */
065:            protected int op = NO_OP;
066:
067:            /** 
068:             * Initializes the search term object. This constructor indicates this search term 
069:             * is an end node and does not contain recursive search terms.
070:             *
071:             * @param name     Name of the attribute to search on.
072:             * @param value    Value of the attribute to search.
073:             * @param exact    Boolean indicating whether search is 'exact'(true) or
074:             *                 'contains'(false).
075:             */
076:            public ABSearchTerm(String name, String value, boolean exact) {
077:                this .name = name;
078:                this .value = value;
079:                this .exact = exact;
080:                this .terms = null;
081:            };
082:
083:            /** 
084:             * Initializes the search term object. This constructor is used for the unary 
085:             * operator NOT on the ABSearchTerm. Usage of this constructor means that ABSearchTerm 
086:             * is recursive and is not the end node, and it will contain terms, op and not name, 
087:             * value.
088:             *
089:             * @param   The recursive ABSearchTerm.
090:             * @param   Operator binding the recursive searchTerms. The value can only be NOT.
091:             */
092:            public ABSearchTerm(ABSearchTerm term, int op)
093:                    throws ABStoreException {
094:                if (op != NOT) {
095:                    String msg = "ABSearchTerm: Invalid operator - " + op
096:                            + ". Operator can only be NOT";
097:                    throw new ABStoreException(msg);
098:                }
099:                ABSearchTerm[] terms = new ABSearchTerm[1];
100:                terms[0] = term;
101:                this .terms = terms;
102:                this .op = op;
103:            };
104:
105:            /** 
106:             * Initializes the search term object. This constructor is used for the binary 
107:             * operators like AND and OR on the ABSearchTerms array. Usage of this constructor 
108:             * means that ABSearchTerm is recursive and is not the end node, and it will 
109:             * contain terms, op and not name, value.
110:             *
111:             * @param   The recursive ABSearchTerm array.
112:             * @param   Operator binding the recursive searchTerms. The values can be AND or OR.
113:             */
114:            public ABSearchTerm(ABSearchTerm[] terms, int op)
115:                    throws ABStoreException {
116:                if ((op != AND) && (op != OR)) {
117:                    String msg = "ABSearchTerm: Invalid operator - " + op
118:                            + ". Operator can only be AND/OR";
119:                    throw new ABStoreException(msg);
120:                }
121:                if ((terms.length < 2)) {
122:                    String msg = "ABSearchTerm: Number of search Terms in array to be AND/ORed wrong - "
123:                            + terms.length;
124:                    throw new ABStoreException(msg);
125:                }
126:                this .terms = terms;
127:                this .op = op;
128:            };
129:
130:            /** 
131:             * Get the name of the attribute to search on.
132:             * 
133:             * @return name   Name of the attribute to search on.
134:             */
135:            public String getName() {
136:                return name;
137:            };
138:
139:            /** 
140:             * Get the value of the attribute to search.
141:             * 
142:             * @return value   Value of the attribute to search.
143:             */
144:            public String getValue() {
145:                return value;
146:            };
147:
148:            /** 
149:             * Get the ABSearchTerm array which stores the recursive ABSearchTerms.
150:             * Present only in case the ABSearchTerm is not an end node.
151:             * 
152:             * @return terms
153:             */
154:            public ABSearchTerm[] getTerms() {
155:                return terms;
156:            };
157:
158:            /** 
159:             * Get the value of the operator binding the recursive searchTerms 
160:             * Present only in case the ABSearchTerm is not an end node.
161:             * 
162:             * @return op - int
163:             */
164:            public int getOp() {
165:                return op;
166:            };
167:
168:            /** 
169:             * Return the value of the exact boolean indicating whether 
170:             * the search is exact or approximate.
171:             * 
172:             * @return exact   Boolean indicating whether search is exact
173:             *                 or contains.
174:             */
175:            public boolean isExact() {
176:                return exact;
177:            };
178:
179:            /** 
180:             * Set the name of the attribute to search on.
181:             * 
182:             * @param name   Name of the attribute to search on.
183:             */
184:            public void setName(String name) {
185:                this .name = name;
186:            };
187:
188:            /** 
189:             * Set the value of the attribute to search.
190:             * 
191:             * @param value   Value of the attribute to search.
192:             */
193:            public void setValue(String value) {
194:                this .value = value;
195:            };
196:
197:            /** 
198:             * Set the value of the exact boolean indicating whether 
199:             * the search is exact or approximate.
200:             * 
201:             * @param exact   Boolean indicating whether search is exact
202:             *                 or contains.
203:             */
204:            public void setExact(boolean exact) {
205:                this .exact = exact;
206:            };
207:
208:            /**
209:             * Set the value of the not boolean indicating the relationship between name and value
210:             *
211:             * @param not	 Boolean indicating the relationship between name and value
212:             */
213:            public void setNot(boolean not) {
214:                this .not = not;
215:            };
216:
217:            /** 
218:             * Set the value of the operator binding the recursive searchTerms 
219:             * Present only in case the ABSearchTerm is not an end node.
220:             * 
221:             * @param op - int
222:             */
223:            public void setOp(int op) {
224:                this .op = op;
225:            };
226:
227:            /**
228:             * Abstract method. The adapters compute the value of the search term following 
229:             * the recursive search terms to the end node.
230:             * 
231:             * @return search filter object to base the search on.
232:             */
233:            public abstract Object compute() throws ABStoreException;
234:
235:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.