50 |
* XXX For real use, this should not block. |
* XXX For real use, this should not block. |
51 |
*/ |
*/ |
52 |
public Set getBlocks(String contentType) throws IOException { |
public Set getBlocks(String contentType) throws IOException { |
53 |
byte[] key = contentType.getBytes("US-ASCII"); |
String key = contentType; |
54 |
Collection mappings = db.get(key).block(); |
Collection mappings = db.get(key).block(); |
55 |
|
|
56 |
Set result = new HashSet(mappings.size()); |
Set result = new HashSet(mappings.size()); |
57 |
|
|
58 |
for(Iterator i=mappings.iterator(); i.hasNext();) { |
for(Iterator i=mappings.iterator(); i.hasNext();) { |
59 |
IndexedPool.Mapping m = (IndexedPool.Mapping)i.next(); |
IndexedPool.Mapping m = (IndexedPool.Mapping)i.next(); |
60 |
if(!java.util.Arrays.equals(key, m.key)) |
if(!key.equals(m.key)) |
61 |
throw new Error("Key does not match"); |
throw new Error("Key does not match"); |
62 |
if(m.value.length != 0) |
if(!m.value.equals("")) |
63 |
throw new Error("Value does not match"); |
throw new Error("Value does not match"); |
64 |
|
|
65 |
result.add(m.block); |
result.add(m.block); |
70 |
} |
} |
71 |
|
|
72 |
public Set getMappings(Block block) throws IOException { |
public Set getMappings(Block block) throws IOException { |
73 |
String ct = block.getId().getContentType(); |
String key = block.getId().getContentType(); |
74 |
byte[] key = ct.getBytes("US-ASCII"); |
String value = ""; |
|
byte[] value = new byte[0]; |
|
75 |
|
|
76 |
IndexedPool.Mapping mapping = new IndexedPool.Mapping(block.getId(), |
IndexedPool.Mapping mapping = new IndexedPool.Mapping(block.getId(), |
77 |
key, value); |
key, value); |