< prev index next >

src/java.base/share/classes/jdk/internal/util/xml/XMLStreamWriter.java

Print this page


   1 /*
   2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.internal.util.xml;
  27 



  28 /**
  29  * Basic XMLStreamWriter for writing simple XML files such as those
  30  * defined in java.util.Properties
  31  *
  32  * This is a subset of javax.xml.stream.XMLStreamWriter
  33  *
  34  * @author Joe Wang
  35  */
  36 public  interface XMLStreamWriter {
  37 
  38     //Defaults the XML version to 1.0, and the encoding to utf-8
  39     public static final String DEFAULT_XML_VERSION = "1.0";
  40     public static final String DEFAULT_ENCODING = "UTF-8";

  41 
  42     /**
  43      * Writes a start tag to the output.  All writeStartElement methods
  44      * open a new scope in the internal namespace context.  Writing the
  45      * corresponding EndElement causes the scope to be closed.
  46      * @param localName local name of the tag, may not be null
  47      * @throws XMLStreamException
  48      */
  49     public void writeStartElement(String localName) throws XMLStreamException;
  50 
  51     /**
  52      * Writes an empty element tag to the output
  53      * @param localName local name of the tag, may not be null
  54      * @throws XMLStreamException
  55      */
  56     public void writeEmptyElement(String localName) throws XMLStreamException;
  57 
  58     /**
  59      * Writes an end tag to the output relying on the internal
  60      * state of the writer to determine the prefix and local name


   1 /*
   2  * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package jdk.internal.util.xml;
  27 
  28 import java.nio.charset.Charset;
  29 import java.nio.charset.StandardCharsets;
  30 
  31 /**
  32  * Basic XMLStreamWriter for writing simple XML files such as those
  33  * defined in java.util.Properties
  34  *
  35  * This is a subset of javax.xml.stream.XMLStreamWriter
  36  *
  37  * @author Joe Wang
  38  */
  39 public  interface XMLStreamWriter {
  40 
  41     //Defaults the XML version to 1.0, and the encoding to utf-8
  42     public static final String DEFAULT_XML_VERSION = "1.0";
  43     public static final String DEFAULT_ENCODING = "UTF-8";
  44     public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
  45 
  46     /**
  47      * Writes a start tag to the output.  All writeStartElement methods
  48      * open a new scope in the internal namespace context.  Writing the
  49      * corresponding EndElement causes the scope to be closed.
  50      * @param localName local name of the tag, may not be null
  51      * @throws XMLStreamException
  52      */
  53     public void writeStartElement(String localName) throws XMLStreamException;
  54 
  55     /**
  56      * Writes an empty element tag to the output
  57      * @param localName local name of the tag, may not be null
  58      * @throws XMLStreamException
  59      */
  60     public void writeEmptyElement(String localName) throws XMLStreamException;
  61 
  62     /**
  63      * Writes an end tag to the output relying on the internal
  64      * state of the writer to determine the prefix and local name


< prev index next >