1 | package org.greenstone.gsdl3.util;
|
---|
2 |
|
---|
3 | public class GS3OID extends OID {
|
---|
4 |
|
---|
5 | /** public static boolean isTop(String oid) {
|
---|
6 | if (oid.equals("")) {
|
---|
7 | return false;
|
---|
8 | }
|
---|
9 | int pos = oid.indexOf('.');
|
---|
10 | if (pos == -1) { // its the top document, not the top structure
|
---|
11 | return false;
|
---|
12 | }
|
---|
13 | pos = pod.indexOf('.', pos+1);
|
---|
14 | if (pos == -1) {
|
---|
15 | return true; // there is only one dot
|
---|
16 | }
|
---|
17 | return false; // there is more than one dot
|
---|
18 |
|
---|
19 | }*/
|
---|
20 |
|
---|
21 | public static boolean isDocTop(String oid) {
|
---|
22 | return oid.indexOf('-')==-1;
|
---|
23 | }
|
---|
24 |
|
---|
25 | public static String createOID(String doc_id, String section_label) {
|
---|
26 | return doc_id + "-"+section_label;
|
---|
27 | }
|
---|
28 |
|
---|
29 | public static String getDocID(String oid) {
|
---|
30 | if (isDocTop(oid)) {
|
---|
31 | return oid;
|
---|
32 | }
|
---|
33 | return oid.substring(0, oid.indexOf('-'));
|
---|
34 | }
|
---|
35 | public static String getSectionLabel(String oid) {
|
---|
36 |
|
---|
37 | if (isDocTop(oid)) {
|
---|
38 | return "";
|
---|
39 | }
|
---|
40 | return oid.substring(oid.indexOf('-')+1);
|
---|
41 |
|
---|
42 | }
|
---|
43 |
|
---|
44 | // put this here for now - may need to go with SQL stuff later
|
---|
45 | public static String translateOID(String oid) {
|
---|
46 |
|
---|
47 | int p = oid.lastIndexOf('.');
|
---|
48 | if (p != oid.length()-3) {
|
---|
49 | System.out.println("translateoid error: '.' is not the third to last char!!");
|
---|
50 | return oid;
|
---|
51 | }
|
---|
52 |
|
---|
53 | String top = oid.substring(0, p);
|
---|
54 | String suff = oid.substring(p+1);
|
---|
55 | if (suff.equals("pr")) {
|
---|
56 | return getParent(top);
|
---|
57 | } else if (suff.equals("rt")) {
|
---|
58 | return getTop(top);
|
---|
59 | }
|
---|
60 | return oid;
|
---|
61 |
|
---|
62 | }
|
---|
63 |
|
---|
64 | }
|
---|