Source Code Cross Referenced for Entries.java in  » Net » lucene-connector » net » bagaluten » jca » lucene » connector » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » lucene connector » net.bagaluten.jca.lucene.connector 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.bagaluten.jca.lucene.connector;
002:
003:        import java.io.IOException;
004:        import java.io.Serializable;
005:        import java.util.Collection;
006:        import java.util.HashMap;
007:        import java.util.HashSet;
008:        import java.util.Iterator;
009:        import java.util.LinkedList;
010:        import java.util.List;
011:        import java.util.ListIterator;
012:        import java.util.Map;
013:        import java.util.Set;
014:
015:        public class Entries implements  List<Entry>, Serializable {
016:
017:            /**
018:             * 
019:             */
020:            private static final long serialVersionUID = 236876586L;
021:
022:            private int hits;
023:
024:            private List<Entry> list = new LinkedList<Entry>();
025:
026:            private Map<String, Integer> keyMap = new HashMap<String, Integer>();
027:
028:            private transient Map<Integer, Integer> countMap = new HashMap<Integer, Integer>();
029:
030:            private transient Map<Integer, String> valueMap = new HashMap<Integer, String>();
031:
032:            private class EntryImpl implements  Entry, Serializable {
033:
034:                private static final long serialVersionUID = 872364865L;
035:
036:                private class MapEntry implements 
037:                        java.util.Map.Entry<String, Field> {
038:                    private String key;
039:
040:                    MapEntry(String key) {
041:                        this .key = key;
042:                    }
043:
044:                    public String getKey() {
045:                        return key;
046:                    }
047:
048:                    public Field getValue() {
049:                        return map.get(keyMap.get(key));
050:                    }
051:
052:                    public Field setValue(Field value) {
053:                        return map.put(keyMap.get(key), value);
054:                    }
055:
056:                }
057:
058:                private Map<Integer, Field> map = new HashMap<Integer, Field>();
059:
060:                private double ranking;
061:
062:                public double getRanking() {
063:                    return ranking;
064:                }
065:
066:                public void setRanking(double ranking) {
067:                    this .ranking = ranking;
068:                }
069:
070:                public void clear() {
071:                    for (Integer p : map.keySet()) {
072:                        remove(p);
073:                    }
074:                }
075:
076:                public boolean containsKey(Object key) {
077:                    return keyMap.containsKey(key) ? map.containsKey(keyMap
078:                            .get(key)) : false;
079:                }
080:
081:                public boolean containsValue(Object value) {
082:                    return map.containsValue(value);
083:                }
084:
085:                public Set<java.util.Map.Entry<String, Field>> entrySet() {
086:                    Set<java.util.Map.Entry<String, Field>> set = new HashSet<Entry<String, Field>>(
087:                            map.size());
088:                    for (Integer i : map.keySet()) {
089:                        java.util.Map.Entry<String, Field> e = new MapEntry(
090:                                valueMap.get(i));
091:                        set.add(e);
092:                    }
093:                    return set;
094:                }
095:
096:                public Field get(Object key) {
097:
098:                    return map.get(keyMap.get(key));
099:                }
100:
101:                public boolean isEmpty() {
102:                    return map.isEmpty();
103:                }
104:
105:                public Set<String> keySet() {
106:                    Set<String> set = new HashSet<String>(map.size());
107:                    for (Integer i : map.keySet()) {
108:                        String s = valueMap.get(i);
109:                        set.add(s);
110:                    }
111:                    return set;
112:                }
113:
114:                Set<Integer> tokenSet() {
115:                    return map.keySet();
116:                }
117:
118:                public Field put(String key, Field value) {
119:                    Integer i = keyMap.get(key);
120:                    if (i == null) {
121:                        i = keyMap.size();
122:                        keyMap.put(key, i);
123:                        valueMap.put(i, key);
124:                        countMap.put(i, 1);
125:                    } else {
126:                        countMap.put(i, countMap.get(i) + 1);
127:                    }
128:                    return map.put(i, value);
129:                }
130:
131:                public void putAll(Map<? extends String, ? extends Field> t) {
132:                    for (Map.Entry<? extends String, ? extends Field> p : t
133:                            .entrySet()) {
134:                        put(p.getKey(), p.getValue());
135:                    }
136:                }
137:
138:                private Field remove(Integer i) {
139:                    if (i != null) {
140:                        Integer count = countMap.get(i) - 1;
141:                        if (count == 0) {
142:                            countMap.remove(i);
143:                            valueMap.remove(keyMap.get(i));
144:                            keyMap.remove(i);
145:                        } else {
146:                            countMap.put(i, count);
147:                        }
148:                    }
149:                    return map.remove(i);
150:                }
151:
152:                public Field remove(Object key) {
153:                    Integer i = keyMap.get(key);
154:                    return remove(i);
155:                }
156:
157:                public int size() {
158:                    return map.size();
159:                }
160:
161:                public Collection<Field> values() {
162:                    return map.values();
163:                }
164:
165:            }
166:
167:            public boolean add(Entry o) {
168:                return list.contains(o);
169:            }
170:
171:            public Entry createEntry() {
172:                Entry e = new EntryImpl();
173:                list.add(e);
174:                return e;
175:            }
176:
177:            public void add(int index, Entry element) {
178:                throw new UnsupportedOperationException();
179:            }
180:
181:            public boolean addAll(Collection<? extends Entry> c) {
182:                throw new UnsupportedOperationException();
183:            }
184:
185:            public boolean addAll(int index, Collection<? extends Entry> c) {
186:                throw new UnsupportedOperationException();
187:            }
188:
189:            public void clear() {
190:                list.clear();
191:                keyMap.clear();
192:                valueMap.clear();
193:            }
194:
195:            public boolean contains(Object o) {
196:                return list.contains(o);
197:            }
198:
199:            public boolean containsAll(Collection<?> c) {
200:                throw new UnsupportedOperationException();
201:            }
202:
203:            public Entry get(int index) {
204:                return list.get(index);
205:            }
206:
207:            public int indexOf(Object o) {
208:                return list.indexOf(o);
209:            }
210:
211:            public boolean isEmpty() {
212:                return list.isEmpty();
213:            }
214:
215:            public Iterator<Entry> iterator() {
216:                return list.iterator();
217:            }
218:
219:            public int lastIndexOf(Object o) {
220:                return list.lastIndexOf(o);
221:            }
222:
223:            public ListIterator<Entry> listIterator() {
224:                return list.listIterator();
225:            }
226:
227:            public ListIterator<Entry> listIterator(int index) {
228:                return list.listIterator(index);
229:            }
230:
231:            /**
232:             * removes Object from collection end clears the object.
233:             * @param o object to remove
234:             * @return true on success
235:             */
236:            public boolean remove(Object o) {
237:                boolean ret = false;
238:                if (o instanceof  EntryImpl) {
239:                    EntryImpl e = (EntryImpl) o;
240:                    e.clear();
241:                    ret = list.remove(o);
242:                }
243:                return ret;
244:            }
245:
246:            public Entry remove(int index) {
247:                Entry ret = list.get(index);
248:                if (!remove(list.get(index))) {
249:                    ret = null;
250:                }
251:                return ret;
252:            }
253:
254:            public boolean removeAll(Collection<?> c) {
255:                throw new UnsupportedOperationException();
256:            }
257:
258:            public boolean retainAll(Collection<?> c) {
259:                throw new UnsupportedOperationException();
260:            }
261:
262:            public Entry set(int index, Entry element) {
263:                throw new UnsupportedOperationException();
264:            }
265:
266:            public int size() {
267:                return list.size();
268:            }
269:
270:            public List<Entry> subList(int fromIndex, int toIndex) {
271:                return list.subList(fromIndex, toIndex);
272:            }
273:
274:            public Object[] toArray() {
275:                return list.toArray();
276:            }
277:
278:            public <T> T[] toArray(T[] a) {
279:                return list.toArray(a);
280:            }
281:
282:            private void readObject(java.io.ObjectInputStream in)
283:                    throws IOException, ClassNotFoundException {
284:                // forst initialize the non transient part
285:                in.defaultReadObject();
286:                // construct the transient revers mapping
287:                for (String key : keyMap.keySet()) {
288:                    valueMap.put(keyMap.get(key), key);
289:                }
290:                // construct reference count
291:                for (Entry e : list) {
292:
293:                    for (Integer key : ((EntryImpl) e).tokenSet()) {
294:                        if (countMap.containsKey(key)) {
295:                            countMap.put(key, countMap.get(key) + 1);
296:
297:                        } else {
298:                            countMap.put(key, 1);
299:
300:                        }
301:                    }
302:                }
303:            }
304:
305:            public int getHits() {
306:                return hits;
307:            }
308:
309:            public void setHits(int hits) {
310:                this.hits = hits;
311:            }
312:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.