KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > taglibs > xtags > xpath > JspCopyOfAction


1 /*
2  * Copyright 1999,2004 The Apache Software Foundation.
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 org.apache.taglibs.xtags.xpath;
18
19 import java.io.IOException JavaDoc;
20
21 import javax.servlet.jsp.PageContext JavaDoc;
22
23 import org.dom4j.Node;
24 import org.dom4j.io.XMLWriter;
25 import org.dom4j.rule.Action;
26
27 /** Outputs the given Node to the current JSP output
28   *
29   * @author James Strachan
30   */

31 public class JspCopyOfAction implements Action {
32
33     /** Holds value of property pageContext. */
34     private PageContext JavaDoc pageContext;
35     
36     /** Holds value of property xmlWriter. */
37     private XMLWriter xmlWriter;
38     
39
40     public JspCopyOfAction() {
41     }
42
43     public JspCopyOfAction(PageContext JavaDoc pageContext) {
44         this.pageContext = pageContext;
45     }
46
47     
48     /** Getter for property pageContext.
49      * @return Value of property pageContext.
50      */

51     public PageContext JavaDoc getPageContext() {
52         return pageContext;
53     }
54     
55     /** Setter for property pageContext.
56      * @param pageContext New value of property pageContext.
57      */

58     public void setPageContext(PageContext JavaDoc pageContext) {
59         this.pageContext = pageContext;
60     }
61     
62     
63     
64     // Action interface
65
//-------------------------------------------------------------------------
66
public void run( Node node ) throws Exception JavaDoc {
67         if ( node != null ) {
68             XMLWriter writer = getXMLWriter();
69             writer.setWriter( pageContext.getOut() );
70             writer.write( node );
71             writer.flush();
72         }
73     }
74
75     // Properties
76
//-------------------------------------------------------------------------
77

78     /** Getter for property xmlWriter.
79      * @return Value of property xmlWriter.
80      */

81     public XMLWriter getXMLWriter() {
82         if ( xmlWriter == null ) {
83             xmlWriter = TagHelper.createXMLWriter( pageContext );
84         }
85         return xmlWriter;
86     }
87     
88     /** Setter for property xmlWriter.
89      * @param xmlWriter New value of property xmlWriter.
90      */

91     public void setXMLWriter(XMLWriter xmlWriter) {
92         this.xmlWriter = xmlWriter;
93     }
94 }
95
Popular Tags