Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Cryptix V3.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## cryptix.util.core
Class ArrayUtil

    java.lang.Object
      |
      +--cryptix.util.core.ArrayUtil

public class ArrayUtil
extends Object

Static methods for converting between arrays of various types, for clearing all or part of a byte array, and for comparing two byte arrays.

Copyright © 1997 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.6 $

Since:
  Cryptix 2.2.2
Author:
  Raif Naffah, David Hopwood, Ian Brown

Method Summary
`static boolean` | `areEqual(byte[] a, byte[] b)` Compares two byte arrays for equality.
`static boolean` | `areEqual(int[] a, int[] b)` Compares two int arrays for equality.
`static void` | `clear(byte[] buf)` Clears a byte array to all-zeroes.
`static void` | `clear(byte[] buf, int offset, int length)` Clears length bytes of a byte array to zeroes, starting at offset.
`static int` | `compared(byte[] a, byte[] b, boolean msbFirst)`
`static boolean` | `isText(byte[] buffer)`
`static byte[]` | `toBytes(int n)` Returns a 4-byte array built from an int.
`static byte[]` | `toBytes(short[] array)`
`static byte[]` | `toBytes(short[] array, int offset, int length)` Returns a byte array built from a short array.
`static int` | `toInt(short s0, short s1)` Returns an int built from two shorts.
`static short` | `toShort(byte b0, byte b1)` Returns a short built from two bytes.
`static short[]` | `toShorts(byte[] array)`
`static short[]` | `toShorts(byte[] array, int offset, int length)` Returns a short array built from a byte array.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### clear

    public static void clear(byte[] buf)

  Clears a byte array to all-zeroes.

### clear

    public static void clear(byte[] buf,
                             int offset,
                             int length)

  Clears length bytes of a byte array to zeroes, starting at offset.

### toInt

    public static int toInt(short s0,
                            short s1)

  Returns an int built from two shorts.
  Parameters:
    `s0` - the least significant short
    `s1` - the most significant short

### toShort

    public static short toShort(byte b0,
                                byte b1)

  Returns a short built from two bytes.
  Parameters:
    `b0` - the least significant byte
    `b1` - the most significant byte

### toBytes

    public static byte[] toBytes(int n)

  Returns a 4-byte array built from an int. The int's MSB is first (big-endian order).

### toBytes

    public static byte[] toBytes(short[] array,
                                 int offset,
                                 int length)

  Returns a byte array built from a short array. Each short is broken into 2 bytes with the short's MSB first (big-endian order).

  If offset and length are omitted, the whole array is used.

### toBytes

    public static byte[] toBytes(short[] array)

### toShorts

    public static short[] toShorts(byte[] array,
                                   int offset,
                                   int length)

  Returns a short array built from a byte array. Each 2 bytes form a short with the first byte as the short's MSB (big-endian order).

  If offset and length are omitted, the whole array is used.

### toShorts

    public static short[] toShorts(byte[] array)

### areEqual

    public static boolean areEqual(byte[] a,
                                   byte[] b)

  Compares two byte arrays for equality.
  Returns:
    true if the arrays have identical contents

### areEqual

    public static boolean areEqual(int[] a,
                                   int[] b)

  Compares two int arrays for equality.
  Returns:
    true if the arrays have identical contents

### compared

    public static int compared(byte[] a,
                               byte[] b,
                               boolean msbFirst)

### isText

    public static boolean isText(byte[] buffer)

  Returns:
    true If the data in the byte array consists of just text.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Cryptix V3.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) 1995-2000 The Cryptix Foundation Ltd. All rights reserved.