0
|
1 package nabble.naml.dom;
|
|
2
|
|
3
|
|
4 public final class Attribute {
|
|
5 final String spaceBeforeName;
|
|
6 final String name;
|
|
7 final String spaceAfterName;
|
|
8 final String spaceBeforeValue;
|
|
9 final Naml value;
|
|
10 final char quote;
|
|
11
|
|
12 Attribute(String spaceBeforeName,String name,String spaceAfterName,String spaceBeforeValue,Naml value,char quote) {
|
|
13 this.spaceBeforeName = spaceBeforeName.intern();
|
|
14 this.name = name.intern();
|
|
15 this.spaceAfterName = spaceAfterName.intern();
|
|
16 this.spaceBeforeValue = spaceBeforeValue.intern();
|
|
17 this.value = value;
|
|
18 this.quote = quote;
|
|
19 }
|
|
20
|
|
21 public String spaceBeforeName() {
|
|
22 return spaceBeforeName;
|
|
23 }
|
|
24
|
|
25 public String name() {
|
|
26 return name;
|
|
27 }
|
|
28
|
|
29 public String spaceAfterName() {
|
|
30 return spaceAfterName;
|
|
31 }
|
|
32
|
|
33 public String spaceBeforeValue() {
|
|
34 return spaceBeforeValue;
|
|
35 }
|
|
36
|
|
37 public Naml value() {
|
|
38 return value;
|
|
39 }
|
|
40
|
|
41 public char quote() {
|
|
42 return quote;
|
|
43 }
|
|
44
|
|
45 public String toString(String value) {
|
|
46 return spaceBeforeName + name + spaceAfterName + '=' + spaceBeforeValue + quote + value + quote;
|
|
47 }
|
|
48
|
|
49 public String toString() {
|
|
50 String s = value.toString();
|
|
51 if( quote == '"' )
|
|
52 s = s.replace('<','[').replace('>',']');
|
|
53 return toString(s);
|
|
54 }
|
|
55 /*
|
|
56 @Override public boolean equals(Object obj) {
|
|
57 if( !(obj instanceof Attribute) )
|
|
58 return false;
|
|
59 Attribute attr = (Attribute)obj;
|
|
60 return attr.name.equals(name)
|
|
61 && (value==null ? attr.value==null : value.equals(attr.value));
|
|
62 }
|
|
63
|
|
64 @Override public int hashCode() {
|
|
65 return name.hashCode() * 31 + value.hashCode();
|
|
66 }
|
|
67 */
|
|
68 }
|