1 23 24 package org.objectweb.medor.lib; 25 26 import org.objectweb.medor.api.Field; 27 import org.objectweb.medor.api.MedorException; 28 import org.objectweb.medor.clone.lib.BasicCloneable; 29 import org.objectweb.jorm.type.api.PType; 30 import org.objectweb.util.monolog.api.Logger; 31 32 import java.util.Map ; 33 34 public class BasicField extends BasicCloneable implements Field { 35 protected String name; 36 protected PType type; 37 protected short valueState; 38 transient protected Logger logger; 39 40 public BasicField() { 41 logger = Log.getLoggerFactory().getLogger(getClass().getName()); 42 } 43 44 public BasicField(String name) { 45 this(); 46 this.name = name; 47 } 48 49 public BasicField(String name, PType type) { 50 this(name); 51 this.type = type; 52 } 53 54 public BasicField(String name, PType type, short valueState) 55 throws MedorException { 56 this(name, type); 57 if ((valueState != Field.NONULLS) && 58 (valueState != Field.NULLABLE) && 59 (valueState != Field.NULLABLEUNKNOWN)) { 60 throw new MedorException("invalid nulStatus Field Error: " + valueState); 61 } 62 this.valueState = valueState; 63 } 64 65 public Object clone(Object clone, 66 Map obj2clone) throws CloneNotSupportedException { 67 clone = super.clone(clone, obj2clone); 68 ((BasicField) clone).name = name; 69 ((BasicField) clone).type = type; 70 ((BasicField) clone).valueState = valueState; 71 return clone; 72 } 73 74 public String getName() { 75 return name; 76 } 77 78 public PType getType() { 79 return type; 80 } 81 82 public short getNullStatus() { 83 return valueState; 84 } 85 86 public String toString() { 87 return name; 88 } 89 90 public int compareTo(Object o) { 91 BasicField bf = (BasicField) o; 92 return name.compareTo(bf.name); 93 } 94 } 95 | Popular Tags |