[1333] | 1 | package test.appProfConverter; |
---|
| 2 | import java.util.HashMap; |
---|
| 3 | import java.util.Map; |
---|
| 4 | |
---|
| 5 | import org.w3c.dom.Element; |
---|
| 6 | import org.w3c.dom.NodeList; |
---|
| 7 | |
---|
| 8 | public class Processor { |
---|
| 9 | public Processor(Element e) throws Exception { |
---|
| 10 | LoadElement(e); |
---|
| 11 | } |
---|
| 12 | |
---|
| 13 | private void LoadElement(Element e) throws Exception { |
---|
| 14 | if (!e.getTagName().equals("Processor")) { |
---|
| 15 | throw new Exception("Invalid element tag."); |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | MaxClockSpeed = Double.parseDouble(e |
---|
| 19 | .getElementsByTagName("MaxClockSpeed").item(0).getChildNodes() |
---|
| 20 | .item(0).getNodeValue().trim()); |
---|
| 21 | Cores = Integer.parseInt(e.getElementsByTagName("Cores").item(0) |
---|
| 22 | .getChildNodes().item(0).getNodeValue().trim()); |
---|
| 23 | |
---|
| 24 | NodeList nl = e.getElementsByTagName("PState"); |
---|
| 25 | Pstate = new PhaseState[nl.getLength()]; |
---|
| 26 | Pstate_map = new HashMap<Double, PhaseState>(); |
---|
| 27 | for (int i = 0; i < Pstate.length; i++) { |
---|
| 28 | Element pstateEl = (Element) nl.item(i); |
---|
| 29 | PhaseState ps = new PhaseState(pstateEl); |
---|
| 30 | Pstate[i] = ps; |
---|
| 31 | Pstate_map.put(ps.Frequency, ps); |
---|
| 32 | } |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | public Double MaxClockSpeed; |
---|
| 36 | public Integer Cores; |
---|
| 37 | public PhaseState Pstate[]; |
---|
| 38 | public Map<Double, PhaseState> Pstate_map; |
---|
| 39 | |
---|
| 40 | public String ToString() { |
---|
| 41 | String str = ""; |
---|
| 42 | |
---|
| 43 | str += "Processor:\n"; |
---|
| 44 | str += " MaxClockSpeed: " + this.MaxClockSpeed + "\n"; |
---|
| 45 | str += " Cores: " + Integer.toString(this.Cores) + "\n"; |
---|
| 46 | str += " PStates:\n"; |
---|
| 47 | for (int i = 0; i < Pstate.length; i++) { |
---|
| 48 | str += Pstate[i].ToString(); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | return str; |
---|
| 52 | } |
---|
| 53 | } |
---|