Source Code Cross Referenced for JdbcFileEntrySettings.java in  » Search-Engine » compass-2.0 » org » apache » lucene » store » jdbc » 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 » Search Engine » compass 2.0 » org.apache.lucene.store.jdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004-2006 the original author or authors.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.apache.lucene.store.jdbc;
018:
019:        import java.util.Properties;
020:
021:        import org.apache.lucene.store.jdbc.handler.MarkDeleteFileEntryHandler;
022:        import org.apache.lucene.store.jdbc.index.FetchOnBufferReadJdbcIndexInput;
023:        import org.apache.lucene.store.jdbc.index.RAMAndFileJdbcIndexOutput;
024:
025:        /**
026:         * A file entry level settings. An abstract view of any type of setting that cab be
027:         * used by the actual file entry handler that uses it.
028:         * <p/>
029:         * Holds the {@link #FILE_ENTRY_HANDLER_TYPE} that defines the type of the
030:         * {@link org.apache.lucene.store.jdbc.handler.FileEntryHandler} that will be created
031:         * and initialized with the settings.
032:         * <p/>
033:         * Default values for a new instanciated instnce are: {@link MarkDeleteFileEntryHandler} for
034:         * the {@link #FILE_ENTRY_HANDLER_TYPE} setting, {@link FetchOnBufferReadJdbcIndexInput} for the
035:         * {@link #INDEX_INPUT_TYPE_SETTING} setting, and {@link RAMAndFileJdbcIndexOutput} for the
036:         * {@link #INDEX_OUTPUT_TYPE_SETTING} setting.
037:         *
038:         * @author kimchy
039:         */
040:        public class JdbcFileEntrySettings {
041:
042:            /**
043:             * The class name of the {@link org.apache.lucene.store.IndexInput}. Only applies
044:             * to {@link org.apache.lucene.store.jdbc.handler.FileEntryHandler}s that use it.
045:             */
046:            public static final String INDEX_INPUT_TYPE_SETTING = "indexInput.type";
047:
048:            /**
049:             * The class name of the {@link org.apache.lucene.store.IndexOutput}. Only applies
050:             * to {@link org.apache.lucene.store.jdbc.handler.FileEntryHandler}s that use it.
051:             */
052:            public static final String INDEX_OUTPUT_TYPE_SETTING = "indexOutput.type";
053:
054:            /**
055:             * The class name of the {@link org.apache.lucene.store.jdbc.handler.FileEntryHandler}.
056:             */
057:            public static final String FILE_ENTRY_HANDLER_TYPE = "type";
058:
059:            private Properties settings = new Properties();
060:
061:            /**
062:             * Creates a new file entry settings, and intialize it to default values.
063:             */
064:            public JdbcFileEntrySettings() {
065:                setClassSetting(JdbcFileEntrySettings.FILE_ENTRY_HANDLER_TYPE,
066:                        MarkDeleteFileEntryHandler.class);
067:                setClassSetting(JdbcFileEntrySettings.INDEX_INPUT_TYPE_SETTING,
068:                        FetchOnBufferReadJdbcIndexInput.class);
069:                setClassSetting(
070:                        JdbcFileEntrySettings.INDEX_OUTPUT_TYPE_SETTING,
071:                        RAMAndFileJdbcIndexOutput.class);
072:            }
073:
074:            /**
075:             * Returns the inner java properties.
076:             */
077:            public Properties getProperties() {
078:                return settings;
079:            }
080:
081:            /**
082:             * Returns the value match for the given setting. <code>null</code> if no
083:             * setting is found.
084:             *
085:             * @param setting The setting name
086:             * @return The value of the setting, or <code>null</code> if none is found
087:             */
088:            public String getSetting(String setting) {
089:                return settings.getProperty(setting);
090:            }
091:
092:            /**
093:             * Returns the value that matches the given setting. If none is found,
094:             * the default value is used.
095:             *
096:             * @param setting The setting name
097:             * @param defaultValue The default value to be used if no setting is found
098:             * @return The value of the setting, or defaultValue if none is found.
099:             */
100:            public String getSetting(String setting, String defaultValue) {
101:                return settings.getProperty(setting, defaultValue);
102:            }
103:
104:            /**
105:             * Returns the float value that matches the given setting. If none if found,
106:             * the default value is used.
107:             *
108:             * @param setting The setting name
109:             * @param defaultValue The default value to be used if no setting is found
110:             * @return The value of the setting, or defaultValue if none is found.
111:             */
112:            public float getSettingAsFloat(String setting, float defaultValue) {
113:                String sValue = getSetting(setting);
114:                if (sValue == null) {
115:                    return defaultValue;
116:                }
117:                return Float.parseFloat(sValue);
118:            }
119:
120:            /**
121:             * Returns the int value that matches the given setting. If none if found,
122:             * the default value is used.
123:             *
124:             * @param setting The setting name
125:             * @param defaultValue The default value to be used if no setting is found
126:             * @return The value of the setting, or defaultValue if none is found.
127:             */
128:            public int getSettingAsInt(String setting, int defaultValue) {
129:                String sValue = getSetting(setting);
130:                if (sValue == null) {
131:                    return defaultValue;
132:                }
133:                return Integer.parseInt(sValue);
134:            }
135:
136:            /**
137:             * Returns the long value that matches the given setting. If none if found,
138:             * the default value is used.
139:             *
140:             * @param setting The setting name
141:             * @param defaultValue The default value to be used if no setting is found
142:             * @return The value of the setting, or defaultValue if none is found.
143:             */
144:            public long getSettingAsLong(String setting, long defaultValue) {
145:                String sValue = getSetting(setting);
146:                if (sValue == null) {
147:                    return defaultValue;
148:                }
149:                return Long.parseLong(sValue);
150:            }
151:
152:            /**
153:             * Returns the class value that matches the given setting. If none if found,
154:             * the default value is used.
155:             *
156:             * @param setting The setting name
157:             * @param defaultValue The default value to be used if no setting is found
158:             * @return The value of the setting, or defaultValue if none is found.
159:             */
160:            public Class getSettingAsClass(String setting, Class defaultValue)
161:                    throws ClassNotFoundException {
162:                return getSettingAsClass(setting, defaultValue, Thread
163:                        .currentThread().getContextClassLoader());
164:            }
165:
166:            /**
167:             * Returns the class value that matches the given setting. If none if found,
168:             * the default value is used.
169:             *
170:             * @param setting The setting name
171:             * @param defaultValue The default value to be used if no setting is found
172:             * @param classLoader The class loader to be used to load the class
173:             * @return The value of the setting, or defaultValue if none is found.
174:             * @throws ClassNotFoundException
175:             */
176:            public Class getSettingAsClass(String setting, Class defaultValue,
177:                    ClassLoader classLoader) throws ClassNotFoundException {
178:                String sValue = getSetting(setting);
179:                if (sValue == null) {
180:                    return defaultValue;
181:                }
182:                return Class.forName(sValue, true, classLoader);
183:            }
184:
185:            /**
186:             * Returns the boolean value that matches the given setting. If none if found,
187:             * the default value is used.
188:             *
189:             * @param setting The setting name
190:             * @param defaultValue The default value to be used if no setting is found
191:             * @return The value of the setting, or defaultValue if none is found.
192:             */
193:            public boolean getSettingAsBoolean(String setting,
194:                    boolean defaultValue) {
195:                String sValue = getSetting(setting);
196:                if (sValue == null) {
197:                    return defaultValue;
198:                }
199:                return Boolean.valueOf(sValue).booleanValue();
200:            }
201:
202:            public JdbcFileEntrySettings setSetting(String setting, String value) {
203:                this .settings.setProperty(setting, value);
204:                return this ;
205:            }
206:
207:            public JdbcFileEntrySettings setBooleanSetting(String setting,
208:                    boolean value) {
209:                setSetting(setting, String.valueOf(value));
210:                return this ;
211:            }
212:
213:            public JdbcFileEntrySettings setFloatSetting(String setting,
214:                    float value) {
215:                setSetting(setting, String.valueOf(value));
216:                return this ;
217:            }
218:
219:            public JdbcFileEntrySettings setIntSetting(String setting, int value) {
220:                setSetting(setting, String.valueOf(value));
221:                return this ;
222:            }
223:
224:            public JdbcFileEntrySettings setLongSetting(String setting,
225:                    long value) {
226:                setSetting(setting, String.valueOf(value));
227:                return this ;
228:            }
229:
230:            public JdbcFileEntrySettings setClassSetting(String setting,
231:                    Class clazz) {
232:                setSetting(setting, clazz.getName());
233:                return this;
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.