File: DTDAttlist.java

package info (click to toggle)
libdtdparser-java 1.21a-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 400 kB
  • ctags: 393
  • sloc: java: 3,143; xml: 66; makefile: 15
file content (115 lines) | stat: -rw-r--r-- 2,834 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package com.wutka.dtd;

import java.util.*;
import java.io.*;

/** Represents an ATTLIST declaration in the DTD. Although attributes are
 *  associated with elements, the ATTLIST is here to allow the DTD object
 *  to write out the DTD in roughly the original form. Because the ATTLIST
 *  may appear somewhere other than immediately after the ELEMENT, this object
 *  is used to keep track of where it is.
 *
 * @author Mark Wutka
 * @version $Revision: 1.16 $ $Date: 2002/07/19 01:20:11 $ by $Author: wutka $
 */
public class DTDAttlist implements DTDOutput
{
/** The name of the element */
    public String name;

/** The attlist's attributes */
    public Vector attributes;

    public DTDAttlist()
    {
        attributes = new Vector();
    }

    public DTDAttlist(String aName)
    {
        name = aName;

        attributes = new Vector();
    }

/** Writes out an ATTLIST declaration */
    public void write(PrintWriter out)
        throws IOException
    {
        out.print("<!ATTLIST ");
        out.println(name);

        Iterator itr = attributes.iterator();

        while (itr.hasNext())
        {
            out.print("           ");
            DTDAttribute attr = (DTDAttribute) itr.next();
            attr.write(out);
            if (itr.hasNext())
            {
                out.println();
            }
            else
            {
                out.println(">");
            }
        }
    }

    public boolean equals(Object ob)
    {
        if (ob == this) return true;
        if (!(ob instanceof DTDAttlist)) return false;

        DTDAttlist other = (DTDAttlist) ob;

        if ((name == null) && (other.name != null)) return false;
        if ((name != null) && !name.equals(other.name)) return false;

        return attributes.equals(other.attributes);
    }

/** Returns the entity name of this attlist */
    public String getName()
    {
        return name;
    }

/** Sets the entity name of this attlist */
    public void setName(String aName)
    {
        name = aName;
    }

/** Returns the attributes in this list */
    public DTDAttribute[] getAttribute()
    {
        DTDAttribute attrs[] = new DTDAttribute[attributes.size()];
        attributes.copyInto(attrs);

        return attrs;
    }

/** Sets the list of attributes */
    public void setAttribute(DTDAttribute[] attrs)
    {
        attributes = new Vector(attrs.length);
        for (int i=0; i < attrs.length; i++)
        {
            attributes.addElement(attrs[i]);
        }
    }

/** Returns a specific attribute from the list */
    public DTDAttribute getAttribute(int i)
    {
        return (DTDAttribute) attributes.elementAt(i);
    }

/** Sets a specific attribute in the list */
    public void setAttribute(DTDAttribute attr, int i)
    {
        attributes.setElementAt(attr, i);
    }
}