jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/packaging/mime/util/QEncoderStream.java
changeset 43852 93a527059d8a
parent 28326 2b9860c0d68a
equal deleted inserted replaced
43752:3c68ef249093 43852:93a527059d8a
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    67     /**
    67     /**
    68      * Encodes the specified <code>byte</code> to this output stream.
    68      * Encodes the specified <code>byte</code> to this output stream.
    69      * @param      c   the <code>byte</code>.
    69      * @param      c   the <code>byte</code>.
    70      * @exception  IOException  if an I/O error occurs.
    70      * @exception  IOException  if an I/O error occurs.
    71      */
    71      */
       
    72     @Override
    72     public void write(int c) throws IOException {
    73     public void write(int c) throws IOException {
    73         c = c & 0xff; // Turn off the MSB.
    74         c = c & 0xff; // Turn off the MSB.
    74         if (c == ' ')
    75         if (c == ' ')
    75             output('_', false);
    76             output('_', false);
    76         else if (c < 040 || c >= 0177 || specials.indexOf(c) >= 0)
    77         else if (c < 040 || c >= 0177 || specials.indexOf(c) >= 0)
    80             output(c, false);
    81             output(c, false);
    81     }
    82     }
    82 
    83 
    83     /**
    84     /**
    84      * Returns the length of the encoded version of this byte array.
    85      * Returns the length of the encoded version of this byte array.
       
    86      *
       
    87      * @param b byte array.
       
    88      * @param encodingWord whether use word or text specials.
       
    89      *
       
    90      * @return length.
    85      */
    91      */
    86     public static int encodedLength(byte[] b, boolean encodingWord) {
    92     public static int encodedLength(byte[] b, boolean encodingWord) {
    87         int len = 0;
    93         int len = 0;
    88         String specials = encodingWord ? WORD_SPECIALS: TEXT_SPECIALS;
    94         String specials = encodingWord ? WORD_SPECIALS: TEXT_SPECIALS;
    89         for (int i = 0; i < b.length; i++) {
    95         for (int i = 0; i < b.length; i++) {