KickJava   Java API By Example, From Geeks To Geeks.

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


1 // $Id: SAXTransformerFactory.java,v 1.2.22.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  * @(#)SAXTransformerFactory.java 1.13 04/07/13
9  */

10 package javax.xml.transform.sax;
11
12 import javax.xml.transform.*;
13
14 import org.xml.sax.XMLFilter JavaDoc;
15
16 /**
17  * This class extends TransformerFactory to provide SAX-specific
18  * factory methods. It provides two types of ContentHandlers,
19  * one for creating Transformers, the other for creating Templates
20  * objects.
21  *
22  * <p>If an application wants to set the ErrorHandler or EntityResolver
23  * for an XMLReader used during a transformation, it should use a URIResolver
24  * to return the SAXSource which provides (with getXMLReader) a reference to
25  * the XMLReader.</p>
26  */

27 public abstract class SAXTransformerFactory extends TransformerFactory {
28
29     /** If {@link javax.xml.transform.TransformerFactory#getFeature}
30      * returns true when passed this value as an argument,
31      * the TransformerFactory returned from
32      * {@link javax.xml.transform.TransformerFactory#newInstance} may
33      * be safely cast to a SAXTransformerFactory.
34      */

35     public static final String JavaDoc FEATURE =
36         "http://javax.xml.transform.sax.SAXTransformerFactory/feature";
37
38     /** If {@link javax.xml.transform.TransformerFactory#getFeature}
39      * returns true when passed this value as an argument,
40      * the {@link #newXMLFilter(Source src)}
41      * and {@link #newXMLFilter(Templates templates)} methods are supported.
42      */

43     public static final String JavaDoc FEATURE_XMLFILTER =
44         "http://javax.xml.transform.sax.SAXTransformerFactory/feature/xmlfilter";
45
46     /**
47      * The default constructor is protected on purpose.
48      */

49     protected SAXTransformerFactory() {}
50
51     /**
52      * Get a TransformerHandler object that can process SAX
53      * ContentHandler events into a Result, based on the transformation
54      * instructions specified by the argument.
55      *
56      * @param src The Source of the transformation instructions.
57      *
58      * @return TransformerHandler ready to transform SAX events.
59      *
60      * @throws TransformerConfigurationException If for some reason the
61      * TransformerHandler can not be created.
62      */

63     public abstract TransformerHandler JavaDoc newTransformerHandler(Source src)
64         throws TransformerConfigurationException;
65
66     /**
67      * Get a TransformerHandler object that can process SAX
68      * ContentHandler events into a Result, based on the Templates argument.
69      *
70      * @param templates The compiled transformation instructions.
71      *
72      * @return TransformerHandler ready to transform SAX events.
73      *
74      * @throws TransformerConfigurationException If for some reason the
75      * TransformerHandler can not be created.
76      */

77     public abstract TransformerHandler JavaDoc newTransformerHandler(
78         Templates templates) throws TransformerConfigurationException;
79
80     /**
81      * Get a TransformerHandler object that can process SAX
82      * ContentHandler events into a Result. The transformation
83      * is defined as an identity (or copy) transformation, for example
84      * to copy a series of SAX parse events into a DOM tree.
85      *
86      * @return A non-null reference to a TransformerHandler, that may
87      * be used as a ContentHandler for SAX parse events.
88      *
89      * @throws TransformerConfigurationException If for some reason the
90      * TransformerHandler cannot be created.
91      */

92     public abstract TransformerHandler JavaDoc newTransformerHandler()
93         throws TransformerConfigurationException;
94
95     /**
96      * Get a TemplatesHandler object that can process SAX
97      * ContentHandler events into a Templates object.
98      *
99      * @return A non-null reference to a TransformerHandler, that may
100      * be used as a ContentHandler for SAX parse events.
101      *
102      * @throws TransformerConfigurationException If for some reason the
103      * TemplatesHandler cannot be created.
104      */

105     public abstract TemplatesHandler JavaDoc newTemplatesHandler()
106         throws TransformerConfigurationException;
107
108     /**
109      * Create an XMLFilter that uses the given Source as the
110      * transformation instructions.
111      *
112      * @param src The Source of the transformation instructions.
113      *
114      * @return An XMLFilter object, or null if this feature is not supported.
115      *
116      * @throws TransformerConfigurationException If for some reason the
117      * TemplatesHandler cannot be created.
118      */

119     public abstract XMLFilter JavaDoc newXMLFilter(Source src)
120         throws TransformerConfigurationException;
121
122     /**
123      * Create an XMLFilter, based on the Templates argument..
124      *
125      * @param templates The compiled transformation instructions.
126      *
127      * @return An XMLFilter object, or null if this feature is not supported.
128      *
129      * @throws TransformerConfigurationException If for some reason the
130      * TemplatesHandler cannot be created.
131      */

132     public abstract XMLFilter JavaDoc newXMLFilter(Templates templates)
133         throws TransformerConfigurationException;
134 }
135
Popular Tags