OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [gnu/] [xml/] [stream/] [XMLEventFactoryImpl.java] - Blame information for rev 769

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 769 jeremybenn
/* XMLEventFactoryImpl.java --
2
   Copyright (C) 2005,2006  Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
package gnu.xml.stream;
39
 
40
import java.util.Collections;
41
import java.util.Iterator;
42
import java.util.LinkedList;
43
import javax.xml.XMLConstants;
44
import javax.xml.namespace.NamespaceContext;
45
import javax.xml.namespace.QName;
46
import javax.xml.stream.Location;
47
import javax.xml.stream.XMLEventFactory;
48
import javax.xml.stream.events.Attribute;
49
import javax.xml.stream.events.Characters;
50
import javax.xml.stream.events.Comment;
51
import javax.xml.stream.events.DTD;
52
import javax.xml.stream.events.EndDocument;
53
import javax.xml.stream.events.EndElement;
54
import javax.xml.stream.events.EntityDeclaration;
55
import javax.xml.stream.events.EntityReference;
56
import javax.xml.stream.events.Namespace;
57
import javax.xml.stream.events.ProcessingInstruction;
58
import javax.xml.stream.events.StartDocument;
59
import javax.xml.stream.events.StartElement;
60
 
61
/**
62
 * Factory for XML events.
63
 *
64
 * @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
65
 */
66
public class XMLEventFactoryImpl
67
  extends XMLEventFactory
68
{
69
 
70
  protected Location location;
71
 
72
  public void setLocation(Location location)
73
  {
74
    this.location = location;
75
  }
76
 
77
  public Attribute createAttribute(String prefix, String namespaceURI,
78
                                   String localName, String value)
79
  {
80
    return new AttributeImpl(location,
81
                             new QName(namespaceURI, localName, prefix),
82
                             value, "CDATA", true);
83
  }
84
 
85
  public Attribute createAttribute(String localName, String value)
86
  {
87
    return new AttributeImpl(location,
88
                             new QName(localName),
89
                             value, "CDATA", true);
90
  }
91
 
92
  public Attribute createAttribute(QName name, String value)
93
  {
94
    return new AttributeImpl(location, name, value,
95
                             "CDATA", true);
96
  }
97
 
98
  public Namespace createNamespace(String namespaceURI)
99
  {
100
    return new NamespaceImpl(location,
101
                             XMLConstants.DEFAULT_NS_PREFIX,
102
                             namespaceURI,
103
                             true);
104
  }
105
 
106
  public Namespace createNamespace(String prefix, String namespaceUri)
107
  {
108
     return new NamespaceImpl(location, prefix, namespaceUri, true);
109
  }
110
 
111
  public StartElement createStartElement(QName name,
112
                                         Iterator attributes,
113
                                         Iterator namespaces)
114
  {
115
    return new StartElementImpl(location, name,
116
                                createLinkedList(attributes),
117
                                createLinkedList(namespaces),
118
                                null);
119
  }
120
 
121
  public StartElement createStartElement(String prefix,
122
                                         String namespaceUri,
123
                                         String localName)
124
  {
125
    return new StartElementImpl(location,
126
                                new QName(namespaceUri, localName, prefix),
127
                                Collections.EMPTY_LIST,
128
                                Collections.EMPTY_LIST,
129
                                null);
130
  }
131
 
132
  public StartElement createStartElement(String prefix,
133
                                         String namespaceUri,
134
                                         String localName,
135
                                         Iterator attributes,
136
                                         Iterator namespaces)
137
  {
138
    return new StartElementImpl(location,
139
                                new QName(namespaceUri, localName, prefix),
140
                                createLinkedList(attributes),
141
                                createLinkedList(namespaces),
142
                                null);
143
  }
144
 
145
  public StartElement createStartElement(String prefix,
146
                                         String namespaceUri,
147
                                         String localName,
148
                                         Iterator attributes,
149
                                         Iterator namespaces,
150
                                         NamespaceContext context)
151
  {
152
    return new StartElementImpl(location,
153
                                new QName(namespaceUri, localName, prefix),
154
                                createLinkedList(attributes),
155
                                createLinkedList(namespaces),
156
                                context);
157
  }
158
 
159
  public EndElement createEndElement(QName name,
160
                                     Iterator namespaces)
161
  {
162
    return new EndElementImpl(location, name,
163
                              createLinkedList(namespaces));
164
  }
165
 
166
  public EndElement createEndElement(String prefix,
167
                                     String namespaceUri,
168
                                     String localName)
169
  {
170
    return new EndElementImpl(location,
171
                              new QName(namespaceUri, localName, prefix),
172
                              Collections.EMPTY_LIST);
173
  }
174
 
175
  public EndElement createEndElement(String prefix,
176
                                     String namespaceUri,
177
                                     String localName,
178
                                     Iterator namespaces)
179
  {
180
    return new EndElementImpl(location,
181
                              new QName(namespaceUri, localName, prefix),
182
                              createLinkedList(namespaces));
183
  }
184
 
185
  public Characters createCharacters(String content)
186
  {
187
    return new CharactersImpl(location, content, false, false, false);
188
  }
189
 
190
  public Characters createCData(String content)
191
  {
192
    return new CharactersImpl(location, content, false, true, false);
193
  }
194
 
195
  public Characters createSpace(String content)
196
  {
197
    return new CharactersImpl(location, content, true, false, false);
198
  }
199
 
200
  public Characters createIgnorableSpace(String content)
201
  {
202
    return new CharactersImpl(location, content, true, false, true);
203
  }
204
 
205
  public StartDocument createStartDocument()
206
  {
207
    return new StartDocumentImpl(location, null, "UTF-8", "1.0",
208
                                 false, false, false);
209
  }
210
 
211
  public StartDocument createStartDocument(String encoding,
212
                                           String version,
213
                                           boolean standalone)
214
  {
215
    return new StartDocumentImpl(location, null, encoding, version,
216
                                 standalone, true, true);
217
  }
218
 
219
  public StartDocument createStartDocument(String encoding,
220
                                           String version)
221
  {
222
    return new StartDocumentImpl(location, null, encoding, version,
223
                                 false, false, true);
224
  }
225
 
226
  public StartDocument createStartDocument(String encoding)
227
  {
228
    return new StartDocumentImpl(location, null, encoding, "1.0",
229
                                 false, false, true);
230
  }
231
 
232
  public EndDocument createEndDocument()
233
  {
234
    return new EndDocumentImpl(location);
235
  }
236
 
237
  public EntityReference createEntityReference(String name,
238
                                               EntityDeclaration declaration)
239
  {
240
    return new EntityReferenceImpl(location, declaration, name);
241
  }
242
 
243
  public Comment createComment(String text)
244
  {
245
    return new CommentImpl(location, text);
246
  }
247
 
248
  public ProcessingInstruction createProcessingInstruction(String target,
249
                                                           String data)
250
  {
251
    return new ProcessingInstructionImpl(location, target, data);
252
  }
253
 
254
  public DTD createDTD(String dtd)
255
  {
256
    return new DTDImpl(location, dtd, null,
257
                       Collections.EMPTY_LIST,
258
                       Collections.EMPTY_LIST);
259
  }
260
 
261
  LinkedList createLinkedList(Iterator i)
262
  {
263
    LinkedList ret = new LinkedList();
264
    while (i.hasNext())
265
      ret.add(i.next());
266
    return ret;
267
  }
268
 
269
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.