< prev index next >

src/java.base/share/classes/sun/misc/CharacterDecoder.java

Print this page




 103      * This method should return, if it knows, the number of bytes
 104      * that will be decoded. Many formats such as uuencoding provide
 105      * this information. By default we return the maximum bytes that
 106      * could have been encoded on the line.
 107      */
 108     protected int decodeLinePrefix(PushbackInputStream aStream, OutputStream bStream) throws IOException {
 109         return (bytesPerLine());
 110     }
 111 
 112     /**
 113      * This method post processes the line, if there are error detection
 114      * or correction codes in a line, they are generally processed by
 115      * this method. The simplest version of this method looks for the
 116      * (newline) character.
 117      */
 118     protected void decodeLineSuffix(PushbackInputStream aStream, OutputStream bStream) throws IOException { }
 119 
 120     /**
 121      * This method does an actual decode. It takes the decoded bytes and
 122      * writes them to the OutputStream. The integer <i>l</i> tells the
 123      * method how many bytes are required. This is always <= bytesPerAtom().
 124      */
 125     protected void decodeAtom(PushbackInputStream aStream, OutputStream bStream, int l) throws IOException {
 126         throw new CEStreamExhausted();
 127     }
 128 
 129     /**
 130      * This method works around the bizarre semantics of BufferedInputStream's
 131      * read method.
 132      */
 133     protected int readFully(InputStream in, byte buffer[], int offset, int len)
 134         throws java.io.IOException {
 135         for (int i = 0; i < len; i++) {
 136             int q = in.read();
 137             if (q == -1)
 138                 return ((i == 0) ? -1 : i);
 139             buffer[i+offset] = (byte)q;
 140         }
 141         return len;
 142     }
 143 




 103      * This method should return, if it knows, the number of bytes
 104      * that will be decoded. Many formats such as uuencoding provide
 105      * this information. By default we return the maximum bytes that
 106      * could have been encoded on the line.
 107      */
 108     protected int decodeLinePrefix(PushbackInputStream aStream, OutputStream bStream) throws IOException {
 109         return (bytesPerLine());
 110     }
 111 
 112     /**
 113      * This method post processes the line, if there are error detection
 114      * or correction codes in a line, they are generally processed by
 115      * this method. The simplest version of this method looks for the
 116      * (newline) character.
 117      */
 118     protected void decodeLineSuffix(PushbackInputStream aStream, OutputStream bStream) throws IOException { }
 119 
 120     /**
 121      * This method does an actual decode. It takes the decoded bytes and
 122      * writes them to the OutputStream. The integer <i>l</i> tells the
 123      * method how many bytes are required. This is always {@literal <=} bytesPerAtom().
 124      */
 125     protected void decodeAtom(PushbackInputStream aStream, OutputStream bStream, int l) throws IOException {
 126         throw new CEStreamExhausted();
 127     }
 128 
 129     /**
 130      * This method works around the bizarre semantics of BufferedInputStream's
 131      * read method.
 132      */
 133     protected int readFully(InputStream in, byte buffer[], int offset, int len)
 134         throws java.io.IOException {
 135         for (int i = 0; i < len; i++) {
 136             int q = in.read();
 137             if (q == -1)
 138                 return ((i == 0) ? -1 : i);
 139             buffer[i+offset] = (byte)q;
 140         }
 141         return len;
 142     }
 143 


< prev index next >