Changeset 3458


Ignore:
Timestamp:
2002-10-11T13:44:41+13:00 (22 years ago)
Author:
kjdon
Message:

added translateOID method - this is related to greenstone - should it go in a separate class?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gdbm/GDBMWrapper.java

    r3289 r3458  
    33import org.greenstone.gsdl3.util.OID;
    44import au.com.pharos.gdbm.GdbmFile;
    5 import au.com.pharos.packing.StringPacking;
     5import au.com.pharos.packing.*;
    66import au.com.pharos.gdbm.GdbmException;
    77
     
    126126    }
    127127
    128     // convenience methods
     128    // greenstone convenience methods - should these go into a separate class?
     129
    129130    /** converts a greenstone OID to internal docnum */
    130131    public long oid2Docnum(String OID) {
     
    139140    return oid;
    140141    }
     142
     143    /** translates oids containing .pr, .fc, .lc, .ns, .ps into proper oids
     144     * a suffix is expected to be present so test before using */
     145    public String translateOID(String oid) {
     146
     147    int p = oid.lastIndexOf('.');
     148    if (p != oid.length()-3) {
     149        System.out.println("translateoid error: '.' is not the third to last char!!");
     150        return oid;
     151    }
     152
     153    String top = oid.substring(0, p);
     154    String suff = oid.substring(p+1);
     155    if (suff.equals("pr")) {
     156        return OID.getParent(top);
     157    } else if (suff.equals("fc")) {
     158    } else if (suff.equals("lc")) {
     159    } else if (suff.equals("ns")) {
     160    } else if (suff.equals("ps")) {
     161    }
     162    return oid;
     163    }
    141164}
Note: See TracChangeset for help on using the changeset viewer.