01: /*
02: * Copyright 2002,2004 The Apache Software Foundation.
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 org.apache.commons.jelly.tags.core;
17:
18: import org.apache.commons.jelly.JellyTagException;
19: import org.apache.commons.jelly.TagSupport;
20: import org.apache.commons.jelly.XMLOutput;
21: import org.xml.sax.helpers.DefaultHandler;
22:
23: /** A tag which executes its body but passing no output.
24: * <p>
25: * Using this tag will still take the time to perform toString on each object
26: * returned to the output (but this toString value is discarded.
27: * A future version should go more internally so that this is avoided.
28: *
29: * @author <a href="mailto:paul@activemath.org">Paul Libbrecht</a>
30: * @version $Revision: 155420 $
31: */
32: public class MuteTag extends TagSupport {
33:
34: /**
35: * Create an instance
36: */
37: public MuteTag() {
38: }
39:
40: /**
41: * Invoke the body and produce no output.
42: * @param output tag output, which is ignored.
43: */
44: public void doTag(XMLOutput output) throws JellyTagException {
45: super .invokeBody(new MuteXMLOutput());
46: }
47:
48: /**
49: * An XMLOutput which really outputs nothing, in particular, avoids calling
50: * toString() in objects returned...
51: */
52: static class MuteXMLOutput extends XMLOutput {
53: public MuteXMLOutput() {
54: super (new DefaultHandler());
55: }
56:
57: /**
58: * Do nothing, not even invoke the toString!
59: */
60: public void objectData(Object o) {
61: }
62: } // class MuteXMLOutput
63: } // class TagSupport
|