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