View Javadoc

1   /*
2    * Copyright 2002,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  package org.apache.commons.jelly.tags.jsl;
17  
18  import org.apache.commons.jelly.XMLOutput;
19  
20  import org.apache.commons.logging.Log;
21  import org.apache.commons.logging.LogFactory;
22  
23  import org.dom4j.Node;
24  import org.dom4j.rule.Action;
25  import org.dom4j.rule.Stylesheet;
26  
27  /***
28   * This class is a specialization of the Stylesheet from dom4j's rule engine
29   * that adds some Jelly specific features.
30   *
31   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
32   * @version $Revision: 155420 $
33   */
34  public class JellyStylesheet extends Stylesheet {
35  
36      /*** The Log to which logging calls will be made. */
37      private Log log = LogFactory.getLog(JellyStylesheet.class);
38  
39      private XMLOutput output;
40  
41      public JellyStylesheet() {
42          setValueOfAction(
43              new Action() {
44                  public void run(Node node) throws Exception {
45                      String text = node.getStringValue();
46                      if ( text != null && text.length() > 0 ) {
47                          getOutput().write( text );
48                      }
49                  }
50              }
51          );
52      }
53  
54      // Properties
55      //-------------------------------------------------------------------------
56  
57      /***
58       * Returns the output.
59       * @return XMLOutput
60       */
61      public XMLOutput getOutput() {
62          return output;
63      }
64  
65      /***
66       * Sets the output.
67       * @param output The output to set
68       */
69      public void setOutput(XMLOutput output) {
70          this.output = output;
71      }
72  
73  }