01: /*
02: * $Id: Attribute.java,v 1.3 2002/09/16 08:05:03 jkl Exp $
03: *
04: * Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
05: *
06: * Use is subject to license terms, as defined in
07: * Anvil Sofware License, Version 1.1. See LICENSE
08: * file, or http://njet.org/license-1.1.txt
09: */
10: package anvil.parser;
11:
12: /**
13: * class Attribute
14: *
15: * @author: Jani Lehtimäki
16: */
17: public class Attribute {
18:
19: private String _name;
20: private String _value;
21:
22: public Attribute(String name, String value) {
23: _name = name;
24: _value = value;
25: }
26:
27: public Attribute(String name) {
28: _name = name;
29: _value = null;
30: }
31:
32: public String getName() {
33: return _name;
34: }
35:
36: public String getValue() {
37: return _value;
38: }
39:
40: void setValue(String value) {
41: _value = value;
42: }
43:
44: public int hashCode() {
45: return _name.hashCode();
46: }
47:
48: public String toString() {
49: if (_value != null) {
50: return _name + "=\"" + _value + "\"";
51: } else {
52: return _name;
53: }
54: }
55:
56: public void toString(StringBuffer buffer) {
57: buffer.append(_name);
58: if (_value != null) {
59: buffer.append('=');
60: buffer.append('"');
61: buffer.append(_value);
62: buffer.append('"');
63: }
64: }
65:
66: }
|