sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi/src/com/nokia/carbide/cpp/internal/pi/analyser/StreamFileParser.java
equal
deleted
inserted
replaced
50 readLoop(); |
50 readLoop(); |
51 } |
51 } |
52 |
52 |
53 public byte[] getDataForTraceType(int traceType) |
53 public byte[] getDataForTraceType(int traceType) |
54 { |
54 { |
55 Integer type = new Integer(traceType); |
55 Integer type = Integer.valueOf(traceType); |
56 if (dataBlocks.containsKey(type)) |
56 if (dataBlocks.containsKey(type)) |
57 { |
57 { |
58 ByteArrayOutputStream baos = |
58 ByteArrayOutputStream baos = |
59 (ByteArrayOutputStream)dataBlocks.get(type); |
59 (ByteArrayOutputStream)dataBlocks.get(type); |
60 return baos.toByteArray(); |
60 return baos.toByteArray(); |
68 public File getTempFileForTraceType(int traceType) throws IOException |
68 public File getTempFileForTraceType(int traceType) throws IOException |
69 { |
69 { |
70 byte[] data = getDataForTraceType(traceType); |
70 byte[] data = getDataForTraceType(traceType); |
71 if (data == null) return null; |
71 if (data == null) return null; |
72 File f = File.createTempFile("type_" + traceType + "_trace_file",".dat"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
72 File f = File.createTempFile("type_" + traceType + "_trace_file",".dat"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
73 //File f = File.createTempFile(getTypeString(new Integer(traceType)),".dat"); |
73 //File f = File.createTempFile(getTypeString(Integer.valueOf(traceType)),".dat"); |
74 f.deleteOnExit(); |
74 f.deleteOnExit(); |
75 |
75 |
76 FileOutputStream fos = new FileOutputStream(f); |
76 FileOutputStream fos = new FileOutputStream(f); |
77 fos.write(data); |
77 fos.write(data); |
78 fos.flush(); |
78 fos.flush(); |
79 fos.close(); |
79 fos.close(); |
80 |
80 |
81 return f; |
81 return f; |
82 } |
82 } |
83 |
83 |
84 private void readLoop() |
84 private void readLoop() throws IOException |
85 { |
85 { |
86 while(setLengthAndMode() == true) |
86 while(setLengthAndMode() == true) |
87 { |
87 { |
88 copyDataBlock(); |
88 copyDataBlock(); |
89 } |
89 } |
116 if (typeValue.intValue() == 7) return "BUP"; |
116 if (typeValue.intValue() == 7) return "BUP"; |
117 |
117 |
118 else return "undefined_type"; |
118 else return "undefined_type"; |
119 }*/ |
119 }*/ |
120 |
120 |
121 public boolean setLengthAndMode() |
121 public boolean setLengthAndMode() throws IOException |
122 { |
122 { |
123 if (readOffset+4 >= streamData.length) |
123 if (readOffset+4 >= streamData.length) |
124 { |
124 { |
125 // end of data buffer reached |
125 // end of data buffer reached |
126 streamData = null; |
126 streamData = null; |
132 int b2 = (streamData[readOffset++]<<24)>>>24; |
132 int b2 = (streamData[readOffset++]<<24)>>>24; |
133 int b3 = (streamData[readOffset++]<<24)>>>24; |
133 int b3 = (streamData[readOffset++]<<24)>>>24; |
134 //System.out.println(" b1:"+b1+" b2:"+b2+" b3:"+b3); |
134 //System.out.println(" b1:"+b1+" b2:"+b2+" b3:"+b3); |
135 currentLength = (int)(b1 | b2<<8 | b3 <<16); |
135 currentLength = (int)(b1 | b2<<8 | b3 <<16); |
136 |
136 |
|
137 if (readOffset+currentLength >= streamData.length){ |
|
138 throw new IOException(Messages.getString("StreamFileParser.0")); //$NON-NLS-1$ |
|
139 } |
|
140 |
137 currentType = streamData[readOffset++]; |
141 currentType = streamData[readOffset++]; |
138 //System.out.println("Length "+currentLength+" mode "+currentType); |
142 //System.out.println("Length "+currentLength+" mode "+currentType); |
139 |
143 |
140 return true; |
144 return true; |
141 } |
145 } |
142 } |
146 } |
143 |
147 |
144 private void copyDataBlock() |
148 private void copyDataBlock() |
145 { |
149 { |
146 Integer typeInt = new Integer(currentType); |
150 Integer typeInt = Integer.valueOf(currentType); |
147 ByteArrayOutputStream baos = null; |
151 ByteArrayOutputStream baos = null; |
148 |
152 |
149 if (dataBlocks.containsKey(typeInt)) |
153 if (dataBlocks.containsKey(typeInt)) |
150 { |
154 { |
151 baos = (ByteArrayOutputStream)dataBlocks.get(typeInt); |
155 baos = (ByteArrayOutputStream)dataBlocks.get(typeInt); |