You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/05/19 21:21:13 UTC

svn commit: r776424 [2/2] - /poi/trunk/src/java/org/apache/poi/ddf/

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherMetafileBlip.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherMetafileBlip.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherMetafileBlip.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherMetafileBlip.java Tue May 19 19:21:12 2009
@@ -1,19 +1,20 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
 package org.apache.poi.ddf;
 
 import org.apache.poi.util.HexDump;
@@ -30,11 +31,8 @@
 
 /**
  * @author Daniel Noll
- * @version $Id$
  */
-public class EscherMetafileBlip
-        extends EscherBlipRecord
-{
+public final class EscherMetafileBlip extends EscherBlipRecord {
     private static final POILogger log = POILogFactory.getLogger(EscherMetafileBlip.class);
 
     public static final short RECORD_ID_EMF = (short) 0xF018 + 2;
@@ -68,16 +66,7 @@
 
     private byte[] raw_pictureData;
 
-    /**
-     * This method deserializes the record from a byte array.
-     *
-     * @param data          The byte array containing the escher record information
-     * @param offset        The starting offset into <code>data</code>.
-     * @param recordFactory May be null since this is not a container record.
-     * @return The number of bytes read from the byte array.
-     */
-    public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory )
-    {
+    public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
         int bytesAfterHeader = readHeader( data, offset );
         int pos = offset + HEADER_SIZE;
 
@@ -105,31 +94,16 @@
 
         // 0 means DEFLATE compression
         // 0xFE means no compression
-        if (field_6_fCompression == 0)
-        {
+        if (field_6_fCompression == 0) {
             field_pictureData = inflatePictureData(raw_pictureData);
-        }
-        else
-        {
+        } else {
             field_pictureData = raw_pictureData;
         }
 
         return bytesAfterHeader + HEADER_SIZE;
     }
 
-    /**
-     * Serializes the record to an existing byte array.
-     *
-     * @param offset    the offset within the byte array
-     * @param data      the data array to serialize to
-     * @param listener  a listener for begin and end serialization events.  This
-     *                  is useful because the serialization is
-     *                  hierarchical/recursive and sometimes you need to be able
-     *                  break into that.
-     * @return the number of bytes written.
-     */
-    public int serialize( int offset, byte[] data, EscherSerializationListener listener )
-    {
+    public int serialize(int offset, byte[] data, EscherSerializationListener listener) {
         listener.beforeRecordSerialize(offset, getRecordId(), this);
 
         int pos = offset;
@@ -138,7 +112,7 @@
         LittleEndian.putInt( data, pos, getRecordSize() - HEADER_SIZE ); pos += 4;
 
         System.arraycopy( field_1_UID, 0, data, pos, field_1_UID.length ); pos += field_1_UID.length;
-        if((getOptions() ^ getSignature()) == 0x10){
+        if ((getOptions() ^ getSignature()) == 0x10) {
             System.arraycopy( field_2_UID, 0, data, pos, field_2_UID.length ); pos += field_2_UID.length;
         }
         LittleEndian.putInt( data, pos, field_2_cb ); pos += 4;
@@ -164,35 +138,24 @@
      * @param data the deflated picture data.
      * @return the inflated picture data.
      */
-    private static byte[] inflatePictureData(byte[] data)
-    {
-        try
-        {
+    private static byte[] inflatePictureData(byte[] data) {
+        try {
             InflaterInputStream in = new InflaterInputStream(
                 new ByteArrayInputStream( data ) );
             ByteArrayOutputStream out = new ByteArrayOutputStream();
             byte[] buf = new byte[4096];
             int readBytes;
-            while ((readBytes = in.read(buf)) > 0)
-            {
+            while ((readBytes = in.read(buf)) > 0) {
                 out.write(buf, 0, readBytes);
             }
             return out.toByteArray();
-        }
-        catch ( IOException e )
-        {
+        } catch (IOException e) {
             log.log(POILogger.WARN, "Possibly corrupt compression or non-compressed data", e);
             return data;
         }
     }
 
-    /**
-     * Returns the number of bytes that are required to serialize this record.
-     *
-     * @return Number of bytes
-     */
-    public int getRecordSize()
-    {
+    public int getRecordSize() {
         int size = 8 + 50 + raw_pictureData.length;
         if((getOptions() ^ getSignature()) == 0x10){
             size += field_2_UID.length;
@@ -200,14 +163,12 @@
         return size;
     }
 
-    public byte[] getUID()
-    {
+    public byte[] getUID() {
         return field_1_UID;
     }
 
-    public void setUID( byte[] field_1_UID )
-    {
-        this.field_1_UID = field_1_UID;
+    public void setUID(byte[] uid) {
+        field_1_UID = uid;
     }
 
     public byte[] getPrimaryUID()
@@ -215,97 +176,73 @@
         return field_2_UID;
     }
 
-    public void setPrimaryUID( byte[] field_2_UID )
-    {
-        this.field_2_UID = field_2_UID;
+    public void setPrimaryUID(byte[] primaryUID) {
+        field_2_UID = primaryUID;
     }
 
-    public int getUncompressedSize()
-    {
+    public int getUncompressedSize() {
         return field_2_cb;
     }
 
-    public void setUncompressedSize(int uncompressedSize)
-    {
+    public void setUncompressedSize(int uncompressedSize) {
         field_2_cb = uncompressedSize;
     }
 
-    public Rectangle getBounds()
-    {
+    public Rectangle getBounds() {
         return new Rectangle(field_3_rcBounds_x1,
                              field_3_rcBounds_y1,
                              field_3_rcBounds_x2 - field_3_rcBounds_x1,
                              field_3_rcBounds_y2 - field_3_rcBounds_y1);
     }
 
-    public void setBounds(Rectangle bounds)
-    {
+    public void setBounds(Rectangle bounds) {
         field_3_rcBounds_x1 = bounds.x;
         field_3_rcBounds_y1 = bounds.y;
         field_3_rcBounds_x2 = bounds.x + bounds.width;
         field_3_rcBounds_y2 = bounds.y + bounds.height;
     }
 
-    public Dimension getSizeEMU()
-    {
+    public Dimension getSizeEMU() {
         return new Dimension(field_4_ptSize_w, field_4_ptSize_h);
     }
 
-    public void setSizeEMU(Dimension sizeEMU)
-    {
+    public void setSizeEMU(Dimension sizeEMU) {
         field_4_ptSize_w = sizeEMU.width;
         field_4_ptSize_h = sizeEMU.height;
     }
 
-    public int getCompressedSize()
-    {
+    public int getCompressedSize() {
         return field_5_cbSave;
     }
 
-    public void setCompressedSize(int compressedSize)
-    {
+    public void setCompressedSize(int compressedSize) {
         field_5_cbSave = compressedSize;
     }
 
-    public boolean isCompressed()
-    {
+    public boolean isCompressed() {
         return (field_6_fCompression == 0);
     }
 
-    public void setCompressed(boolean compressed)
-    {
+    public void setCompressed(boolean compressed) {
         field_6_fCompression = compressed ? 0 : (byte)0xFE;
     }
 
     // filtering is always 254 according to available docs, so no point giving it a setter method.
 
-    public String toString()
-    {
-        String nl = System.getProperty( "line.separator" );
-
-        String extraData;
-        ByteArrayOutputStream b = new ByteArrayOutputStream();
-        try
-        {
-            HexDump.dump( this.field_pictureData, 0, b, 0 );
-            extraData = b.toString();
-        }
-        catch ( Exception e )
-        {
-            extraData = e.toString();
-        }
-        return getClass().getName() + ":" + nl +
-                "  RecordId: 0x" + HexDump.toHex( getRecordId() ) + nl +
-                "  Options: 0x" + HexDump.toHex( getOptions() ) + nl +
-                "  UID: 0x" + HexDump.toHex( field_1_UID ) + nl +
-                (field_2_UID == null ? "" : ("  UID2: 0x" + HexDump.toHex( field_2_UID ) + nl)) +
-                "  Uncompressed Size: " + HexDump.toHex( field_2_cb ) + nl +
-                "  Bounds: " + getBounds() + nl +
-                "  Size in EMU: " + getSizeEMU() + nl +
-                "  Compressed Size: " + HexDump.toHex( field_5_cbSave ) + nl +
-                "  Compression: " + HexDump.toHex( field_6_fCompression ) + nl +
-                "  Filter: " + HexDump.toHex( field_7_fFilter ) + nl +
-                "  Extra Data:" + nl + extraData;
+    public String toString() {
+        String extraData = HexDump.toHex(field_pictureData, 32);
+        return getClass().getName() + ":" + '\n' +
+                "  RecordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' +
+                "  Options: 0x" + HexDump.toHex( getOptions() ) + '\n' +
+                "  UID: 0x" + HexDump.toHex( field_1_UID ) + '\n' +
+                (field_2_UID == null ? "" : ("  UID2: 0x" + HexDump.toHex( field_2_UID ) + '\n')) +
+                "  Uncompressed Size: " + HexDump.toHex( field_2_cb ) + '\n' +
+                "  Bounds: " + getBounds() + '\n' +
+                "  Size in EMU: " + getSizeEMU() + '\n' +
+                "  Compressed Size: " + HexDump.toHex( field_5_cbSave ) + '\n' +
+                "  Compression: " + HexDump.toHex( field_6_fCompression ) + '\n' +
+                "  Filter: " + HexDump.toHex( field_7_fFilter ) + '\n' +
+                "  Extra Data:" + '\n' + extraData;
     }
 
     /**
@@ -313,14 +250,13 @@
      *
      * @return the blip signature
      */
-    public short getSignature(){
-        short sig = 0;
-        switch(getRecordId()){
-            case RECORD_ID_EMF: sig = SIGNATURE_EMF; break;
-            case RECORD_ID_WMF: sig = SIGNATURE_WMF; break;
-            case RECORD_ID_PICT: sig = SIGNATURE_PICT; break;
-            default: log.log(POILogger.WARN, "Unknown metafile: " + getRecordId()); break;
+    public short getSignature() {
+        switch (getRecordId()) {
+            case RECORD_ID_EMF:  return SIGNATURE_EMF;
+            case RECORD_ID_WMF:  return SIGNATURE_WMF;
+            case RECORD_ID_PICT: return  SIGNATURE_PICT;
         }
-        return sig;
+        log.log(POILogger.WARN, "Unknown metafile: " + getRecordId());
+        return 0;
     }
 }

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherOptRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherOptRecord.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherOptRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherOptRecord.java Tue May 19 19:21:12 2009
@@ -15,7 +15,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 import java.util.ArrayList;
@@ -42,16 +42,7 @@
 
     private List properties = new ArrayList();
 
-    /**
-     * This method deserializes the record from a byte array.
-     *
-     * @param data          The byte array containing the escher record information
-     * @param offset        The starting offset into <code>data</code>.
-     * @param recordFactory May be null since this is not a container record.
-     * @return The number of bytes read from the byte array.
-     */
-    public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory )
-    {
+    public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
         int bytesRemaining = readHeader( data, offset );
         int pos = offset + 8;
 
@@ -60,16 +51,6 @@
         return bytesRemaining + 8;
     }
 
-    /**
-     * This method serializes this escher record into a byte array.
-     *
-     * @param offset   The offset into <code>data</code> to start writing the record data to.
-     * @param data     The byte array to serialize to.
-     * @param listener A listener to retrieve start and end callbacks.  Use a <code>NullEscherSerailizationListener</code> to ignore these events.
-     *
-     * @return The number of bytes written.
-     * @see NullEscherSerializationListener
-     */
     public int serialize( int offset, byte[] data, EscherSerializationListener listener )
     {
         listener.beforeRecordSerialize( offset, getRecordId(), this );
@@ -92,11 +73,6 @@
         return pos - offset;
     }
 
-    /**
-     * Returns the number of bytes that are required to serialize this record.
-     *
-     * @return Number of bytes
-     */
     public int getRecordSize()
     {
         return 8 + getPropertiesSize();
@@ -111,11 +87,7 @@
         return super.getOptions();
     }
 
-    /**
-     * The short name for this record
-     */
-    public String getRecordName()
-    {
+    public String getRecordName() {
         return "Opt";
     }
 

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherPictBlip.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherPictBlip.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherPictBlip.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherPictBlip.java Tue May 19 19:21:12 2009
@@ -1,19 +1,20 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
 package org.apache.poi.ddf;
 
 import org.apache.poi.util.HexDump;
@@ -30,11 +31,8 @@
 
 /**
  * @author Daniel Noll
- * @version $Id$
  */
-public class EscherPictBlip
-        extends EscherBlipRecord
-{
+public final class EscherPictBlip extends EscherBlipRecord {
     private static final POILogger log = POILogFactory.getLogger(EscherPictBlip.class);
 
     public static final short RECORD_ID_EMF = (short) 0xF018 + 2;
@@ -57,17 +55,8 @@
 
     private byte[] raw_pictureData;
 
-    /**
-     * This method deserializes the record from a byte array.
-     *
-     * @param data          The byte array containing the escher record information
-     * @param offset        The starting offset into <code>data</code>.
-     * @param recordFactory May be null since this is not a container record.
-     * @return The number of bytes read from the byte array.
-     */
-    public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory )
-    {
-        int bytesAfterHeader = readHeader( data, offset );
+    public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
+        int bytesAfterHeader = readHeader(data, offset);
         int pos = offset + HEADER_SIZE;
 
         field_1_UID = new byte[16];
@@ -100,19 +89,7 @@
         return bytesAfterHeader + HEADER_SIZE;
     }
 
-    /**
-     * Serializes the record to an existing byte array.
-     *
-     * @param offset    the offset within the byte array
-     * @param data      the data array to serialize to
-     * @param listener  a listener for begin and end serialization events.  This
-     *                  is useful because the serialization is
-     *                  hierarchical/recursive and sometimes you need to be able
-     *                  break into that.
-     * @return the number of bytes written.
-     */
-    public int serialize( int offset, byte[] data, EscherSerializationListener listener )
-    {
+    public int serialize(int offset, byte[] data, EscherSerializationListener listener) {
         listener.beforeRecordSerialize(offset, getRecordId(), this);
 
         int pos = offset;
@@ -144,133 +121,95 @@
      * @param data the deflated picture data.
      * @return the inflated picture data.
      */
-    private static byte[] inflatePictureData(byte[] data)
-    {
-        try
-        {
-            InflaterInputStream in = new InflaterInputStream(
-                new ByteArrayInputStream( data ) );
+    private static byte[] inflatePictureData(byte[] data) {
+        try {
+            InflaterInputStream in = new InflaterInputStream(new ByteArrayInputStream(data));
             ByteArrayOutputStream out = new ByteArrayOutputStream();
             byte[] buf = new byte[4096];
             int readBytes;
-            while ((readBytes = in.read(buf)) > 0)
-            {
+            while ((readBytes = in.read(buf)) > 0) {
                 out.write(buf, 0, readBytes);
             }
             return out.toByteArray();
-        }
-        catch ( IOException e )
-        {
+        } catch (IOException e) {
             log.log(POILogger.INFO, "Possibly corrupt compression or non-compressed data", e);
             return data;
         }
     }
 
-    /**
-     * Returns the number of bytes that are required to serialize this record.
-     *
-     * @return Number of bytes
-     */
-    public int getRecordSize()
-    {
+    public int getRecordSize() {
         return 8 + 50 + raw_pictureData.length;
     }
 
-    public byte[] getUID()
-    {
+    public byte[] getUID() {
         return field_1_UID;
     }
 
-    public void setUID( byte[] field_1_UID )
-    {
-        this.field_1_UID = field_1_UID;
+    public void setUID(byte[] uid) {
+        this.field_1_UID = uid;
     }
 
-    public int getUncompressedSize()
-    {
+    public int getUncompressedSize() {
         return field_2_cb;
     }
 
-    public void setUncompressedSize(int uncompressedSize)
-    {
+    public void setUncompressedSize(int uncompressedSize) {
         field_2_cb = uncompressedSize;
     }
 
-    public Rectangle getBounds()
-    {
+    public Rectangle getBounds() {
         return new Rectangle(field_3_rcBounds_x1,
                              field_3_rcBounds_y1,
                              field_3_rcBounds_x2 - field_3_rcBounds_x1,
                              field_3_rcBounds_y2 - field_3_rcBounds_y1);
     }
 
-    public void setBounds(Rectangle bounds)
-    {
+    public void setBounds(Rectangle bounds) {
         field_3_rcBounds_x1 = bounds.x;
         field_3_rcBounds_y1 = bounds.y;
         field_3_rcBounds_x2 = bounds.x + bounds.width;
         field_3_rcBounds_y2 = bounds.y + bounds.height;
     }
 
-    public Dimension getSizeEMU()
-    {
+    public Dimension getSizeEMU() {
         return new Dimension(field_4_ptSize_w, field_4_ptSize_h);
     }
 
-    public void setSizeEMU(Dimension sizeEMU)
-    {
+    public void setSizeEMU(Dimension sizeEMU) {
         field_4_ptSize_w = sizeEMU.width;
         field_4_ptSize_h = sizeEMU.height;
     }
 
-    public int getCompressedSize()
-    {
+    public int getCompressedSize() {
         return field_5_cbSave;
     }
 
-    public void setCompressedSize(int compressedSize)
-    {
+    public void setCompressedSize(int compressedSize) {
         field_5_cbSave = compressedSize;
     }
 
-    public boolean isCompressed()
-    {
+    public boolean isCompressed() {
         return (field_6_fCompression == 0);
     }
 
-    public void setCompressed(boolean compressed)
-    {
+    public void setCompressed(boolean compressed) {
         field_6_fCompression = compressed ? 0 : (byte)0xFE;
     }
 
     // filtering is always 254 according to available docs, so no point giving it a setter method.
 
-    public String toString()
-    {
-        String nl = System.getProperty( "line.separator" );
-
-        String extraData;
-        ByteArrayOutputStream b = new ByteArrayOutputStream();
-        try
-        {
-            HexDump.dump( this.field_pictureData, 0, b, 0 );
-            extraData = b.toString();
-        }
-        catch ( Exception e )
-        {
-            extraData = e.toString();
-        }
-        return getClass().getName() + ":" + nl +
-                "  RecordId: 0x" + HexDump.toHex( getRecordId() ) + nl +
-                "  Options: 0x" + HexDump.toHex( getOptions() ) + nl +
-                "  UID: 0x" + HexDump.toHex( field_1_UID ) + nl +
-                "  Uncompressed Size: " + HexDump.toHex( field_2_cb ) + nl +
-                "  Bounds: " + getBounds() + nl +
-                "  Size in EMU: " + getSizeEMU() + nl +
-                "  Compressed Size: " + HexDump.toHex( field_5_cbSave ) + nl +
-                "  Compression: " + HexDump.toHex( field_6_fCompression ) + nl +
-                "  Filter: " + HexDump.toHex( field_7_fFilter ) + nl +
-                "  Extra Data:" + nl + extraData;
+    public String toString() {
+        String extraData = HexDump.toHex(field_pictureData, 32);
+        return getClass().getName() + ":" + '\n' +
+                "  RecordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' +
+                "  Options: 0x" + HexDump.toHex( getOptions() ) + '\n' +
+                "  UID: 0x" + HexDump.toHex( field_1_UID ) + '\n' +
+                "  Uncompressed Size: " + HexDump.toHex( field_2_cb ) + '\n' +
+                "  Bounds: " + getBounds() + '\n' +
+                "  Size in EMU: " + getSizeEMU() + '\n' +
+                "  Compressed Size: " + HexDump.toHex( field_5_cbSave ) + '\n' +
+                "  Compression: " + HexDump.toHex( field_6_fCompression ) + '\n' +
+                "  Filter: " + HexDump.toHex( field_7_fFilter ) + '\n' +
+                "  Extra Data:" + '\n' + extraData;
     }
-
 }

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherProperties.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherProperties.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherProperties.java Tue May 19 19:21:12 2009
@@ -15,7 +15,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 import java.util.HashMap;

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherProperty.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherProperty.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherProperty.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherProperty.java Tue May 19 19:21:12 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 /**
@@ -25,61 +24,52 @@
  *
  * @author Glen Stampoultzis (glens at apache.org)
  */
-abstract public class EscherProperty
-{
-    protected short  id;
+public abstract class EscherProperty {
+    private short  _id;
 
     /**
      * The id is distinct from the actual property number.  The id includes the property number the blip id
      * flag and an indicator whether the property is complex or not.
      */
-    public EscherProperty( short id )
-    {
-        this.id   = id;
+    public EscherProperty(short id) {
+        _id   = id;
     }
 
     /**
      * Constructs a new escher property.  The three parameters are combined to form a property
      * id.
      */
-    public EscherProperty( short propertyNumber, boolean isComplex, boolean isBlipId )
-    {
-        this.id   = (short)(propertyNumber +
+    public EscherProperty(short propertyNumber, boolean isComplex, boolean isBlipId) {
+        _id   = (short)(propertyNumber +
                 (isComplex ? 0x8000 : 0x0) +
                 (isBlipId ? 0x4000 : 0x0));
     }
 
-    public short getId()
-    {
-        return id;
+    public short getId() {
+        return _id;
     }
 
-    public short getPropertyNumber()
-    {
-        return (short) ( id & (short) 0x3FFF );
+    public short getPropertyNumber() {
+        return (short) (_id & (short) 0x3FFF);
     }
 
-    public boolean isComplex()
-    {
-        return ( id & (short) 0x8000 ) != 0;
+    public boolean isComplex() {
+        return (_id & (short) 0x8000) != 0;
     }
 
-    public boolean isBlipId()
-    {
-        return ( id & (short) 0x4000 ) != 0;
+    public boolean isBlipId() {
+        return (_id & (short) 0x4000) != 0;
     }
 
-    public String getName()
-    {
-        return EscherProperties.getPropertyName(id);
+    public String getName() {
+        return EscherProperties.getPropertyName(_id);
     }
 
     /**
      * Most properties are just 6 bytes in length.  Override this if we're
      * dealing with complex properties.
      */
-    public int getPropertySize()
-    {
+    public int getPropertySize() {
         return 6;
     }
 

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherPropertyFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherPropertyFactory.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherPropertyFactory.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherPropertyFactory.java Tue May 19 19:21:12 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 import org.apache.poi.util.LittleEndian;
@@ -29,8 +28,7 @@
  *
  * @author Glen Stampoultzis
  */
-public class EscherPropertyFactory
-{
+public final class EscherPropertyFactory {
     /**
      * Create new properties from a byte array.
      *
@@ -38,15 +36,13 @@
      * @param offset            The starting offset into the byte array
      * @return                  The new properties
      */
-    public List createProperties( byte[] data, int offset, short numProperties )
-    {
-        List results = new ArrayList();
+    public List<EscherProperty> createProperties(byte[] data, int offset, short numProperties) {
+        List<EscherProperty> results = new ArrayList<EscherProperty>();
 
         int pos = offset;
 
 //        while ( bytesRemaining >= 6 )
-        for (int i = 0; i < numProperties; i++)
-        {
+        for (int i = 0; i < numProperties; i++) {
             short propId;
             int propData;
             propId = LittleEndian.getShort( data, pos );
@@ -55,7 +51,7 @@
             boolean isComplex = ( propId & (short) 0x8000 ) != 0;
             boolean isBlipId = ( propId & (short) 0x4000 ) != 0;
 
-            byte propertyType = EscherProperties.getPropertyType( (short) propNumber );
+            byte propertyType = EscherProperties.getPropertyType(propNumber);
             if ( propertyType == EscherPropertyMetaData.TYPE_BOOLEAN )
                 results.add( new EscherBoolProperty( propId, propData ) );
             else if ( propertyType == EscherPropertyMetaData.TYPE_RGB )
@@ -72,7 +68,6 @@
                         results.add( new EscherArrayProperty( propId, new byte[propData]) );
                     else
                         results.add( new EscherComplexProperty( propId, new byte[propData]) );
-
                 }
             }
             pos += 6;
@@ -80,26 +75,18 @@
         }
 
         // Get complex data
-        for ( Iterator iterator = results.iterator(); iterator.hasNext(); )
-        {
-            EscherProperty p = (EscherProperty) iterator.next();
-            if (p instanceof EscherComplexProperty)
-            {
-                if (p instanceof EscherArrayProperty)
-                {
+        for (Iterator<EscherProperty> iterator = results.iterator(); iterator.hasNext();) {
+            EscherProperty p = iterator.next();
+            if (p instanceof EscherComplexProperty) {
+                if (p instanceof EscherArrayProperty) {
                     pos += ((EscherArrayProperty)p).setArrayData(data, pos);
-                }
-                else
-                {
+                } else {
                     byte[] complexData = ((EscherComplexProperty)p).getComplexData();
                     System.arraycopy(data, pos, complexData, 0, complexData.length);
                     pos += complexData.length;
                 }
             }
         }
-
         return results;
     }
-
-
 }

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherPropertyMetaData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherPropertyMetaData.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherPropertyMetaData.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherPropertyMetaData.java Tue May 19 19:21:12 2009
@@ -15,7 +15,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 /**

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherRGBProperty.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherRGBProperty.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherRGBProperty.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherRGBProperty.java Tue May 19 19:21:12 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 /**

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherRecord.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherRecord.java Tue May 19 19:21:12 2009
@@ -15,7 +15,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 import org.apache.poi.util.LittleEndian;

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherRecordFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherRecordFactory.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherRecordFactory.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherRecordFactory.java Tue May 19 19:21:12 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 /**
@@ -24,8 +23,7 @@
  *
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public interface EscherRecordFactory
-{
+public interface EscherRecordFactory {
     /**
      * Create a new escher record from the data provided.  Does not attempt
      * to fill the contents of the record however.

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherSerializationListener.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherSerializationListener.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherSerializationListener.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherSerializationListener.java Tue May 19 19:21:12 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 /**

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherShapePathProperty.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherShapePathProperty.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherShapePathProperty.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherShapePathProperty.java Tue May 19 19:21:12 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 /**
@@ -23,9 +22,7 @@
  *
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class EscherShapePathProperty
-        extends EscherSimpleProperty
-{
+public class EscherShapePathProperty extends EscherSimpleProperty {
 
     public static final int LINE_OF_STRAIGHT_SEGMENTS = 0;
     public static final int CLOSED_POLYGON = 1;
@@ -37,7 +34,4 @@
     {
         super( propertyNumber, false, false, shapePath );
     }
-
-
-
 }

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherSimpleProperty.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherSimpleProperty.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherSimpleProperty.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherSimpleProperty.java Tue May 19 19:21:12 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 import org.apache.poi.util.LittleEndian;

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherSpRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherSpRecord.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherSpRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherSpRecord.java Tue May 19 19:21:12 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 import org.apache.poi.util.HexDump;
@@ -49,16 +48,7 @@
     private int field_1_shapeId;
     private int field_2_flags;
 
-    /**
-     * This method deserializes the record from a byte array.
-     *
-     * @param data          The byte array containing the escher record information
-     * @param offset        The starting offset into <code>data</code>.
-     * @param recordFactory May be null since this is not a container record.
-     * @return The number of bytes read from the byte array.
-     */
-    public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory )
-    {
+    public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
         int bytesRemaining = readHeader( data, offset );
         int pos            = offset + 8;
         int size           = 0;
@@ -95,32 +85,20 @@
         return 8 + 8;
     }
 
-    /**
-     * Returns the number of bytes that are required to serialize this record.
-     *
-     * @return Number of bytes
-     */
     public int getRecordSize()
     {
         return 8 + 8;
     }
 
-    /**
-     * @return  the 16 bit identifier for this record.
-     */
-    public short getRecordId()
-    {
+    public short getRecordId() {
         return RECORD_ID;
     }
 
-    /**
-     * The short name for this record
-     */
-    public String getRecordName()
-    {
+    public String getRecordName() {
         return "Sp";
     }
 
+
     /**
      * @return  the string representing this shape.
      */

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherSpgrRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherSpgrRecord.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherSpgrRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherSpgrRecord.java Tue May 19 19:21:12 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 import org.apache.poi.util.HexDump;
@@ -39,16 +38,7 @@
     private int field_3_rectX2;
     private int field_4_rectY2;
 
-    /**
-     * This method deserializes the record from a byte array.
-     *
-     * @param data          The byte array containing the escher record information
-     * @param offset        The starting offset into <code>data</code>.
-     * @param recordFactory May be null since this is not a container record.
-     * @return The number of bytes read from the byte array.
-     */
-    public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory )
-    {
+    public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
         int bytesRemaining = readHeader( data, offset );
         int pos            = offset + 8;
         int size           = 0;
@@ -63,16 +53,6 @@
         return 8 + size + bytesRemaining;
     }
 
-    /**
-     * This method serializes this escher record into a byte array.
-     *
-     * @param offset   The offset into <code>data</code> to start writing the record data to.
-     * @param data     The byte array to serialize to.
-     * @param listener A listener to retrieve start and end callbacks.  Use a <code>NullEscherSerailizationListener</code> to ignore these events.
-     * @return The number of bytes written.
-     *
-     * @see NullEscherSerializationListener
-     */
     public int serialize( int offset, byte[] data, EscherSerializationListener listener )
     {
         listener.beforeRecordSerialize( offset, getRecordId(), this );
@@ -90,58 +70,30 @@
         return 8 + 16;
     }
 
-    /**
-     * Returns the number of bytes that are required to serialize this record.
-     *
-     * @return Number of bytes
-     */
     public int getRecordSize()
     {
         return 8 + 16;
     }
 
-    /**
-     * The 16 bit identifier of this shape group record.
-     */
-    public short getRecordId()
-    {
+    public short getRecordId() {
         return RECORD_ID;
     }
 
-    /**
-     * The short name for this record
-     */
-    public String getRecordName()
-    {
+    public String getRecordName() {
         return "Spgr";
     }
 
     /**
      * @return  the string representation of this record.
      */
-    public String toString()
-    {
-        String nl = System.getProperty("line.separator");
-
-//        String extraData;
-//        ByteArrayOutputStream b = new ByteArrayOutputStream();
-//        try
-//        {
-//            HexDump.dump(this.remainingData, 0, b, 0);
-//            extraData = b.toString();
-//        }
-//        catch ( Exception e )
-//        {
-//            extraData = "error";
-//        }
-        return getClass().getName() + ":" + nl +
-                "  RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl +
-                "  Options: 0x" + HexDump.toHex(getOptions()) + nl +
-                "  RectX: " + field_1_rectX1 + nl +
-                "  RectY: " + field_2_rectY1 + nl +
-                "  RectWidth: " + field_3_rectX2 + nl +
-                "  RectHeight: " + field_4_rectY2 + nl;
-
+    public String toString() {
+        return getClass().getName() + ":" + '\n' +
+                "  RecordId: 0x" + HexDump.toHex(RECORD_ID) + '\n' +
+                "  Options: 0x" + HexDump.toHex(getOptions()) + '\n' +
+                "  RectX: " + field_1_rectX1 + '\n' +
+                "  RectY: " + field_2_rectY1 + '\n' +
+                "  RectWidth: " + field_3_rectX2 + '\n' +
+                "  RectHeight: " + field_4_rectY2 + '\n';
     }
 
     /**
@@ -203,8 +155,7 @@
     /**
      * The starting bottom-right coordinate of child records.
      */
-    public void setRectY2( int field_4_rectY2 )
-    {
-        this.field_4_rectY2 = field_4_rectY2;
+    public void setRectY2(int rectY2) {
+        this.field_4_rectY2 = rectY2;
     }
 }

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherSplitMenuColorsRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherSplitMenuColorsRecord.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherSplitMenuColorsRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherSplitMenuColorsRecord.java Tue May 19 19:21:12 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 import org.apache.poi.util.HexDump;
@@ -39,16 +38,7 @@
     private int field_3_color3;
     private int field_4_color4;
 
-    /**
-     * This method deserializes the record from a byte array.
-     *
-     * @param data          The byte array containing the escher record information
-     * @param offset        The starting offset into <code>data</code>.
-     * @param recordFactory May be null since this is not a container record.
-     * @return The number of bytes read from the byte array.
-     */
-    public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory )
-    {
+    public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
         int bytesRemaining = readHeader( data, offset );
         int pos            = offset + 8;
         int size           = 0;
@@ -62,16 +52,6 @@
         return 8 + size + bytesRemaining;
     }
 
-    /**
-     * This method serializes this escher record into a byte array.
-     *
-     * @param offset   The offset into <code>data</code> to start writing the record data to.
-     * @param data     The byte array to serialize to.
-     * @param listener A listener to retrieve start and end callbacks.  Use a <code>NullEscherSerailizationListener</code> to ignore these events.
-     * @return The number of bytes written.
-     *
-     * @see NullEscherSerializationListener
-     */
     public int serialize( int offset, byte[] data, EscherSerializationListener listener )
     {
 //        int field_2_numIdClusters = field_5_fileIdClusters.length + 1;
@@ -91,59 +71,31 @@
         return getRecordSize();
     }
 
-    /**
-     * Returns the number of bytes that are required to serialize this record.
-     *
-     * @return Number of bytes
-     */
     public int getRecordSize()
     {
         return 8 + 4 * 4;
     }
 
-    /**
-     * @return  the 16 bit identifer for this record.
-     */
-    public short getRecordId()
-    {
+    public short getRecordId() {
         return RECORD_ID;
     }
 
-    /**
-     * The short name for this record
-     */
-    public String getRecordName()
-    {
+    public String getRecordName() {
         return "SplitMenuColors";
     }
 
     /**
      * @return  a string representation of this record.
      */
-    public String toString()
-    {
-        String nl = System.getProperty("line.separator");
-
-//        String extraData;
-//        ByteArrayOutputStream b = new ByteArrayOutputStream();
-//        try
-//        {
-//            HexDump.dump(this.remainingData, 0, b, 0);
-//            extraData = b.toString();
-//        }
-//        catch ( Exception e )
-//        {
-//            extraData = "error";
-//        }
-        return getClass().getName() + ":" + nl +
-                "  RecordId: 0x" + HexDump.toHex(RECORD_ID) + nl +
-                "  Options: 0x" + HexDump.toHex(getOptions()) + nl +
-                "  Color1: 0x" + HexDump.toHex(field_1_color1) + nl +
-                "  Color2: 0x" + HexDump.toHex(field_2_color2) + nl +
-                "  Color3: 0x" + HexDump.toHex(field_3_color3) + nl +
-                "  Color4: 0x" + HexDump.toHex(field_4_color4) + nl +
+    public String toString() {
+        return getClass().getName() + ":" + '\n' +
+                "  RecordId: 0x" + HexDump.toHex(RECORD_ID) + '\n' +
+                "  Options: 0x" + HexDump.toHex(getOptions()) + '\n' +
+                "  Color1: 0x" + HexDump.toHex(field_1_color1) + '\n' +
+                "  Color2: 0x" + HexDump.toHex(field_2_color2) + '\n' +
+                "  Color3: 0x" + HexDump.toHex(field_3_color3) + '\n' +
+                "  Color4: 0x" + HexDump.toHex(field_4_color4) + '\n' +
                 "";
-
     }
 
     public int getColor1()

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherTextboxRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherTextboxRecord.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherTextboxRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherTextboxRecord.java Tue May 19 19:21:12 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 import org.apache.poi.util.HexDump;
@@ -24,7 +23,7 @@
 
 /**
  * Holds data from the parent application. Most commonly used to store
- *  text in the format of the parent application, rather than in 
+ *  text in the format of the parent application, rather than in
  *  Escher format. We don't attempt to understand the contents, since
  *  they will be in the parent's format, not Escher format.
  *
@@ -45,16 +44,7 @@
     {
     }
 
-    /**
-     * This method deserializes the record from a byte array.
-     *
-     * @param data          The byte array containing the escher record information
-     * @param offset        The starting offset into <code>data</code>.
-     * @param recordFactory May be null since this is not a container record.
-     * @return The number of bytes read from the byte array.
-     */
-    public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory )
-    {
+    public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
         int bytesRemaining = readHeader( data, offset );
 
         // Save the data, ready for the calling code to do something
@@ -64,12 +54,6 @@
         return bytesRemaining + 8;
     }
 
-    /**
-     * Writes this record and any contained records to the supplied byte
-     * array.
-     *
-     * @return  the number of bytes written.
-     */
     public int serialize( int offset, byte[] data, EscherSerializationListener listener )
     {
         listener.beforeRecordSerialize( offset, getRecordId(), this );
@@ -113,12 +97,6 @@
         setData(b,0,b.length);
     }
 
-
-    /**
-     * Returns the number of bytes that are required to serialize this record.
-     *
-     * @return Number of bytes
-     */
     public int getRecordSize()
     {
         return 8 + thedata.length;
@@ -130,11 +108,7 @@
         return super.clone();
     }
 
-    /**
-     * The short name for this record
-     */
-    public String getRecordName()
-    {
+    public String getRecordName() {
         return "ClientTextbox";
     }
 

Modified: poi/trunk/src/java/org/apache/poi/ddf/NullEscherSerializationListener.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/NullEscherSerializationListener.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/NullEscherSerializationListener.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/NullEscherSerializationListener.java Tue May 19 19:21:12 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
 /**
@@ -23,16 +22,12 @@
  *
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class NullEscherSerializationListener implements EscherSerializationListener
-{
-    public void beforeRecordSerialize( int offset, short recordId, EscherRecord record )
-    {
+public class NullEscherSerializationListener implements EscherSerializationListener {
+    public void beforeRecordSerialize(int offset, short recordId, EscherRecord record) {
         // do nothing
     }
 
-    public void afterRecordSerialize( int offset, short recordId, int size, EscherRecord record )
-    {
+    public void afterRecordSerialize(int offset, short recordId, int size, EscherRecord record) {
         // do nothing
     }
-
 }

Modified: poi/trunk/src/java/org/apache/poi/ddf/UnknownEscherRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/UnknownEscherRecord.java?rev=776424&r1=776423&r2=776424&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/UnknownEscherRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/UnknownEscherRecord.java Tue May 19 19:21:12 2009
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,47 +14,35 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.ddf;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.poi.util.HexDump;
 import org.apache.poi.util.LittleEndian;
 
-import java.util.Iterator;
-import java.util.List;
-import java.util.ArrayList;
-
 /**
  * This record is used whenever a escher record is encountered that
  * we do not explicitly support.
  *
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class UnknownEscherRecord extends EscherRecord
-{
+public final class UnknownEscherRecord extends EscherRecord {
     private static final byte[] NO_BYTES = new byte[0];
 
     /** The data for this record not including the the 8 byte header */
     private byte[] thedata = NO_BYTES;
-    private List childRecords = new ArrayList();
+    private List<EscherRecord> _childRecords;
 
-    public UnknownEscherRecord()
-    {
+    public UnknownEscherRecord() {
+        _childRecords = new ArrayList<EscherRecord>();
     }
 
-    /**
-     * This method deserializes the record from a byte array.
-     *
-     * @param data          The byte array containing the escher record information
-     * @param offset        The starting offset into <code>data</code>.
-     * @param recordFactory May be null since this is not a container record.
-     * @return The number of bytes read from the byte array.
-     */
-    public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory )
-    {
+    public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
         int bytesRemaining = readHeader( data, offset );
-        if ( isContainerRecord() )
-        {
+        if (isContainerRecord()) {
             int bytesWritten = 0;
             thedata = new byte[0];
             offset += 8;
@@ -71,38 +58,24 @@
             }
             return bytesWritten;
         }
-        else
-        {
-            thedata = new byte[bytesRemaining];
-            System.arraycopy( data, offset + 8, thedata, 0, bytesRemaining );
-            return bytesRemaining + 8;
-        }
+        thedata = new byte[bytesRemaining];
+        System.arraycopy( data, offset + 8, thedata, 0, bytesRemaining );
+        return bytesRemaining + 8;
     }
 
-    /**
-     * Writes this record and any contained records to the supplied byte
-     * array.
-     *
-     * @return  the number of bytes written.
-     */
-    public int serialize( int offset, byte[] data, EscherSerializationListener listener )
-    {
+    public int serialize(int offset, byte[] data, EscherSerializationListener listener) {
         listener.beforeRecordSerialize( offset, getRecordId(), this );
 
         LittleEndian.putShort(data, offset, getOptions());
         LittleEndian.putShort(data, offset+2, getRecordId());
         int remainingBytes = thedata.length;
-        for ( Iterator iterator = getChildRecords().iterator(); iterator.hasNext(); )
-        {
-            EscherRecord r = (EscherRecord) iterator.next();
+        for (EscherRecord r : _childRecords) {
             remainingBytes += r.getRecordSize();
         }
         LittleEndian.putInt(data, offset+4, remainingBytes);
         System.arraycopy(thedata, 0, data, offset+8, thedata.length);
         int pos = offset+8+thedata.length;
-        for ( Iterator iterator = getChildRecords().iterator(); iterator.hasNext(); )
-        {
-            EscherRecord r = (EscherRecord) iterator.next();
+        for (EscherRecord r : _childRecords) {
             pos += r.serialize(pos, data, listener );
         }
 
@@ -110,90 +83,53 @@
         return pos - offset;
     }
 
-    public byte[] getData()
-    {
+    public byte[] getData() {
         return thedata;
     }
 
-    /**
-     * Returns the number of bytes that are required to serialize this record.
-     *
-     * @return Number of bytes
-     */
-    public int getRecordSize()
-    {
+    public int getRecordSize() {
         return 8 + thedata.length;
     }
 
-    public List getChildRecords()
-    {
-        return childRecords;
+    public List<EscherRecord> getChildRecords() {
+        return _childRecords;
     }
 
-    public void setChildRecords( List childRecords )
-    {
-        this.childRecords = childRecords;
+    public void setChildRecords(List<EscherRecord> childRecords) {
+        _childRecords = childRecords;
     }
 
-    public Object clone()
-    {
+    public Object clone() {
         // shallow clone
         return super.clone();
     }
 
-    /**
-     * The short name for this record
-     */
-    public String getRecordName()
-    {
+    public String getRecordName() {
         return "Unknown 0x" + HexDump.toHex(getRecordId());
     }
 
-    public String toString()
-    {
-        String nl = System.getProperty( "line.separator" );
-
+    public String toString() {
         StringBuffer children = new StringBuffer();
-        if ( getChildRecords().size() > 0 )
-        {
-            children.append( "  children: " + nl );
-            for ( Iterator iterator = getChildRecords().iterator(); iterator.hasNext(); )
-            {
-                EscherRecord record = (EscherRecord) iterator.next();
+        if (getChildRecords().size() > 0) {
+            children.append( "  children: " + '\n' );
+            for (EscherRecord record : _childRecords) {
                 children.append( record.toString() );
-                children.append( nl );
+                children.append( '\n' );
             }
         }
 
-        String theDumpHex = "";
-        try
-        {
-            if (thedata.length != 0)
-            {
-                theDumpHex = "  Extra Data("+thedata.length+"):" + nl;
-                theDumpHex += HexDump.dump(thedata, 0, 0);
-            }
-        }
-        catch ( Exception e )
-        {
-            theDumpHex = "Error!!";
-        }
+        String theDumpHex = HexDump.toHex(thedata, 32);
 
-        return getClass().getName() + ":" + nl +
-                "  isContainer: " + isContainerRecord() + nl +
-                "  options: 0x" + HexDump.toHex( getOptions() ) + nl +
-                "  recordId: 0x" + HexDump.toHex( getRecordId() ) + nl +
-                "  numchildren: " + getChildRecords().size() + nl +
+        return getClass().getName() + ":" + '\n' +
+                "  isContainer: " + isContainerRecord() + '\n' +
+                "  options: 0x" + HexDump.toHex( getOptions() ) + '\n' +
+                "  recordId: 0x" + HexDump.toHex( getRecordId() ) + '\n' +
+                "  numchildren: " + getChildRecords().size() + '\n' +
                 theDumpHex +
                 children.toString();
     }
 
-    public void addChildRecord( EscherRecord childRecord )
-    {
+    public void addChildRecord(EscherRecord childRecord) {
         getChildRecords().add( childRecord );
     }
-
 }
-
-
-



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org