1 16 package org.jmanage.core.management; 17 18 import org.jmanage.util.StringUtils; 19 import org.jmanage.core.management.data.DataFormatUtil; 20 21 26 public class ObjectAttribute implements java.io.Serializable { 27 28 public static final int STATUS_OK = 0; 29 public static final int STATUS_ERROR = 1; 30 public static final int STATUS_NOT_FOUND = 2; 31 32 private String name; 33 private Object value; 34 private int status = STATUS_OK; 35 private String errorString; 36 37 public ObjectAttribute(String name, Object value) { 38 this.name = name; 39 this.value = value; 40 } 41 42 public ObjectAttribute(String name, int status, String errorString){ 43 this.name = name; 44 this.status = status; 45 this.errorString = errorString; 46 } 47 48 public boolean equals(Object o) { 49 if(o instanceof ObjectAttribute){ 50 ObjectAttribute attr = (ObjectAttribute)o; 51 if(attr.name.equals(this.name) && attr.value.equals(this.value)){ 52 return true; 53 } 54 } 55 return false; 56 } 57 58 public String getName() { 59 return name; 60 } 61 62 public Object getValue() { 63 return value; 64 } 65 66 public int getStatus() { 67 return status; 68 } 69 70 public String getErrorString() { 71 return errorString; 72 } 73 74 public String getDisplayValue(){ 75 String attrValue = null; 76 if(getStatus() == STATUS_OK){ 77 attrValue = DataFormatUtil.format(getValue()); 78 }else if(getStatus() == ObjectAttribute.STATUS_NOT_FOUND){ 79 attrValue = "<not found>"; 81 }else{ 82 attrValue = "<error>"; 84 } 85 return attrValue; 86 } 87 } 88 | Popular Tags |