KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > configuration > ScriptingElement


1 /*
2  * Copyright 2006-2007 The Scriptella Project Team.
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 package scriptella.configuration;
17
18 import scriptella.spi.DialectIdentifier;
19 import scriptella.spi.Resource;
20
21
22 /**
23  * Base class for queries and scripts.
24  *
25  * @author Fyodor Kupolov
26  * @version 1.0
27  */

28 public abstract class ScriptingElement extends XmlConfigurableBase {
29     private String JavaDoc connectionId;
30     private String JavaDoc ifExpr;
31     private DialectBasedContentEl contentEl;
32     private ScriptingElement parent;
33
34     protected ScriptingElement(ScriptingElement parent) {
35         this.parent = parent;
36     }
37
38     public String JavaDoc getConnectionId() {
39         return connectionId;
40     }
41
42     public void setConnectionId(final String JavaDoc connectionId) {
43         this.connectionId = connectionId;
44     }
45
46     public Location getLocation() {
47         return super.getLocation();
48     }
49
50     public String JavaDoc getIf() {
51         return ifExpr;
52     }
53
54     public void setIf(final String JavaDoc ifExpr) {
55         this.ifExpr = ifExpr;
56     }
57
58     public Resource getContent() {
59         return contentEl.getContent(null);
60     }
61
62
63     public Resource getDialectContent(DialectIdentifier id) {
64         return contentEl.getContent(id);
65     }
66
67     public ScriptingElement getParent() {
68         return parent;
69     }
70
71     public void configure(final XmlElement element) {
72         setLocation(element);
73         setProperty(element, "connection-id", "connectionId");
74         setProperty(element, "if");
75         contentEl = new DialectBasedContentEl(element);
76         contentEl.setLocation(getLocation());
77     }
78
79
80     public String JavaDoc toString() {
81         return "connectionId='" + connectionId + '\'' +
82                 ", location=" + getLocation() +
83                 ", ifExpr='" + ifExpr + '\'';
84
85     }
86 }
87
Popular Tags