View Javadoc

1   /* 
2    *  Copyright 2004 University of Hannover
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  
17  package olr.viewer;
18  
19  import olr.rdf.Definitions;
20  import olr.rdf.Resource;
21  import olr.rdf.Tools;
22  
23  /***
24   * @version $Id: ModelViewerRow.java,v 1.5 2004/08/03 08:33:53 roku Exp $
25   */
26  public class ModelViewerRow {
27  
28      public ModelViewerRow(ModelViewer modelViewer, String resource, int level, boolean isPredicate) {
29          this(modelViewer, resource, level);
30          this.isPredicate = isPredicate;
31          this.hasSub = false;
32      }
33  
34      public ModelViewerRow(ModelViewer modelViewer, String resource, int level) {
35          expanded = false;
36          isPredicate = false;
37          hasSub = false;
38          this.modelViewer = modelViewer;
39          this.resource = resource;
40          this.level = level;
41      }
42  
43      public boolean isExpanded() {
44          return expanded;
45      }
46  
47      public void expand() {
48          expanded = !expanded;
49      }
50  
51      public boolean isExpandable() {
52          if (!isPredicate) {
53              return hasSub;
54          } else
55              return false;
56      }
57  
58      public void setSub(boolean b) {
59          hasSub = b;
60      }
61  
62      public boolean isPredicate() {
63          return isPredicate;
64      }
65  
66      public String getID() {
67          return getResource();
68      }
69  
70      public String getTitle() {
71          if (Definitions.isRDF(getResource())
72                  || Tools.isSameNS(modelViewer.getNamespace(), getResource()))
73              return Tools.getName(getResource());
74          else
75              return getResource();
76      }
77  
78      public int getIndent() {
79          return level;
80      }
81  
82      public boolean isSchemaProperty() {
83          return level == 0 && (modelViewer instanceof SchemaViewer);
84      }
85  
86      public String getResource() {
87          return resource.toString();
88      }
89  
90      private Resource getResourceObject() {
91          return modelViewer.getModel().getStatementPool().getResource(getResource());
92      }
93  
94      protected ModelViewer modelViewer;
95  
96      protected String resource;
97  
98      protected int level;
99  
100     protected boolean expanded;
101 
102     protected boolean isPredicate;
103 
104     protected boolean hasSub;
105 }