01: /*
02: * Copyright 2001-2007 Hippo (www.hippo.nl)
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 nl.hippo.cms.editor.flow;
17:
18: import org.w3c.dom.Document;
19: import javax.xml.parsers.DocumentBuilderFactory;
20: import javax.xml.parsers.ParserConfigurationException;
21:
22: public class FlowContext extends AbstractFlowContextComponent {
23:
24: public FlowContext(Configuration conf, FlowHelper fh) {
25: super (conf, fh);
26: addComponent(new FlowDocument(conf, fh));
27: }
28:
29: public String getComponentKey() {
30: return "flowContext";
31: }
32:
33: public Document toDOM() {
34: Document d = null;
35: try {
36: d = DocumentBuilderFactory.newInstance()
37: .newDocumentBuilder().newDocument();
38: } catch (ParserConfigurationException pce) {
39: helper.log(
40: "Unable to get new instance of document builder",
41: pce);
42: }
43: if (d != null) {
44: d.appendChild(this .toXML(d));
45: }
46:
47: return d;
48: }
49:
50: public FlowDocument getFlowDocument() {
51: AbstractFlowContextComponent comp = getComponent("document");
52: if (comp instanceof FlowDocument) {
53: return (FlowDocument) comp;
54: }
55:
56: return null;
57: }
58:
59: }
|