sackley     02/04/19 15:30:50

  Modified:    src/java/org/apache/poi/util LittleEndian.java HexDump.java
  Log:
  Made some changes for HDF types
  
  Revision  Changes    Path
  1.5       +29 -4     jakarta-poi/src/java/org/apache/poi/util/LittleEndian.java
  
  Index: LittleEndian.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/util/LittleEndian.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LittleEndian.java 20 Mar 2002 12:35:26 -0000      1.4
  +++ LittleEndian.java 19 Apr 2002 22:30:50 -0000      1.5
  @@ -95,12 +95,10 @@
       }
   
       /**
  -     * get a short array from a byte array.  The short array is assumed
  -     * to start with a word describing the length of the array.
  +     * get a short array from a byte array.
        */
  -    public static short[] getShortArray(final byte[] data, final int offset)
  +    public static short[] getSimpleShortArray(final byte[] data, final int offset, 
final int size)
       {
  -        int size = (short) getNumber(data, offset, SHORT_SIZE);
           short[] results = new short[size];
           for (int i = 0; i < size; i++)
           {
  @@ -108,6 +106,16 @@
           }
           return results;
       }
  +    /**
  +     * get a short array from a byte array.  The short array is assumed
  +     * to start with a word describing the length of the array.
  +     */
  +    public static short[] getShortArray(final byte[] data, final int offset)
  +    {
  +        int size = (short) getNumber(data, offset, SHORT_SIZE);
  +        short[] results = getSimpleShortArray(data, offset, size);
  +        return results;
  +    }
   
       /**
        * get a short value from the beginning of a byte array
  @@ -565,6 +573,23 @@
       public static int getUnsignedByte(final byte[] data)
       {
           return getUnsignedByte(data, 0);
  +    }
  +    /**
  +     * Copy a portion of a byte array
  +     *
  +     * @param data the original byte array
  +     * @param offset Where to start copying from.
  +     * @param size Number of bytes to copy.
  +     *
  +     * @throws IndexOutOfBoundsException - if copying would cause access of data
  +     *                                     outside array bounds.
  +     */
  +    public static byte[] getByteArray(final byte[] data, int offset, int size)
  +    {
  +        byte[] copy = new byte[size];
  +        System.arraycopy(data, offset, copy, 0, size);
  +
  +        return copy;
       }
   
   }
  
  
  
  1.3       +18 -0     jakarta-poi/src/java/org/apache/poi/util/HexDump.java
  
  Index: HexDump.java
  ===================================================================
  RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/util/HexDump.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HexDump.java      10 Feb 2002 04:32:06 -0000      1.2
  +++ HexDump.java      19 Apr 2002 22:30:50 -0000      1.3
  @@ -187,6 +187,24 @@
        * Converts the parameter to a hex value.
        *
        * @param value     The value to convert
  +     * @return          A String representing the array of bytes
  +     */
  +    public static String toHex(final byte[] value)
  +    {
  +        StringBuffer retVal = new StringBuffer();
  +        retVal.append('[');
  +        for(int x = 0; x < value.length; x++)
  +        {
  +            retVal.append(toHex(value[x]));
  +            retVal.append(", ");
  +        }
  +        retVal.append(']');
  +        return retVal.toString();
  +    }
  +    /**
  +     * Converts the parameter to a hex value.
  +     *
  +     * @param value     The value to convert
        * @return          The result right padded with 0
        */
       public static String toHex(final short value)
  
  
  


Reply via email to