01: /*
02: * Copyright 2006-2007 The Scriptella Project Team.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: * Base class for queries and scripts.
23: *
24: * @author Fyodor Kupolov
25: * @version 1.0
26: */
27: public abstract class ScriptingElement extends XmlConfigurableBase {
28: private String connectionId;
29: private String ifExpr;
30: private DialectBasedContentEl contentEl;
31: private ScriptingElement parent;
32:
33: protected ScriptingElement(ScriptingElement parent) {
34: this .parent = parent;
35: }
36:
37: public String getConnectionId() {
38: return connectionId;
39: }
40:
41: public void setConnectionId(final String connectionId) {
42: this .connectionId = connectionId;
43: }
44:
45: public Location getLocation() {
46: return super .getLocation();
47: }
48:
49: public String getIf() {
50: return ifExpr;
51: }
52:
53: public void setIf(final String ifExpr) {
54: this .ifExpr = ifExpr;
55: }
56:
57: public Resource getContent() {
58: return contentEl.getContent(null);
59: }
60:
61: public ContentEl getDialectContent(DialectIdentifier id) {
62: return contentEl.getContent(id);
63: }
64:
65: public ScriptingElement getParent() {
66: return parent;
67: }
68:
69: public void configure(final XmlElement element) {
70: setLocation(element);
71: setProperty(element, "connection-id", "connectionId");
72: setProperty(element, "if");
73: contentEl = new DialectBasedContentEl(element);
74: contentEl.setLocation(getLocation());
75: }
76:
77: public String toString() {
78: return "connectionId='" + connectionId + '\'' + ", location="
79: + getLocation() + ", ifExpr='" + ifExpr + '\'';
80:
81: }
82: }
|