001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.search;
034:
035: import org.apache.lucene.document.Document;
036: import org.apache.lucene.document.Field;
037:
038: import java.net.URI;
039:
040: /**
041: * LibreSource
042: *
043: * @author <a href="mailto:bort@loria.fr">Guillaume Bort</a> - <a
044: * href="http://www.inria.fr">INRIA Lorraine</a>
045: */
046: public class LibresourceResourceDocument {
047: private URI uri;
048: private String service;
049: private String resourceType;
050: private String content;
051: private String shortName;
052:
053: public LibresourceResourceDocument(URI uri, String service,
054: String resourceType, String shortName, String content) {
055: this .service = service;
056: this .resourceType = resourceType;
057: this .content = clarify(content);
058: this .uri = uri;
059: this .shortName = shortName;
060: }
061:
062: public Document getDocument() {
063: Document document = new Document();
064: document.add(new Field("URI", LibresourceSearch
065: .normalizeURIForIndexation(uri), Field.Store.YES,
066: Field.Index.UN_TOKENIZED));
067: document.add(new Field("SERVICE", service, Field.Store.YES,
068: Field.Index.NO));
069: document.add(new Field("TYPE", resourceType, Field.Store.YES,
070: Field.Index.NO));
071: document.add(new Field("CONTENT", content, Field.Store.YES,
072: Field.Index.TOKENIZED));
073: document.add(new Field("NAME", shortName, Field.Store.YES,
074: Field.Index.TOKENIZED));
075:
076: return document;
077: }
078:
079: public String toString() {
080: return "Document [" + uri + "," + shortName + "]";
081: }
082:
083: public String getContent() {
084: return content;
085: }
086:
087: public String getResourceType() {
088: return resourceType;
089: }
090:
091: public String getService() {
092: return service;
093: }
094:
095: public String getName() {
096: return shortName;
097: }
098:
099: public URI getUri() {
100: return uri;
101: }
102:
103: // simplify the indeable content
104: private String clarify(String content) {
105: return StringHelper.clarify(content);
106: }
107: }
|