DefaultX9RecordFactoryStrategy implements X9RecordFactoryStrategy { public X9RecordFactory factory(X937FileHeaderRecord fileHeaderRecord) { String standardIdentifier = null; int standardLevel = 0; try { standardLevel = fileHeaderRecord.standardLevelAsInt(); } catch (InvalidDataException e) { throw new InvalidStandardLevelException(); } String encoding = fileHeaderRecord.record().getEncoding(); if (standardLevel == X9Record.STANDARD_LEVEL_DSTU) { standardIdentifier = X937_STANDARD_DSTU; } else if (standardLevel == X9Record.STANDARD_LEVEL_SVPCO) { standardIdentifier = X937_STANDARD_SVPCO; } else if (standardLevel == X9Record.STANDARD_LEVEL_2001) { standardIdentifier = X937_STANDARD_2001; } else if (standardLevel == X9Record.STANDARD_LEVEL_1994) { standardIdentifier = X937_STANDARD_1994; } else { throw new InvalidStandardLevelException(); } X9RecordFactory factory = factory(standardIdentifier, encoding); return factory; }  X9RecordFactory factory(X937FileHeaderRecord fileHeaderRecord); X9RecordFactory factory(String standardIdentifier); X9RecordFactory factory(String standardIdentifier, String encoding);  }
@Test public void testFactory() throws Exception { X9RecordFactoryStrategy strategy = new DefaultX9RecordFactoryStrategy(); X9RecordFactory factory = strategy.factory(X9RecordFactoryStrategy.X937_STANDARD_DSTU); Record x9Record = factory.newX9Record(X9Record.TYPE_FILE_HEADER); X937FileHeaderRecord fileHeaderRecord = (X937FileHeaderRecord) x9Record; assertEquals("03", fileHeaderRecord.standardLevel()); assertEquals(3, fileHeaderRecord.standardLevelAsInt()); }