|
3 | 3 | import android.util.Log; |
4 | 4 |
|
5 | 5 | import java.io.BufferedReader; |
6 | | -import java.io.EOFException; |
7 | 6 | import java.io.FileInputStream; |
8 | 7 | import java.io.FileNotFoundException; |
9 | 8 | import java.io.IOException; |
10 | 9 | import java.io.InputStreamReader; |
11 | | -import java.io.InterruptedIOException; |
12 | | - |
13 | | -import java.util.*; |
14 | | -import java.util.List; |
15 | 10 | import java.util.ArrayList; |
16 | | -import java.util.Iterator; |
| 11 | +import java.util.List; |
| 12 | +import java.util.ListIterator; |
17 | 13 |
|
18 | 14 |
|
19 | 15 | /** |
@@ -101,6 +97,29 @@ public int searchForData(String search) throws IOException { |
101 | 97 | // Return -1 if no match |
102 | 98 | return -1; |
103 | 99 | } |
| 100 | + |
| 101 | + /* |
| 102 | + * A function to search for data in a hex file |
| 103 | + * @param the _string_ of data to search for |
| 104 | + * @return the index of the data. -1 if not found. |
| 105 | + */ |
| 106 | + public int searchForDataRegEx(String search) throws IOException { |
| 107 | + // Iterate through |
| 108 | + ListIterator i = hexLines.listIterator(); |
| 109 | + while (i.hasNext()) { |
| 110 | + // Have to call nextIndex() before next() |
| 111 | + int index = i.nextIndex(); |
| 112 | + |
| 113 | + // Return index if successful |
| 114 | + String match = i.next().toString(); |
| 115 | + if(match.matches(search)){ |
| 116 | + return index; |
| 117 | + } |
| 118 | + } |
| 119 | + |
| 120 | + // Return -1 if no match |
| 121 | + return -1; |
| 122 | + } |
104 | 123 |
|
105 | 124 | /* |
106 | 125 | * Returns data from an index |
@@ -130,6 +149,15 @@ public int getRecordAddressFromIndex(int index) throws IOException { |
130 | 149 | return getRecordAddress(hexLines.get(index)); |
131 | 150 | } |
132 | 151 |
|
| 152 | + /* |
| 153 | + Used to get the data length from a record |
| 154 | + @param Record as a String |
| 155 | + @return Data length as a decimal / # of chars |
| 156 | + */ |
| 157 | + public int getRecordDataLengthFromIndex(int index){ |
| 158 | + return getRecordDataLength(hexLines.get(index)); |
| 159 | + } |
| 160 | + |
133 | 161 | /* |
134 | 162 | * Returns segment address from an index |
135 | 163 | * @param index |
|
0 commit comments