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