1/* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved.
2 *
3 * This program and the accompanying materials are made available under
4 * the terms of the Common Public License v1.0 which accompanies this distribution,
5 * and is available at http://www.eclipse.org/legal/cpl-v10.html
6 *
7 * $Id: Attribute.java,v 1.1.1.1 2004/05/09 16:57:41 vlad_r Exp $
8 */
9package com.vladium.emma.report.html.doc;
10
11import com.vladium.util.asserts.$assert;
12
13// ----------------------------------------------------------------------------
14/**
15 * @author Vlad Roubtsov, (C) 2003
16 */
17public
18abstract class Attribute implements IContent
19{
20    // public: ................................................................
21
22    public static final Attribute ID = new AttributeImpl ("ID");
23    public static final Attribute NAME = new AttributeImpl ("NAME");
24    public static final Attribute TITLE = new AttributeImpl ("TITLE");
25    public static final Attribute TYPE = new AttributeImpl ("TYPE");
26    public static final Attribute CLASS = new AttributeImpl ("CLASS");
27    public static final Attribute HTTP_EQUIV = new AttributeImpl ("HTTP-EQUIV");
28    public static final Attribute CONTENT = new AttributeImpl ("CONTENT");
29    public static final Attribute HREF = new AttributeImpl ("HREF");
30    public static final Attribute SRC = new AttributeImpl ("SRC");
31    public static final Attribute REL = new AttributeImpl ("REL");
32    public static final Attribute WIDTH = new AttributeImpl ("WIDTH");
33    public static final Attribute SIZE = new AttributeImpl ("SIZE");
34    public static final Attribute BORDER = new AttributeImpl ("BORDER");
35    public static final Attribute CELLPADDING = new AttributeImpl ("CELLPADDING");
36    public static final Attribute CELLSPACING = new AttributeImpl ("CELLSPACING");
37    public static final Attribute ALIGN = new AttributeImpl ("ALIGN");
38    public static final Attribute COLSPAN = new AttributeImpl ("COLSPAN");
39
40    public abstract String getName ();
41
42    public abstract boolean equals (final Object rhs);
43    public abstract int hashCode ();
44
45
46    // protected: .............................................................
47
48    // package: ...............................................................
49
50
51    Attribute () {}
52
53    // private: ...............................................................
54
55
56    private static final class AttributeImpl extends Attribute
57    {
58
59        public boolean equals (final Object rhs)
60        {
61            if (this == rhs) return true;
62            if (! (rhs instanceof AttributeImpl)) return false;
63
64            return m_name.equals (((AttributeImpl) rhs).m_name);
65        }
66
67        public int hashCode ()
68        {
69            return m_name.hashCode ();
70        }
71
72        public String toString ()
73        {
74            return m_name;
75        }
76
77        public void emit (final HTMLWriter out)
78        {
79            out.write (m_name); // no need to escape anything
80        }
81
82        public String getName ()
83        {
84            return m_name;
85        }
86
87
88        AttributeImpl (final String name)
89        {
90            if ($assert.ENABLED) $assert.ASSERT (name != null, "name = null");
91
92            m_name = name;
93        }
94
95
96        private final String m_name;
97
98    } // end of nested class
99
100} // end of class
101// ----------------------------------------------------------------------------