KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > search > SearchDocument


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.core.search;
12
13 import org.eclipse.jdt.internal.core.search.indexing.InternalSearchDocument;
14
15 /**
16  * A search document encapsulates a content to be either indexed or searched in.
17  * A search particpant creates a search document.
18  * <p>
19  * This class is intended to be subclassed by clients.
20  * </p>
21  *
22  * @since 3.0
23  */

24 public abstract class SearchDocument extends InternalSearchDocument {
25     private String JavaDoc documentPath;
26     private SearchParticipant participant;
27     
28     /**
29      * Creates a new search document. The given document path is a string that uniquely identifies the document.
30      * Most of the time it is a workspace-relative path, but it can also be a file system path, or a path inside a zip file.
31      *
32      * @param documentPath the path to the document,
33      * or <code>null</code> if none
34      * @param participant the participant that creates the search document
35      */

36     protected SearchDocument(String JavaDoc documentPath, SearchParticipant participant) {
37         this.documentPath = documentPath;
38         this.participant = participant;
39     }
40
41     /**
42      * Adds the given index entry (category and key) coming from this
43      * document to the index. This method must be called from
44      * {@link SearchParticipant#indexDocument(SearchDocument document, org.eclipse.core.runtime.IPath indexPath)}.
45      *
46      * @param category the category of the index entry
47      * @param key the key of the index entry
48      */

49     public void addIndexEntry(char[] category, char[] key) {
50         super.addIndexEntry(category, key);
51     }
52     
53     /**
54      * Returns the contents of this document.
55      * Contents may be different from actual resource at corresponding document path,
56      * in case of preprocessing.
57      * <p>
58      * This method must be implemented in subclasses.
59      * </p><p>
60      * Note: some implementation may choose to cache the contents directly on the
61      * document for performance reason. However, this could induce scalability issues due
62      * to the fact that collections of documents are manipulated throughout the search
63      * operation, and cached contents would then consume lots of memory until they are
64      * all released at once in the end.
65      * </p>
66      *
67      * @return the contents of this document,
68      * or <code>null</code> if none
69      */

70     public abstract byte[] getByteContents();
71
72     /**
73      * Returns the contents of this document.
74      * Contents may be different from actual resource at corresponding document
75      * path due to preprocessing.
76      * <p>
77      * This method must be implemented in subclasses.
78      * </p><p>
79      * Note: some implementation may choose to cache the contents directly on the
80      * document for performance reason. However, this could induce scalability issues due
81      * to the fact that collections of documents are manipulated throughout the search
82      * operation, and cached contents would then consume lots of memory until they are
83      * all released at once in the end.
84      * </p>
85      *
86      * @return the contents of this document,
87      * or <code>null</code> if none
88      */

89     public abstract char[] getCharContents();
90
91     /**
92      * Returns the encoding for this document.
93      * <p>
94      * This method must be implemented in subclasses.
95      * </p>
96      *
97      * @return the encoding for this document,
98      * or <code>null</code> if none
99      */

100     public abstract String JavaDoc getEncoding();
101
102     /**
103      * Returns the participant that created this document.
104      *
105      * @return the participant that created this document
106      */

107     public final SearchParticipant getParticipant() {
108         return this.participant;
109     }
110     
111     /**
112      * Returns the path to the original document to publicly mention in index
113      * or search results. This path is a string that uniquely identifies the document.
114      * Most of the time it is a workspace-relative path, but it can also be a file system path,
115      * or a path inside a zip file.
116      *
117      * @return the path to the document
118      */

119     public final String JavaDoc getPath() {
120         return this.documentPath;
121     }
122     /**
123      * Removes all index entries from the index for the given document.
124      * This method must be called from
125      * {@link SearchParticipant#indexDocument(SearchDocument document, org.eclipse.core.runtime.IPath indexPath)}.
126      */

127     public void removeAllIndexEntries() {
128         super.removeAllIndexEntries();
129     }
130 }
131
Popular Tags