JdmAttribute.java |
1 /* 2 * JdmAttribute.java 3 * 4 * Copyright (c) 1998-2005, The University of Sheffield. 5 * 6 * This file is part of GATE (see http://gate.ac.uk/), and is free 7 * software, licenced under the GNU Library General Public License, 8 * Version 2, June 1991 (in the distribution as file licence.html, 9 * and also available at http://gate.ac.uk/gate/licence.html). 10 * 11 * Kalina Bontcheva, 23/02/2000 12 * 13 * $Id: JdmAttribute.java,v 1.8 2005/01/11 13:51:36 ian Exp $ 14 * 15 * Description: This is JDM aimed at repeating the functionality of GDM 16 */ 17 18 package gate.jape; 19 20 import java.io.Serializable; 21 22 /** 23 * THIS CLASS SHOULDN'T BE HERE. Please let's all ignore it, and maybe 24 * it will go away. 25 * <P> 26 * Implements the TIPSTER and GDM API for attributes. 27 * Test code in <code>testAttributes</code> class. <P> 28 * The JdmAttribute class would accept all java serialisable classes, all 29 * jdm classes and also all user-defined classes provided they implement 30 * the Serializable interface. This restriction is necessary since Jdm 31 * uses Java serialisation to ensure object persistency. However, making 32 * classes serialisable is usually quite straightforward. <P> 33 * @author Kalina Bontcheva 34 */ 35 public class JdmAttribute implements Serializable { 36 37 /** Debug flag */ 38 private static final boolean DEBUG = false; 39 40 private String name; 41 private Object value; 42 43 protected JdmAttribute() { 44 } 45 46 /** throws JdmException when the value isn't one of the types we know 47 * how to store, i.e., a serialisable or Jdm class. 48 */ 49 public JdmAttribute(String name, Object value) { 50 this.name = name; this.value = value; 51 } 52 53 /** throws JdmException when the value isn't one of the types we know 54 * how to store, i.e., a serialisable or Jdm class. 55 */ 56 public JdmAttribute(JdmAttribute jdmAttr) { 57 String name = jdmAttr.getName(); 58 Object value = jdmAttr.getValue(); 59 } 60 61 public String getName() { 62 return name; 63 } 64 65 public Object getValue() { 66 return value; 67 } 68 69 public String getValueType() { 70 return value.getClass().getName(); 71 } 72 73 public boolean equals(Object obj) { 74 JdmAttribute a = (JdmAttribute) obj; 75 return a.getName().equals(name) && a.getValue().equals(value); 76 } 77 78 public String toString() { 79 return "JdmAttr: name=" + name + "; value=" + value.toString(); 80 81 } 82 83 } // class JdmAttribute 84