@Nonnull public final THISTYPE addChildAt (@Nonnegative final int nIndex, @Nullable final CHILDTYPE aChild) { ValueEnforcer.isBetweenInclusive (nIndex, "Index", 0, getChildCount ()); _internalAddChild (nIndex, aChild); return thisAsT (); }
@Nonnull public final THISTYPE removeChildAt (@Nonnegative final int nIndex) { final CHILDTYPE aRemovedChild = CollectionHelper.removeAndReturnElementAtIndex (m_aChildren, nIndex); if (aRemovedChild != null) afterRemoveChild (nIndex, aRemovedChild); return thisAsT (); }
@Nonnull public final THISTYPE removeAllChildren () { if (m_aChildren != null) { // Call method to ensure callbacks are invoked properly while (m_aChildren.isNotEmpty ()) removeChildAt (0); m_aChildren = null; } return thisAsT (); }
@Nonnull public final THISTYPE addChild (@Nullable final CHILDTYPE aChild) { _internalAddChild (CGlobal.ILLEGAL_UINT, aChild); return thisAsT (); }
@Override @OverrideOnDemand @OverridingMethodsMustInvokeSuper protected void fillMicroElement (final IMicroElement aElement, final IHCConversionSettingsToNode aConversionSettings) { super.fillMicroElement (aElement, aConversionSettings); if (hasChildren ()) for (final CHILDTYPE aChild : getChildrenFormEmitting (m_aChildren)) aElement.appendChild (aChild.convertToMicroNode (aConversionSettings)); if (!aElement.hasChildren ()) { // If no children are present, add an empty text node so that an opening // and a closing tag are written separately // Note: just using "hasChildren" is not enough, in case a child is // present, that is not rendered! if (!getElement ().mayBeSelfClosed ()) aElement.appendText (""); } }
@Override @Nonnull public String getPlainText () { if (!hasChildren ()) return ""; final StringBuilder ret = new StringBuilder (); for (final CHILDTYPE aChild : getChildrenFormEmitting (m_aChildren)) { final String sPlainText = aChild.getPlainText (); if (StringHelper.hasText (sPlainText)) { if (ret.length () > 0) ret.append (' '); ret.append (sPlainText); } } return ret.toString (); }
private void _internalAddChild (@CheckForSigned final int nIndex, @Nullable final CHILDTYPE aChild) { if (aChild == this) throw new IllegalArgumentException ("Cannot append child to self: " + aChild); if (aChild != null) { beforeAddChild (aChild); if (m_aChildren == null) m_aChildren = new CommonsArrayList <> (); int nAddIndex; if (nIndex < 0) { nAddIndex = m_aChildren.size (); m_aChildren.add (aChild); } else { nAddIndex = nIndex; m_aChildren.add (nIndex, aChild); } afterAddChild (nAddIndex, aChild); } }
@Override protected void fillMicroElement (final IMicroElement aElement, final IHCConversionSettingsToNode aConversionSettings) { super.fillMicroElement (aElement, aConversionSettings); if (m_bDisabled) aElement.setAttribute (CHTMLAttributes.DISABLED, CHTMLAttributeValues.DISABLED); if (m_sLabel != null) aElement.setAttribute (CHTMLAttributes.LABEL, m_sLabel); }
@Override protected void fillMicroElement (final IMicroElement aElement, final IHCConversionSettingsToNode aConversionSettings) { super.fillMicroElement (aElement, aConversionSettings); if (m_bDisabled) aElement.setAttribute (CHTMLAttributes.DISABLED, CHTMLAttributeValues.DISABLED); if (m_sLabel != null) aElement.setAttribute (CHTMLAttributes.LABEL, m_sLabel); if (m_bSelected) aElement.setAttribute (CHTMLAttributes.SELECTED, CHTMLAttributeValues.SELECTED); if (m_sValue != null) aElement.setAttribute (CHTMLAttributes.VALUE, m_sValue); }
@Nonnull public final THISTYPE removeChild (@Nullable final CHILDTYPE aChild) { if (aChild != null && m_aChildren != null) { final int nChildIndex = m_aChildren.indexOf (aChild); if (nChildIndex >= 0) removeChildAt (nChildIndex); } return thisAsT (); }
@Override @OverridingMethodsMustInvokeSuper protected void fillMicroElement (final IMicroElement aElement, final IHCConversionSettingsToNode aConversionSettings) { super.fillMicroElement (aElement, aConversionSettings); if (m_bAutoPlay) aElement.setAttribute (CHTMLAttributes.AUTOPLAY, CHTMLAttributeValues.AUTOPLAY); if (m_ePreload != null) aElement.setAttribute (CHTMLAttributes.PRELOAD, m_ePreload); if (m_bControls) aElement.setAttribute (CHTMLAttributes.CONTROLS, CHTMLAttributeValues.CONTROLS); if (m_bLoop) aElement.setAttribute (CHTMLAttributes.LOOP, CHTMLAttributeValues.LOOP); if (m_bMuted) aElement.setAttribute (CHTMLAttributes.MUTED, CHTMLAttributeValues.MUTED); if (m_aSrc != null) aElement.setAttribute (CHTMLAttributes.SRC, m_aSrc.getAsStringWithEncodedParameters (aConversionSettings.getCharset ())); if (m_eCrossOrigin != null) aElement.setAttribute (CHTMLAttributes.CROSSORIGIN, m_eCrossOrigin); } }