@Test public void testSplitCondition() throws Exception { XDOM xdom = xwikiParser.parse(new StringReader("=Test=")); SplittingCriterion splittingCriterion = new HeadingLevelSplittingCriterion(new int[] {3, 2, 1}); Block sectionBlock = xdom.getChildren().get(0); Assert.assertTrue(splittingCriterion.shouldSplit(sectionBlock, 1)); splittingCriterion = new HeadingLevelSplittingCriterion(new int[] {3, 2}); Assert.assertTrue(!splittingCriterion.shouldSplit(sectionBlock, 1)); }
@Override public boolean shouldSplit(Block block, int depth) { boolean shouldSplit = false; if (block instanceof SectionBlock) { SectionBlock section = (SectionBlock) block; Block firstChild = section.getChildren().get(0); shouldSplit = (firstChild instanceof HeaderBlock) && (Arrays.binarySearch(headingLevels, depth) >= 0); } return shouldSplit; }
HeadingLevelSplittingCriterion implements SplittingCriterion { @Override public boolean shouldSplit(Block block, int depth) { boolean shouldSplit = false; if (block instanceof SectionBlock) { SectionBlock section = (SectionBlock) block; Block firstChild = section.getChildren().get(0); shouldSplit = (firstChild instanceof HeaderBlock) && (Arrays.binarySearch(headingLevels, depth) >= 0); } return shouldSplit; } }
HeadingLevelSplittingCriterion implements SplittingCriterion { @Override public boolean shouldSplit(Block block, int depth) { boolean shouldSplit = false; if (block instanceof SectionBlock) { SectionBlock section = (SectionBlock) block; Block firstChild = section.getChildren().get(0); shouldSplit = (firstChild instanceof HeaderBlock) && (Arrays.binarySearch(headingLevels, depth) >= 0); } return shouldSplit; } HeadingLevelSplittingCriterion(int[] headingLevels); }
HeadingLevelSplittingCriterion implements SplittingCriterion { @Override public boolean shouldSplit(Block block, int depth) { boolean shouldSplit = false; if (block instanceof SectionBlock) { SectionBlock section = (SectionBlock) block; Block firstChild = section.getChildren().get(0); shouldSplit = (firstChild instanceof HeaderBlock) && (Arrays.binarySearch(headingLevels, depth) >= 0); } return shouldSplit; } HeadingLevelSplittingCriterion(int[] headingLevels); @Override boolean shouldIterate(Block block, int depth); @Override boolean shouldSplit(Block block, int depth); }
HeadingLevelSplittingCriterion implements SplittingCriterion { @Override public boolean shouldSplit(Block block, int depth) { boolean shouldSplit = false; if (block instanceof SectionBlock) { SectionBlock section = (SectionBlock) block; Block firstChild = section.getChildren().get(0); shouldSplit = (firstChild instanceof HeaderBlock) && (Arrays.binarySearch(headingLevels, depth) >= 0); } return shouldSplit; } HeadingLevelSplittingCriterion(int[] headingLevels); @Override boolean shouldIterate(Block block, int depth); @Override boolean shouldSplit(Block block, int depth);  }