jaxws/src/share/jaxws_classes/com/sun/codemodel/internal/writer/OutputStreamCodeWriter.java
author mkos
Mon, 31 Mar 2014 10:43:20 +0200
changeset 23782 953bfc3fbe31
permissions -rw-r--r--
8036030: Update JAX-WS RI integration to latest version Summary: JAX-WS RI upgrade from 2.2.9-b130926.1035 to 2.2.10-b140228.1436; Reviewed-by: chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
     1
/*
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
     4
 *
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    10
 *
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    15
 * accompanied this code).
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    16
 *
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    20
 *
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    23
 * questions.
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    24
 */
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    25
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    26
/**
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    27
 * Output all source files into a single stream.
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    28
 *
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    29
 * This is primarily for test purposes.
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    30
 *
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    31
 * @author
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    32
 *      Aleksei Valikov (valikov@gmx.net)
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    33
 */
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    34
package com.sun.codemodel.internal.writer;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    35
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    36
import java.io.FilterOutputStream;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    37
import java.io.IOException;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    38
import java.io.OutputStream;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    39
import java.io.PrintStream;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    40
import java.io.UnsupportedEncodingException;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    41
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    42
import com.sun.codemodel.internal.CodeWriter;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    43
import com.sun.codemodel.internal.JPackage;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    44
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    45
public class OutputStreamCodeWriter extends CodeWriter {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    46
        private final PrintStream out;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    47
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    48
        /**
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    49
         * @param os
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    50
         *            This stream will be closed at the end of the code generation.
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    51
         */
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    52
        public OutputStreamCodeWriter(OutputStream os, String encoding) {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    53
                try {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    54
                        this.out = new PrintStream(os, false, encoding);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    55
                } catch (UnsupportedEncodingException ueex) {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    56
                        throw new IllegalArgumentException(ueex);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    57
                }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    58
                this.encoding = encoding;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    59
        }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    60
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    61
        public OutputStream openBinary(JPackage pkg, String fileName)
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    62
                        throws IOException {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    63
                return new FilterOutputStream(out) {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    64
                        public void close() {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    65
                                // don't let this stream close
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    66
                        }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    67
                };
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    68
        }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    69
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    70
        public void close() throws IOException {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    71
                out.close();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    72
        }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents:
diff changeset
    73
}