~hjd/ubuntu/wily/xmlgraphics-commons/debian-merged

« back to all changes in this revision

Viewing changes to src/java/org/apache/xmlgraphics/util/io/ASCII85InputStream.java

  • Committer: Bazaar Package Importer
  • Author(s): Vincent Fourmond
  • Date: 2011-02-11 14:15:14 UTC
  • mfrom: (8.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110211141514-h67achft6x31gju1
Tags: 1.4.dfsg-3
Uploading to unstable, hoping we won't break too many things ;-)...

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
6
 * (the "License"); you may not use this file except in compliance with
7
7
 * the License.  You may obtain a copy of the License at
8
 
 * 
 
8
 *
9
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 
 * 
 
10
 *
11
11
 * Unless required by applicable law or agreed to in writing, software
12
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
 * limitations under the License.
16
16
 */
17
17
 
18
 
/* $Id: ASCII85InputStream.java 426584 2006-07-28 16:01:47Z jeremias $ */
19
 
 
 
18
/* $Id: ASCII85InputStream.java 750418 2009-03-05 11:03:54Z vhennebert $ */
 
19
 
20
20
package org.apache.xmlgraphics.util.io;
21
21
 
22
22
import java.io.InputStream;
29
29
 * we can use the read(byte[], int, int) method from InputStream which simply
30
30
 * delegates to read(). This makes the implementation easier.
31
31
 * <p>
32
 
 * The filter is described in chapter 3.13.3 of the PostScript Language 
 
32
 * The filter is described in chapter 3.13.3 of the PostScript Language
33
33
 * Reference (third edition).
34
34
 *
35
 
 * @version $Id: ASCII85InputStream.java 426584 2006-07-28 16:01:47Z jeremias $
 
35
 * @version $Id: ASCII85InputStream.java 750418 2009-03-05 11:03:54Z vhennebert $
36
36
 */
37
37
public class ASCII85InputStream extends InputStream
38
38
            implements ASCII85Constants {
41
41
    private boolean eodReached = false;
42
42
    private int[] b = new int[4]; //decoded
43
43
    private int bSize = 0;
44
 
    private int bIndex = 0; 
 
44
    private int bIndex = 0;
45
45
 
46
46
    /** @see java.io.FilterInputStream **/
47
47
    public ASCII85InputStream(InputStream in) {
55
55
        if (bIndex >= bSize) {
56
56
            if (eodReached) {
57
57
                return -1;
58
 
            } 
 
58
            }
59
59
            readNextTuple();
60
60
            if (bSize == 0) {
61
61
                if (!eodReached) {
69
69
        bIndex++;
70
70
        return result;
71
71
    }
72
 
    
 
72
 
73
73
    private int filteredRead() throws IOException {
74
74
        int buf;
75
75
        while (true) {
94
94
            }
95
95
        }
96
96
    }
97
 
    
 
97
 
98
98
    private void handleEOD() throws IOException {
99
99
        final int buf = in.read();
100
100
        if (buf != EOD[1]) {
104
104
        bSize = 0;
105
105
        bIndex = 0;
106
106
    }
107
 
    
 
107
 
108
108
    private void readNextTuple() throws IOException {
109
109
        int buf;
110
110
        long tuple = 0;
138
138
                //Violation 3
139
139
                throw new IOException("Only one character in tuple");
140
140
            }
141
 
            //Handle optional, trailing, incomplete tuple 
 
141
            //Handle optional, trailing, incomplete tuple
142
142
            while (cIndex < 5) {
143
143
                tuple += POW85[cIndex - 1];
144
144
                cIndex++;