01: package simpleorm.core;
02:
03: /** Miscellaneous static utility methods that have
04: nowhere else to live. */
05:
06: public class SUte {
07:
08: /** Depricated!
09: ` True if <code>element</code> is in <code>bitSet</code>. Throws
10: exception if lower short does not match the <code>setType</code>
11: indicating mismatched flags.*/
12: public static boolean inBitSet(long bitSet, long element,
13: long setType) {
14: if ((bitSet != 0 && (bitSet & 0xFFFF) != (setType & 0xFFFF))
15: || ((element & 0xFFFF) != (setType & 0xFFFF)))
16: throw new SException.Error("Mismatched BitSet " + bitSet
17: + ", " + element + " vs " + setType);
18: return (bitSet & element & 0xFFFFFFFFFFFF0000L) != 0;
19: }
20:
21: /** Pretty class names without package prefixes etc. */
22: public static String cleanClass(Class cls) {
23: if (cls == null)
24: return "NullClass";
25: String className = cls.getName();
26: int x1 = className.lastIndexOf(".") + 1;
27: int x2 = className.lastIndexOf("$") + 1;
28: return className.substring(x1 > x2 ? x1 : x2);
29: }
30:
31: /** Makes a string out of elements of an array for tracing.
32: * If array is not an object just toString it.
33: */
34: public static String arrayToString(Object array) {
35: if (array == null)
36: return "{NULL}";
37: if (!(array instanceof Object[]))
38: return array.toString();
39: Object[] realArray = (Object[]) array;
40: StringBuffer sb = new StringBuffer("{");
41: for (int ax = 0; ax < realArray.length; ax++) {
42: if (ax > 0)
43: sb.append(", ");
44: sb.append(realArray[ax] + "");
45: }
46: return sb.toString() + "}";
47: }
48:
49: /** The SimpleORM Version. Major.Minor. Guaranteed upward
50: compatibility within all major versions (except 00.*!).
51: Guaranteed that these will sort properly, hence leading
52: zeros.
53:
54: Is not a constant because Java will copy the
55: constant into any dependent modules !!! */
56: public static String simpleormVersion() {
57: return "02.21";
58: }
59: }
|