01: package com.jamonapi.utils;
02:
03: /** Difficult to group Utilities **/
04:
05: public class Misc extends java.lang.Object {
06: /** Returns an Objects ClassName minus the package name
07: * Sample Call:
08: * String className=Misc.getClassName("My Object"); // returns "String"
09: **/
10: public static String getClassName(Object object) {
11: String className = (object == null ? "null" : object.getClass()
12: .getName()); // gov.gsa.fss.fim.Misc
13: return className.substring(className.lastIndexOf(".") + 1); // Misc
14: }
15:
16: public static void isObjectString(Object arg) {
17: if (!(arg instanceof String))
18: throw new IllegalArgumentException(
19: "Illegal Argument exception: This object must be of type String.");
20: }
21:
22: /** Sort a 2 dimensional array based on 1 columns data in either ascending or descending order.
23: * array - Array to be sorted
24: * sortCol - column to sort by
25: * sortOrder - sort the column in ascending or descending order. Valid arguments are "asc" and "desc".
26: **/
27: public static Object[][] sort(Object[][] array, int sortCol,
28: String sortOrder) {
29: ArraySorter sorter = new ArraySorter(array, sortCol, sortOrder);
30: return sorter.sort();
31: }
32: }
|