01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.objectserver.mgmt;
05:
06: import com.tc.object.dna.impl.ClassInstance;
07: import com.tc.object.dna.impl.UTF8ByteDataHolder;
08:
09: public class FacadeUtil {
10:
11: public static String getFieldType(Object value) {
12: // XXX: this is kinda wrong actually...we'll end up returning "Integer" for "int" fields and what not.
13: return getShortClassName(value.getClass().getName());
14: }
15:
16: private static String getShortClassName(String className) {
17: char chars[] = className.toCharArray();
18: int lastDot = 0;
19: for (int i = 0; i < chars.length; i++) {
20: if (chars[i] == '.') {
21: lastDot = i + 1;
22: continue;
23: }
24: if (chars[i] == '$')
25: chars[i] = '.';
26: }
27:
28: return new String(chars, lastDot, chars.length - lastDot);
29: }
30:
31: public static Object processValue(Object value) {
32: if (value instanceof UTF8ByteDataHolder) {
33: value = ((UTF8ByteDataHolder) value).asString();
34: } else if (value instanceof ClassInstance) {
35: value = ((ClassInstance) value).getName().asString();
36: }
37: return value;
38: }
39:
40: }
|