1 package com.wutka.dtd;
2
3 import java.io.*;
4 import java.util.*;
5
6 /*** Represents a choice of items.
7 * A choice in a DTD looks like (option1 | option2 | option3)
8 *
9 * @author Mark Wutka
10 * @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
11 */
12 public class DTDChoice extends DTDContainer
13 {
14 public DTDChoice()
15 {
16 }
17
18 /*** Writes out the possible choices to a PrintWriter */
19 public void write(PrintWriter out)
20 throws IOException
21 {
22 out.print("(");
23 Enumeration e = getItemsVec().elements();
24 boolean isFirst = true;
25
26 while (e.hasMoreElements())
27 {
28 if (!isFirst) out.print(" | ");
29 isFirst = false;
30
31 DTDItem item = (DTDItem) e.nextElement();
32
33 item.write(out);
34 }
35 out.print(")");
36 cardinal.write(out);
37 }
38
39 public boolean equals(Object ob)
40 {
41 if (ob == this) return true;
42 if (!(ob instanceof DTDChoice)) return false;
43
44 return super.equals(ob);
45 }
46 }