KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > transform > sax > SAXResult


1 // $Id: SAXResult.java,v 1.2.24.1 2004/07/13 22:27:50 jsuttor Exp $
2
/*
3  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
4  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
5  */

6
7 /*
8  * @(#)SAXResult.java 1.13 04/07/13
9  */

10 package javax.xml.transform.sax;
11
12 import javax.xml.transform.Result JavaDoc;
13
14 import org.xml.sax.ContentHandler JavaDoc;
15 import org.xml.sax.ext.LexicalHandler JavaDoc;
16
17 /**
18  * <p>Acts as an holder for a transformation Result.</p>
19  *
20  * @author <a HREF="Jeff.Suttor@Sun.com">Jeff Suttor</a>
21  */

22 public class SAXResult implements Result JavaDoc {
23
24     /**
25      * If {@link javax.xml.transform.TransformerFactory#getFeature}
26      * returns true when passed this value as an argument,
27      * the Transformer supports Result output of this type.
28      */

29     public static final String JavaDoc FEATURE =
30         "http://javax.xml.transform.sax.SAXResult/feature";
31
32     /**
33      * Zero-argument default constructor.
34      */

35     public SAXResult() {
36     }
37
38     /**
39      * Create a SAXResult that targets a SAX2 {@link org.xml.sax.ContentHandler}.
40      *
41      * @param handler Must be a non-null ContentHandler reference.
42      */

43     public SAXResult(ContentHandler JavaDoc handler) {
44         setHandler(handler);
45     }
46
47     /**
48      * Set the target to be a SAX2 {@link org.xml.sax.ContentHandler}.
49      *
50      * @param handler Must be a non-null ContentHandler reference.
51      */

52     public void setHandler(ContentHandler JavaDoc handler) {
53         this.handler = handler;
54     }
55
56     /**
57      * Get the {@link org.xml.sax.ContentHandler} that is the Result.
58      *
59      * @return The ContentHandler that is to be transformation output.
60      */

61     public ContentHandler JavaDoc getHandler() {
62         return handler;
63     }
64
65     /**
66      * Set the SAX2 {@link org.xml.sax.ext.LexicalHandler} for the output.
67      *
68      * <p>This is needed to handle XML comments and the like. If the
69      * lexical handler is not set, an attempt should be made by the
70      * transformer to cast the {@link org.xml.sax.ContentHandler} to a
71      * <code>LexicalHandler</code>.</p>
72      *
73      * @param handler A non-null <code>LexicalHandler</code> for
74      * handling lexical parse events.
75      */

76     public void setLexicalHandler(LexicalHandler JavaDoc handler) {
77         this.lexhandler = handler;
78     }
79
80     /**
81      * Get a SAX2 {@link org.xml.sax.ext.LexicalHandler} for the output.
82      *
83      * @return A <code>LexicalHandler</code>, or null.
84      */

85     public LexicalHandler JavaDoc getLexicalHandler() {
86         return lexhandler;
87     }
88
89     /**
90      * Method setSystemId Set the systemID that may be used in association
91      * with the {@link org.xml.sax.ContentHandler}.
92      *
93      * @param systemId The system identifier as a URI string.
94      */

95     public void setSystemId(String JavaDoc systemId) {
96         this.systemId = systemId;
97     }
98
99     /**
100      * Get the system identifier that was set with setSystemId.
101      *
102      * @return The system identifier that was set with setSystemId, or null
103      * if setSystemId was not called.
104      */

105     public String JavaDoc getSystemId() {
106         return systemId;
107     }
108
109     //////////////////////////////////////////////////////////////////////
110
// Internal state.
111
//////////////////////////////////////////////////////////////////////
112

113     /**
114      * The handler for parse events.
115      */

116     private ContentHandler JavaDoc handler;
117
118     /**
119      * The handler for lexical events.
120      */

121     private LexicalHandler JavaDoc lexhandler;
122
123     /**
124      * The systemID that may be used in association
125      * with the node.
126      */

127     private String JavaDoc systemId;
128 }
129
Popular Tags