KickJava   Java API By Example, From Geeks To Geeks.

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


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
20 import javax.servlet.jsp.JspException JavaDoc;
21
22 import org.dom4j.Node;
23 import org.dom4j.rule.Action;
24
25 /** An Action which tells the Stylesheet tag which template
26   * body to execute.
27   *
28   * @author James Elson
29   */

30 public class BodyAction implements Action {
31
32     /** Holds value of property stylesheetTag */
33     private StylesheetTag stylesheetTag;
34     
35     private String JavaDoc match;
36
37     private Node contextNode;
38     
39     public BodyAction() {
40     }
41
42     public BodyAction(StylesheetTag stylesheetTag, String JavaDoc match) {
43         this.stylesheetTag = stylesheetTag;
44         this.match = match;
45     }
46     
47     public String JavaDoc getMatch() {
48         return this.match;
49     }
50
51     public Node getContextNode() {
52         return this.contextNode;
53     }
54     
55     
56     // Action interface
57
//-------------------------------------------------------------------------
58
public void run( Node node ) throws Exception JavaDoc {
59         if ( this.stylesheetTag == null ) {
60             throw new JspException JavaDoc( "No StylesheetTag. Cannot execute Action");
61         }
62         else {
63             TemplateExecution te = new TemplateExecution(node, this.match);
64             stylesheetTag.addTemplateExecution(te);
65         }
66     }
67 }
68
Popular Tags