Hi,
I’m trying to read a config file like this:
<MapRules>
<Rule>
<Name>TerrainsToBeFoggedWithinLos</Name>
<Value>FOREST</Price>
</Rule>
<Rule>
<Name>BuildingsToBeFoggedWithinLos</Name>
<Value>CITY,FACTORY,PORT</Price>
</Rule>
<Rule>
<Name>FogOn</Name>
<Value>true</Price>
</Rule>
</MapRules>
I know howto read it out the xml file(using org.w3c.dom) ,
but I don’t know how to store it(in a good way) into java
I want to get the correct type, support lists
If i would create a hashmap:
private static HashMap<String, Object> rules;
public static Object getRule(String rule) {
return rules.get(rule);
}
Then my ide complains that it is unsafe to get it directly
List foggedTerrains = (List) Rules.getRule(“TerrainsToBeFoggedWithinLos”);
List foggedBuildings = (List) Rules.getRule(“BuildingsToBeFoggedWithinLos”);
Should I create getInt, getByte, getList ? or …