001: /*
002: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003: * notice. All rights reserved.
004: */
005: package com.tc.object.appevent;
006:
007: import com.tc.util.NonPortableReason;
008:
009: import java.io.Serializable;
010: import java.util.ArrayList;
011: import java.util.List;
012:
013: /**
014: * Represents an object in the object graph held in a non-portable event context.
015: */
016: public class NonPortableObjectState implements Serializable {
017: private String label, fieldName, typeName;
018: private boolean isPortable, isTransient, neverPortable,
019: isPreInstrumented, isRepeated, isSystemType, isNull;
020: private String explaination;
021: private NonPortableReason nonPortableReason;
022: private List requiredBootTypes;
023: private List requiredIncludeTypes;
024:
025: /**
026: * Construct with all default values.
027: */
028: public NonPortableObjectState() {
029: this (null, null, null, false, false, false, false, false,
030: false, false);
031: }
032:
033: /**
034: * Construct with all values
035: * @param label Label
036: * @param fieldName Field name
037: * @param typeName Type name
038: * @param isPortable Portable flag
039: * @param isTransient Transient flag
040: * @param neverPortable Never portable flag
041: * @param isPreInstrumented Is pre-instrumented flag
042: * @param isRepeated Is repeated flag
043: * @param isSystemType Is system type
044: * @param isNull Is null
045: */
046: public NonPortableObjectState(String label, String fieldName,
047: String typeName, boolean isPortable, boolean isTransient,
048: boolean neverPortable, boolean isPreInstrumented,
049: boolean isRepeated, boolean isSystemType, boolean isNull) {
050: this .label = label;
051: this .fieldName = fieldName;
052: this .typeName = typeName;
053: this .isPortable = isPortable;
054: this .isTransient = isTransient;
055: this .neverPortable = neverPortable;
056: this .isPreInstrumented = isPreInstrumented;
057: this .isRepeated = isRepeated;
058: this .isSystemType = isSystemType;
059: this .isNull = isNull;
060: }
061:
062: /**
063: * Set explanation
064: * @param explaination Explanation
065: */
066: public void setExplaination(String explaination) {
067: this .explaination = explaination;
068: }
069:
070: /**
071: * @return Explanation
072: */
073: public String getExplaination() {
074: return this .explaination;
075: }
076:
077: /**
078: * Set reason why this object is non portable
079: * @param nonPortableReason The reason
080: */
081: public void setNonPortableReason(NonPortableReason nonPortableReason) {
082: this .nonPortableReason = nonPortableReason;
083: requiredBootTypes = new ArrayList(nonPortableReason
084: .getErroneousBootJarSuperClasses());
085: if (isRequiredBootJarType()) {
086: requiredBootTypes.add(getTypeName());
087: }
088: requiredIncludeTypes = new ArrayList(nonPortableReason
089: .getErroneousSuperClasses());
090: if (isRequiredIncludeType()) {
091: requiredIncludeTypes.add(getTypeName());
092: }
093: }
094:
095: /**
096: * @return Reason why this object is non portable
097: */
098: public NonPortableReason getNonPortableReason() {
099: return this .nonPortableReason;
100: }
101:
102: /**
103: * @return Label
104: */
105: public String getLabel() {
106: return this .label;
107: }
108:
109: /**
110: * @param label label
111: */
112: public void setLabel(String label) {
113: this .label = label;
114: }
115:
116: /**
117: * @return Field name
118: */
119: public String getFieldName() {
120: return this .fieldName;
121: }
122:
123: /**
124: * @poram fieldName Field name
125: */
126: public void setFieldName(String fieldName) {
127: this .fieldName = fieldName;
128: }
129:
130: /**
131: * Get type name for this node's state
132: */
133: public String getTypeName() {
134: return this .typeName;
135: }
136:
137: public String toString() {
138: return getLabel();
139: }
140:
141: /**
142: * @return True if portable
143: */
144: public boolean isPortable() {
145: return this .isPortable;
146: }
147:
148: /**
149: * @return True if this is transient
150: */
151: public boolean isTransient() {
152: return this .isTransient;
153: }
154:
155: /**
156: * @return True if this type is never portable
157: */
158: public boolean isNeverPortable() {
159: return this .neverPortable;
160: }
161:
162: /**
163: * @return True if this is pre-instrumented
164: */
165: public boolean isPreInstrumented() {
166: return this .isPreInstrumented;
167: }
168:
169: /**
170: * @return True if this is a system type
171: */
172: public boolean isSystemType() {
173: return this .isSystemType;
174: }
175:
176: /**
177: * @return True if repeated
178: */
179: public boolean isRepeated() {
180: return this .isRepeated;
181: }
182:
183: /**
184: * @return True if null
185: */
186: public boolean isNull() {
187: return this .isNull;
188: }
189:
190: /**
191: * @return List of types that should be included in the boot jar
192: */
193: public List getRequiredBootTypes() {
194: return requiredBootTypes;
195: }
196:
197: /**
198: * @return List of types that should be included in the config
199: */
200: public List getRequiredIncludeTypes() {
201: return requiredIncludeTypes;
202: }
203:
204: /**
205: * @return List of all super classes that are non-portable objects
206: */
207: public List getNonPortableBaseTypes() {
208: return nonPortableReason != null ? nonPortableReason
209: .getErroneousSuperClasses() : null;
210: }
211:
212: /**
213: * @return True if class extends a logically managed type
214: */
215: public boolean extendsLogicallyManagedType() {
216: if (nonPortableReason != null) {
217: return nonPortableReason.getReason() == NonPortableReason.SUBCLASS_OF_LOGICALLY_MANAGED_CLASS;
218: }
219: return false;
220: }
221:
222: /**
223: * @return True if class is required in boot jar
224: */
225: public boolean isRequiredBootJarType() {
226: if (nonPortableReason != null) {
227: return nonPortableReason.getReason() == NonPortableReason.CLASS_NOT_IN_BOOT_JAR;
228: }
229: return false;
230: }
231:
232: /**
233: * @return True if class was not included in the config
234: */
235: public boolean isRequiredIncludeType() {
236: if (nonPortableReason != null) {
237: return nonPortableReason.getReason() == NonPortableReason.CLASS_NOT_INCLUDED_IN_CONFIG;
238: }
239: return false;
240: }
241:
242: /**
243: * @return Get summary of this node's state
244: */
245: public String summary() {
246: StringBuffer sb = new StringBuffer();
247: String l = getLabel();
248:
249: if (l == null)
250: return "NonPortableTreeRoot";
251: sb.append(l);
252: if (isNeverPortable()) {
253: sb.append(" Never portable");
254: } else {
255: sb.append(isPortable() ? " portable" : " not portable");
256: }
257: if (isTransient()) {
258: sb.append(", transient");
259: }
260: if (isPreInstrumented()) {
261: sb.append(", pre-instrumented");
262: }
263: if (isRepeated()) {
264: sb.append(", repeated");
265: }
266: if (isSystemType()) {
267: sb.append(", system type");
268: }
269:
270: return sb.toString();
271: }
272: }
|