KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > objectserver > mgmt > FacadeUtil


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.objectserver.mgmt;
5
6 import com.tc.object.dna.impl.ClassInstance;
7 import com.tc.object.dna.impl.UTF8ByteDataHolder;
8
9 public class FacadeUtil {
10
11   public static String JavaDoc getFieldType(Object JavaDoc 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 JavaDoc getShortClassName(String JavaDoc 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] == '$') chars[i] = '.';
25     }
26
27     return new String JavaDoc(chars, lastDot, chars.length - lastDot);
28   }
29
30   public static Object JavaDoc processValue(Object JavaDoc value) {
31     if (value instanceof UTF8ByteDataHolder) {
32       value = ((UTF8ByteDataHolder) value).asString();
33     } else if (value instanceof ClassInstance) {
34       value = ((ClassInstance) value).getName().asString();
35     }
36     return value;
37   }
38
39 }
40
Popular Tags