BowlerKernel
Core.java
Go to the documentation of this file.
1 package com.neuronrobotics.sdk.bootloader;
2 
3 import java.io.BufferedReader;
4 import java.io.DataInputStream;
5 import java.io.FileInputStream;
6 import java.io.InputStreamReader;
7 import java.util.ArrayList;
8 
9 // TODO: Auto-generated Javadoc
13 public class Core {
14 
16  private int index;
17 
20 
22  private ArrayList<hexLine> lines = new ArrayList<hexLine>();
23 
31  public Core(int core,ArrayList<hexLine> lines,NRBootCoreType type){
32  setIndex(core);
33  this.setType(type);
34  this.lines=lines;
35  }
36 
44  public Core(int core,String file, NRBootCoreType type){
45  setIndex(core);
46  this.setType(type);
47  try {
48  ArrayList<hexLine> tmp = new ArrayList<hexLine>();
49  // Get the object of DataInputStream
50  DataInputStream in = new DataInputStream(new FileInputStream(file));
51  BufferedReader br = new BufferedReader(new InputStreamReader(in));
52  String strLine;
53  while ((strLine = br.readLine()) != null) {
54  // Print the content on the console
55  try {
56  tmp.add(new hexLine(strLine));
57  } catch (Exception e) {
58  System.err.println("This is not a valid hex file");
59  }
60  }
61  //Close the input stream
62  in.close();
63  setLines(tmp);
64  }catch (Exception e) {
66  }
67  }
68 
74  public void setIndex(int index) {
75  this.index = index;
76  }
77 
83  public int getIndex() {
84  return index;
85  }
86 
92  public void setType(NRBootCoreType type) {
93  this.type = type;
94  }
95 
102  return type;
103  }
104 
110  public void setLines(ArrayList<hexLine> lines) {
111  this.lines = lines;
112  }
113 
119  public ArrayList<hexLine> getLines() {
120  return lines;
121  }
122 
123  /* (non-Javadoc)
124  * @see java.lang.Object#toString()
125  */
126  @Override
127  public String toString() {
128  return "Core: "+index+" of type: "+type;
129  }
130 }
void setType(NRBootCoreType type)
Definition: Core.java:92
ArrayList< hexLine > lines
Definition: Core.java:22
Core(int core, String file, NRBootCoreType type)
Definition: Core.java:44
ArrayList< hexLine > getLines()
Definition: Core.java:119
Core(int core, ArrayList< hexLine > lines, NRBootCoreType type)
Definition: Core.java:31
void setLines(ArrayList< hexLine > lines)
Definition: Core.java:110