Source Code Cross Referenced for Result.java in  » Search-Engine » zilverline » org » zilverline » core » 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 » zilverline » org.zilverline.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2003-2004 Michael Franken, Zilverline.
003:         *
004:         * The contents of this file, or the files included with this file, are subject to
005:         * the current version of ZILVERLINE Collaborative Source License for the
006:         * Zilverline Search Engine (the "License"); You may not use this file except in
007:         * compliance with the License.
008:         *
009:         * You may obtain a copy of the License at
010:         *
011:         *     http://www.zilverline.org.
012:         *
013:         * See the License for the rights, obligations and
014:         * limitations governing use of the contents of the file.
015:         *
016:         * The Original and Upgraded Code is the Zilverline Search Engine. The developer of
017:         * the Original and Upgraded Code is Michael Franken. Michael Franken owns the
018:         * copyrights in the portions it created. All Rights Reserved.
019:         *
020:         */
021:
022:        package org.zilverline.core;
023:
024:        import java.text.NumberFormat;
025:        import java.util.Date;
026:
027:        import org.apache.commons.logging.Log;
028:        import org.apache.commons.logging.LogFactory;
029:
030:        /**
031:         * A Result is a individual hit result from a search. It corresponds to a {@link org.apache.lucene.document.Document Document}.
032:         * 
033:         * <p>
034:         * This class is used to represent a Result in the model of our MVC pattern.
035:         * </p>
036:         * 
037:         * @author Michael Franken
038:         * @version $Revision: 1.17 $
039:         * 
040:         * @see org.apache.lucene.document.Document
041:         */
042:        public class Result {
043:            /** 1024 is the number of bytes that goes into a KB. */
044:            private static final int KILO = 1024;
045:
046:            /** logger for Commons logging. */
047:            private static Log log = LogFactory.getLog(Result.class);
048:
049:            /** cache of result (= document). */
050:            private String cache;
051:
052:            /** name of collection this result is from. */
053:            private String collection;
054:
055:            /** date of result (= document). */
056:            private Date modificationDate;
057:
058:            /** name of result (= document). */
059:            private String name;
060:
061:            /** path within this document. */
062:            private String path;
063:
064:            /** score of result. */
065:            private float score;
066:
067:            /** score of result as a percentage String 0.13 => 13,00%. */
068:            private String scoreString;
069:
070:            /** size of in bytes as String. */
071:            private String size;
072:
073:            /** summary of result (= document). */
074:            private String summary;
075:
076:            /** title of result (= document). */
077:            private String title;
078:
079:            /** type of Document: pdf, word. */
080:            private String type;
081:
082:            /** url of result (= document). */
083:            private String url;
084:
085:            /** name within this document. */
086:            private String zipName;
087:
088:            /** path within this document. */
089:            private String zipPath;
090:
091:            /**
092:             * The ISBN number of the document.
093:             */
094:            private String ISBN = "";
095:
096:            /**
097:             * @return Returns the ISBN number.
098:             */
099:            public String getISBN() {
100:                return ISBN;
101:            }
102:
103:            /**
104:             * @param isbn The ISBN number to set.
105:             */
106:            public void setISBN(String isbn) {
107:                ISBN = isbn;
108:            }
109:
110:            /**
111:             * Default Constructor setting all fields to non null defaults.
112:             */
113:            public Result() {
114:                name = "";
115:                title = "";
116:                type = "";
117:                score = 0;
118:                scoreString = "";
119:                size = "";
120:                path = "";
121:                zipPath = "";
122:                summary = "";
123:                modificationDate = null;
124:            }
125:
126:            /**
127:             * Get the cache of this result.
128:             * 
129:             * @return the Cache
130:             */
131:            public final String getCache() {
132:                return cache;
133:            }
134:
135:            /**
136:             * Get the collection of this result.
137:             * 
138:             * @return the collection
139:             */
140:            public final String getCollection() {
141:                return collection;
142:            }
143:
144:            /**
145:             * Get the modificationDate of this result.
146:             * 
147:             * @return String modification date of the result.
148:             */
149:            public final Date getModificationDate() {
150:                return modificationDate;
151:            }
152:
153:            /**
154:             * Get the name of this result.
155:             * 
156:             * @return the name of this result.
157:             */
158:            public final String getName() {
159:                return name;
160:            }
161:
162:            /**
163:             * Get the path of this result.
164:             * 
165:             * @return the path of this result. e.g. chapter24/chapter24.html
166:             */
167:            public final String getPath() {
168:                return path;
169:            }
170:
171:            /**
172:             * Get the score of this result.
173:             * 
174:             * @return the score of the result as a float between 0 and 1.
175:             */
176:            public final float getScore() {
177:                return score;
178:            }
179:
180:            /**
181:             * Get the string representation of the score in percentage.
182:             * 
183:             * @return String string representation of score. Includes percentage sign, e.g. 13%
184:             */
185:            public final String getScoreString() {
186:                return scoreString;
187:            }
188:
189:            /**
190:             * Get the size of the result.
191:             * 
192:             * <p>
193:             * use getSizeAsString to get a human friendly version
194:             * </p>
195:             * 
196:             * @return String size of result (= document) as a String.
197:             */
198:            public final String getSize() {
199:                return size;
200:            }
201:
202:            /**
203:             * Get the human friendly representation of the size of the result.
204:             * 
205:             * <p>
206:             * returns B, KB, MB, GB, e.g. 12345 returns 12KB, B = 1024 bytes
207:             * </p>
208:             * 
209:             * @return String the size in bytes in human readable format, "" if unknown.
210:             */
211:            public final String getSizeAsString() {
212:                try {
213:                    int byteSize = Integer.parseInt(size);
214:
215:                    if ((byteSize / (KILO * KILO * KILO)) > 0) { // GB
216:
217:                        return (byteSize / (KILO * KILO * KILO)) + "GB";
218:                    } else if ((byteSize / (KILO * KILO)) > 0) { // MB
219:
220:                        return (byteSize / (KILO * KILO)) + "MB";
221:                    } else if ((byteSize / KILO) > 0) { // KB
222:
223:                        return (byteSize / KILO) + "KB";
224:                    }
225:
226:                    return byteSize + "B";
227:                } catch (NumberFormatException e) {
228:                    return "";
229:                }
230:            }
231:
232:            /**
233:             * Get the summary of the result.
234:             * 
235:             * @return a summary of the result, if any
236:             */
237:            public final String getSummary() {
238:                return summary;
239:            }
240:
241:            /**
242:             * Get the title of the result.
243:             * 
244:             * @return title of the result
245:             */
246:            public final String getTitle() {
247:                return title;
248:            }
249:
250:            /**
251:             * Get the type of the result.
252:             * 
253:             * @return String the type of the document, such as PDF, WORD.
254:             */
255:            public final String getType() {
256:                return type;
257:            }
258:
259:            /**
260:             * Get the URL of the result.
261:             * 
262:             * @return url
263:             */
264:            public final String getURL() {
265:                return url;
266:            }
267:
268:            /**
269:             * Get the zipName of the result.
270:             * 
271:             * @return String the zipName
272:             */
273:            public final String getZipName() {
274:                return zipName;
275:            }
276:
277:            /**
278:             * Get the zpPath of the result.
279:             * 
280:             * @return String the zipPath
281:             */
282:            public final String getZipPath() {
283:                return zipPath;
284:            }
285:
286:            /**
287:             * Set the cache of the result.
288:             * 
289:             * @param string cache
290:             */
291:            public final void setCache(final String string) {
292:                cache = string;
293:            }
294:
295:            /**
296:             * Set the collection of the result.
297:             * 
298:             * @param string collection by name
299:             */
300:            public final void setCollection(final String string) {
301:                collection = string;
302:            }
303:
304:            /**
305:             * Set the modification date of the result.
306:             * 
307:             * @param theModificationDate the modification date of the result.
308:             */
309:            public final void setModificationDate(final Date theModificationDate) {
310:                modificationDate = theModificationDate;
311:            }
312:
313:            /**
314:             * DOCUMENT ME!
315:             * 
316:             * @param theName the path of this result. e.g. j2ee.zip
317:             */
318:            public final void setName(final String theName) {
319:                name = theName;
320:            }
321:
322:            /**
323:             * DOCUMENT ME!
324:             * 
325:             * @param thePath the path of this result. e.g. http://search.company.com/books/ldap.pdf
326:             */
327:            public final void setPath(final String thePath) {
328:                path = thePath;
329:            }
330:
331:            /**
332:             * DOCUMENT ME!
333:             * 
334:             * @param theScore float sets the score, and set scoreString to the String representation of the score as a percentage, e.g.
335:             *            13%.
336:             */
337:            public final void setScore(final float theScore) {
338:                score = theScore;
339:
340:                NumberFormat percentFormatter = NumberFormat
341:                        .getPercentInstance();
342:
343:                scoreString = percentFormatter.format(theScore);
344:            }
345:
346:            /**
347:             * DOCUMENT ME!
348:             * 
349:             * @param theSize the size of the result as a String. the size is in bytes
350:             */
351:            public final void setSize(final String theSize) {
352:                size = theSize;
353:            }
354:
355:            /**
356:             * DOCUMENT ME!
357:             * 
358:             * @param theSummary sets the summary of the result.
359:             */
360:            public final void setSummary(final String theSummary) {
361:                summary = theSummary;
362:            }
363:
364:            /**
365:             * DOCUMENT ME!
366:             * 
367:             * @param theTitle sets the summary of the result.
368:             */
369:            public final void setTitle(final String theTitle) {
370:                title = theTitle;
371:            }
372:
373:            /**
374:             * Set the type of the result.
375:             * 
376:             * @param theType the type of the document, such as PDF, WORD.
377:             */
378:            public final void setType(final String theType) {
379:                type = theType;
380:            }
381:
382:            /**
383:             * Set the URL of this result.
384:             * 
385:             * @param string url
386:             */
387:            public final void setURL(final String string) {
388:                url = string;
389:            }
390:
391:            /**
392:             * Set the zipName of the result.
393:             * 
394:             * @param string zipName is the name within the archive
395:             */
396:            public final void setZipName(final String string) {
397:                zipName = string;
398:            }
399:
400:            /**
401:             * Set the sipPath of the result.
402:             * 
403:             * @param string zipPath is the path within the archive
404:             */
405:            public final void setZipPath(final String string) {
406:                zipPath = string;
407:            }
408:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.