View Javadoc

1   /**
2    * $Id: BaseItemImpl.java 31 2006-10-26 04:11:36Z maldito_orco $
3    * $Revision: 31 $
4    * $Date: 2006-10-26 01:11:36 -0300 (Thu, 26 Oct 2006) $
5    *
6    * =========================================================================
7    *
8    * Copyright 2005 Tubo
9    *
10   *  Licensed under the Apache License, Version 2.0 (the "License");
11   *  you may not use this file except in compliance with the License.
12   *  You may obtain a copy of the License at
13   *
14   *     http://www.apache.org/licenses/LICENSE-2.0
15   *
16   *  Unless required by applicable law or agreed to in writing, software
17   *  distributed under the License is distributed on an "AS IS" BASIS,
18   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   *  See the License for the specific language governing permissions and
20   *  limitations under the License.
21   */
22  package org.tubo.item;
23  
24  //log
25  import org.apache.commons.logging.Log;
26  import org.apache.commons.logging.LogFactory;
27  //util
28  import java.util.Map;
29  import java.util.HashMap;
30  
31  /**
32   * Created: Jun 18, 2005 7:29:29 AM
33   * Last Modification Date: $Date: 2006-10-26 01:11:36 -0300 (Thu, 26 Oct 2006) $
34   *
35   * @author jvlio (jvlio@users.sourceforge.net)
36   * @version $Revision: 31 $
37   */
38  public class BaseItemImpl implements Item {
39      public static final String RCS_ID = "$Id: BaseItemImpl.java 31 2006-10-26 04:11:36Z maldito_orco $";
40  
41      private static Log log = LogFactory.getLog(BaseItemImpl.class);
42  
43      private Object id = null;
44      private long index = -1;
45      private long consumeTime = -1;
46      private Object consumedRawData = null;
47      private Map properties = null;
48  
49      /**
50       * Default constructor
51       */
52      public BaseItemImpl() {}
53  
54      public Object getId() { return id; }
55      public void setId(Object id) {
56          this.id = id;
57      }
58  
59      public long getIndex() { return index; }
60      public void setIndex(long index) {
61          this.index = index;
62      }
63  
64      public long getConsumeTime() { return consumeTime; }
65      public void setConsumeTime(long consumeTime) {
66          this.consumeTime = consumeTime;
67      }
68  
69      public Object getConsumedRawData() { return consumedRawData; }
70      public void setConsumedRawData(Object consumedRawData) {
71          this.consumedRawData = consumedRawData;
72      }
73  
74      /**
75       * Returns properties Map
76       * @return Properties Map
77       */
78      public Map getProperties() {
79          if (properties == null)
80              properties = new HashMap();
81          return properties;
82      }
83  
84      /**
85       * Replace own properties Map with this
86       * @param properties Properties Map replacement
87       */
88      public void setProperties(Map properties) {
89          this.properties = properties;
90      }
91  
92     /**
93      * Return a property from properties Map
94      * @param key Property Key.
95      * @return Property value or null if key not found
96      */
97      public Object getProperty(Object key) {
98          return getProperties().get(key);
99      }
100 
101     /**
102      * Set o replace a property in properties Map
103      * @param key Property key
104      * @param value Property value
105      */
106     public void setProperty(Object key, Object value) {
107         getProperties().put(key,value);
108     }
109 
110 }