View Javadoc

1   /*   Copyright 2004 BEA Systems, Inc.
2    *
3    *   Licensed under the Apache License, Version 2.0 (the "License");
4    *   you may not use this file except in compliance with the License.
5    *   You may obtain a copy of the License at
6    *
7    *       http://www.apache.org/licenses/LICENSE-2.0
8    *
9    *   Unless required by applicable law or agreed to in writing, software
10   *   distributed under the License is distributed on an "AS IS" BASIS,
11   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   *   See the License for the specific language governing permissions and
13   *   limitations under the License.
14   */
15  package com.bea.xml.stream;
16  
17  import java.util.Hashtable;
18  import javax.xml.transform.Result;
19  import javax.xml.stream.XMLOutputFactory;
20  import javax.xml.stream.XMLEventWriter;
21  import javax.xml.stream.XMLStreamWriter;
22  import javax.xml.stream.XMLStreamException;
23  
24  /***
25   * <p> Creates instances of the various interfaces for XML output </p>
26   */
27  
28  public class XMLOutputFactoryBase 
29    extends XMLOutputFactory
30  {
31    ConfigurationContextBase config = 
32      new ConfigurationContextBase();
33  
34    public static XMLOutputFactory newInstance() {
35      return XMLOutputFactory.newInstance();
36    }
37  
38    public XMLStreamWriter createXMLStreamWriter(java.io.Writer stream) 
39      throws XMLStreamException
40    {
41      XMLWriterBase b = 
42        new XMLWriterBase(stream); 
43      b.setConfigurationContext(config);
44      return b;
45    }
46  
47    public  XMLStreamWriter createXMLStreamWriter(java.io.OutputStream stream) 
48      throws XMLStreamException
49    {
50      return createXMLStreamWriter(new java.io.OutputStreamWriter(stream)); 
51    }
52  
53    public  XMLStreamWriter createXMLStreamWriter(java.io.OutputStream stream,
54                                   String encoding) 
55      throws XMLStreamException
56    {
57      try {
58      return createXMLStreamWriter(new java.io.OutputStreamWriter(stream,encoding)); 
59      } catch (java.io.UnsupportedEncodingException uee) {
60        throw new XMLStreamException("Unsupported encoding "+encoding,uee);
61      }
62    }
63    public  XMLEventWriter createXMLEventWriter(java.io.OutputStream stream) 
64      throws XMLStreamException
65    {
66      return new XMLEventWriterBase(createXMLStreamWriter(stream));
67    }
68  
69    public  XMLEventWriter createXMLEventWriter(java.io.Writer stream) 
70      throws XMLStreamException
71    {
72      return new XMLEventWriterBase(createXMLStreamWriter(stream));
73    }
74  
75    public  XMLEventWriter createXMLEventWriter(java.io.OutputStream stream,
76                                             String encoding) 
77      throws XMLStreamException
78    {
79      return new XMLEventWriterBase(createXMLStreamWriter(stream,encoding));
80    }
81    public  void setProperty(java.lang.String name, 
82                            Object value){
83      config.setProperty(name,value);
84    }
85    public  Object getProperty(java.lang.String name) {
86      return config.getProperty(name);
87    }
88    public  boolean isPrefixDefaulting(){ 
89      return config.isPrefixDefaulting();
90    }
91    public  void setPrefixDefaulting(boolean value){
92      config.setPrefixDefaulting(value);
93    }
94    public boolean isPropertySupported(String name) {
95      return config.isPropertySupported(name);
96    }
97    public XMLStreamWriter createXMLStreamWriter(Result result) 
98      throws XMLStreamException 
99    {
100     throw new UnsupportedOperationException();
101   }
102 
103   public XMLEventWriter createXMLEventWriter(Result result) 
104     throws XMLStreamException
105   {
106     throw new UnsupportedOperationException();
107   }
108 
109 }
110