-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFeatures_record.java
More file actions
86 lines (82 loc) · 2.65 KB
/
Features_record.java
File metadata and controls
86 lines (82 loc) · 2.65 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
78
79
80
81
82
83
84
85
86
/*
% Copyright 2016 by Farhad Shakerin
%
% Permission to use this software is granted subject to the
% following restrictions and understandings:
%
% 1. This material is for educational and research purposes only.
%
% 2. Farhad Shakerin has provided this software AS IS. Farhad
% has made no warranty or representation that the
% operation of this software will be error-free, and he is
% under no obligation to provide any services, by way of
% maintenance, update, or otherwise.
%
% 3. Any user of such software agrees to indemnify and hold
% harmless Farhad Shakerin from
% all claims arising out of the use or misuse of this
% software, or arising out of any accident, injury, or damage
% whatsoever, and from all costs, counsel fees and liabilities
% incurred in or about any such claim, action, or proceeding
% brought thereon.
%
% 4. Users are requested, but not required, to inform Farhad Shakerin
% of any noteworthy uses of this software.
*/package decisiontree;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
*
* @author asus
*/
public class Features_record {
private LinkedHashMap m_mapVals;
private boolean m_bLabel;
public Features_record(String[] x_arrColumns)
{
m_mapVals = new LinkedHashMap();
for(int i = 0 ; i < x_arrColumns.length ; i++)
m_mapVals.put(x_arrColumns[i], "");
}
public boolean GetLabel()
{
return m_bLabel;
}
public void SetLabel(boolean x_bLabel)
{
m_bLabel = x_bLabel;
}
public void SetAttributeValue(String x_strAttrib,String x_strVal)
{
if(m_mapVals.containsKey(x_strAttrib))
m_mapVals.put(x_strAttrib, x_strVal);
else
{
System.out.printf("invalid attribute %s\r\n",x_strAttrib);
System.exit(-1);
}
}
public String GetAttributeValue(String x_strAttrib)
{
String strVal = "";
if(m_mapVals.containsKey(x_strAttrib))
{
strVal = (String)m_mapVals.get(x_strAttrib);
}
else
{
System.out.printf("invalid attribute %s\r\n",x_strAttrib);
System.exit(-1);
}
return strVal;
}
public String[] GetAttributeArray()
{
String[] arr = new String[m_mapVals.size()];
for(int i = 0 ; i < m_mapVals.size() ; i++)
arr[i] = (new ArrayList<String>(m_mapVals.values())).get(i);
return arr;
}
}