-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNamedAttribute.java
More file actions
54 lines (34 loc) · 981 Bytes
/
Copy pathNamedAttribute.java
File metadata and controls
54 lines (34 loc) · 981 Bytes
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
// NamedAttribute.java
// Andrew Davison, ad@fivedots.coe.psu.ac.th, July 2016
// Used by JPrint.java
import javax.print.attribute.Attribute;
public class NamedAttribute implements Comparable<NamedAttribute>
{
private String name;
private Attribute attr;
public NamedAttribute(Attribute attr)
{
name = attr.getName();
this.attr = attr;
}
public String getName()
{ return name; }
public Attribute getAttribute()
{ return attr; }
public boolean equals(Object obj)
{
if(this == obj)
return true;
if((obj == null) || (obj.getClass() != this.getClass()))
return false;
NamedAttribute na = (NamedAttribute)obj;
return name.equals(na.getName());
}
public int hashCode()
{ return name.hashCode(); }
public int compareTo(NamedAttribute na)
// ascending order by name
{ return name.compareTo(na.getName()); }
public String toString()
{ return name; }
} // end of NamedAttribute class