View Javadoc

1   package org.catacomb.interlish.resource;
2   
3   import org.catacomb.interlish.structure.Attribute;
4   import org.catacomb.interlish.structure.Element;
5   import org.catacomb.interlish.structure.ElementReader;
6   import org.catacomb.report.E;
7   
8   
9   
10  
11  public abstract class Role implements ElementReader {
12  
13      public String resource;
14      public String function;
15      public String value;
16  
17  
18      private Object p_cached;   // POSERR not sure want this?
19  
20  
21      public Role() {
22  
23      }
24  
25  
26  
27      public Role(String sr, String sf, String sv) {
28          resource = sr;
29          function = sf;
30          value = sv;
31      }
32  
33  
34      public void populateFrom(Element elt) {
35  
36          for (Attribute att : elt.getAttributes()) {
37              String sn = att.getName();
38              String sv = att.getValue();
39              if (sn.equals("resource")) {
40                  resource = sv;
41              } else if (sn.equals("function")) {
42                  function = sv;
43              } else if (sn.equals("value")) {
44                  value = sv;
45  
46                  // alt form;
47              } else if (function == null) {
48                  function = sn;
49                  value = sv;
50              } else {
51                  E.error("role reading alreadyu have function (" + function + ") but read " +
52                          sn + " " + sv);
53              }
54          }
55      }
56  
57  
58      public void setResource(String s) {
59          resource = s;
60      }
61  
62      public String getResource() {
63          return resource;
64      }
65  
66  
67      public String getFunction() {
68          return function;
69      }
70  
71  
72      public String getValue() {
73          return value;
74      }
75  
76  
77      public void cachePlayer(Object obj) {
78          p_cached = obj;
79      }
80  
81      public boolean hasCachedPlayer() {
82          return (p_cached != null);
83      }
84  
85      public Object getCachedPlayer() {
86          return p_cached;
87      }
88  
89  
90  }