1 26 27 package net.sourceforge.groboutils.codecoverage.v2.datastore; 28 29 import java.io.IOException ; 30 import java.io.Reader ; 31 import java.io.Writer ; 32 33 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisMetaData; 34 35 42 class AnalysisMetaDataIO 43 { 44 public AnalysisMetaDataIO() 45 { 46 } 48 49 50 private static class StaleAnalysisMetaData implements IAnalysisMetaData 51 { 52 private String covered; 53 private String notCovered; 54 private byte weight; 55 56 public StaleAnalysisMetaData( String c, String n, byte w ) 57 { 58 this.covered = c; 59 this.notCovered = n; 60 this.weight = w; 61 } 62 63 public String getCoveredFormattedText() { return this.covered; } 64 public String getNotCoveredFormattedText() { return this.notCovered; } 65 public byte getInstructionWeight() { return this.weight; } 66 } 67 68 public void writeAnalysisMetaData( IAnalysisMetaData ams, Writer out ) 69 throws IOException 70 { 71 StringBuffer sb = new StringBuffer (); 72 73 sb.append( ams.getCoveredFormattedText().length() ). 74 append( ':' ). 75 append( ams.getCoveredFormattedText() ). 76 append( ',' ). 77 append( ams.getNotCoveredFormattedText().length() ). 78 append( ':' ). 79 append( ams.getNotCoveredFormattedText() ). 80 append( ',' ). 81 append( ams.getInstructionWeight() ). 82 append( ',' ); 83 84 out.write( sb.toString() ); 85 } 86 87 88 public IAnalysisMetaData readAnalysisMetaData( Reader in ) 89 throws IOException 90 { 91 int count = ReadUtil.toInt( 92 ReadUtil.readTo( in, ':' ) ); 93 String covered = ReadUtil.readCount( in, count ); 94 ReadUtil.readTo( in, ',' ); 95 96 count = ReadUtil.toInt( 97 ReadUtil.readTo( in, ':' ) ); 98 String notCovered = ReadUtil.readCount( in, count ); 99 ReadUtil.readTo( in, ',' ); 100 101 int iweight = ReadUtil.toInt( 102 ReadUtil.readTo( in, ',' ) ); 103 104 return new StaleAnalysisMetaData( covered, notCovered, (byte)iweight ); 105 } 106 } 107 108 | Popular Tags |