@Test public void idOverlapTest() { assertEquals("#bar", getRealChildrenId("foo", "#bar")); assertEquals("#bar", getRealChildrenId("foo#foo", "#bar")); assertEquals("#foo#bar", getRealChildrenId("foo", "#foo#bar")); assertEquals("#bar", getRealChildrenId("foo#foo", "#foo#bar")); assertEquals("#bar", getRealChildrenId("#foo", "#bar")); assertEquals("#bar", getRealChildrenId("#foo#foo", "#bar")); assertEquals("#bar", getRealChildrenId("#foo", "#foo#bar")); assertEquals("#bar", getRealChildrenId("#foo#foo", "#foo#bar")); assertEquals("#bar", getRealChildrenId("foo#foo2", "#bar")); assertEquals("#foo#bar", getRealChildrenId("foo#foo2", "#foo#bar")); assertEquals("#bar", getRealChildrenId("foo#foo2#foo", "#foo#bar")); assertEquals("#foo#bar", getRealChildrenId("foo#foo2#foo#bar", "#foo#bar")); assertEquals("#foo#bar", getRealChildrenId("foo#foo2#foo#bar", "#foo#bar#foo#bar")); }
@Nonnull static String getRealChildrenId(@Nonnull final CharSequence parent, @Nonnull final String child) { int lastSharpIndex = child.lastIndexOf('#'); if (lastSharpIndex <= 0) { return child; } final String[] elementIdParts = ID_SPLIT.split(child); final String[] parentIdParts = ID_SPLIT.split(parent); int currentIndex = -1; while (currentIndex < parentIdParts.length) { currentIndex = findInArray(parentIdParts, currentIndex + 1, elementIdParts[0]); if (currentIndex == -1) { return child; } else if (isOverlapping(parentIdParts, currentIndex, elementIdParts)) { final int remaining = parentIdParts.length - currentIndex; StringBuilder idBuilder = new StringBuilder(); for (int i = remaining; i < elementIdParts.length; i++) { idBuilder.append(elementIdParts[i]); } return idBuilder.toString(); } } return child; }
ControlType extends ElementType { @Nonnull static String getRealChildrenId(@Nonnull final CharSequence parent, @Nonnull final String child) { int lastSharpIndex = child.lastIndexOf('#'); if (lastSharpIndex <= 0) { return child; } final String[] elementIdParts = ID_SPLIT.split(child); final String[] parentIdParts = ID_SPLIT.split(parent); int currentIndex = -1; while (currentIndex < parentIdParts.length) { currentIndex = findInArray(parentIdParts, currentIndex + 1, elementIdParts[0]); if (currentIndex == -1) { return child; } else if (isOverlapping(parentIdParts, currentIndex, elementIdParts)) { final int remaining = parentIdParts.length - currentIndex; StringBuilder idBuilder = new StringBuilder(); for (int i = remaining; i < elementIdParts.length; i++) { idBuilder.append(elementIdParts[i]); } return idBuilder.toString(); } } return child; } }
ControlType extends ElementType { @Nonnull static String getRealChildrenId(@Nonnull final CharSequence parent, @Nonnull final String child) { int lastSharpIndex = child.lastIndexOf('#'); if (lastSharpIndex <= 0) { return child; } final String[] elementIdParts = ID_SPLIT.split(child); final String[] parentIdParts = ID_SPLIT.split(parent); int currentIndex = -1; while (currentIndex < parentIdParts.length) { currentIndex = findInArray(parentIdParts, currentIndex + 1, elementIdParts[0]); if (currentIndex == -1) { return child; } else if (isOverlapping(parentIdParts, currentIndex, elementIdParts)) { final int remaining = parentIdParts.length - currentIndex; StringBuilder idBuilder = new StringBuilder(); for (int i = remaining; i < elementIdParts.length; i++) { idBuilder.append(elementIdParts[i]); } return idBuilder.toString(); } } return child; } ControlType();  ControlType(@Nonnull final ControlType src);  ControlType(@Nonnull final Attributes attributes); }
ControlType extends ElementType { @Nonnull static String getRealChildrenId(@Nonnull final CharSequence parent, @Nonnull final String child) { int lastSharpIndex = child.lastIndexOf('#'); if (lastSharpIndex <= 0) { return child; } final String[] elementIdParts = ID_SPLIT.split(child); final String[] parentIdParts = ID_SPLIT.split(parent); int currentIndex = -1; while (currentIndex < parentIdParts.length) { currentIndex = findInArray(parentIdParts, currentIndex + 1, elementIdParts[0]); if (currentIndex == -1) { return child; } else if (isOverlapping(parentIdParts, currentIndex, elementIdParts)) { final int remaining = parentIdParts.length - currentIndex; StringBuilder idBuilder = new StringBuilder(); for (int i = remaining; i < elementIdParts.length; i++) { idBuilder.append(elementIdParts[i]); } return idBuilder.toString(); } } return child; } ControlType();  ControlType(@Nonnull final ControlType src);  ControlType(@Nonnull final Attributes attributes); @Override @Nonnull ElementType copy(); }
ControlType extends ElementType { @Nonnull static String getRealChildrenId(@Nonnull final CharSequence parent, @Nonnull final String child) { int lastSharpIndex = child.lastIndexOf('#'); if (lastSharpIndex <= 0) { return child; } final String[] elementIdParts = ID_SPLIT.split(child); final String[] parentIdParts = ID_SPLIT.split(parent); int currentIndex = -1; while (currentIndex < parentIdParts.length) { currentIndex = findInArray(parentIdParts, currentIndex + 1, elementIdParts[0]); if (currentIndex == -1) { return child; } else if (isOverlapping(parentIdParts, currentIndex, elementIdParts)) { final int remaining = parentIdParts.length - currentIndex; StringBuilder idBuilder = new StringBuilder(); for (int i = remaining; i < elementIdParts.length; i++) { idBuilder.append(elementIdParts[i]); } return idBuilder.toString(); } } return child; } ControlType();  ControlType(@Nonnull final ControlType src);  ControlType(@Nonnull final Attributes attributes); @Override @Nonnull ElementType copy();  }