Source for javax.xml.stream.XMLStreamWriter

   1: /* XMLStreamWriter.java --
   2:    Copyright (C) 2005  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 javax.xml.stream;
  39: 
  40: import javax.xml.namespace.NamespaceContext;
  41: 
  42: /**
  43:  * Interface for writing XML to a stream.
  44:  */
  45: public interface XMLStreamWriter
  46: {
  47: 
  48:   /**
  49:    * Write the start of a tag.
  50:    */
  51:   void writeStartElement(String localName)
  52:     throws XMLStreamException;
  53: 
  54:   /**
  55:    * Write the start of a tag.
  56:    */
  57:   void writeStartElement(String namespaceURI, String localName)
  58:     throws XMLStreamException;
  59: 
  60:   /**
  61:    * Write the start of a tag.
  62:    */
  63:   void writeStartElement(String prefix, String localName, String namespaceURI)
  64:     throws XMLStreamException;
  65: 
  66:   /**
  67:    * Write an empty tag.
  68:    */
  69:   void writeEmptyElement(String namespaceURI, String localName)
  70:     throws XMLStreamException;
  71: 
  72:   /**
  73:    * Write an empty tag.
  74:    */
  75:   void writeEmptyElement(String prefix, String localName, String namespaceURI)
  76:     throws XMLStreamException;
  77: 
  78:   /**
  79:    * Write an empty tag.
  80:    */
  81:   void writeEmptyElement(String localName)
  82:     throws XMLStreamException;
  83: 
  84:   /**
  85:    * Closes the currently open tag.
  86:    */
  87:   void writeEndElement()
  88:     throws XMLStreamException;
  89: 
  90:   /**
  91:    * Closes any currently open tags.
  92:    */
  93:   void writeEndDocument()
  94:     throws XMLStreamException;
  95: 
  96:   /**
  97:    * Frees any resources used by this writer.
  98:    * This will not close the underlying output sink.
  99:    */
 100:   void close()
 101:     throws XMLStreamException;
 102: 
 103:   /**
 104:    * Flushes any cached information to the underlying output sink.
 105:    */
 106:   void flush()
 107:     throws XMLStreamException;
 108: 
 109:   /**
 110:    * Write an attribute.
 111:    */
 112:   void writeAttribute(String localName, String value)
 113:     throws XMLStreamException;
 114: 
 115:   /**
 116:    * Write an attribute.
 117:    */
 118:   void writeAttribute(String prefix, String namespaceURI,
 119:                       String localName, String value)
 120:     throws XMLStreamException;
 121: 
 122:   /**
 123:    * Write an attribute.
 124:    */
 125:   void writeAttribute(String namespaceURI, String localName, String value)
 126:     throws XMLStreamException;
 127: 
 128:   /**
 129:    * Write a namespace declaration.
 130:    */
 131:   void writeNamespace(String prefix, String namespaceURI)
 132:     throws XMLStreamException;
 133: 
 134:   /**
 135:    * Write a default namespace declaration.
 136:    */
 137:   void writeDefaultNamespace(String namespaceURI)
 138:     throws XMLStreamException;
 139: 
 140:   /**
 141:    * Write a comment.
 142:    */
 143:   void writeComment(String data)
 144:     throws XMLStreamException;
 145: 
 146:   /**
 147:    * Write a processing instruction.
 148:    */
 149:   void writeProcessingInstruction(String target)
 150:     throws XMLStreamException;
 151: 
 152:   /**
 153:    * Write a processing instruction.
 154:    */
 155:   void writeProcessingInstruction(String target, String data)
 156:     throws XMLStreamException;
 157: 
 158:   /**
 159:    * Write a CDATA section.
 160:    */
 161:   void writeCData(String data)
 162:     throws XMLStreamException;
 163: 
 164:   /**
 165:    * Write a DOCTYPE declaration.
 166:    */
 167:   void writeDTD(String dtd)
 168:     throws XMLStreamException;
 169: 
 170:   /**
 171:    * Write an entity reference.
 172:    */
 173:   void writeEntityRef(String name)
 174:     throws XMLStreamException;
 175: 
 176:   /**
 177:    * Write an XML declaration.
 178:    */
 179:   void writeStartDocument()
 180:     throws XMLStreamException;
 181: 
 182:   /**
 183:    * Write an XML declaration with the specified XML version.
 184:    */
 185:   void writeStartDocument(String version)
 186:     throws XMLStreamException;
 187: 
 188:   /**
 189:    * Write an XML declaration with the specifed XML version and encoding.
 190:    */
 191:   void writeStartDocument(String encoding, String version)
 192:     throws XMLStreamException;
 193: 
 194:   /**
 195:    * Write the specified text.
 196:    */
 197:   void writeCharacters(String text)
 198:     throws XMLStreamException;
 199: 
 200:   /**
 201:    * Write the specified text.
 202:    */
 203:   void writeCharacters(char[] text, int start, int len)
 204:     throws XMLStreamException;
 205: 
 206:   /**
 207:    * Returns the prefix associated with the given namespace URI.
 208:    */
 209:   String getPrefix(String uri)
 210:     throws XMLStreamException;
 211: 
 212:   /**
 213:    * Sets the prefix for the given namespace URI.
 214:    */
 215:   void setPrefix(String prefix, String uri)
 216:     throws XMLStreamException;
 217: 
 218:   /**
 219:    * Sets the URI for the default namespace.
 220:    */
 221:   void setDefaultNamespace(String uri)
 222:     throws XMLStreamException;
 223: 
 224:   /**
 225:    * Sets the namespace context for namespace resolution.
 226:    */
 227:   void setNamespaceContext(NamespaceContext context)
 228:     throws XMLStreamException;
 229: 
 230:   /**
 231:    * Returns the current namespace context.
 232:    */
 233:   NamespaceContext getNamespaceContext();
 234: 
 235:   /**
 236:    * Returns the implementation-specific feature or property of the given
 237:    * name.
 238:    * @exception IllegalArgumentException if the property is not supported
 239:    */
 240:   Object getProperty(String name)
 241:     throws IllegalArgumentException;
 242: 
 243: }