Repository navigation
Expand file tree
/
Copy pathHCol.java
More file actions
77 lines (64 loc) · 1.94 KB
/
Copy pathHCol.java
File metadata and controls
77 lines (64 loc) · 1.94 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// Copyright (c) 2012, Brian Frank
// Licensed under the Academic Free License version 3.0
//
// History:
// 24 Sep 2012 Brian Frank Creation
//
package org.projecthaystack;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
/**
* HCol is a column in a HGrid.
*
* @see <a href='http://project-haystack.org/doc/Grids'>Project Haystack</a>
*/
public class HCol
{
//////////////////////////////////////////////////////////////////////////
// Constructor
//////////////////////////////////////////////////////////////////////////
/** Package private constructor */
HCol(int index, String name, HDict meta)
{
this.index = index;
this.name = name;
this.meta = meta;
}
//////////////////////////////////////////////////////////////////////////
// Access
//////////////////////////////////////////////////////////////////////////
/** Return programatic name of column */
public String name() { return name; }
/** Return display name of column which is meta.dis or name */
public String dis()
{
HVal dis = meta.get("dis", false);
if (dis instanceof HStr) return ((HStr)dis).val;
return name;
}
/** Column meta-data tags */
public HDict meta() { return meta; };
//////////////////////////////////////////////////////////////////////////
// Identity
//////////////////////////////////////////////////////////////////////////
/** Hash code is based on name and meta */
public final int hashCode()
{
return (name.hashCode() << 13) ^ meta.hashCode();
}
/** Equality is name and meta */
public final boolean equals(Object that)
{
if (!(that instanceof HCol)) return false;
HCol x = (HCol)that;
return name.equals(x.name) && meta.equals(x.meta);
}
//////////////////////////////////////////////////////////////////////////
// Fields
//////////////////////////////////////////////////////////////////////////
final int index;
final String name;
final HDict meta;
}