@Test public void testStep1_4Partial() { ParserStatus expectedStatus = ParserStatus.PARTIAL; int expectedStep = 1; BufferedInputStream testInputStream = new BufferedInputStream( new ByteArrayInputStream(new byte[] { (byte)0x6f, (byte)0x75, (byte)0x4d, (byte)0x19, (byte)0xa4, (byte)0xa1, (byte)0x5c, (byte)0xce, (byte)0x67, (byte)0x06, (byte)0x00, (byte)0x00, (byte)0x04 })); try { assertEquals(expectedStatus, testDistressMsgFileParser.parseFile(testInputStream, "testLogFile.bin")); assertEquals(expectedStep, testDistressMsgFileParser.getStep()); } catch (FileParserException e) { fail("Unexpected exception: " + e); } }
@Override public ParserStatus parseFile(BufferedInputStream bis, String fileName) throws FileParserException { ParserStatus status; try { status = super.parseFile(bis, fileName); if (status != ParserStatus.COMPLETE) return status; if (getStep() == 1) { status = nextStep(bis, fileName, locationParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 2) { status = nextStep(bis, fileName, timeParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 3) { status = nextStep(bis, fileName, secResCodeParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 4) { status = nextStep(bis, fileName, payloadParser); if (status != ParserStatus.COMPLETE) return status; } resetStep(); status = ParserStatus.COMPLETE; } catch (Exception e) { throw new FileParserException(String.format("Error parsing %s on step %d", fileName, getStep()), e); } return status; }
DistressMsgFileParser extends LogFileParser { @Override public ParserStatus parseFile(BufferedInputStream bis, String fileName) throws FileParserException { ParserStatus status; try { status = super.parseFile(bis, fileName); if (status != ParserStatus.COMPLETE) return status; if (getStep() == 1) { status = nextStep(bis, fileName, locationParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 2) { status = nextStep(bis, fileName, timeParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 3) { status = nextStep(bis, fileName, secResCodeParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 4) { status = nextStep(bis, fileName, payloadParser); if (status != ParserStatus.COMPLETE) return status; } resetStep(); status = ParserStatus.COMPLETE; } catch (Exception e) { throw new FileParserException(String.format("Error parsing %s on step %d", fileName, getStep()), e); } return status; } }
DistressMsgFileParser extends LogFileParser { @Override public ParserStatus parseFile(BufferedInputStream bis, String fileName) throws FileParserException { ParserStatus status; try { status = super.parseFile(bis, fileName); if (status != ParserStatus.COMPLETE) return status; if (getStep() == 1) { status = nextStep(bis, fileName, locationParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 2) { status = nextStep(bis, fileName, timeParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 3) { status = nextStep(bis, fileName, secResCodeParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 4) { status = nextStep(bis, fileName, payloadParser); if (status != ParserStatus.COMPLETE) return status; } resetStep(); status = ParserStatus.COMPLETE; } catch (Exception e) { throw new FileParserException(String.format("Error parsing %s on step %d", fileName, getStep()), e); } return status; } DistressMsgFileParser(); }
DistressMsgFileParser extends LogFileParser { @Override public ParserStatus parseFile(BufferedInputStream bis, String fileName) throws FileParserException { ParserStatus status; try { status = super.parseFile(bis, fileName); if (status != ParserStatus.COMPLETE) return status; if (getStep() == 1) { status = nextStep(bis, fileName, locationParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 2) { status = nextStep(bis, fileName, timeParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 3) { status = nextStep(bis, fileName, secResCodeParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 4) { status = nextStep(bis, fileName, payloadParser); if (status != ParserStatus.COMPLETE) return status; } resetStep(); status = ParserStatus.COMPLETE; } catch (Exception e) { throw new FileParserException(String.format("Error parsing %s on step %d", fileName, getStep()), e); } return status; } DistressMsgFileParser(); @Override ParserStatus parseFile(BufferedInputStream bis, String fileName); }
DistressMsgFileParser extends LogFileParser { @Override public ParserStatus parseFile(BufferedInputStream bis, String fileName) throws FileParserException { ParserStatus status; try { status = super.parseFile(bis, fileName); if (status != ParserStatus.COMPLETE) return status; if (getStep() == 1) { status = nextStep(bis, fileName, locationParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 2) { status = nextStep(bis, fileName, timeParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 3) { status = nextStep(bis, fileName, secResCodeParser); if (status != ParserStatus.COMPLETE) return status; } if (getStep() == 4) { status = nextStep(bis, fileName, payloadParser); if (status != ParserStatus.COMPLETE) return status; } resetStep(); status = ParserStatus.COMPLETE; } catch (Exception e) { throw new FileParserException(String.format("Error parsing %s on step %d", fileName, getStep()), e); } return status; } DistressMsgFileParser(); @Override ParserStatus parseFile(BufferedInputStream bis, String fileName);  }