1 4 package com.tc.objectserver.mgmt; 5 6 import com.tc.object.ObjectID; 7 8 import java.io.Serializable ; 9 10 public class LogicalManagedObjectFacade extends AbstractObjectFacade implements Serializable { 11 private static final int MAP = 1; 12 private static final int LIST = 2; 13 private static final int SET = 3; 14 15 private final boolean isMap; 16 private final boolean isSet; 17 private final boolean isList; 18 private final int trueSize; 19 private final ObjectID objectID; 20 private final String className; 21 private final int facadeSize; 22 private final Object [] data; 23 24 public static LogicalManagedObjectFacade createSetInstance(ObjectID id, String className, Object [] data, int trueSize) { 25 return new LogicalManagedObjectFacade(id, className, SET, data, trueSize); 26 } 27 28 public static LogicalManagedObjectFacade createListInstance(ObjectID id, String className, Object [] data, int trueSize) { 29 return new LogicalManagedObjectFacade(id, className, LIST, data, trueSize); 30 } 31 32 public static LogicalManagedObjectFacade createMapInstance(ObjectID id, String className, MapEntryFacade[] data, 33 int trueSize) { 34 return new LogicalManagedObjectFacade(id, className, MAP, data, trueSize); 35 } 36 37 private LogicalManagedObjectFacade(ObjectID objectID, String className, int type, Object [] data, int trueObjectSize) { 38 if (type != MAP && type != SET && type != LIST) { throw new IllegalArgumentException ("Bad type: " + type); } 39 this.isMap = type == MAP; 40 this.isSet = type == SET; 41 this.isList = type == LIST; 42 this.objectID = objectID; 43 this.className = className; 44 this.data = data; 45 this.facadeSize = data.length; 46 this.trueSize = trueObjectSize; 47 } 48 49 public String getClassName() { 50 return this.className; 51 } 52 53 public String [] getFields() { 54 String [] names = new String [this.facadeSize]; 55 for (int i = 0; i < facadeSize; i++) { 56 names[i] = String.valueOf(i); 57 } 58 return names; 59 } 60 61 protected Object basicGetFieldValue(String fieldName) { 62 int index = Integer.valueOf(fieldName).intValue(); 63 return this.data[index]; 64 } 65 66 public boolean isPrimitive(String fieldName) { 67 return false; 69 } 70 71 public ObjectID getObjectId() { 72 return this.objectID; 73 } 74 75 public boolean isInnerClass() { 76 return false; 77 } 78 79 public ObjectID getParentObjectId() { 80 throw new IllegalStateException ("Not an inner class"); 81 } 82 83 public boolean isArray() { 84 return false; 85 } 86 87 public int getArrayLength() { 88 throw new IllegalStateException ("Not an array"); 89 } 90 91 public boolean isList() { 92 return this.isList; 93 } 94 95 public boolean isSet() { 96 return this.isSet; 97 } 98 99 public boolean isMap() { 100 return this.isMap; 101 } 102 103 public int getFacadeSize() { 104 return this.facadeSize; 105 } 106 107 public int getTrueObjectSize() { 108 return this.trueSize; 109 } 110 111 } 112 | Popular Tags |