You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2002/09/09 12:54:00 UTC

cvs commit: xml-fop/src/org/apache/fop/render/ps ASCII85OutputStream.java ASCIIHexOutputStream.java Finalizable.java FlateEncodeOutputStream.java PSStream.java RunLengthEncodeOutputStream.java

jeremias    2002/09/09 03:54:00

  Modified:    src/org/apache/fop/render/ps ASCII85OutputStream.java
                        ASCIIHexOutputStream.java Finalizable.java
                        FlateEncodeOutputStream.java PSStream.java
                        RunLengthEncodeOutputStream.java
  Log:
  Fixed checkstyle violations
  
  Revision  Changes    Path
  1.3       +25 -16    xml-fop/src/org/apache/fop/render/ps/ASCII85OutputStream.java
  
  Index: ASCII85OutputStream.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/ps/ASCII85OutputStream.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ASCII85OutputStream.java	12 Aug 2002 16:56:22 -0000	1.2
  +++ ASCII85OutputStream.java	9 Sep 2002 10:54:00 -0000	1.3
  @@ -25,10 +25,10 @@
       private static final int EOL           = 0x0A; //"\n"
       private static final byte[] EOD        = {0x7E, 0x3E}; //"~>"
   
  -    private static final long base85_4 = 85;
  -    private static final long base85_3 = base85_4 * base85_4;
  -    private static final long base85_2 = base85_3 * base85_4;
  -    private static final long base85_1 = base85_2 * base85_4;
  +    private static final long BASE85_4 = 85;
  +    private static final long BASE85_3 = BASE85_4 * BASE85_4;
  +    private static final long BASE85_2 = BASE85_3 * BASE85_4;
  +    private static final long BASE85_1 = BASE85_2 * BASE85_4;
   
       private static final boolean DEBUG = false;
   
  @@ -38,11 +38,13 @@
       private int bw = 0;
   
   
  +    /** @see java.io.FilterOutputStream **/
       public ASCII85OutputStream(OutputStream out) {
           super(out);
       }
   
   
  +    /** @see java.io.FilterOutputStream **/
       public void write(int b) throws IOException {
           if (pos == 0) {
               buffer += (b << 24) & 0xff000000L;
  @@ -82,10 +84,14 @@
       private void checkedWrite(byte[] buf , int len) throws IOException {
           if (posinline + len > 80) {
               int firstpart = len - (posinline + len - 80);
  -            if (firstpart > 0) out.write(buf, 0, firstpart);
  +            if (firstpart > 0) {
  +                out.write(buf, 0, firstpart);
  +            }
               out.write(EOL); bw++;
               int rest = len - firstpart;
  -            if (rest > 0) out.write(buf, firstpart, rest);
  +            if (rest > 0) {
  +                out.write(buf, firstpart, rest);
  +            }
               posinline = rest;
           } else {
               out.write(buf, 0, len);
  @@ -113,17 +119,18 @@
               if (word < 0) {
                   word = -word;
               }
  -            byte c1 = (byte)((word / base85_1) & 0xFF);
  -            byte c2 = (byte)(((word - (c1 * base85_1)) / base85_2) & 0xFF);
  +            byte c1 = (byte)((word / BASE85_1) & 0xFF);
  +            byte c2 = (byte)(((word - (c1 * BASE85_1)) / BASE85_2) & 0xFF);
               byte c3 =
  -                (byte)(((word - (c1 * base85_1) - (c2 * base85_2)) / base85_3)
  -                       & 0xFF);
  +                (byte)(((word - (c1 * BASE85_1) - (c2 * BASE85_2))
  +                        / BASE85_3) & 0xFF);
               byte c4 =
  -                (byte)(((word - (c1 * base85_1) - (c2 * base85_2) - (c3 * base85_3)) / base85_4)
  -                       & 0xFF);
  +                (byte)(((word - (c1 * BASE85_1) - (c2 * BASE85_2) - (c3 * BASE85_3))
  +                        / BASE85_4) & 0xFF);
               byte c5 =
  -                (byte)(((word - (c1 * base85_1) - (c2 * base85_2) - (c3 * base85_3) - (c4 * base85_4)))
  -                       & 0xFF);
  +                (byte)(((word - (c1 * BASE85_1) - (c2 * BASE85_2) - (c3 * BASE85_3)
  +                        - (c4 * BASE85_4)))
  +                        & 0xFF);
   
               byte[] ret = {
                   (byte)(c1 + START), (byte)(c2 + START),
  @@ -144,6 +151,7 @@
       }
   
   
  +    /** @see org.apache.fop.render.ps.Finalizable **/
       public void finalizeStream() throws IOException {
           // now take care of the trailing few bytes.
           // with n leftover bytes, we append 0 bytes to make a full group of 4
  @@ -191,6 +199,7 @@
       }
   
   
  +    /** @see java.io.FilterOutputStream **/
       public void close() throws IOException {
           finalizeStream();
           super.close();
  
  
  
  1.3       +16 -7     xml-fop/src/org/apache/fop/render/ps/ASCIIHexOutputStream.java
  
  Index: ASCIIHexOutputStream.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/ps/ASCIIHexOutputStream.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ASCIIHexOutputStream.java	12 Aug 2002 16:56:22 -0000	1.2
  +++ ASCIIHexOutputStream.java	9 Sep 2002 10:54:00 -0000	1.3
  @@ -16,32 +16,39 @@
    * @author <a href="mailto:jeremias.maerki@outline.ch">Jeremias Maerki</a>
    * @version $Id$
    */
  -public class ASCIIHexOutputStream extends FilterOutputStream {
  +public class ASCIIHexOutputStream extends FilterOutputStream
  +        implements Finalizable {
   
       private static final int EOL   = 0x0A; //"\n"
       private static final int EOD   = 0x3E; //">"
       private static final int ZERO  = 0x30; //"0"
       private static final int NINE  = 0x39; //"9"
       private static final int A     = 0x41; //"A"
  -    private static final int ADIFF = A - NINE -1;
  +    private static final int ADIFF = A - NINE - 1;
   
       private int posinline = 0;
   
   
  +    /** @see java.io.FilterOutputStream **/
       public ASCIIHexOutputStream(OutputStream out) {
           super(out);
       }
   
   
  +    /** @see java.io.FilterOutputStream **/
       public void write(int b) throws IOException {
           b &= 0xFF;
   
           int digit1 = ((b & 0xF0) >> 4) + ZERO;
  -        if (digit1 > NINE) digit1 += ADIFF;
  +        if (digit1 > NINE) {
  +            digit1 += ADIFF;
  +        }
           out.write(digit1);
   
           int digit2 = (b & 0x0F) + ZERO;
  -        if (digit2 > NINE) digit2 += ADIFF;
  +        if (digit2 > NINE) {
  +            digit2 += ADIFF;
  +        }
           out.write(digit2);
   
           posinline++;
  @@ -58,6 +65,7 @@
       }
   
   
  +    /** @see org.apache.fop.render.ps.Finalizable **/
       public void finalizeStream() throws IOException {
           checkLineWrap();
           //Write closing character ">"
  @@ -65,11 +73,12 @@
   
           flush();
           if (out instanceof Finalizable) {
  -            ((Finalizable)out).finalizeStream();
  +            ((Finalizable) out).finalizeStream();
           }
       }
   
   
  +    /** @see java.io.FilterOutputStream **/
       public void close() throws IOException {
           finalizeStream();
           super.close();
  
  
  
  1.3       +3 -3      xml-fop/src/org/apache/fop/render/ps/Finalizable.java
  
  Index: Finalizable.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/ps/Finalizable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Finalizable.java	12 Aug 2002 16:56:22 -0000	1.2
  +++ Finalizable.java	9 Sep 2002 10:54:00 -0000	1.3
  @@ -24,7 +24,7 @@
        *
        * @exception java.io.IOException  In case of an IO problem
        */
  -    public void finalizeStream()
  +    void finalizeStream()
           throws java.io.IOException;
   
   }
  
  
  
  1.3       +6 -4      xml-fop/src/org/apache/fop/render/ps/FlateEncodeOutputStream.java
  
  Index: FlateEncodeOutputStream.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/ps/FlateEncodeOutputStream.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FlateEncodeOutputStream.java	12 Aug 2002 16:56:22 -0000	1.2
  +++ FlateEncodeOutputStream.java	9 Sep 2002 10:54:00 -0000	1.3
  @@ -7,12 +7,12 @@
   package org.apache.fop.render.ps;
   
   import java.io.OutputStream;
  -import java.io.FilterOutputStream;
   import java.io.IOException;
   
   /**
    * This class applies a FlateEncode filter to the stream. It is basically the
  - * normal DeflaterOutputStream except now conformi
  + * normal DeflaterOutputStream except now also implementing the Finalizable
  + * interface.
    *
    * @author <a href="mailto:jeremias.maerki@outline.ch">Jeremias Maerki</a>
    * @version $Id$
  @@ -21,11 +21,13 @@
               implements Finalizable {
   
   
  +    /** @see java.util.zip.DeflaterOutputStream **/
       public FlateEncodeOutputStream(OutputStream out) {
           super(out);
       }
   
   
  +    /** @see org.apache.fop.render.ps.Finalizable **/
       public void finalizeStream() throws IOException {
           finish();
           flush();
  
  
  
  1.4       +28 -7     xml-fop/src/org/apache/fop/render/ps/PSStream.java
  
  Index: PSStream.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/ps/PSStream.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PSStream.java	16 Nov 2001 19:36:41 -0000	1.3
  +++ PSStream.java	9 Sep 2002 10:54:00 -0000	1.4
  @@ -1,29 +1,50 @@
   /*
    * $Id$
  - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  + * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
    * For details on use and redistribution please refer to the
    * LICENSE file included with these sources.
    */
  -
   package org.apache.fop.render.ps;
   
  -import java.io.*;
  +import java.io.OutputStream;
  +import java.io.FilterOutputStream;
  +import java.io.IOException;
   
  +/**
  + * PSStream is used to to output PostScript code from the PostScript renderer.
  + */
   public class PSStream extends FilterOutputStream {
   
  +    /** @see java.io.FilterOutputStream **/
       public PSStream(OutputStream out) {
           super(out);
       }
  -    
  +
  +
  +    /**
  +     * Writes a PostScript command to the stream.
  +     *
  +     * @param cmd              The PostScript code to be written.
  +     * @exception IOException  In case of an I/O problem
  +     */
       public void write(String cmd) throws IOException {
  -        if (cmd.length() > 255)
  +        if (cmd.length() > 255) {
               throw new RuntimeException("PostScript command exceeded limit of 255 characters");
  +        }
           write(cmd.getBytes("US-ASCII"));
           write('\n');
       }
  -    
  +
  +
  +    /**
  +     * Writes encoded data to the PostScript stream.
  +     *
  +     * @param cmd              The encoded PostScript code to be written.
  +     * @exception IOException  In case of an I/O problem
  +     */
       public void writeByteArr(byte[] cmd) throws IOException {
           write(cmd);
           write('\n');
       }
  +
   }
  
  
  
  1.2       +16 -48    xml-fop/src/org/apache/fop/render/ps/RunLengthEncodeOutputStream.java
  
  Index: RunLengthEncodeOutputStream.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/ps/RunLengthEncodeOutputStream.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RunLengthEncodeOutputStream.java	12 Aug 2002 16:56:22 -0000	1.1
  +++ RunLengthEncodeOutputStream.java	9 Sep 2002 10:54:00 -0000	1.2
  @@ -16,41 +16,30 @@
    * @author   <a href="mailto:smwolke@geistig.com">Stephen Wolke</a>
    * @version  $Id$
    */
  -
   public class RunLengthEncodeOutputStream extends FilterOutputStream
               implements Finalizable {
   
  -    private final static int MAX_SEQUENCE_COUNT = 127;
  -    private final static int END_OF_DATA = 128;
  -    private final static int BYTE_MAX = 256;
  -
  -    private final static int NOT_IDENTIFY_SEQUENCE = 0;
  -    private final static int START_SEQUENCE = 1;
  -    private final static int IN_SEQUENCE = 2;
  -    private final static int NOT_IN_SEQUENCE = 3;
  +    private static final int MAX_SEQUENCE_COUNT    = 127;
  +    private static final int END_OF_DATA           = 128;
  +    private static final int BYTE_MAX              = 256;
  +
  +    private static final int NOT_IDENTIFY_SEQUENCE = 0;
  +    private static final int START_SEQUENCE        = 1;
  +    private static final int IN_SEQUENCE           = 2;
  +    private static final int NOT_IN_SEQUENCE       = 3;
   
       private int runCount = 0;
       private int isSequence = NOT_IDENTIFY_SEQUENCE;
       private byte[] runBuffer = new byte[MAX_SEQUENCE_COUNT + 1];
   
   
  -    /**
  -     * Constructor for the RunLengthEncode Filter.
  -     *
  -     * @param out  The OutputStream to write to
  -     */
  +    /** @see java.io.FilterOutputStream **/
       public RunLengthEncodeOutputStream(OutputStream out) {
           super(out);
       }
   
   
  -    /**
  -     * @see        java.io.OutputStream#write(int)
  -     * @param      b   the <code>byte</code>.
  -     * @exception  IOException  if an I/O error occurs. In particular,
  -     *             an <code>IOException</code> may be thrown if the
  -     *             output stream has been closed.
  -     */
  +    /** @see java.io.FilterOutputStream **/
       public void write(byte b)
           throws java.io.IOException {
           runBuffer[runCount] = b;
  @@ -131,11 +120,7 @@
       }
   
   
  -    /**
  -     * @see        java.io.OutputStream#write(byte[])
  -     * @param      b   the data.
  -     * @exception  IOException  if an I/O error occurs.
  -     */
  +    /** @see java.io.FilterOutputStream **/
       public void write(byte[] b)
           throws IOException {
   
  @@ -145,15 +130,7 @@
       }
   
   
  -    /**
  -     * @see        java.io.OutputStream#write(byte[], int, int)
  -     * @param      b     the data.
  -     * @param      off   the start offset in the data.
  -     * @param      len   the number of bytes to write.
  -     * @exception  IOException  if an I/O error occurs. In particular,
  -     *             an <code>IOException</code> is thrown if the output
  -     *             stream is closed.
  -     */
  +    /** @see java.io.FilterOutputStream **/
       public void write(byte[] b, int off, int len)
           throws IOException {
   
  @@ -163,12 +140,7 @@
       }
   
   
  -    /**
  -     * Flushes the the stream and writes out the trailer, but, unlike close(),
  -     * without closing the stream.
  -     *
  -     * @exception  IOException  if an I/O error occurs.
  -     */
  +    /** @see org.apache.fop.render.ps.Finalizable **/
       public void finalizeStream()
           throws IOException {
           switch (isSequence) {
  @@ -190,11 +162,7 @@
       }
   
   
  -    /**
  -     * Closes the stream.
  -     *
  -     * @exception  IOException  if an I/O error occurs.
  -     */
  +    /** @see java.io.FilterOutputStream **/
       public void close()
           throws IOException {
           finalizeStream();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org