1
2
3
4 package ca.spaz.cron.database;
5
6 import java.util.*;
7
8 public class NutrientInfo {
9
10 private String tag;
11
12 private String name;
13
14 private String units;
15
16 private String category;
17
18 private double RDI = -1;
19
20 private double RDA_MIN;
21
22 private double RDA_MAX;
23
24 private static List macroNutrients = null;
25
26 private static List minerals = null;
27
28 private static List aminoAcids = null;
29
30 private static List vitamins = null;
31
32 private static List lipids = null;
33
34 private static List globalList;
35
36 private NutrientInfo(String tag, String name, String units, String category) {
37 this.tag = tag;
38 this.name = name;
39 this.units = units;
40 this.category = category;
41 }
42
43 private NutrientInfo(String tag, String name, String units, String category, double DV) {
44 this(tag, name, units, category);
45 this.RDI = DV;
46 }
47
48
49 public String getName() {
50 return name;
51 }
52
53 public String getUnits() {
54 return units;
55 }
56
57 public String getTag() {
58 return tag;
59 }
60
61 public String getCategory() {
62 return category;
63 }
64
65 public static List getMacroNutrients() {
66 if (null == macroNutrients) {
67 macroNutrients = new ArrayList();
68 macroNutrients.add(new NutrientInfo("kcals", "Energy", "kcal",
69 "MacroNutrients", 2000));
70 macroNutrients.add(new NutrientInfo("protein", "Protein", "g",
71 "MacroNutrients", 50));
72 macroNutrients.add(new NutrientInfo("carbs", "Carbs", "g",
73 "MacroNutrients", 300));
74 macroNutrients.add(new NutrientInfo("lipid", "Fat", "g",
75 "MacroNutrients", 65));
76 macroNutrients.add(new NutrientInfo("water", "Water", "g",
77 "MacroNutrients", 1500));
78 macroNutrients.add(new NutrientInfo("fiber", "Fiber", "g",
79 "MacroNutrients", 25));
80 macroNutrients.add(new NutrientInfo("starch", "Starch", "g",
81 "MacroNutrients"));
82 macroNutrients.add(new NutrientInfo("ash", "Ash", "g",
83 "MacroNutrients"));
84 }
85 return Collections.unmodifiableList(macroNutrients);
86 }
87
88 public static List getMinerals() {
89 if (null == minerals) {
90 minerals = new ArrayList();
91 minerals.add(new NutrientInfo("calcium", "Calcium", "mg",
92 "Minerals", 1000));
93 minerals.add(new NutrientInfo("copper", "Copper", "mg", "Minerals", 2));
94 minerals.add(new NutrientInfo("iron", "Iron", "mg", "Minerals", 18));
95 minerals.add(new NutrientInfo("magnesium", "Magnesium", "mg",
96 "Minerals", 400));
97 minerals.add(new NutrientInfo("manganese", "Manganese", "mg",
98 "Minerals", 2.0));
99 minerals.add(new NutrientInfo("phosphorus", "Phosphorus", "mg",
100 "Minerals", 1000));
101 minerals.add(new NutrientInfo("potassium", "Potassium", "mg",
102 "Minerals", 3500));
103 minerals.add(new NutrientInfo("selenium", "Selenium", "mcg",
104 "Minerals", 70.0));
105 minerals.add(new NutrientInfo("sodium", "Sodium", "mg", "Minerals", 2400));
106 minerals.add(new NutrientInfo("zinc", "Zinc", "mg", "Minerals", 15));
107 }
108 return Collections.unmodifiableList(minerals);
109 }
110
111 public static List getAminoAcids() {
112 if (null == aminoAcids) {
113 aminoAcids = new ArrayList();
114 aminoAcids.add(new NutrientInfo("ALA", "ALA", "g", "AminoAcids"));
115 aminoAcids.add(new NutrientInfo("ASP", "ASP", "g", "AminoAcids"));
116 aminoAcids.add(new NutrientInfo("ARG", "ARG", "g", "AminoAcids"));
117 aminoAcids.add(new NutrientInfo("CYS", "CYS", "g", "AminoAcids"));
118 aminoAcids.add(new NutrientInfo("GLU", "GLU", "g", "AminoAcids"));
119 aminoAcids.add(new NutrientInfo("GLY", "GLY", "g", "AminoAcids"));
120 aminoAcids.add(new NutrientInfo("HIS", "HIS", "g", "AminoAcids"));
121 aminoAcids.add(new NutrientInfo("HYP", "HYP", "g", "AminoAcids"));
122 aminoAcids.add(new NutrientInfo("ILE", "ILE", "g", "AminoAcids"));
123 aminoAcids.add(new NutrientInfo("LEU", "LEU", "g", "AminoAcids"));
124 aminoAcids.add(new NutrientInfo("LYS", "LYS", "g", "AminoAcids"));
125 aminoAcids.add(new NutrientInfo("MET", "MET", "g", "AminoAcids"));
126 aminoAcids.add(new NutrientInfo("PHE", "PHE", "g", "AminoAcids"));
127 aminoAcids.add(new NutrientInfo("PRO", "PRO", "g", "AminoAcids"));
128 aminoAcids.add(new NutrientInfo("SER", "SER", "g", "AminoAcids"));
129 aminoAcids.add(new NutrientInfo("THR", "THR", "g", "AminoAcids"));
130 aminoAcids.add(new NutrientInfo("TRP", "TRP", "g", "AminoAcids"));
131 aminoAcids.add(new NutrientInfo("TYR", "TYR", "g", "AminoAcids"));
132 aminoAcids.add(new NutrientInfo("VAL", "VAL", "g", "AminoAcids"));
133 }
134 return Collections.unmodifiableList(aminoAcids);
135 }
136
137 public static List getVitamins() {
138 if (null == vitamins) {
139 vitamins = new ArrayList();
140 vitamins.add(new NutrientInfo("vit_a", "Vitamin A", "IU", "Vitamins", 5000));
141 vitamins.add(new NutrientInfo("retinol", "Retinol", "mcg", "Vitamins"));
142 vitamins.add(new NutrientInfo("alpha_carotene", "Alpha-carotene", "mcg", "Vitamins"));
143 vitamins.add(new NutrientInfo("beta_carotene", "Beta-carotene", "mcg", "Vitamins"));
144 vitamins.add(new NutrientInfo("beta_cryptoxanthin", "Beta-cryptoxanthin", "mcg", "Vitamins"));
145 vitamins.add(new NutrientInfo("lycopene", "Lycopene", "mcg", "Vitamins"));
146 vitamins.add(new NutrientInfo("lutein", "Lutein+Zeaxanthin", "mcg", "Vitamins"));
147 vitamins.add(new NutrientInfo("thiamin", "B1 (Thiamine)", "mg", "Vitamins", 1.5));
148 vitamins.add(new NutrientInfo("riboflavin", "B2 (Riboflavin)", "mg", "Vitamins",1.7));
149 vitamins.add(new NutrientInfo("niacin", "B3 (Niacin)", "mg", "Vitamins",20));
150 vitamins.add(new NutrientInfo("panto_acid", "B5 (Pantothenic Acid)", "mg", "Vitamins",10));
151 vitamins.add(new NutrientInfo("vit_b6", "B6 (Pyridoxine)", "mg", "Vitamins", 2));
152 vitamins.add(new NutrientInfo("vit_b12", "B12 (Cyanocobalamin)", "mcg", "Vitamins", 6));
153 vitamins.add(new NutrientInfo("vit_c", "Vitamin C", "mg", "Vitamins", 60));
154 vitamins.add(new NutrientInfo("vit_d", "Vitamin D", "IU", "Vitamins", 400));
155 vitamins.add(new NutrientInfo("vit_e", "Vitamin E", "mg", "Vitamins", 30));
156 vitamins.add(new NutrientInfo("beta_tocopherol", "Beta Tocopherol", "mg", "Vitamins"));
157 vitamins.add(new NutrientInfo("delta_tocopherol", "Delta Tocopherol", "mg", "Vitamins"));
158 vitamins.add(new NutrientInfo("gamma_tocopherol", "Gamma Tocopherol", "mg", "Vitamins"));
159 vitamins.add(new NutrientInfo("vit_k", "Vitamin K", "mcg", "Vitamins", 80));
160 vitamins.add(new NutrientInfo("folate", "Folate", "mcg", "Vitamins", 400));
161
162 }
163 return Collections.unmodifiableList(vitamins);
164 }
165
166 public static List getLipids() {
167 if (null == lipids) {
168 lipids = new ArrayList();
169 lipids.add(new NutrientInfo("saturated", "Saturated", "g", "Lipids", 20));
170 lipids.add(new NutrientInfo("monounsaturated", "Monounsaturated", "g", "Lipids"));
171 lipids.add(new NutrientInfo("polyunsaturated", "Polyunsaturated", "g", "Lipids"));
172 lipids.add(new NutrientInfo("omega3", "Omega-3", "g", "Lipids"));
173 lipids.add(new NutrientInfo("omega6", "Omega-6", "g", "Lipids"));
174 lipids.add(new NutrientInfo("transfats", "Trans-Fats", "g", "Lipids"));
175 lipids.add(new NutrientInfo("cholesterol", "Cholesterol", "g", "Lipids", 300));
176 lipids.add(new NutrientInfo("phytosterol", "Phytosterol", "g", "Lipids"));
177 }
178 return Collections.unmodifiableList(lipids);
179 }
180
181 public static NutrientInfo getByTableName(String tableName) {
182 NutrientInfo ret = null;
183 List srch = getGlobalList();
184 for (Iterator iter = srch.iterator(); iter.hasNext();) {
185 NutrientInfo element = (NutrientInfo) iter.next();
186 if (element.getTag().equalsIgnoreCase(tableName)) {
187 ret = element;
188 break;
189 }
190 }
191 return ret;
192 }
193
194 public static NutrientInfo getByName(String name) {
195 NutrientInfo ret = null;
196 List srch = getGlobalList();
197 for (Iterator iter = srch.iterator(); iter.hasNext();) {
198 NutrientInfo element = (NutrientInfo) iter.next();
199 if (element.getName().equalsIgnoreCase(name)) {
200 ret = element;
201 break;
202 }
203 }
204 return ret;
205 }
206
207 public static List getGlobalList() {
208 if (null == globalList) {
209 globalList = new ArrayList();
210 globalList.addAll(getMacroNutrients());
211 globalList.addAll(getAminoAcids());
212 globalList.addAll(getMinerals());
213 globalList.addAll(getVitamins());
214 globalList.addAll(getLipids());
215 }
216 return Collections.unmodifiableList(globalList);
217 }
218
219 public double getTarget() {
220 return getReferenceDailyIntake();
221 }
222
223 public double getReferenceDailyIntake() {
224 return RDI;
225 }
226 }
227
228
229
230
231
232
233
234
235
236
237