[FOray-commit] SF.net SVN: foray: [7817] trunk/foray/foray-graphic
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-07-23 19:16:27
|
Revision: 7817 Author: victormote Date: 2006-07-23 12:16:06 -0700 (Sun, 23 Jul 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7817&view=rev Log Message: ----------- Implement standard use of final modifier on local variable and method parameters. Modified Paths: -------------- trunk/foray/foray-graphic/.project trunk/foray/foray-graphic/src/java/org/foray/graphic/BMPGraphic.java trunk/foray/foray-graphic/src/java/org/foray/graphic/EPSGraphic.java trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java trunk/foray/foray-graphic/src/java/org/foray/graphic/GIFGraphic.java trunk/foray/foray-graphic/src/java/org/foray/graphic/Graphic.java trunk/foray/foray-graphic/src/java/org/foray/graphic/ImageConsumerImpl.java trunk/foray/foray-graphic/src/java/org/foray/graphic/JAIGraphic.java trunk/foray/foray-graphic/src/java/org/foray/graphic/JPEGGraphic.java trunk/foray/foray-graphic/src/java/org/foray/graphic/PDFGraphic.java trunk/foray/foray-graphic/src/java/org/foray/graphic/PNGGraphic.java trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java trunk/foray/foray-graphic/src/java/org/foray/graphic/TIFFGraphic.java trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/BMPFactory.java trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/EPSFactory.java trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/GIFFactory.java trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/GraphicFactory.java trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/JPEGFactory.java trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/PDFFactory.java trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/PNGFactory.java trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/SVGFactory.java trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/TIFFFactory.java Modified: trunk/foray/foray-graphic/.project =================================================================== --- trunk/foray/foray-graphic/.project 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/.project 2006-07-23 19:16:06 UTC (rev 7817) @@ -7,12 +7,12 @@ </projects> <buildSpec> <buildCommand> - <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name> + <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> </buildCommand> <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> + <name>com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder</name> <arguments> </arguments> </buildCommand> Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/BMPGraphic.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/BMPGraphic.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/BMPGraphic.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -40,21 +40,22 @@ public static final int BMP_SIG_LENGTH = 26; - public BMPGraphic(FOrayGraphicServer server, URL href, - BufferedInputStream bis) { + public BMPGraphic(final FOrayGraphicServer server, final URL href, + final BufferedInputStream bis) { super(server, href, bis); } public void loadImage() throws GraphicException { - int wpos = 18; - int hpos = 22; // offset positioning for w and height in bmp files - int[] headermap = new int[54]; + final int wpos = 18; + // offset positioning for w and height in bmp files + final int hpos = 22; + final int[] headermap = new int[54]; int filepos = 0; byte palette[] = null; try { boolean eof = false; while ((!eof) && (filepos < 54)) { - int input = bis.read(); + final int input = bis.read(); if (input == -1) { eof = true; } else { @@ -63,13 +64,13 @@ } if (headermap[28] == 4 || headermap[28] == 8) { - int palettesize = 1 << headermap[28]; + final int palettesize = 1 << headermap[28]; palette = new byte[palettesize * 3]; int countr = 0; while (!eof && countr < palettesize) { int count2 = 2; while (!eof && count2 >= -1) { - int input = bis.read(); + final int input = bis.read(); if (input == -1) { eof = true; } else if (count2 >= 0) { @@ -81,7 +82,7 @@ countr++; } } - } catch (IOException e) { + } catch (final IOException e) { throw new GraphicException("Error while loading image " + this.url.toString() + " : " + e.getClass() + " - " @@ -95,7 +96,7 @@ + headermap[hpos + 2] * 256 * 256 + headermap[hpos + 3] * 256 * 256 * 256; - int imagestart = headermap[10] + headermap[11] * 256 + final int imagestart = headermap[10] + headermap[11] * 256 + headermap[12] * 256 * 256 + headermap[13] * 256 * 256 * 256; this.bitDepth = headermap[28]; @@ -121,7 +122,7 @@ this.contentSize = this.pixelWidth * this.pixelHeight * 3; this.content = new byte[this.contentSize]; - int[] temp = new int[bytes * this.pixelHeight]; + final int[] temp = new int[bytes * this.pixelHeight]; try { int input; int count = 0; @@ -130,7 +131,7 @@ temp[count++] = input; } bis.close(); - } catch (IOException e) { + } catch (final IOException e) { throw new GraphicException("Error while loading image " + this.url.toString() + " : " + e.getClass() + " - " @@ -177,7 +178,7 @@ } else if (this.bitDepth == 4) { for (int countr = 0; countr < 2 && x < this.pixelWidth; countr++) { - int pal = ((p & 0xF0) >> 4) * 3; + final int pal = ((p & 0xF0) >> 4) * 3; this.content[3 * (i * this.pixelWidth + x)] = palette[pal]; this.content[3 * (i * this.pixelWidth + x) + 1] = @@ -232,7 +233,7 @@ * {@inheritDoc} */ public void parseBasics() throws IOException { - byte[] header = new byte[BMPGraphic.BMP_SIG_LENGTH]; + final byte[] header = new byte[BMPGraphic.BMP_SIG_LENGTH]; bis.read(header); // little endian notation int byte1 = header[18] & 0xff; Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/EPSGraphic.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/EPSGraphic.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/EPSGraphic.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -69,8 +69,8 @@ /** The entire contents of the file. */ private byte[] fileContents; - public EPSGraphic(FOrayGraphicServer server, URL href, - BufferedInputStream bis, boolean isASCII) { + public EPSGraphic(final FOrayGraphicServer server, final URL href, + final BufferedInputStream bis, final boolean isASCII) { super(server, href, bis); docName = href.toString(); this.isAscii = isASCII; @@ -88,8 +88,8 @@ return; } imageLoaded = true; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] readBuf = new byte[20480]; + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final byte[] readBuf = new byte[20480]; int bytes_read; try { @@ -101,7 +101,7 @@ break; } } - } catch (IOException ex) { + } catch (final IOException ex) { throw new GraphicException("Error while loading image " + this.url.toString() + " : " + ex.getClass() + " - " + ex.getMessage()); @@ -125,7 +125,7 @@ * {@inheritDoc} */ protected void parseBasics() throws IOException { - byte[] fileStart = new byte[this.maxBytesToParseBasics()]; + final byte[] fileStart = new byte[this.maxBytesToParseBasics()]; bis.read(fileStart); if (! isAscii) { this.psStart = parseInteger(fileStart, 4); @@ -153,7 +153,7 @@ if (isAscii) { return this.fileContents; } - byte[] epsFile = new byte[psLength]; + final byte[] epsFile = new byte[psLength]; System.arraycopy(this.fileContents, psStart, epsFile, 0, psLength); return epsFile; } @@ -173,8 +173,8 @@ /** Extract bounding box from eps part */ - private void readBBox(byte[] fileStart) { - byte[] bbxName = "%%BoundingBox:".getBytes(); + private void readBBox(final byte[] fileStart) { + final byte[] bbxName = "%%BoundingBox:".getBytes(); boolean found = false; int index = 0; for (index = 0; index + bbxName.length < fileStart.length && !found; @@ -192,7 +192,8 @@ index += readLongString(fileStart, 3, index); } - private int readLongString(byte[] fileStart, int bboxIndex, int idx) { + private int readLongString(final byte[] fileStart, final int bboxIndex, + int idx) { while (idx < fileStart.length && (fileStart[idx] == 32)) { idx++; } @@ -202,9 +203,9 @@ (fileStart[nidx] == 45))) { nidx++; } - byte[] num = new byte[nidx - idx]; + final byte[] num = new byte[nidx - idx]; System.arraycopy(fileStart, idx, num, 0, nidx - idx); - String ns = new String(num); + final String ns = new String(num); this.bbox[bboxIndex] = Integer.parseInt(ns); return (1 + nidx - idx); } Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/FOrayGraphicServer.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -85,7 +85,8 @@ /** * Constructor. */ - public FOrayGraphicServer(Log logger, String svgParserClassName) { + public FOrayGraphicServer(final Log logger, + final String svgParserClassName) { this.logger = logger; if (this.logger == null) { this.logger = Logging.makeDefaultLogger(); @@ -98,7 +99,7 @@ "com.sun.media.jai.codec.FileCacheSeekableStream"); aClass = Class.forName("javax.media.jai.JAI"); this.jaiAvailable = (aClass != null); - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { this.jaiAvailable = false; } } @@ -125,7 +126,7 @@ * @param factory The factory that should be added to the list of factories. * @return True if the factory was successfully registered, false if not. */ - public boolean registerFactory(GraphicFactory factory) { + public boolean registerFactory(final GraphicFactory factory) { customFactories.add(factory); return true; } @@ -133,8 +134,8 @@ /** * {@inheritDoc} */ - public synchronized org.axsl.graphicR.Graphic makeGraphic(String href, - URL[] baseURLs, boolean cachingThisGraphic) + public synchronized org.axsl.graphicR.Graphic makeGraphic(final String href, + final URL[] baseURLs, final boolean cachingThisGraphic) throws GraphicException { URL absoluteURL = null; @@ -145,13 +146,13 @@ // An exception was thrown in buildURLList if urlList is null. try { urlList = URLUtil.buildURLList(baseURLs, href); - } catch (MalformedURLException e) { + } catch (final MalformedURLException e) { throw new GraphicException(e.getMessage()); } // See if any of the possibilities are in our cache for (int i = 0; i < urlList.size(); i++) { absoluteURL = (URL) urlList.get(i); - Graphic imageObject = (Graphic)m_urlMap.get(href); + final Graphic imageObject = (Graphic)m_urlMap.get(href); if (imageObject != null) { return imageObject; } @@ -161,11 +162,11 @@ for (int i = 0; i < urlList.size(); i++) { absoluteURL = (URL) urlList.get(i); try { - InputStream inputStream = absoluteURL.openStream(); + final InputStream inputStream = absoluteURL.openStream(); if (inputStream != null) { imgIS = new BufferedInputStream(inputStream); } - } catch (IOException e1) { + } catch (final IOException e1) { /* * Ignore this. We'll throw an Exception at the end if none * of these work. @@ -179,7 +180,7 @@ throw new GraphicException("Cannot open URL: " + href); } - Graphic graphic = createGraphic(absoluteURL, imgIS); + final Graphic graphic = createGraphic(absoluteURL, imgIS); if (graphic == null) { throw new GraphicException("No Graphic Factory: " @@ -199,8 +200,8 @@ * @return The newly-created Graphic instance. * @throws GraphicException */ - private Graphic createGraphic(URL absoluteURL, BufferedInputStream imgIS) - throws GraphicException { + private Graphic createGraphic(final URL absoluteURL, + final BufferedInputStream imgIS) throws GraphicException { /* Try custom factories first, so that they can override. */ Graphic graphic = createGraphicFromFactoryList(this.customFactories, absoluteURL, imgIS); @@ -220,8 +221,8 @@ * @return The newly-created Graphic. * @throws GraphicException */ - private Graphic createGraphicFromFactoryList(ArrayList factoryList, - URL absoluteURL, BufferedInputStream imgIS) + private Graphic createGraphicFromFactoryList(final ArrayList factoryList, + final URL absoluteURL, final BufferedInputStream imgIS) throws GraphicException { Graphic graphic = null; /* @@ -229,11 +230,11 @@ * to create a Graphic instance. */ for (int i = 0; i < factoryList.size(); i++) { - GraphicFactory factory = (GraphicFactory) + final GraphicFactory factory = (GraphicFactory) factoryList.get(i); try { graphic = factory.makeGraphic(absoluteURL, imgIS); - } catch (IOException e) { + } catch (final IOException e) { throw new GraphicException("Error parsing Graphic: " + e.getMessage()); } @@ -251,7 +252,7 @@ m_urlMap.clear(); } - private String getMapKey(URL url) { + private String getMapKey(final URL url) { return url.getFile(); } Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/GIFGraphic.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/GIFGraphic.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/GIFGraphic.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -46,16 +46,16 @@ public static final int GIF_SIG_LENGTH = 10; - public GIFGraphic(FOrayGraphicServer server, URL href, - BufferedInputStream bis) { + public GIFGraphic(final FOrayGraphicServer server, final URL href, + final BufferedInputStream bis) { super(server, href, bis); } public void loadImage() throws GraphicException { int[] tmpMap = null; try { - ImageProducer ip = (ImageProducer)this.url.getContent(); - ImageConsumerImpl consumer = new ImageConsumerImpl(ip); + final ImageProducer ip = (ImageProducer)this.url.getContent(); + final ImageConsumerImpl consumer = new ImageConsumerImpl(ip); ip.startProduction(consumer); @@ -69,12 +69,12 @@ try { tmpMap = consumer.getImage(); - } catch (Exception ex) { + } catch (final Exception ex) { throw new GraphicException("Image grabbing interrupted : " + ex.getMessage()); } - ColorModel cm = consumer.getColorModel(); + final ColorModel cm = consumer.getColorModel(); this.bitDepth = 8; // this.m_bitsPerPixel = cm.getPixelSize(); this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB); @@ -83,7 +83,7 @@ } else { this.isTransparent = false; } - } catch (Exception ex) { + } catch (final Exception ex) { throw new GraphicException("Error while loading image " + this.url.toString() + " : " + ex.getClass() + " - " @@ -95,10 +95,10 @@ this.content = new byte[this.contentSize]; for (int i = 0; i < this.pixelHeight; i++) { for (int j = 0; j < this.pixelWidth; j++) { - int p = tmpMap[i * this.pixelWidth + j]; - int r = (p >> 16) & 0xFF; - int g = (p >> 8) & 0xFF; - int b = (p) & 0xFF; + final int p = tmpMap[i * this.pixelWidth + j]; + final int r = (p >> 16) & 0xFF; + final int g = (p >> 8) & 0xFF; + final int b = (p) & 0xFF; this.content[3 * (i * this.pixelWidth + j)] = (byte)(r & 0xFF); this.content[3 * (i * this.pixelWidth + j) + 1] = (byte)(g & 0xFF); @@ -108,7 +108,7 @@ } } - private void loadTransparency(ColorModel cm) { + private void loadTransparency(final ColorModel cm) { switch (cm.getTransparency()) { case Transparency.OPAQUE: this.isTransparent = false; @@ -138,16 +138,16 @@ } } - private void loadBitmapTransparency(ColorModel cm) { + private void loadBitmapTransparency(final ColorModel cm) { if (cm instanceof IndexColorModel) { this.isTransparent = false; - byte[] alphas = + final byte[] alphas = new byte[((IndexColorModel)cm).getMapSize()]; - byte[] reds = + final byte[] reds = new byte[((IndexColorModel)cm).getMapSize()]; - byte[] greens = + final byte[] greens = new byte[((IndexColorModel)cm).getMapSize()]; - byte[] blues = + final byte[] blues = new byte[((IndexColorModel)cm).getMapSize()]; ((IndexColorModel)cm).getAlphas(alphas); ((IndexColorModel)cm).getReds(reds); @@ -184,7 +184,7 @@ * {@inheritDoc} */ public void parseBasics() throws IOException { - byte[] header = new byte[GIFGraphic.GIF_SIG_LENGTH]; + final byte[] header = new byte[GIFGraphic.GIF_SIG_LENGTH]; bis.read(header); // little endian notation int byte1 = header[6] & 0xff; Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/Graphic.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/Graphic.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/Graphic.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -93,8 +93,8 @@ /** Set this flag to false if the image is not valid. */ protected boolean isValid = true; - public Graphic(FOrayGraphicServer server, URL href, - BufferedInputStream bis) { + public Graphic(final FOrayGraphicServer server, final URL href, + final BufferedInputStream bis) { this.server = server; this.url = href; this.bis = bis; @@ -265,7 +265,7 @@ this.bis.mark(this.maxBytesToParseBasics()); parseBasics(); this.bis.reset(); - } catch (IOException e) { + } catch (final IOException e) { throw new GraphicException(e.getMessage()); } this.basicsParsed = true; @@ -306,8 +306,9 @@ /** * {@inheritDoc} */ - public final int absoluteWidth(int pixelsPerInch) throws GraphicException { - int absoluteWidth = absoluteWidthReal(); + public final int absoluteWidth(final int pixelsPerInch) + throws GraphicException { + final int absoluteWidth = absoluteWidthReal(); if (absoluteWidth > 0) { // The graphic knows its absolute width. return absoluteWidth; @@ -316,7 +317,7 @@ // The user does not want the fallback computation. return -1; } - int pixelWidth = pixelWidth(); + final int pixelWidth = pixelWidth(); if (pixelWidth < 1) { // pixel Width is not valid return -1; @@ -335,8 +336,9 @@ /** * {@inheritDoc} */ - public final int absoluteHeight(int pixelsPerInch) throws GraphicException { - int absoluteHeight = absoluteHeightReal(); + public final int absoluteHeight(final int pixelsPerInch) + throws GraphicException { + final int absoluteHeight = absoluteHeightReal(); if (absoluteHeight > 0) { // The graphic knows its absolute height. return absoluteHeight; @@ -345,7 +347,7 @@ // The user does not want the fallback computation. return -1; } - int pixelHeight = pixelHeight(); + final int pixelHeight = pixelHeight(); if (pixelHeight < 1) { // pixel Height is not valid return -1; @@ -361,14 +363,14 @@ return -1; } - protected int parseInteger(byte[] buf, int idx) { + protected int parseInteger(final byte[] buf, final int idx) { if (idx > buf.length - 4) { return 0x00; } - int b1 = buf[idx] & 0xff; - int b2 = buf[idx+1] & 0xff; - int b3 = buf[idx+2] & 0xff; - int b4 = buf[idx+3] & 0xff; + final int b1 = buf[idx] & 0xff; + final int b2 = buf[idx+1] & 0xff; + final int b3 = buf[idx+2] & 0xff; + final int b4 = buf[idx+3] & 0xff; return (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; } Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/ImageConsumerImpl.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/ImageConsumerImpl.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/ImageConsumerImpl.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -43,11 +43,11 @@ protected ColorModel cm = null; protected ImageProducer ip = null; - public ImageConsumerImpl(ImageProducer iprod) { + public ImageConsumerImpl(final ImageProducer iprod) { this.ip = iprod; } - public void imageComplete(int status) { + public void imageComplete(final int status) { /* * MessageHandler.error("Status "); * if (status == ImageConsumer.COMPLETESCANLINES) { @@ -80,32 +80,34 @@ } } - public void setColorModel(ColorModel model) { + public void setColorModel(final ColorModel model) { // MessageHandler.errorln("setColorModel: " + model); this.cm = model; } - public void setDimensions(int width, int height) { + public void setDimensions(final int width, final int height) { // MessageHandler.errorln("setDimension: w=" + width + " h=" + height); this.width = width; this.height = height; } - public void setHints(int hintflags) { + public void setHints(final int hintflags) { // MessageHandler.errorln("setHints: " + hintflags); this.hints = hintflags; } - public void setProperties(Hashtable props) { + public void setProperties(final Hashtable props) { // MessageHandler.errorln("setProperties: " + props); this.properties = props; } - public void setPixels(int x, int y, int w, int h, ColorModel model, - byte[] pixels, int off, int scansize) {} + public void setPixels(final int x, final int y, final int w, final int h, + final ColorModel model, final byte[] pixels, final int off, + final int scansize) {} - public void setPixels(int x, int y, int w, int h, ColorModel model, - int[] pixels, int off, int scansize) {} + public void setPixels(final int x, final int y, final int w, final int h, + final ColorModel model, final int[] pixels, final int off, + final int scansize) {} public boolean isImageReady() throws Exception { synchronized (this.imageStatus) { @@ -138,8 +140,8 @@ } public int[] getImage() throws Exception { - int tmpMap[] = new int[this.width * this.height]; - PixelGrabber pg = new PixelGrabber(this.ip, 0, 0, this.width, + final int tmpMap[] = new int[this.width * this.height]; + final PixelGrabber pg = new PixelGrabber(this.ip, 0, 0, this.width, this.height, tmpMap, 0, this.width); pg.setDimensions(this.width, this.height); @@ -148,7 +150,7 @@ pg.setProperties(this.properties); try { pg.grabPixels(); - } catch (InterruptedException intex) { + } catch (final InterruptedException intex) { throw new Exception("Image grabbing interrupted : " + intex.getMessage()); } Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/JAIGraphic.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/JAIGraphic.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/JAIGraphic.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -51,25 +51,25 @@ /** The JAI stream manager that is used for handling IO. */ FileCacheSeekableStream seekableInput2 = null; - public JAIGraphic(FOrayGraphicServer server, URL href, - BufferedInputStream bis) { + public JAIGraphic(final FOrayGraphicServer server, final URL href, + final BufferedInputStream bis) { super(server, href, bis); } public void loadImage() throws GraphicException { try { - RenderedOp imageOp = JAI.create("stream", getSeekableInput()); + final RenderedOp imageOp = JAI.create("stream", getSeekableInput()); this.pixelHeight = imageOp.getHeight(); this.pixelWidth = imageOp.getWidth(); - ColorModel cm = imageOp.getColorModel(); + final ColorModel cm = imageOp.getColorModel(); this.bitDepth = 8; // this.m_bitsPerPixel = cm.getPixelSize(); this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB); - BufferedImage imageData = imageOp.getAsBufferedImage(); - int[] tmpMap = imageData.getRGB(0, 0, this.pixelWidth, + final BufferedImage imageData = imageOp.getAsBufferedImage(); + final int[] tmpMap = imageData.getRGB(0, 0, this.pixelWidth, this.pixelHeight, null, 0, this.pixelWidth); @@ -80,10 +80,10 @@ this.content = new byte[this.contentSize]; for (int i = 0; i < this.pixelHeight; i++) { for (int j = 0; j < this.pixelWidth; j++) { - int p = tmpMap[i * this.pixelWidth + j]; - int r = (p >> 16) & 0xFF; - int g = (p >> 8) & 0xFF; - int b = (p) & 0xFF; + final int p = tmpMap[i * this.pixelWidth + j]; + final int r = (p >> 16) & 0xFF; + final int g = (p >> 8) & 0xFF; + final int b = (p) & 0xFF; this.content[3 * (i * this.pixelWidth + j)] = (byte)(r & 0xFF); this.content[3 * (i * this.pixelWidth + j) + 1] = (byte)(g @@ -93,7 +93,7 @@ } } - } catch (Exception ex) { + } catch (final Exception ex) { throw new GraphicException("Error while loading image " + this.url.toString() + " : " + ex.getClass() + " - " @@ -101,26 +101,26 @@ } } - private void checkAlpha(ColorModel cm) { + private void checkAlpha(final ColorModel cm) { if (! cm.hasAlpha()) { this.isTransparent = false; return; } // Transparency. BITMASK or OPAQUE or TRANSLUCENT - int transparencyType = cm.getTransparency(); + final int transparencyType = cm.getTransparency(); if (transparencyType == Transparency.OPAQUE) { this.isTransparent = false; } else if (transparencyType == Transparency.BITMASK) { if (cm instanceof IndexColorModel) { this.isTransparent = false; - byte[] alphas = + final byte[] alphas = new byte[((IndexColorModel)cm).getMapSize()]; - byte[] reds = + final byte[] reds = new byte[((IndexColorModel)cm).getMapSize()]; - byte[] greens = + final byte[] greens = new byte[((IndexColorModel)cm).getMapSize()]; - byte[] blues = + final byte[] blues = new byte[((IndexColorModel)cm).getMapSize()]; ((IndexColorModel)cm).getAlphas(alphas); ((IndexColorModel)cm).getReds(reds); @@ -169,7 +169,7 @@ * {@inheritDoc} */ public void parseBasics() throws IOException { - RenderedOp imageOp = JAI.create("stream", getSeekableInput()); + final RenderedOp imageOp = JAI.create("stream", getSeekableInput()); this.pixelHeight = imageOp.getHeight(); this.pixelWidth = imageOp.getWidth(); this.basicsParsed = true; Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/JPEGGraphic.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/JPEGGraphic.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/JPEGGraphic.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -76,8 +76,8 @@ boolean found_icc_profile = false; boolean found_dimensions = false; - public JPEGGraphic(FOrayGraphicServer server, URL href, - BufferedInputStream bis) { + public JPEGGraphic(final FOrayGraphicServer server, final URL href, + final BufferedInputStream bis) { super(server, href, bis); } @@ -89,18 +89,18 @@ if (! this.isValid) { return; } - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ByteArrayOutputStream iccStream = new ByteArrayOutputStream(); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ByteArrayOutputStream iccStream = new ByteArrayOutputStream(); this.colorSpace = null; - byte[] readBuf = new byte[4096]; + final byte[] readBuf = new byte[4096]; int bytes_read; - int index = 0; + final int index = 0; try { while ((bytes_read = bis.read(readBuf)) != -1) { baos.write(readBuf, 0, bytes_read); } - } catch (IOException ex) { + } catch (final IOException ex) { this.isValid = false; throw new GraphicException("Error loading image:\n " + this.url.toString() @@ -126,14 +126,15 @@ + "\n JpegImage - Invalid JPEG Header."); } if (iccStream.size() > 0) { - byte[] align = new byte[((iccStream.size()) % 8) + 8]; + final byte[] align = new byte[((iccStream.size()) % 8) + 8]; try { iccStream.write(align); - } catch (Exception e) { + } catch (final Exception e) { throw new GraphicException("\n1 Error while loading image " + this.url.toString() + " : " + e.getMessage()); } - ICC_Profile icc = ICC_Profile.getInstance(iccStream.toByteArray()); + final ICC_Profile icc = ICC_Profile.getInstance( + iccStream.toByteArray()); this.colorSpace = new ICC_ColorSpace(icc); } @@ -143,7 +144,8 @@ } } - private void processRemainder(ByteArrayOutputStream iccStream, int index) { + private void processRemainder(final ByteArrayOutputStream iccStream, + int index) { boolean cont = true; index += 2; while (index < this.content.length && cont) { @@ -155,8 +157,8 @@ } } - private boolean processNextChunk(ByteArrayOutputStream iccStream, - int index) { + private boolean processNextChunk(final ByteArrayOutputStream iccStream, + final int index) { //check to be sure this is the begining of a header if (! isBeginningOfHeader(index)) { // throw new GraphicException("\n2 Error while loading " @@ -192,12 +194,12 @@ return true; } - private boolean createdByPhotoshop(int index) { + private boolean createdByPhotoshop(final int index) { return ((uByte(this.content[index]) == 0xff)) && (uByte(this.content[index + 1]) == 0xe1); } - private boolean isICCProfile(int index) { + private boolean isICCProfile(final int index) { return uByte(this.content[index+1]) == 226 && this.content.length > (index+60); } @@ -217,7 +219,7 @@ * * This code will remain present for the time being. -blg */ - private boolean hasAPPEMarker(int index) { + private boolean hasAPPEMarker(final int index) { //hasAPPEMarker = true; return (uByte(this.content[index]) == 0xff && @@ -231,12 +233,12 @@ * 192 or 194 are the header bytes that contain the jpeg * width height and color depth. */ - private boolean isDimensionsAndColor(int index) { + private boolean isDimensionsAndColor(final int index) { return uByte(this.content[index + 1]) == 192 || uByte(this.content[index + 1]) == 194; } - private boolean isBeginningOfHeader(int index) { + private boolean isBeginningOfHeader(final int index) { if (this.content.length > (index + 2) && uByte(this.content[index]) == 255) { return true; @@ -244,9 +246,10 @@ return false; } - private void checkICCProfile(ByteArrayOutputStream iccStream, int index) { + private void checkICCProfile(final ByteArrayOutputStream iccStream, + final int index) { // Check if ICC profile - byte[] icc_string = new byte[11]; + final byte[] icc_string = new byte[11]; System.arraycopy(this.content, index+4, icc_string, 0, 11); /* @@ -259,7 +262,7 @@ } */ if ("ICC_PROFILE".equals(new String(icc_string))){ - int chunkSize = calcBytes(this.content[index + 2], + final int chunkSize = calcBytes(this.content[index + 2], this.content[index + 3]) + 2; // eller 18.. iccStream.write(this.content, index+16, chunkSize - 18); @@ -267,7 +270,7 @@ } - private void getColorSpace(int index) { + private void getColorSpace(final int index) { if (this.content[index + 9] == 1) { this.colorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY); } else if (this.content[index + 9] == 3) { @@ -281,18 +284,18 @@ } } - private void getDimensions(int index) { + private void getDimensions(final int index) { this.pixelHeight = calcBytes(this.content[index + 5], this.content[index + 6]); this.pixelWidth = calcBytes(this.content[index + 7], this.content[index + 8]); } - private int calcBytes(byte bOne, byte bTwo) { + private int calcBytes(final byte bOne, final byte bTwo) { return (uByte(bOne) * 256) + uByte(bTwo); } - private int uByte(byte bIn) { + private int uByte(final byte bIn) { if (bIn < 0) { return 256 + bIn; } @@ -349,7 +352,7 @@ * @param readBuffer Byte array containing either the contents of the * entire file, or some portion of the beginning of the file. */ - protected void findImageSize(byte[] readBuffer) { + protected void findImageSize(final byte[] readBuffer) { /* Start index at 2 because the first two bytes are the SOI marker. */ int index = 2; while (this.pixelHeight < 1 && this.pixelWidth < 1) { @@ -357,7 +360,7 @@ /* This is not the beginning of a segment.*/ return; } - byte markerType = readBuffer[index + 1]; + final byte markerType = readBuffer[index + 1]; switch (markerType) { case SOF1: case SOF2: @@ -377,7 +380,7 @@ default: { // Eat the segment marker and segment type bytes index += 2; - int toSkip = combine2bytes(readBuffer[index], + final int toSkip = combine2bytes(readBuffer[index], readBuffer[index + 1]); index += toSkip; } @@ -385,9 +388,10 @@ } } - protected static int combine2bytes(byte highOrder, byte lowOrder) { - int intHigh = highOrder << 24 >>> 16; - int intLow = lowOrder << 24 >>> 24; + protected static int combine2bytes(final byte highOrder, + final byte lowOrder) { + final int intHigh = highOrder << 24 >>> 16; + final int intLow = lowOrder << 24 >>> 24; return intHigh | intLow; } Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/PDFGraphic.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/PDFGraphic.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/PDFGraphic.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -36,8 +36,8 @@ */ public class PDFGraphic extends Graphic { - public PDFGraphic(FOrayGraphicServer server, URL href, - BufferedInputStream bis) { + public PDFGraphic(final FOrayGraphicServer server, final URL href, + final BufferedInputStream bis) { super(server, href, bis); } @@ -53,8 +53,8 @@ return; } imageLoaded = true; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] readBuf = new byte[20480]; + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final byte[] readBuf = new byte[20480]; int bytes_read; try { while (true) { @@ -65,7 +65,7 @@ break; } } - } catch (IOException ex) { + } catch (final IOException ex) { throw new GraphicException("Error while loading image " + this.url.toString() + " : " + ex.getClass() + " - " + ex.getMessage()); Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/PNGGraphic.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/PNGGraphic.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/PNGGraphic.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -36,8 +36,8 @@ public static final int PNG_SIG_LENGTH = 24; - public PNGGraphic(FOrayGraphicServer server, URL href, - BufferedInputStream bis) { + public PNGGraphic(final FOrayGraphicServer server, final URL href, + final BufferedInputStream bis) { super(server, href, bis); } @@ -49,7 +49,7 @@ * {@inheritDoc} */ public void parseBasics() throws IOException { - byte[] header = new byte[PNGGraphic.PNG_SIG_LENGTH]; + final byte[] header = new byte[PNGGraphic.PNG_SIG_LENGTH]; bis.read(header); // png is always big endian int byte1 = header[16] & 0xff; Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/SVGGraphic.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -51,17 +51,17 @@ private SVGDocument doc; - public SVGGraphic(FOrayGraphicServer server, URL href, - BufferedInputStream bis) { + public SVGGraphic(final FOrayGraphicServer server, final URL href, + final BufferedInputStream bis) { super(server, href, bis); } public void loadImage() throws GraphicException { try { - SAXSVGDocumentFactory factory = + final SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(this.server.getSVGParserClassName()); doc = factory.createSVGDocument(this.url.toExternalForm()); - } catch (Exception e) { + } catch (final Exception e) { getLogger().error("Could not load external SVG: " + e.getMessage()); } @@ -92,21 +92,22 @@ public void parseBasics() throws IOException { // parse document and get the size attributes of the svg element try { - SAXSVGDocumentFactory factory = + final SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(server.getSVGParserClassName()); /* It seems klunky to open another stream here, but the * createDocument method apparently closes the one that gets * passed to it. We need to leave it open so that it can be * reused later on. */ - SVGDocument doc = (SVGDocument)factory.createDocument( + final SVGDocument doc = (SVGDocument)factory.createDocument( url.toString(), url.openStream()); - UserAgent userAgent = new MUserAgent(new AffineTransform()); - BridgeContext ctx = new BridgeContext(userAgent); + final UserAgent userAgent = new MUserAgent(new AffineTransform()); + final BridgeContext ctx = new BridgeContext(userAgent); - Element e = doc.getRootElement(); - UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, e); + final Element e = doc.getRootElement(); + final UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, + e); String s; // 'width' attribute - default is 100% @@ -125,7 +126,7 @@ this.pixelHeight = (int)UnitProcessor.svgVerticalLengthToUserSpace (s, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, uctx); - } catch (NoClassDefFoundError ncdfe) { + } catch (final NoClassDefFoundError ncdfe) { getLogger().error("Batik not in class path"); return; } @@ -141,21 +142,21 @@ /** * Creates a new SVGUserAgent. */ - protected MUserAgent(AffineTransform at) { + protected MUserAgent(final AffineTransform at) { currentTransform = at; } /** * Displays an error message. */ - public void displayError(String message) { + public void displayError(final String message) { getLogger().error(message); } /** * Displays an error resulting from the specified Exception. */ - public void displayError(Exception ex) { + public void displayError(final Exception ex) { getLogger().error("SVGGraphic Exception", ex); } @@ -163,7 +164,7 @@ * Displays a message in the User Agent interface. * The given message is typically displayed in a status bar. */ - public void displayMessage(String message) { + public void displayMessage(final String message) { getLogger().info(message); } Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/TIFFGraphic.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/TIFFGraphic.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/TIFFGraphic.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -44,8 +44,8 @@ public class TIFFGraphic extends JAIGraphic { private int m_compression = 0; - public TIFFGraphic(FOrayGraphicServer server, URL href, - BufferedInputStream bis) { + public TIFFGraphic(final FOrayGraphicServer server, final URL href, + final BufferedInputStream bis) { super(server, href, bis); } @@ -55,7 +55,7 @@ } imageLoaded = true; try { - TIFFDirectory ifd = new TIFFDirectory(getSeekableInput(), 0); + final TIFFDirectory ifd = new TIFFDirectory(getSeekableInput(), 0); TIFFField fld = null; this.pixelHeight = (int)ifd.getFieldAsLong(0x101); @@ -112,10 +112,10 @@ + "only single strip images supported "); } } - long offset = ifd.getFieldAsLong(0x111); - long length = ifd.getFieldAsLong(0x117); + final long offset = ifd.getFieldAsLong(0x111); + final long length = ifd.getFieldAsLong(0x117); - byte[] readBuf = new byte[(int)length]; + final byte[] readBuf = new byte[(int)length]; int bytes_read; bis.close(); @@ -130,11 +130,11 @@ } this.content = readBuf; - } catch (GraphicException fie) { + } catch (final GraphicException fie) { getLogger().error("Reverting to TIFF image handling " + "through JAI: " + fie.getMessage()); super.loadImage(); - } catch (Exception ex) { + } catch (final Exception ex) { throw new GraphicException("Error while loading image " + this.url.toString() + " : " + ex.getClass() + " - " Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/BMPFactory.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/BMPFactory.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/BMPFactory.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -38,15 +38,15 @@ */ public class BMPFactory extends GraphicFactory { - public BMPFactory(FOrayGraphicServer server) { + public BMPFactory(final FOrayGraphicServer server) { super(server); } - public Graphic attemptCreate(URL url, BufferedInputStream bis) + public Graphic attemptCreate(final URL url, final BufferedInputStream bis) throws IOException { - byte[] header = new byte[BMPGraphic.BMP_SIG_LENGTH]; + final byte[] header = new byte[BMPGraphic.BMP_SIG_LENGTH]; bis.read(header); - boolean supported = ((header[0] == (byte)0x42) + final boolean supported = ((header[0] == (byte)0x42) && (header[1] == (byte)0x4d)); if (! supported) { return null; Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/EPSFactory.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/EPSFactory.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/EPSFactory.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -38,13 +38,13 @@ */ public class EPSFactory extends GraphicFactory { - public EPSFactory(FOrayGraphicServer server) { + public EPSFactory(final FOrayGraphicServer server) { super(server); } - public Graphic attemptCreate(URL url, BufferedInputStream bis) + public Graphic attemptCreate(final URL url, final BufferedInputStream bis) throws IOException { - byte[] header = new byte[30]; + final byte[] header = new byte[30]; bis.read(header, 0, 30); boolean isEPS = false; boolean isAscii = false; @@ -55,7 +55,7 @@ isEPS = true; } else { // Check if plain ascii - byte[] epsh = "%!PS".getBytes(); + final byte[] epsh = "%!PS".getBytes(); if (epsh[0] == header[0] && epsh[1] == header[1] && epsh[2] == header[2] && Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/GIFFactory.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/GIFFactory.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/GIFFactory.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -39,15 +39,15 @@ */ public class GIFFactory extends GraphicFactory { - public GIFFactory(FOrayGraphicServer server) { + public GIFFactory(final FOrayGraphicServer server) { super(server); } - public Graphic attemptCreate(URL url, BufferedInputStream bis) + public Graphic attemptCreate(final URL url, final BufferedInputStream bis) throws IOException { - byte[] header = new byte[GIFGraphic.GIF_SIG_LENGTH]; + final byte[] header = new byte[GIFGraphic.GIF_SIG_LENGTH]; bis.read(header); - boolean supported = ((header[0] == 'G') && (header[1] == 'I') + final boolean supported = ((header[0] == 'G') && (header[1] == 'I') && (header[2] == 'F') && (header[3] == '8') && (header[4] == '7' || header[4] == '9') && (header[5] == 'a')); Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/GraphicFactory.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/GraphicFactory.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/GraphicFactory.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -53,15 +53,15 @@ /** The parent GraphicServer instance. */ protected FOrayGraphicServer server = null; - public GraphicFactory(FOrayGraphicServer server) { + public GraphicFactory(final FOrayGraphicServer server) { this.server = server; } - public Graphic makeGraphic(URL url, BufferedInputStream bis) + public Graphic makeGraphic(final URL url, final BufferedInputStream bis) throws IOException { // Mark the stream so that it can be reset after the attempt. bis.mark(maxBytesToVerify()); - Graphic graphic = attemptCreate(url, bis); + final Graphic graphic = attemptCreate(url, bis); // Reset the stream so that is can be reused later. bis.reset(); return graphic; @@ -88,11 +88,11 @@ return this.server.getLogger(); } - protected long getLong(byte[] buf, int idx) { - int b1 = buf[idx] & 0xff; - int b2 = buf[idx+1] & 0xff; - int b3 = buf[idx+2] & 0xff; - int b4 = buf[idx+3] & 0xff; + protected long getLong(final byte[] buf, final int idx) { + final int b1 = buf[idx] & 0xff; + final int b2 = buf[idx+1] & 0xff; + final int b3 = buf[idx+2] & 0xff; + final int b4 = buf[idx+3] & 0xff; return (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; } Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/JPEGFactory.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/JPEGFactory.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/JPEGFactory.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -40,15 +40,15 @@ */ public class JPEGFactory extends GraphicFactory { - public JPEGFactory(FOrayGraphicServer server) { + public JPEGFactory(final FOrayGraphicServer server) { super(server); } - public Graphic attemptCreate(URL url, BufferedInputStream bis) + public Graphic attemptCreate(final URL url, final BufferedInputStream bis) throws IOException { - byte[] header = new byte[JPEGGraphic.JPG_SIG_LENGTH]; + final byte[] header = new byte[JPEGGraphic.JPG_SIG_LENGTH]; bis.read(header); - boolean supported = ((header[0] == (byte)0xff) + final boolean supported = ((header[0] == (byte)0xff) && (header[1] == (byte)0xd8)); if (! supported) { return null; Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/PDFFactory.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/PDFFactory.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/PDFFactory.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -38,13 +38,13 @@ */ public class PDFFactory extends GraphicFactory { - public PDFFactory(FOrayGraphicServer server) { + public PDFFactory(final FOrayGraphicServer server) { super(server); } - public Graphic attemptCreate(URL url, BufferedInputStream bis) + public Graphic attemptCreate(final URL url, final BufferedInputStream bis) throws IOException { - byte[] header = new byte[4]; + final byte[] header = new byte[4]; bis.read(header, 0, 4); if (header[0] == 0x25 // % && header[1] == 0x50 // P Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/PNGFactory.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/PNGFactory.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/PNGFactory.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -39,15 +39,15 @@ */ public class PNGFactory extends GraphicFactory { - public PNGFactory(FOrayGraphicServer server) { + public PNGFactory(final FOrayGraphicServer server) { super(server); } - public Graphic attemptCreate(URL url, BufferedInputStream bis) + public Graphic attemptCreate(final URL url, final BufferedInputStream bis) throws IOException { - byte[] header = new byte[PNGGraphic.PNG_SIG_LENGTH]; + final byte[] header = new byte[PNGGraphic.PNG_SIG_LENGTH]; bis.read(header); - boolean supported + final boolean supported = ((header[0] == (byte) 0x89) // HTJ control character && (header[1] == (byte) 0x50) // P && (header[2] == (byte) 0x4e) // N Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/SVGFactory.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/SVGFactory.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/SVGFactory.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -37,20 +37,20 @@ */ public class SVGFactory extends GraphicFactory { - public SVGFactory(FOrayGraphicServer server) { + public SVGFactory(final FOrayGraphicServer server) { super(server); } - public Graphic attemptCreate(URL url, BufferedInputStream bis) + public Graphic attemptCreate(final URL url, final BufferedInputStream bis) throws IOException { - byte[] header = new byte[1024]; + final byte[] header = new byte[1024]; bis.read(header); /* * For now, try to avoid parsing the whole document. Converting a byte * array to a String is a bit risky & this may need some more work. */ - String headerString = new String(header); - int svgStringIndex = headerString.indexOf("<svg"); + final String headerString = new String(header); + final int svgStringIndex = headerString.indexOf("<svg"); if (svgStringIndex < 0) { return null; } Modified: trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/TIFFFactory.java =================================================================== --- trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/TIFFFactory.java 2006-07-23 17:25:44 UTC (rev 7816) +++ trunk/foray/foray-graphic/src/java/org/foray/graphic/factory/TIFFFactory.java 2006-07-23 19:16:06 UTC (rev 7817) @@ -39,13 +39,13 @@ public class TIFFFactory extends GraphicFactory { protected static final int TIFF_SIG_LENGTH = 8; - public TIFFFactory(FOrayGraphicServer server) { + public TIFFFactory(final FOrayGraphicServer server) { super(server); } - public Graphic attemptCreate(URL url, BufferedInputStream bis) + public Graphic attemptCreate(final URL url, final BufferedInputStream bis) throws IOException { - byte[] header = new byte[TIFF_SIG_LENGTH]; + final byte[] header = new byte[TIFF_SIG_LENGTH]; bis.read(header); boolean supported = false; // first 2 bytes = II (little endian encoding) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |