forked from Klortho/DtdAnalyzer
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Element.java
executable file
·126 lines (109 loc) · 3.09 KB
/
Element.java
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
116
117
118
119
120
121
122
123
124
125
/*
* Element.java
*
* Created on November 9, 2005, 5:18 PM
*/
package gov.ncbi.pmc.dtdanalyzer;
import java.util.*;
/**
* Holds all the information associated with an element declaration in the DTD.
* Class does not hold any attribute information, but this can be accessed through
* the {@link Attribute} and {@link Attributes} classes. <code>Element</code>
* also provides no "context" information (ie, the
* places where a given element can occur), but this information is available
* through the {@link ModelBuilder} class.
*
* @author Demian Hess
*/
public class Element {
private String name = null; // Element name
private ContentModel cmodel; // Content model
private int dtdOrder = 0; // Order declared in the DTD
private Location location; // Location inside the DTD
private boolean isRoot = false; // True if this is one of a set of possible roots
private boolean reachable = true;
/**
* Creates a new instance of the class
*
* @param eName Element name
* @param eModel Content model
* @param order Order in which this declaration appeared in the DTD
*/
public Element( String eName, String eModel, int order ){
name = eName;
cmodel = new ContentModel(eModel);
dtdOrder = order;
}
/**
* Returns the number indicating the order of this element declaration
* relative to other elements in the DTD
*
* @return Declaration order
*/
public int getDTDOrder(){
return dtdOrder;
}
/**
* Returns the location of the element declaration in the DTD (file name and line number)
*
* @return Declaration location
*/
public Location getLocation(){
return location;
}
/**
* Returns the ContentModel object associated with this element definition.
*
* @return Content model object
*/
public ContentModel getContentModel() {
return cmodel;
}
/**
* Returns the minified content model string for the element declaration
*
* @return Content model string */
public String getMinifiedModel(){
return cmodel.getMinifiedModel();
}
/**
* Returns the name of the element
*
* @return Element name
*/
public String getName(){
return name;
}
/**
* Sets the location for this element declaration inside the DTD.
*
* @param loc Location information
*/
public void setLocation( Location loc ){
location = loc;
}
/**
* Sets the value of the isRoot flag to true.
*/
public void setIsRoot() {
isRoot = true;
}
/**
* Returns the value of the isRoot flag.
*/
public boolean isRoot() {
return isRoot;
}
/**
* Sets the reachable flag to false.
*/
public void setUnreachable() {
reachable = false;
}
/**
* Returns the value of the reachable flag.
*/
public boolean isReachable() {
return reachable;
}
}