View Javadoc
1   /*
2    * Copyright (c) 2002-2020, City of Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.document.service.docsearch;
35  
36  import org.apache.lucene.document.Document;
37  
38  
39  /**
40   * DocSearchItem
41   */
42  public class DocSearchItem
43  {
44      public static final String FIELD_UID = "uid";
45      public static final String FIELD_CONTENTS = "contents";
46      public static final String FIELD_TITLE = "title";
47      public static final String FIELD_SUMMARY = "summary";
48      public static final String FIELD_DATE = "date";
49      public static final String FIELD_TYPE = "type";
50      public static final String FIELD_SPACE = "space";
51  
52      // Variables declarations
53      private String _strId;
54      private String _strTitle;
55      private String _strSummary;
56      private String _strLastModifiedDate;
57      private String _strType;
58  
59      /**
60       * The constructor
61       * @param document the lucene document
62       */
63      public DocSearchItem( Document document )
64      {
65          setId( document.get( FIELD_UID ) );
66          setTitle( document.get( FIELD_TITLE ) );
67          setSummary( document.get( FIELD_SUMMARY ) );
68          setDate( document.get( FIELD_DATE ) );
69          setType( document.get( FIELD_TYPE ) );
70      }
71  
72      /**
73       * Returns the Id
74       *
75       * @return The Id
76       */
77      public String getId(  )
78      {
79          return _strId;
80      }
81  
82      /**
83       * Sets the Id
84       *
85       * @param strId The Id
86       */
87      public void setId( String strId )
88      {
89          _strId = strId;
90      }
91  
92      /**
93       * Returns the Title
94       *
95       * @return The Title
96       */
97      public String getTitle(  )
98      {
99          return _strTitle;
100     }
101 
102     /**
103      * Sets the Title
104      *
105      * @param strTitle The Title
106      */
107     public void setTitle( String strTitle )
108     {
109         _strTitle = strTitle;
110     }
111 
112     /**
113      * Returns the Summary
114      *
115      * @return The Summary
116      */
117     public String getSummary(  )
118     {
119         return ( _strSummary != null ) ? _strSummary : "";
120     }
121 
122     /**
123      * Sets the Summary
124      *
125      * @param strSummary The Summary
126      */
127     public void setSummary( String strSummary )
128     {
129         _strSummary = strSummary;
130     }
131 
132     /**
133      * Returns the LastModifiedDate
134      *
135      * @return The LastModifiedDate
136      */
137     public String getDate(  )
138     {
139         return ( _strLastModifiedDate != null ) ? _strLastModifiedDate : "";
140     }
141 
142     /**
143      * Sets the LastModifiedDate
144      *
145      * @param strLastModifiedDate The LastModifiedDate
146      */
147     public void setDate( String strLastModifiedDate )
148     {
149         _strLastModifiedDate = strLastModifiedDate;
150     }
151 
152     /**
153      * Returns the Type
154      *
155      * @return The Type
156      */
157     public String getType(  )
158     {
159         return _strType;
160     }
161 
162     /**
163      * Sets the Type
164      *
165      * @param strType The Type
166      */
167     public void setType( String strType )
168     {
169         _strType = strType;
170     }
171 }