@Test public void testDumpMacroBlockWithSource() throws Exception { Block macro1 = new MacroBlock("macro", params, "content", false); Block macro2 = new MacroBlock("macro", params, "content", false); XDOM xdom1 = new XDOM(Collections.singletonList(macro1)); XDOM xdom2 = new XDOM(Collections.singletonList(macro2)); xdom1.getMetaData().addMetaData(MetaData.SOURCE, "source"); xdom2.getMetaData().addMetaData(MetaData.SOURCE, "source"); byte[] dump1 = dumper.dump(macro1); byte[] dump2 = dumper.dump(macro2); assertThat(dump1, equalTo(dump2)); dump2 = dumper.dump(new MacroBlock("macro", params, "content", false)); assertThat(dump1, not(equalTo(dump2))); xdom2.getMetaData().addMetaData(MetaData.SOURCE, "other"); dump2 = dumper.dump(macro2); assertThat(dump1, not(equalTo(dump2))); xdom2.getMetaData().addMetaData(MetaData.SOURCE, null); dump1 = dumper.dump(new MacroBlock("macro", params, "content", false)); dump2 = dumper.dump(macro2); assertThat(dump1, equalTo(dump2)); }
@Override public void dump(OutputStream out, Block block) throws IOException { if (block instanceof MacroBlock) { MacroBlock b = (MacroBlock) block; dump(out, b.getId(), b.getParameters(), b.getContent()); } else if (block instanceof MacroMarkerBlock) { MacroMarkerBlock b = (MacroMarkerBlock) block; dump(out, b.getId(), b.getParameters(), b.getContent()); } else { throw new IllegalArgumentException("Unsupported block [" + block.getClass().getName() + "]."); } String source = getSourceReference(block); if (source != null) { out.write(toBytes(source)); } out.write(0x00); }
MacroBlockDumper implements BlockDumper { @Override public void dump(OutputStream out, Block block) throws IOException { if (block instanceof MacroBlock) { MacroBlock b = (MacroBlock) block; dump(out, b.getId(), b.getParameters(), b.getContent()); } else if (block instanceof MacroMarkerBlock) { MacroMarkerBlock b = (MacroMarkerBlock) block; dump(out, b.getId(), b.getParameters(), b.getContent()); } else { throw new IllegalArgumentException("Unsupported block [" + block.getClass().getName() + "]."); } String source = getSourceReference(block); if (source != null) { out.write(toBytes(source)); } out.write(0x00); } }
MacroBlockDumper implements BlockDumper { @Override public void dump(OutputStream out, Block block) throws IOException { if (block instanceof MacroBlock) { MacroBlock b = (MacroBlock) block; dump(out, b.getId(), b.getParameters(), b.getContent()); } else if (block instanceof MacroMarkerBlock) { MacroMarkerBlock b = (MacroMarkerBlock) block; dump(out, b.getId(), b.getParameters(), b.getContent()); } else { throw new IllegalArgumentException("Unsupported block [" + block.getClass().getName() + "]."); } String source = getSourceReference(block); if (source != null) { out.write(toBytes(source)); } out.write(0x00); }  }
MacroBlockDumper implements BlockDumper { @Override public void dump(OutputStream out, Block block) throws IOException { if (block instanceof MacroBlock) { MacroBlock b = (MacroBlock) block; dump(out, b.getId(), b.getParameters(), b.getContent()); } else if (block instanceof MacroMarkerBlock) { MacroMarkerBlock b = (MacroMarkerBlock) block; dump(out, b.getId(), b.getParameters(), b.getContent()); } else { throw new IllegalArgumentException("Unsupported block [" + block.getClass().getName() + "]."); } String source = getSourceReference(block); if (source != null) { out.write(toBytes(source)); } out.write(0x00); }  @Override void dump(OutputStream out, Block block); @Override byte[] dump(Block block); }
MacroBlockDumper implements BlockDumper { @Override public void dump(OutputStream out, Block block) throws IOException { if (block instanceof MacroBlock) { MacroBlock b = (MacroBlock) block; dump(out, b.getId(), b.getParameters(), b.getContent()); } else if (block instanceof MacroMarkerBlock) { MacroMarkerBlock b = (MacroMarkerBlock) block; dump(out, b.getId(), b.getParameters(), b.getContent()); } else { throw new IllegalArgumentException("Unsupported block [" + block.getClass().getName() + "]."); } String source = getSourceReference(block); if (source != null) { out.write(toBytes(source)); } out.write(0x00); }  @Override void dump(OutputStream out, Block block); @Override byte[] dump(Block block);  }