File: ObjectRef.java

package info (click to toggle)
thepeg 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 9,312 kB
  • ctags: 11,509
  • sloc: cpp: 57,129; sh: 11,315; java: 3,212; lisp: 1,402; makefile: 830; ansic: 58; perl: 3
file content (63 lines) | stat: -rw-r--r-- 1,187 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package ThePEG;

import java.util.*;

public class ObjectRef {

  SetupThePEG thepeg;
  String name;
  String fullName;
  boolean dir = false;
  String pclass;

  public ObjectRef(SetupThePEG tp, String nm, String fn, boolean isd) {
    thepeg = tp;
    name = nm;
    fullName = fn;
    dir = isd;
  }

  public ObjectRef(SetupThePEG tp, String f) {
    thepeg = tp;
    fullName = f;
    if ( f.charAt(f.length() - 1) == '/' ) {
      f = f.substring(0, f.length() - 1);
      dir = true;
    }
    name = f.substring(f.lastIndexOf('/') + 1);
  }

  public String toString() {
    return name;
  }

  public String getClassName() {
    if ( pclass != null ) return pclass;
    if ( isDir() ) return "";
    LinkedList ret = thepeg.exec("fulldescribe " + getFullName());
    if ( ret.size() > 0 ) ret.remove(0);
    if ( ret.size() > 0 ) pclass = (String)ret.remove(0);  
    return pclass;
  }

  public String getName() {
    return name;
  }

  public String getFullName() {
    return fullName;
  }

  public boolean isDir() {
    return dir;
  }

  public void open() {
    if ( isDir() ) return;
    thepeg.openObject(getFullName());
  }

  public static void classcheck() {}

}