@Override protected void doLoad(InputStream inputStream, Map<?, ?> options) throws IOException { TraceRegionSerializer serializer = new TraceRegionSerializer(); DebugTraceRegion result = serializer.doReadFrom(inputStream, new Strategy()); getContents().add(result); }
@Override protected void doSave(OutputStream outputStream, Map<?, ?> options) throws IOException { TraceRegionSerializer serializer = new TraceRegionSerializer(); serializer.doWriteTo(new Strategy(), (DebugTraceRegion) getContents().get(0), outputStream); } };
public <Region, Location> Region doReadFrom(InputStream contents, Strategy<Region, Location> reader) throws IOException { DataInputStream dataStream = new DataInputStream(new BufferedInputStream(contents)); int version = dataStream.readInt(); if (version != VERSION_3 && version != VERSION_4) return null; boolean isNull = !dataStream.readBoolean(); if (isNull) return null; return doReadFrom(dataStream, reader, null, version); }
/** * @since 2.4 */ protected void generateTrace(String generatedFile, String outputConfigName, CharSequence contents) { try { if (contents instanceof ITraceRegionProvider) { String traceFileName = traceFileNameProvider.getTraceFromJava(generatedFile); File traceFile = getFile(traceFileName, outputConfigName); OutputStream out = new BufferedOutputStream(new FileOutputStream(traceFile)); try { AbstractTraceRegion traceRegion = ((ITraceRegionProvider) contents).getTraceRegion(); traceSerializer.writeTraceRegionTo(traceRegion, out); } finally { out.close(); } } } catch (FileNotFoundException e) { throw new RuntimeIOException(e); } catch (IOException e) { throw new RuntimeIOException(e); } }
public void writeTraceRegionTo(AbstractTraceRegion region, OutputStream stream) throws IOException { if (region != null && region.getParent() != null) throw new IllegalArgumentException("region must be the root"); doWriteTo(new IdentityStrategy(), region, stream); }
public AbstractTraceRegion getTraceRegion() { IStorage resource = derivedResource; if (resource instanceof IFile) { IStorage traceFile = getTraceFile(resource); if (traceFile instanceof IFile && ((IFile)traceFile).exists()) { InputStream contents = null; try { contents = traceFile.getContents(); return traceRegionSerializer.readTraceRegionFrom(contents); } catch (Exception e) { log.error(e.getMessage(), e); } finally { Closeables.closeQuietly(contents); } } } throw new TraceNotFoundException(); } });
public AbstractTraceRegion readTraceRegionFrom(InputStream contents) throws IOException { return doReadFrom(contents, new IdentityStrategy()); }
traceSerializer.writeTraceRegionTo(traceRegion, data);
public AbstractTraceRegion getTraceRegion() { String traceSimpleFileName = getTraceSimpleFileName(classFile); if (traceSimpleFileName == null) return null; String pathInFragmentRoot = getPathInFragmentRoot(classFile); URI traceURI = URI.createURI(pathInFragmentRoot + traceSimpleFileName); try { InputStream contents = result.getContents(traceURI, result.getLocalProject()); if (contents != null) try { return traceRegionSerializer.readTraceRegionFrom(contents); } finally { contents.close(); } } catch (CoreException e) { log.error(e); } catch (IOException e) { log.error(e); } return null; } });
int childrenSize = dataStream.readInt(); while(childrenSize != 0) { doReadFrom(dataStream, reader, result, version); childrenSize--;
try { contents = ((IStorage) traceFile).getContents(); AbstractTraceRegion traceRegion = traceRegionSerializer.readTraceRegionFrom(contents); final IStorage generatedFileForTraceFile = getGeneratedFileForTraceFile(traceFile); if (generatedFileForTraceFile == null)