AbstractHtml5SharedObject implements Serializable { public DataWffId getNewDataWffId(final Object accessObject) { if (accessObject == null || !((SecurityClassConstants.ABSTRACT_HTML .equals(accessObject.getClass().getName())) || (SecurityClassConstants.BROWSER_PAGE .equals(accessObject.getClass().getName())))) { throw new WffSecurityException( "Not allowed to consume this method. This method is for internal use."); } while (tagByWffId.size() < Integer.MAX_VALUE) { final int incrementedDataWffId = dataWffId.incrementAndGet(); if (incrementedDataWffId < 0 || dataWffIdSecondCycle.get()) { dataWffIdSecondCycle.compareAndSet(false, true); int newDataWffId = incrementedDataWffId < 0 ? ((incrementedDataWffId - Integer.MAX_VALUE) - 1) : incrementedDataWffId; String id = "S" + (newDataWffId); while (tagByWffId.containsKey(id)) { newDataWffId++; if (newDataWffId < 0) { newDataWffId = (newDataWffId - Integer.MAX_VALUE) - 1; } id = "S" + newDataWffId; } if (dataWffId.compareAndSet(incrementedDataWffId, newDataWffId)) { return new DataWffId("S" + newDataWffId); } continue; } return new DataWffId("S" + incrementedDataWffId); } throw new DataWffIdOutOfRangeError( "BrowserPage object has reached an impossible worst case! No enough DataWffId available to assign to a new tag."); } AbstractHtml5SharedObject(final AbstractHtml rootTag); DataWffId getNewDataWffId(final Object accessObject); ReentrantReadWriteLock getLock(final Object accessObject); int getLastDataWffId(final Object accessObject); boolean isChildModified(); void setChildModified(final boolean childModified); @Deprecated Set<AbstractTagBase> getRebuiltTags(final Object accessObject); ChildTagAppendListener getChildTagAppendListener(
            final Object accessObject); void setChildTagAppendListener(
            final ChildTagAppendListener childTagAppendListener,
            final Object accessObject); ChildTagRemoveListener getChildTagRemoveListener(
            final Object accessObject); void setChildTagRemoveListener(
            final ChildTagRemoveListener childTagRemoveListener,
            final Object accessObject); AttributeAddListener getAttributeAddListener(
            final Object accessObject); void setAttributeAddListener(
            final AttributeAddListener attributeAddListener,
            final Object accessObject); AttributeRemoveListener getAttributeRemoveListener(
            final Object accessObject); void setAttributeRemoveListener(
            final AttributeRemoveListener attributeRemoveListener,
            final Object accessObject); InnerHtmlAddListener getInnerHtmlAddListener(
            final Object accessObject); void setInnerHtmlAddListener(
            final InnerHtmlAddListener innerHtmlAddListener,
            final Object accessObject); Map<String, AbstractHtml> getTagByWffId(final Object accessObject); Map<String, AbstractHtml> initTagByWffId(final Object accessObject); AttributeValueChangeListener getValueChangeListener(
            final Object accessObject); void setValueChangeListener(
            final AttributeValueChangeListener valueChangeListener,
            final Object accessObject); @Deprecated InsertBeforeListener getInsertBeforeListener(
            final Object accessObject); @Deprecated void setInsertBeforeListener(
            final InsertBeforeListener insertBeforeListener,
            final Object accessObject); ReplaceListener getReplaceListener(final Object accessObject); void setReplaceListener(final ReplaceListener replaceListener,
            final Object accessObject); InsertTagsBeforeListener getInsertTagsBeforeListener(
            final Object accessObject); void setInsertTagsBeforeListener(
            final InsertTagsBeforeListener insertTagsBeforeListener,
            final Object accessObject); InsertAfterListener getInsertAfterListener(
            final Object accessObject); void setInsertAfterListener(
            final InsertAfterListener insertAfterListener,
            final Object accessObject); void setWffBMDataDeleteListener(
            final WffBMDataDeleteListener wffBMDataDeleteListener,
            final Object accessObject); void setWffBMDataUpdateListener(
            final WffBMDataUpdateListener wffBMDataUpdateListener,
            final Object accessObject); WffBMDataDeleteListener getWffBMDataDeleteListener(
            final Object accessObject); WffBMDataUpdateListener getWffBMDataUpdateListener(
            final Object accessObject); AbstractHtml getRootTag(); Object getSharedData(); void setSharedData(final Object sharedData); boolean setSharedDataIfNull(final Object sharedData); void setPushQueue(final PushQueue pushQueue,
            final Object accessObject); PushQueue getPushQueue(final Object accessObject); void setActiveWSListener(final boolean activeWSListener,
            final Object accessObject); boolean isActiveWSListener();  }
@Test public void testGetNewDataWffId() { BrowserPage browserPage = new BrowserPage() { @Override public String webSocketUrl() { return "wss: } @Override public AbstractHtml render() { Html html = new Html(null) { { new Head(this); new Body(this); } }; html.setPrependDocType(true); return html; } }; browserPage.toHtmlString(); final Html html = browserPage.getTagRepository().findOneTagAssignableToTag(Html.class); final Head head = browserPage.getTagRepository().findOneTagAssignableToTag(Head.class); final Body body = browserPage.getTagRepository().findOneTagAssignableToTag(Body.class); final DocType doc = browserPage.getTagRepository().findOneTagAssignableToTag(DocType.class); assertEquals("data-wff-id=\"S0\"", doc.getDataWffId().toHtmlString()); assertEquals("data-wff-id=\"S0\"", html.getDataWffId().toHtmlString()); assertEquals("data-wff-id=\"S1\"", head.getDataWffId().toHtmlString()); assertEquals("data-wff-id=\"S2\"", body.getDataWffId().toHtmlString()); { Div div = new Div(null); html.appendChild(div); assertEquals("data-wff-id=\"S4\"", div.getDataWffId().toHtmlString()); } { Div div = new Div(null); html.appendChild(div); assertEquals("data-wff-id=\"S5\"", div.getDataWffId().toHtmlString()); } }