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