src/share/classes/java/beans/XMLEncoder.java

Print this page




 187  * with an "index" attribute whose value the value of the
 188  * first argument.
 189  * <li>
 190  * A reference to an array is written using the "array"
 191  * tag. The "class" and "length" attributes specify the
 192  * sub-type of the array and its length respectively.
 193  * </ul>
 194  *
 195  *<p>
 196  * For more information you might also want to check out
 197  * <a
 198  href="http://java.sun.com/products/jfc/tsc/articles/persistence4">Using XMLEncoder</a>,
 199  * an article in <em>The Swing Connection.</em>
 200  * @see XMLDecoder
 201  * @see java.io.ObjectOutputStream
 202  *
 203  * @since 1.4
 204  *
 205  * @author Philip Milne
 206  */
 207 public class XMLEncoder extends Encoder {
 208 
 209     private final CharsetEncoder encoder;
 210     private final String charset;
 211     private final boolean declaration;
 212 
 213     private OutputStreamWriter out;
 214     private Object owner;
 215     private int indentation = 0;
 216     private boolean internal = false;
 217     private Map<Object, ValueData> valueToExpression;
 218     private Map<Object, List<Statement>> targetToStatementList;
 219     private boolean preambleWritten = false;
 220     private NameGenerator nameGenerator;
 221 
 222     private class ValueData {
 223         public int refs = 0;
 224         public boolean marked = false; // Marked -> refs > 0 unless ref was a target.
 225         public String name = null;
 226         public Expression exp = null;
 227     }




 187  * with an "index" attribute whose value the value of the
 188  * first argument.
 189  * <li>
 190  * A reference to an array is written using the "array"
 191  * tag. The "class" and "length" attributes specify the
 192  * sub-type of the array and its length respectively.
 193  * </ul>
 194  *
 195  *<p>
 196  * For more information you might also want to check out
 197  * <a
 198  href="http://java.sun.com/products/jfc/tsc/articles/persistence4">Using XMLEncoder</a>,
 199  * an article in <em>The Swing Connection.</em>
 200  * @see XMLDecoder
 201  * @see java.io.ObjectOutputStream
 202  *
 203  * @since 1.4
 204  *
 205  * @author Philip Milne
 206  */
 207 public class XMLEncoder extends Encoder implements AutoCloseable {
 208 
 209     private final CharsetEncoder encoder;
 210     private final String charset;
 211     private final boolean declaration;
 212 
 213     private OutputStreamWriter out;
 214     private Object owner;
 215     private int indentation = 0;
 216     private boolean internal = false;
 217     private Map<Object, ValueData> valueToExpression;
 218     private Map<Object, List<Statement>> targetToStatementList;
 219     private boolean preambleWritten = false;
 220     private NameGenerator nameGenerator;
 221 
 222     private class ValueData {
 223         public int refs = 0;
 224         public boolean marked = false; // Marked -> refs > 0 unless ref was a target.
 225         public String name = null;
 226         public Expression exp = null;
 227     }