Mercurial Hosting > luan
annotate core/src/luan/AbstractLuanTable.java @ 273:073044e3ac03
fix mmake.sh and multipart mail
git-svn-id: https://luan-java.googlecode.com/svn/trunk@274 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 31 Oct 2014 18:44:11 +0000 |
parents | b25feac318d8 |
children | 8afe9f2fdfec |
rev | line source |
---|---|
222
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
1 package luan; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
2 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
3 import java.util.Iterator; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
4 import java.util.ListIterator; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
5 import java.util.Map; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
6 import java.util.HashMap; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
7 import java.util.List; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
8 import java.util.ArrayList; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
9 import java.util.Collections; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
10 import java.util.Comparator; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
11 import java.util.Set; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
12 import java.util.HashSet; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
13 import java.util.IdentityHashMap; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
14 import java.util.regex.Pattern; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
15 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
16 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
17 public abstract class AbstractLuanTable implements LuanTable { |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
18 |
233
ef39bc4d3f70
basic lucene works
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
224
diff
changeset
|
19 @Override public boolean isEmpty() { |
ef39bc4d3f70
basic lucene works
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
224
diff
changeset
|
20 return isList() && length()==0; |
ef39bc4d3f70
basic lucene works
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
224
diff
changeset
|
21 } |
ef39bc4d3f70
basic lucene works
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
224
diff
changeset
|
22 |
ef39bc4d3f70
basic lucene works
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
224
diff
changeset
|
23 @Override public boolean isList() { |
ef39bc4d3f70
basic lucene works
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
224
diff
changeset
|
24 return asList().size() == asMap().size(); |
ef39bc4d3f70
basic lucene works
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
224
diff
changeset
|
25 } |
ef39bc4d3f70
basic lucene works
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
224
diff
changeset
|
26 |
222
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
27 @Override public List<Object> asList() { |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
28 return Collections.emptyList(); |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
29 } |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
30 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
31 @Override public Map<Object,Object> asMap() { |
234
b25feac318d8
add lucene jar and minor changes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
233
diff
changeset
|
32 Map<Object,Object> map = new HashMap<Object,Object>(); |
b25feac318d8
add lucene jar and minor changes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
233
diff
changeset
|
33 for( Map.Entry<Object,Object> entry : this ) { |
b25feac318d8
add lucene jar and minor changes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
233
diff
changeset
|
34 map.put(entry.getKey(),entry.getValue()); |
b25feac318d8
add lucene jar and minor changes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
233
diff
changeset
|
35 } |
b25feac318d8
add lucene jar and minor changes
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
233
diff
changeset
|
36 return map; |
222
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
37 } |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
38 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
39 protected abstract String type(); |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
40 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
41 @Override public final String toString() { |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
42 return type() + ": " + Integer.toHexString(hashCode()); |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
43 } |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
44 |
224
05eb2837ddbf
change LuanTable.put() to not return old value
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
222
diff
changeset
|
45 @Override public void put(Object key,Object val) { |
222
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
46 throw new UnsupportedOperationException("can't put into a "+type()); |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
47 } |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
48 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
49 @Override public void insert(int pos,Object value) { |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
50 throw new UnsupportedOperationException("can't insert into a "+type()); |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
51 } |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
52 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
53 @Override public void add(Object value) { |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
54 throw new UnsupportedOperationException("can't add to a "+type()); |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
55 } |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
56 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
57 @Override public Object remove(int pos) { |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
58 throw new UnsupportedOperationException("can't remove from a "+type()); |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
59 } |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
60 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
61 @Override public void sort(Comparator<Object> cmp) { |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
62 } |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
63 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
64 @Override public int length() { |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
65 return 0; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
66 } |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
67 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
68 @Override public LuanTable subList(int from,int to) { |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
69 throw new UnsupportedOperationException("can't get a sub-list of a "+type()); |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
70 } |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
71 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
72 @Override public LuanTable getMetatable() { |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
73 return null; |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
74 } |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
75 |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
76 @Override public void setMetatable(LuanTable metatable) { |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
77 throw new UnsupportedOperationException("can't set a metatable on a "+type()); |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
78 } |
b76fcb72d97d
add AbstractLuanTable and improve HttpLuan
fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
parents:
diff
changeset
|
79 } |