1 19 20 21 package org.apache.cayenne.map; 22 23 import java.io.Serializable ; 24 25 import org.apache.cayenne.util.CayenneMapEntry; 26 import org.apache.cayenne.util.XMLEncoder; 27 import org.apache.cayenne.util.XMLSerializable; 28 29 35 public abstract class Attribute implements CayenneMapEntry, XMLSerializable, Serializable { 36 37 protected String name; 38 protected Entity entity; 39 40 43 public Attribute() { 44 } 45 46 49 public Attribute(String name) { 50 this.name = name; 51 } 52 53 public abstract void encodeAsXML(XMLEncoder encoder); 54 55 58 public Entity getEntity() { 59 return entity; 60 } 61 62 65 public void setEntity(Entity entity) { 66 this.entity = entity; 67 } 68 69 public String getName() { 70 return name; 71 } 72 73 public void setName(String name) { 74 this.name = name; 75 } 76 77 public Object getParent() { 78 return getEntity(); 79 } 80 81 public void setParent(Object parent) { 82 if (parent != null && !(parent instanceof Entity)) { 83 throw new IllegalArgumentException ("Expected null or Entity, got: " + parent); 84 } 85 86 setEntity((Entity) parent); 87 } 88 } 89 | Popular Tags |