01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.template.script.event;
18:
19: import java.util.HashMap;
20: import java.util.Map;
21:
22: import org.apache.cocoon.components.expression.ExpressionContext;
23: import org.apache.cocoon.template.environment.ExecutionContext;
24: import org.apache.cocoon.template.instruction.MacroContext;
25: import org.apache.cocoon.xml.XMLConsumer;
26: import org.apache.excalibur.source.SourceValidity;
27: import org.xml.sax.Locator;
28: import org.xml.sax.SAXException;
29:
30: /**
31: * @version SVN $Id: StartDocument.java 449189 2006-09-23 06:52:29Z crossley $
32: */
33: public class StartDocument extends Event {
34: public StartDocument(Locator location) {
35: super (location);
36: templateProperties = new HashMap();
37: }
38:
39: private SourceValidity sourceValidity;
40: private String uri;
41: private EndDocument endDocument; // null if document fragment
42: private Map templateProperties;
43:
44: public EndDocument getEndDocument() {
45: return endDocument;
46: }
47:
48: public void setEndDocument(EndDocument endDoc) {
49: this .endDocument = endDoc;
50: }
51:
52: public Map getTemplateProperties() {
53: return templateProperties;
54: }
55:
56: public String getUri() {
57: return this .uri;
58: }
59:
60: public void setUri(String uri) {
61: this .uri = uri;
62: }
63:
64: /**
65: * @param sourceValidity
66: * The compileTime to set.
67: */
68: public void setSourceValidity(SourceValidity sourceValidity) {
69: this .sourceValidity = sourceValidity;
70: }
71:
72: /**
73: * @return Returns the compileTime.
74: */
75: public SourceValidity getSourceValidity() {
76: return sourceValidity;
77: }
78:
79: /**
80: * @param name
81: */
82: public Object getTemplateProperty(String name) {
83: return getTemplateProperties().get(name);
84: }
85:
86: public Event execute(XMLConsumer consumer,
87: ExpressionContext expressionContext,
88: ExecutionContext executionContext,
89: MacroContext macroContext, Event startEvent, Event endEvent)
90: throws SAXException {
91: if (getEndDocument() != null)
92: consumer.startDocument();
93: return getNext();
94: }
95: }
|