35 |
|
|
36 |
public class TitleIndex { |
public class TitleIndex { |
37 |
public static boolean dbg = false; |
public static boolean dbg = false; |
38 |
private static void p(String s) { System.out.println("PointerIndex:: "+s); } |
private static void p(String s) { System.out.println("TitleIndex:: "+s); } |
39 |
|
|
40 |
public static final String uri = |
public static final String uri = |
41 |
"http://fenfire.org/2003/05/pointer-title-index-0.1"; |
"http://fenfire.org/2003/05/pointer-title-index-0.1"; |
44 |
|
|
45 |
protected IndexedPool pool; |
protected IndexedPool pool; |
46 |
protected IndexedPool.DB db; |
protected IndexedPool.DB db; |
|
protected PointerIndex pointerIndex; |
|
47 |
|
|
48 |
/** Returns a set of *current* pointer blocks. |
/** Returns a set of *current* pointer blocks. |
49 |
|
* XXX not async at all |
50 |
*/ |
*/ |
51 |
public Set getPointers(String query) throws IOException { |
public Set getPointers(String query) throws IOException { |
52 |
Iterator i=splitWords(query).iterator(); |
Iterator i=splitWords(query).iterator(); |
60 |
IndexedPool.Mapping m = (IndexedPool.Mapping)i.next(); |
IndexedPool.Mapping m = (IndexedPool.Mapping)i.next(); |
61 |
try { |
try { |
62 |
PointerId id = new PointerId(m.value); |
PointerId id = new PointerId(m.value); |
63 |
PointerBlock cur = pointerIndex.getPointerBlock(id); |
PointerBlock cur = pointerIndex().getPointerBlock(id); |
64 |
if(cur.getBlockId().equals(m.block)) |
if(cur.getBlockId().equals(m.block)) |
65 |
result.add(cur); |
result.add(cur); |
66 |
} catch(Throwable _) { |
} catch(Throwable _) { |
81 |
|
|
82 |
String s = ""; |
String s = ""; |
83 |
for(int i=0; i<title.length(); i++) { |
for(int i=0; i<title.length(); i++) { |
84 |
char c = s.charAt(i); |
char c = title.charAt(i); |
85 |
if(Character.isLetterOrDigit(c)) |
if(Character.isLetterOrDigit(c)) |
86 |
s += c; |
s += c; |
87 |
else { |
else { |
137 |
} |
} |
138 |
} |
} |
139 |
|
|
140 |
|
protected final PointerIndex pointerIndex() { |
141 |
|
return (PointerIndex)pool.getIndex(PointerIndex.uri); |
142 |
|
} |
143 |
|
|
144 |
public TitleIndex(IndexedPool pool, IndexedPool.DB db) { |
public TitleIndex(IndexedPool pool, IndexedPool.DB db) { |
145 |
this.pool = pool; |
this.pool = pool; |
146 |
this.db = db; |
this.db = db; |
|
this.pointerIndex = |
|
|
(PointerIndex)pool.getIndex(PointerIndex.uri); |
|
147 |
} |
} |
148 |
} |
} |