Ignore:
Timestamp:
2009-02-11T15:44:57+13:00 (15 years ago)
Author:
oranfry
Message:

whitespace fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • greenstone3/trunk/src/java/org/greenstone/gsdl3/util/OID.java

    r16869 r18503  
    2626   
    2727    /** returns everything up to the first dot
    28     if no dot, returns oid */
     28      if no dot, returns oid */
    2929    public static String getTop(String oid) {
    30     int pos = oid.indexOf('.');
    31     if (pos == -1) {
    32         return oid;
    33     }
    34     return oid.substring(0, pos);
    35    
     30      int pos = oid.indexOf('.');
     31      if (pos == -1) {
     32          return oid;
     33      }
     34      return oid.substring(0, pos);
     35     
    3636    }
    3737    /** returns true is oid is top level (ie has no dots)
    3838     returns false for an empty oid */
    3939    public static boolean isTop(String oid) {
    40     if (oid.equals("")) {
    41         return false;
    42     }
    43     return (oid.indexOf('.')==-1);
     40      if (oid.equals("")) {
     41          return false;
     42      }
     43      return (oid.indexOf('.')==-1);
    4444    }
    45    
     45     
    4646    /** returns the parent of oid (everything up to last dot)
    4747     returns oid if oid has no parent */
    4848    public static String getParent(String oid) {
    49     int pos = oid.lastIndexOf('.');
    50     if (pos == -1) {
    51         return oid;
    52     }
    53     return oid.substring(0, pos);
     49      int pos = oid.lastIndexOf('.');
     50      if (pos == -1) {
     51          return oid;
     52      }
     53      return oid.substring(0, pos);
    5454    }
    5555
    5656    /** returns the full name - replaces all " with parent */
    5757    public static String translateParent(String oid, String parent) {
    58     return oid.replaceAll("\"", parent);
     58      return oid.replaceAll("\"", parent);
    5959    }
    6060    /** does the opposite to translate_parent */
    6161    public static String shrinkParent(String oid) {
    62     int pos = oid.lastIndexOf('.');
    63     if (pos==-1) return oid;
    64     return "\""+oid.substring(pos);
     62      int pos = oid.lastIndexOf('.');
     63      if (pos==-1) return oid;
     64      return "\""+oid.substring(pos);
    6565    }
    6666    /** returns true if oid uses .fc, .lc, .pr, .ns, .ps .rt (root) .ss (specified sibling)*/
    6767    public static boolean needsTranslating(String oid) {
    68     if (oid.length()<4) return false;
    69     String tail = oid.substring(oid.length()-3);
    70     return (tail.equals(".fc") || tail.equals(".lc") ||
    71         tail.equals(".pr") || tail.equals(".ns") ||
    72         tail.equals(".ps") || tail.equals(".rt") ||
    73         tail.equals(".ss") || tail.equals(".np") ||
    74         tail.equals(".pp"));
     68      if (oid.length()<4) return false;
     69      String tail = oid.substring(oid.length()-3);
     70      return (tail.equals(".fc") || tail.equals(".lc") ||
     71            tail.equals(".pr") || tail.equals(".ns") ||
     72            tail.equals(".ps") || tail.equals(".rt") ||
     73            tail.equals(".ss") || tail.equals(".np") ||
     74            tail.equals(".pp"));
    7575    }
    7676    /** strips suffix from end */
    7777    public static String stripSuffix(String oid) {
    78     String tail = oid.substring(oid.length()-3);
    79     while (tail.equals(".fc") || tail.equals(".lc") ||
    80            tail.equals(".pr") || tail.equals(".ns") ||
    81            tail.equals(".ps") || tail.equals(".ss") ||
    82            tail.equals(".np") || tail.equals(".pp") ||
    83            tail.equals(".rt") ) {
    84         if (tail.equals(".ss")) { // have doc.sibnum.ss
    85         oid = oid.substring(0, oid.length()-3);
    86         int pos = oid.lastIndexOf('.');
    87         //strip that too
    88         oid = oid.substring(0, pos);
    89         }
    90         oid = oid.substring(0, oid.length()-3);
    91         tail = oid.substring(oid.length()-3);
    92     }
    93    
    94     return oid;
     78      String tail = oid.substring(oid.length()-3);
     79      while (tail.equals(".fc") || tail.equals(".lc") ||
     80             tail.equals(".pr") || tail.equals(".ns") ||
     81             tail.equals(".ps") || tail.equals(".ss") ||
     82             tail.equals(".np") || tail.equals(".pp") ||
     83             tail.equals(".rt") ) {
     84          if (tail.equals(".ss")) { // have doc.sibnum.ss
     85            oid = oid.substring(0, oid.length()-3);
     86            int pos = oid.lastIndexOf('.');
     87            //strip that too
     88            oid = oid.substring(0, pos);
     89          }
     90          oid = oid.substring(0, oid.length()-3);
     91          tail = oid.substring(oid.length()-3);
     92      }
     93     
     94      return oid;
    9595    }
    9696    /** returns true if child is a child of parent
    9797     an oid is not a child of itself */
    9898    public static boolean isChildOf(String parent, String child) {
    99     if (parent.equals(child)) {
    100         return false;
    101     }
    102     return child.startsWith(parent);
     99      if (parent.equals(child)) {
     100          return false;
     101      }
     102      return child.startsWith(parent);
    103103    }
    104104}
Note: See TracChangeset for help on using the changeset viewer.