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.io.File;
025: import java.io.Reader;
026:
027: import org.apache.commons.logging.Log;
028: import org.apache.commons.logging.LogFactory;
029:
030: /**
031: * Java bean for the Result of a Parsed File. Used in {@link Extractor}.
032: *
033: * @author Michael Franken
034: * @version $Revision: 1.6 $
035: */
036: public final class ParsedFileInfo {
037: /** logger for Commons logging. */
038: private static Log log = LogFactory.getLog(ParsedFileInfo.class);
039:
040: /**
041: * The file from which the info is extracted.
042: */
043: private File file;
044:
045: /**
046: * The reader containing the extracted text.
047: */
048: private Reader reader;
049:
050: /**
051: * The author of the document.
052: */
053: private String author = "";
054:
055: /**
056: * The ISBN number of the document.
057: */
058: private String ISBN = "";
059:
060: /**
061: * The title of the document.
062: */
063: private String title = "";
064:
065: /**
066: * The summary of the document.
067: */
068: private String summary = "";
069:
070: /**
071: * The creation date of the document.
072: */
073: private long creationDate;
074:
075: /**
076: * The modification date of the document.
077: */
078: private long modificationDate;
079:
080: /**
081: * The type of the document.
082: */
083: private String type = "";
084:
085: /**
086: * The size of the document.
087: */
088: private long size;
089:
090: /**
091: * Get the author of the document.
092: *
093: * @return the author
094: */
095: public String getAuthor() {
096: return author;
097: }
098:
099: /**
100: * Get the creation date of the document.
101: *
102: * @return the creation data
103: */
104: public long getCreationDate() {
105: return creationDate;
106: }
107:
108: /**
109: * Get the modification date of the document.
110: *
111: * @return the modification data
112: */
113: public long getModificationDate() {
114: return modificationDate;
115: }
116:
117: /**
118: * Get the text of the document as a reader.
119: *
120: * @return the text of the document
121: */
122: public Reader getReader() {
123: return reader;
124: }
125:
126: /**
127: * Get the summary of the document.
128: *
129: * @return the summary
130: */
131: public String getSummary() {
132: return summary;
133: }
134:
135: /**
136: * Get the type of the document.
137: *
138: * @return the type
139: */
140: public String getType() {
141: return type;
142: }
143:
144: /**
145: * Set the author of the document.
146: *
147: * @param string the Author
148: */
149: public void setAuthor(final String string) {
150: author = string;
151: }
152:
153: /**
154: * Set the creation date of the document.
155: *
156: * @param theDate the date of creation in milliseconds since midnight, January 1, 1970 UTC
157: */
158: public void setCreationDate(final long theDate) {
159: creationDate = theDate;
160: }
161:
162: /**
163: * Set the mofification date of the document.
164: *
165: * @param theDate the date of last modification in milliseconds since midnight, January 1, 1970 UTC
166: */
167: public void setModificationDate(final long theDate) {
168: modificationDate = theDate;
169: }
170:
171: /**
172: * Set the reader containing the plain text of this document.
173: *
174: * @param thisReader the reader constructed to contain just the text of the document
175: */
176: public void setReader(final Reader this Reader) {
177: this .reader = this Reader;
178: }
179:
180: /**
181: * Set the summary containing the a short summary of this document.
182: *
183: * @param string containing
184: */
185: public void setSummary(final String string) {
186: summary = string;
187: }
188:
189: /**
190: * Set the type of this document.
191: *
192: * @param string (such as "PDF", "Word")
193: */
194: public void setType(final String string) {
195: type = string;
196: }
197:
198: /**
199: * Get the file from which the info is extracted.
200: *
201: * @return file
202: */
203: public File getFile() {
204: return file;
205: }
206:
207: /**
208: * Get the size of the document in bytes.
209: *
210: * @return size
211: */
212: public long getSize() {
213: return size;
214: }
215:
216: /**
217: * Get the title of the document.
218: *
219: * @return title
220: */
221: public String getTitle() {
222: return title;
223: }
224:
225: /**
226: * Set the file containing the document.
227: *
228: * @param thisFile file
229: */
230: public void setFile(final File this File) {
231: this .file = this File;
232: }
233:
234: /**
235: * Set the size of the document.
236: *
237: * @param l in bytes
238: */
239: public void setSize(final long l) {
240: size = l;
241: }
242:
243: /**
244: * Set the title of the document.
245: *
246: * @param string title
247: */
248: public void setTitle(final String string) {
249: title = string;
250: }
251:
252: /**
253: * Print the file info for logging purposes.
254: *
255: * @return string pretty formatted
256: */
257: public String toString() {
258: StringBuffer info = new StringBuffer();
259:
260: info.append("File: " + file.getName());
261: info.append(", type: " + type);
262: info.append(", title: " + title);
263: info.append(", author: " + author);
264: info.append(", creationDate: " + creationDate);
265: info.append(", modificationDate: " + modificationDate);
266: info.append(", size: " + size);
267: info.append(", summary: " + summary);
268:
269: return info.toString();
270: }
271:
272: /**
273: * @return Returns the iSBN.
274: */
275: public String getISBN() {
276: return ISBN;
277: }
278:
279: /**
280: * @param isbn The iSBN to set.
281: */
282: public void setISBN(String isbn) {
283: ISBN = isbn;
284: }
285: }
|