Java Stream Close closeXMLState(int toState)

Here you can find the source of closeXMLState(int toState)

Description

output whatever is required to close the current xml for the current xml state.

License

Open Source License

Declaration

protected static void closeXMLState(int toState) throws IOException 

Method Source Code

//package com.java2s;
/** /* w  w w  .  ja  va  2 s. c om*/
 ** Copyright (C) SAS Institute, All rights reserved.
 ** General Public License: http://www.opensource.org/licenses/gpl-license.php
 **/

import java.io.*;

public class Main {
    /** 
     * Used internally for writing process container object information to output file. 
     * An external ProcessContainer-type class should set this to a valid open BufferedWriter 
     * to capture the Instruments output into the external file.  (Re)Set it to null when it 
     * is not in use.
     **/
    public static BufferedWriter spcOutputWriter = null;
    public static final int STATE_INIT = -1;
    public static final int STATE_SYSTEM = 0;
    public static final int STATE_APP = 1;
    public static final int STATE_WIN = 2;
    public static final int STATE_CHILD = 3;
    public static final int STATE_CHILD_COMPLETE = 4;
    public static final int STATE_WIN_PROP = 5;
    public static final int STATE_CHILD_PROP = 6;
    /**
     * -1: init state;<br>
     *  0: system out state;<br>
     *  1: app out state;<br>
     *  2: win out state;<br>
     *  3: child out state;<br>
     */
    public static int xmlstate = STATE_INIT;

    /**
     * output whatever is required to close the current xml for the current xml state.
     */
    protected static void closeXMLState(int toState) throws IOException {
        if (spcOutputWriter != null) {
            if (toState == STATE_INIT) {
                if (xmlstate == STATE_CHILD_COMPLETE) {
                    spcOutputWriter.write("</window></application></object>");
                    spcOutputWriter.newLine();
                } else if (xmlstate == STATE_WIN) {
                    spcOutputWriter.write(" /></application></object>");
                    spcOutputWriter.newLine();
                } else if (xmlstate == STATE_WIN_PROP) {
                    spcOutputWriter.write("</window></application></object>");
                    spcOutputWriter.newLine();
                } else if (xmlstate == STATE_APP) {
                    spcOutputWriter.write(" /></object>");
                    spcOutputWriter.newLine();
                } else {
                    spcOutputWriter.write("</object>");
                    spcOutputWriter.newLine();
                }
            } else if ((xmlstate == STATE_SYSTEM) || (xmlstate == STATE_CHILD)) {
                spcOutputWriter.write(" />");
                spcOutputWriter.newLine();
            } else if ((xmlstate == STATE_CHILD_COMPLETE) || (xmlstate == STATE_CHILD_PROP)) {
                spcOutputWriter.write("</child>");
                spcOutputWriter.newLine();
            } else if ((xmlstate == STATE_WIN) || (xmlstate == STATE_WIN_PROP)) {
                spcOutputWriter.write("</window>");
                spcOutputWriter.newLine();
            } else if (xmlstate == STATE_APP) {
                spcOutputWriter.write("</application>");
                spcOutputWriter.newLine();
            }
            xmlstate = toState;
        }
    }
}

Related

  1. closeWriteFile(FileOutputStream fileoutputstream)
  2. closeWriter(final Writer writer)
  3. closeWriter(PrintWriter pw)
  4. closeWriter(Writer writer)
  5. closexBaseJProperty()
  6. closeZipOutputStreamQuietly(ZipOutputStream zipOutputStream)
  7. closeZipQuietly(@Nullable ZipFile file)