org.eclipse.osgi.framework.internal.core
Class Util

java.lang.Object
  extended by org.eclipse.osgi.framework.internal.core.Util

public class Util
extends java.lang.Object

This class contains utility functions.


Constructor Summary
Util()
           
 
Method Summary
static void dsort(java.lang.Object[] array, int start, int end)
          Sorts the specified range in the array in descending order.
static void qsort(java.lang.Object[] array, int start, int stop)
          Sorts the array of objects by their string representation in ascending order.
static void sort(java.lang.Object[] array)
          Performs a quicksort of the given objects by their string representation in ascending order.
static void sort(java.lang.Object[] array, int start, int end)
          Sorts the specified range in the array in ascending order.
static void swap(java.lang.Object[] array)
          Reverse the elements in the array.
static java.lang.String toString(java.lang.Object object, int length)
          Returns a string representation of the object in the given length.
static java.lang.String toString(java.lang.Object object, int length, char pad, boolean onLeft)
          Returns a string representation of the object in the given length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

sort

public static void sort(java.lang.Object[] array)
Performs a quicksort of the given objects by their string representation in ascending order.

Parameters:
array - The array of objects to sort

qsort

public static void qsort(java.lang.Object[] array,
                         int start,
                         int stop)
Sorts the array of objects by their string representation in ascending order.

This is a version of C.A.R Hoare's Quick Sort algorithm.

Parameters:
array - the array of objects to sort
start - the start index to begin sorting
stop - the end index to stop sorting
Throws:
java.lang.ArrayIndexOutOfBoundsException - when start < 0 or end >= array.length

sort

public static void sort(java.lang.Object[] array,
                        int start,
                        int end)
Sorts the specified range in the array in ascending order.

Parameters:
array - the Object array to be sorted
start - the start index to sort
end - the last + 1 index to sort
Throws:
java.lang.ClassCastException - when an element in the array does not implement Comparable or elements cannot be compared to each other
java.lang.IllegalArgumentException - when start > end
java.lang.ArrayIndexOutOfBoundsException - when start < 0 or end > array.size()

dsort

public static void dsort(java.lang.Object[] array,
                         int start,
                         int end)
Sorts the specified range in the array in descending order.

Parameters:
array - the Object array to be sorted
start - the start index to sort
end - the last + 1 index to sort
Throws:
java.lang.ClassCastException - when an element in the array does not implement Comparable or elements cannot be compared to each other
java.lang.IllegalArgumentException - when start > end
java.lang.ArrayIndexOutOfBoundsException - when start < 0 or end > array.size()

swap

public static void swap(java.lang.Object[] array)
Reverse the elements in the array.

Parameters:
array - the Object array to be reversed

toString

public static java.lang.String toString(java.lang.Object object,
                                        int length)
Returns a string representation of the object in the given length. If the string representation of the given object is longer then it is truncated. If it is shorter then it is padded with the blanks to the given total length. If the given object is a number then the padding is done on the left, otherwise on the right.

Parameters:
object - the object to convert
length - the length the output string

toString

public static java.lang.String toString(java.lang.Object object,
                                        int length,
                                        char pad,
                                        boolean onLeft)
Returns a string representation of the object in the given length. If the string representation of the given object is longer then it is truncated. If it is shorter then it is padded to the left or right with the given character to the given total length.

Parameters:
object - the object to convert
length - the length the output string
pad - the pad character
onLeft - if true pad on the left, otherwise an the right