1 package com.wutka.dtd;
2
3 import java.io.*;
4
5 /*** Represents any item in the DTD
6 *
7 * @author Mark Wutka
8 * @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
9 */
10 public abstract class DTDItem implements DTDOutput
11 {
12 /*** Indicates how often the item may occur */
13 public DTDCardinal cardinal;
14
15 public DTDItem()
16 {
17 cardinal = DTDCardinal.NONE;
18 }
19
20 public DTDItem(DTDCardinal aCardinal)
21 {
22 cardinal = aCardinal;
23 }
24
25 /*** Writes out a declaration for this item */
26 public abstract void write(PrintWriter out)
27 throws IOException;
28
29 public boolean equals(Object ob)
30 {
31 if (ob == this) return true;
32 if (!(ob instanceof DTDItem)) return false;
33
34 DTDItem other = (DTDItem) ob;
35
36 if (cardinal == null)
37 {
38 if (other.cardinal != null) return false;
39 }
40 else
41 {
42 if (!cardinal.equals(other.cardinal)) return false;
43 }
44
45 return true;
46 }
47
48 /*** Sets the cardinality of the item */
49 public void setCardinal(DTDCardinal aCardinal)
50 {
51 cardinal = aCardinal;
52 }
53
54 /*** Retrieves the cardinality of the item */
55 public DTDCardinal getCardinal()
56 {
57 return cardinal;
58 }
59 }