KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > search > CmsSearchIndexUpdateData


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/search/CmsSearchIndexUpdateData.java,v $
3  * Date : $Date: 2006/03/27 14:52:54 $
4  * Version: $Revision: 1.3 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (C) 2002 - 2005 Alkacon Software (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.search;
33
34 import org.opencms.db.CmsPublishedResource;
35
36 import java.util.ArrayList JavaDoc;
37 import java.util.List JavaDoc;
38
39 /**
40  * A collection of resources for the incremental update of a search index.<p>
41  *
42  * @author Alexander Kandzior
43  *
44  * @version $Revision: 1.3 $
45  *
46  * @since 6.0.1
47  */

48 public class CmsSearchIndexUpdateData {
49
50     /** The indexer of this update collection. */
51     private I_CmsIndexer m_indexer;
52
53     /** List of <code>{@link org.opencms.db.CmsPublishedResource}</code> instances that must be deleted. */
54     private List JavaDoc m_resourcesToDelete;
55
56     /** List of <code>{@link org.opencms.db.CmsPublishedResource}</code> instances that must be updated. */
57     private List JavaDoc m_resourcesToUpdate;
58
59     /** The search index source of this update collection. */
60     private CmsSearchIndexSource m_source;
61
62     /**
63      * Creates a new instance of an update collection.<p>
64      *
65      * @param source the search index source of this update collection
66      * @param indexer the indexer of this update collection
67      */

68     public CmsSearchIndexUpdateData(CmsSearchIndexSource source, I_CmsIndexer indexer) {
69
70         m_source = source;
71         m_indexer = indexer;
72         m_resourcesToDelete = new ArrayList JavaDoc();
73         m_resourcesToUpdate = new ArrayList JavaDoc();
74     }
75
76     /**
77      * Adds the given resource to the resources that must be deleted from the search index.<p>
78      *
79      * @param resource the resource to add
80      */

81     public void addResourceToDelete(CmsPublishedResource resource) {
82
83         m_resourcesToDelete.add(resource);
84     }
85
86     /**
87      * Adds the given resource to the resources that must be updated in the search index.<p>
88      *
89      * @param resource the resource to add
90      */

91     public void addResourceToUpdate(CmsPublishedResource resource) {
92
93         m_resourcesToUpdate.add(resource);
94     }
95
96     /**
97      * Returns the indexer of this update collection.<p>
98      *
99      * @return the indexer of this update collection
100      */

101     public I_CmsIndexer getIndexer() {
102
103         return m_indexer;
104     }
105
106     /**
107      * Returns the list of <code>{@link org.opencms.db.CmsPublishedResource}</code> instances that must be deleted.<p>
108      *
109      * @return the list of <code>{@link org.opencms.db.CmsPublishedResource}</code> instances that must be deleted
110      */

111     public List JavaDoc getResourcesToDelete() {
112
113         return m_resourcesToDelete;
114     }
115
116     /**
117      * Returns the list of <code>{@link org.opencms.db.CmsPublishedResource}</code> instances that must be updated.<p>
118      *
119      * @return the list of <code>{@link org.opencms.db.CmsPublishedResource}</code> instances that must be updated
120      */

121     public List JavaDoc getResourcesToUpdate() {
122
123         return m_resourcesToUpdate;
124     }
125
126     /**
127      * Returns the search index source of this update collection.<p>
128      *
129      * @return the search index source of this update collection
130      */

131     public CmsSearchIndexSource getSource() {
132
133         return m_source;
134     }
135
136     /**
137      * Returns <code>true</code> if this collections contains resources to delete.<p>
138      *
139      * @return <code>true</code> if this collections contains resources to delete
140      */

141     public boolean hasResourcesToDelete() {
142
143         return !m_resourcesToDelete.isEmpty();
144     }
145
146     /**
147      * Returns <code>true</code> if this collections contains resources to update.<p>
148      *
149      * @return <code>true</code> if this collections contains resources to update
150      */

151     public boolean hasResourceToUpdate() {
152
153         return !m_resourcesToUpdate.isEmpty();
154     }
155
156     /**
157      * Returns <code>true</code> if this collections contains no resources to update or delete.<p>
158      *
159      * @return <code>true</code> if this collections contains no resources to update or delete
160      */

161     public boolean isEmpty() {
162
163         return m_resourcesToDelete.isEmpty() && m_resourcesToUpdate.isEmpty();
164     }
165 }
Popular Tags