~ubuntu-branches/ubuntu/utopic/jing-trang/utopic

« back to all changes in this revision

Viewing changes to mod/convert-to-xsd/src/main/com/thaiopensource/relaxng/output/xsd/basic/Attribute.java

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Thibault
  • Date: 2009-09-01 15:53:03 UTC
  • Revision ID: james.westby@ubuntu.com-20090901155303-2kweef05h5v9j3ni
Tags: upstream-20090818
ImportĀ upstreamĀ versionĀ 20090818

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package com.thaiopensource.relaxng.output.xsd.basic;
 
2
 
 
3
import com.thaiopensource.xml.util.Name;
 
4
import com.thaiopensource.relaxng.edit.SourceLocation;
 
5
import com.thaiopensource.util.Equal;
 
6
 
 
7
public class Attribute extends SingleAttributeUse implements Structure {
 
8
  private final Name name;
 
9
  private final SimpleType type;
 
10
 
 
11
   /**
 
12
   * type may be null, indicating any type
 
13
   */
 
14
 
 
15
   public Attribute(SourceLocation location, Annotation annotation, Name name, SimpleType type) {
 
16
    super(location, annotation);
 
17
    this.name = name;
 
18
    this.type = type;
 
19
  }
 
20
 
 
21
  public Name getName() {
 
22
    return name;
 
23
  }
 
24
 
 
25
  public SimpleType getType() {
 
26
    return type;
 
27
  }
 
28
 
 
29
  public <T> T accept(AttributeUseVisitor<T> visitor) {
 
30
    return visitor.visitAttribute(this);
 
31
  }
 
32
 
 
33
  public <T> T accept(StructureVisitor<T> visitor) {
 
34
    return visitor.visitAttribute(this);
 
35
  }
 
36
 
 
37
  public boolean equals(Object obj) {
 
38
    if (!super.equals(obj))
 
39
      return false;
 
40
    Attribute other = (Attribute)obj;
 
41
    return Equal.equal(this.type, other.type) && this.name.equals(other.name);
 
42
  }
 
43
 
 
44
  public int hashCode() {
 
45
    int hc = super.hashCode() ^ name.hashCode();
 
46
    if (type != null)
 
47
      hc ^= type.hashCode();
 
48
    return hc;
 
49
  }
 
50
 
 
51
  public boolean isOptional() {
 
52
    return false;
 
53
  }
 
54
}