Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hyperic.util
Class ArrayUtil

    java.lang.Object
      org.hyperic.util.ArrayUtil

    public class ArrayUtil

extends java.lang.Object

Constructor Summary
`ArrayUtil()`

Method Summary
`static double` | `average(double[] values)` Get the average of an array of values.
`static byte[]` | `clone(byte[] orig)` Clone a byte array, maintaining awareness of null arrays
`static java.lang.Object[]` | `combine(java.lang.Object[] a1, java.lang.Object[] a2)` Combine two arrays into a single, larger array.
`static boolean` | `equals(java.lang.Object[] a1, java.lang.Object[] a2)` Array equality
`static boolean` | `exists(java.lang.Object[] array, java.lang.Object element)` Return a boolean whether or not the element exists in the array
`static int` | `find(java.lang.Object[] array, java.lang.Object element)` Find the index of the first appearance of an object in the array
`static int` | `findMinDiff(double[] values)` Find the 2 values with the smallest difference between them.
`static boolean` | `isUniq(java.lang.String[] values)` Check to see if a _sorted_ array of values contains all unique values.
`static int` | `max(double[] values)` Find the maximum value in an array of double values.
`static int` | `max(int[] values)` Find the maximum value in an array of int values.
`static java.lang.Object[]` | `merge(java.lang.Object[][] arrays, java.lang.Object[] arrType)`
`static java.lang.Object[]` | `merge(java.lang.Object[] one, java.lang.Object[] two, java.lang.Object[] arrType)`
`static int` | `min(double[] values)` Find the minimum value in an array of double values.
`static int[]` | `stringToInt(java.lang.String[] array)` Convert a string array to an array of int.
`static java.lang.Integer[]` | `stringToInteger(java.lang.String[] array)` Convert a string array to an array of Integer.
`static java.lang.String` | `toString(java.lang.Object[] array)`
`static double[]` | `uniq(double[] values)` Return an array of values where every value is unique.

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

Constructor Detail

### ArrayUtil

    public ArrayUtil()

Method Detail

### toString

    public static java.lang.String toString(java.lang.Object[] array)

### merge

    public static java.lang.Object[] merge(java.lang.Object[][] arrays,
                                           java.lang.Object[] arrType)

### merge

    public static java.lang.Object[] merge(java.lang.Object[] one,
                                           java.lang.Object[] two,
                                           java.lang.Object[] arrType)

### max

    public static int max(double[] values)

  Find the maximum value in an array of double values.

  Parameters:
    `values` - Values to search for to find the max of
  Returns:
    The index of the maximum value, or -1 if 'values' was 0 length

### max

    public static int max(int[] values)

  Find the maximum value in an array of int values.

  Parameters:
    `values` - Values to search for to find the max of
  Returns:
    The index of the maximum value, or -1 if 'values' was 0 length

### min

    public static int min(double[] values)

  Find the minimum value in an array of double values.

  Parameters:
    `values` - Values to search for to find the min of
  Returns:
    The index of the minimum value, or -1 if 'values' was 0 length

### average

    public static double average(double[] values)

  Get the average of an array of values.

### uniq

    public static double[] uniq(double[] values)

  Return an array of values where every value is unique.

  Parameters:
    `values` - Values to get the unique of. Note that this array _must_ be sorted, prior to invoking this method
  Returns:
    a new array with values represented in the 'values' argument only a single time each

### isUniq

    public static boolean isUniq(java.lang.String[] values)

  Check to see if a _sorted_ array of values contains all unique values.

### equals

    public static boolean equals(java.lang.Object[] a1,
                                 java.lang.Object[] a2)

  Array equality

  Returns:
    true if both arrays contain elements in the same positions that are also equal. Returns false if either (or both) arrays are null;

### findMinDiff

    public static int findMinDiff(double[] values)

  Find the 2 values with the smallest difference between them. In the case of a tie, the earlier value in the array will be returned. Ex: findMinDiff({1, 2, 3, 4, 5}) -> 0 findMinDiff({1, 2, 2.2, 3, 4, 5}) -> 1

  Parameters:
    `values` - An array of _sorted_, _unique_ values
  Returns:
    The index of the first number in the pair with the smallest difference.

### exists

    public static boolean exists(java.lang.Object[] array,
                                 java.lang.Object element)

  Return a boolean whether or not the element exists in the array

  Parameters:
    `array` - An array of objects
    `element` - The element to look for in the array
  Returns:
    true if element is in the array

### find

    public static int find(java.lang.Object[] array,
                           java.lang.Object element)

  Find the index of the first appearance of an object in the array

### stringToInteger

    public static java.lang.Integer[] stringToInteger(java.lang.String[] array)

  Convert a string array to an array of Integer. If `array` is null, null will be returned.

  Parameters:
    `array` - string array
  Returns:
    the Integer array
  Throws:
    `java.lang.NumberFormatException` - if an element in the String array is not parseable into an Integer

### stringToInt

    public static int[] stringToInt(java.lang.String[] array)

  Convert a string array to an array of int. If `array` is null, null will be returned.

  Parameters:
    `array` - string array
  Returns:
    the int array
  Throws:
    `java.lang.NumberFormatException` - if an element in the String array is not parseable into an int

### combine

    public static java.lang.Object[] combine(java.lang.Object[] a1,
                                             java.lang.Object[] a2)

  Combine two arrays into a single, larger array. This method only returns null if both a1 and a2 are null. If a1 is not null, the array that is returned has the same class as a1. Otherwise it will be the the same class as a2.

  Parameters:
    `a1` - The first array. If this is null, a copy of the second array is returned (unless it's null too, then null is returned).
    `a2` - The second array. If this is null, a copy of the first array is returned (unless it's null too, then null is returned).
  Returns:
    An array that is effectively a2 appended to a1, or null if both a1 and a2 are null. The class of the array is the same as a1, unless a1 is null in which case the class of the array is the same as a2, unless a2 is also null, in which case this method returns null;

### clone

    public static byte[] clone(byte[] orig)

  Clone a byte array, maintaining awareness of null arrays

  Parameters:
    `orig` - Byte array to clone (can be null)
  Returns:
    a clone of the array (or null if the argument was null)

Overview | Package | Class | Tree | Deprecated | Index | Help
| Hyperic HQ Plugin API v. 4.4.0.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.