Changeset 4156
- Timestamp:
- 2003-04-15T12:41:15+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gdbm/GDBMWrapper.java
r4029 r4156 127 127 128 128 // greenstone convenience methods - should these go into a separate class? 129 129 // yes I think so. 130 130 /** converts a greenstone OID to internal docnum */ 131 131 public long oid2Docnum(String OID) { … … 146 146 public String translateOID(String oid) { 147 147 148 148 149 int p = oid.lastIndexOf('.'); 149 150 if (p != oid.length()-3) { … … 156 157 if (suff.equals("pr")) { 157 158 return OID.getParent(top); 158 } else if (suff.equals("fc")) {159 } else if (suff.equals("lc")) {160 } else if (suff.equals("ns")) {161 } else if (suff.equals("ps")) {162 159 } else if (suff.equals("rt")) { 163 160 return OID.getTop(top); 164 } 165 return oid; 161 } else { 162 System.out.println("looking up gdbm db"); 163 // need to get info out of gdbm db - 164 String doc_id = top; 165 if (suff.endsWith("s")) { 166 doc_id = OID.getParent(top); 167 } 168 System.out.println("doc id to lok up is"+doc_id); 169 DBInfo info = getInfo(doc_id); 170 if (info==null) { 171 System.out.println("info is null!!"); 172 return top; 173 } 174 String contains = info.getInfo("contains"); 175 contains.replaceAll("\"", doc_id); 176 if (contains.equals("")) { 177 // something is wrong 178 return top; 179 } 180 contains = contains.replaceAll("\"", doc_id); 181 String [] children = contains.split(";"); 182 if (suff.equals("fc")) { 183 return children[0]; 184 } else if (suff.equals("lc")) { 185 return children[children.length-1]; 186 } else { 187 // find the position that we are at. 188 int i=0; 189 while (i<children.length) { 190 if (children[i].equals(top)) { 191 break; 192 } 193 i++; 194 } 195 196 if (suff.equals("ns")) { 197 if (i==children.length-1)return children[i]; 198 return children[i+1]; 199 } else if (suff.equals("ps")) { 200 if (i==0) return children[i]; 201 return children[i-1]; 202 } 203 } 204 } 205 return top; 166 206 } 167 207 }
Note:
See TracChangeset
for help on using the changeset viewer.