wffweb/src/main/java/com/webfirmframework/wffweb/tag/html/AbstractHtml.java
private void recurChildrenToWffBinaryMessageOutputStream(
            final Set<AbstractHtml> children, final boolean rebuild)
            throws IOException {
        if (children != null && children.size() > 0) {
            for (final AbstractHtml child : children) {
                child.setRebuild(rebuild);
                // wffBinaryMessageOutputStreamer

                // outputStream.write(child.getOpeningTag().getBytes(charset));

                NameValue nameValue = new NameValue();

                final int tagNameIndex = TagRegistry.getTagNames()
                        .indexOf(child.getTagName());

                // if the tag index is -1 i.e. it's not indexed then the tag
                // name prepended with 0 value byte should be set.
                // If the first byte == 0 and length is greater than 1 then it's
                // a tag name, if the first byte is greater than 0 then it is
                // index bytes

                byte[] closingTagNameConvertedBytes = null;
                if (tagNameIndex == -1) {

                    final byte[] tagNameBytes = child.getTagName()
                            .getBytes(charset);

                    byte[] nameBytes = new byte[tagNameBytes.length + 1];

                    nameBytes[0] = 0;

                    System.arraycopy(tagNameBytes, 0, nameBytes, 1,
                            tagNameBytes.length);
                    nameValue.setName(nameBytes);
                    closingTagNameConvertedBytes = nameBytes;
                    // explicitly dereferenced right after use
                    // because it's a recursive method.
                    nameBytes = null;
                } else {

                    // final byte[] indexBytes = WffBinaryMessageUtil
                    // .getOptimizedBytesFromInt(tagNameIndex);
                    // directly passed it as argument to
                    // avoid consuming stack space
                    nameValue.setName(WffBinaryMessageUtil
                            .getOptimizedBytesFromInt(tagNameIndex));
                    closingTagNameConvertedBytes = WffBinaryMessageUtil
                            .getOptimizedBytesFromInt((tagNameIndex * (-1)));
                }

                nameValue.setValues(
                        child.getAttributeHtmlBytesCompressedByIndex(rebuild,
                                charset));

                wffBinaryMessageOutputStreamer.write(nameValue);
                // explicitly dereferenced right after use
                // because it's a recursive method.
                nameValue = null;

                // final Set<AbstractHtml> childrenOfChildren = child.children;
                // declaring a separate local variable childrenOfChildren will
                // consume stack space so directly passed it as argument
                recurChildrenToWffBinaryMessageOutputStream(child.children,
                        rebuild);

                NameValue closingTagNameValue = new NameValue();
                closingTagNameValue.setName(closingTagNameConvertedBytes);
                closingTagNameValue.setValues(new byte[0][0]);
                wffBinaryMessageOutputStreamer.write(closingTagNameValue);

                // explicitly dereferenced right after use
                // because it's a recursive method.
                closingTagNameValue = null;
                closingTagNameConvertedBytes = null;

                // outputStream.write(child.closingTag.getBytes(charset));
            }
        }
    }
private void recurChildrenToWffBinaryMessageOutputStream(
            final Set<AbstractHtml> children, final boolean rebuild)
            throws IOException {
        if (children != null && children.size() > 0) {
            for (final AbstractHtml child : children) {
                child.setRebuild(rebuild);
                // wffBinaryMessageOutputStreamer

                // outputStream.write(child.getOpeningTag().getBytes(charset));

                NameValue nameValue = new NameValue();

                final int tagNameIndex = TagRegistry.getTagNames()
                        .indexOf(child.getTagName());

                // if the tag index is -1 i.e. it's not indexed then the tag
                // name prepended with 0 value byte should be set.
                // If the first byte == 0 and length is greater than 1 then it's
                // a tag name, if the first byte is greater than 0 then it is
                // index bytes

                byte[] closingTagNameConvertedBytes = null;
                if (tagNameIndex == -1) {

                    final byte[] tagNameBytes = child.getTagName()
                            .getBytes(charset);

                    byte[] nameBytes = new byte[tagNameBytes.length + 1];

                    nameBytes[0] = 0;

                    System.arraycopy(tagNameBytes, 0, nameBytes, 1,
                            tagNameBytes.length);
                    nameValue.setName(nameBytes);
                    closingTagNameConvertedBytes = nameBytes;
                    // explicitly dereferenced right after use
                    // because it's a recursive method.
                    nameBytes = null;
                } else {

                    // final byte[] indexBytes = WffBinaryMessageUtil
                    // .getOptimizedBytesFromInt(tagNameIndex);
                    // directly passed it as argument to
                    // avoid consuming stack space
                    nameValue.setName(WffBinaryMessageUtil
                            .getOptimizedBytesFromInt(tagNameIndex));
                    closingTagNameConvertedBytes = WffBinaryMessageUtil
                            .getOptimizedBytesFromInt((tagNameIndex * (-1)));
                }

                nameValue.setValues(
                        child.getAttributeHtmlBytesCompressedByIndex(rebuild,
                                charset));

                wffBinaryMessageOutputStreamer.write(nameValue);
                // explicitly dereferenced right after use
                // because it's a recursive method.
                nameValue = null;

                // final Set<AbstractHtml> childrenOfChildren = child.children;
                // declaring a separate local variable childrenOfChildren will
                // consume stack space so directly passed it as argument
                recurChildrenToWffBinaryMessageOutputStream(child.children,
                        rebuild);

                NameValue closingTagNameValue = new NameValue();
                closingTagNameValue.setName(closingTagNameConvertedBytes);
                closingTagNameValue.setValues(new byte[0][0]);
                wffBinaryMessageOutputStreamer.write(closingTagNameValue);

                // explicitly dereferenced right after use
                // because it's a recursive method.
                closingTagNameValue = null;
                closingTagNameConvertedBytes = null;

                // outputStream.write(child.closingTag.getBytes(charset));
            }
        }
    }
private void recurChildrenToWffBinaryMessageOutputStream ( final Set < AbstractHtml > children , final boolean rebuild ) throws IOException { if ( children != null && children . size ( ) > 0 ) { for ( final AbstractHtml child : children ) { child . setRebuild ( rebuild ) ; // wffBinaryMessageOutputStreamer // outputStream.write(child.getOpeningTag().getBytes(charset)); NameValue nameValue = new NameValue ( ) ; final int tagNameIndex = TagRegistry . getTagNames ( ) . indexOf ( child . getTagName ( ) ) ; // if the tag index is -1 i.e. it's not indexed then the tag // name prepended with 0 value byte should be set. // If the first byte == 0 and length is greater than 1 then it's // a tag name, if the first byte is greater than 0 then it is // index bytes byte [ ] closingTagNameConvertedBytes = null ; if ( tagNameIndex == - 1 ) { final byte [ ] tagNameBytes = child . getTagName ( ) . getBytes ( charset ) ; byte [ ] nameBytes = new byte [ tagNameBytes . length + 1 ] ; nameBytes [ 0 ] = 0 ; System . arraycopy ( tagNameBytes , 0 , nameBytes , 1 , tagNameBytes . length ) ; nameValue . setName ( nameBytes ) ; closingTagNameConvertedBytes = nameBytes ; // explicitly dereferenced right after use // because it's a recursive method. nameBytes = null ; } else { // final byte[] indexBytes = WffBinaryMessageUtil // .getOptimizedBytesFromInt(tagNameIndex); // directly passed it as argument to // avoid consuming stack space nameValue . setName ( WffBinaryMessageUtil . getOptimizedBytesFromInt ( tagNameIndex ) ) ; closingTagNameConvertedBytes = WffBinaryMessageUtil . getOptimizedBytesFromInt ( ( tagNameIndex * ( - 1 ) ) ) ; } nameValue . setValues ( child . getAttributeHtmlBytesCompressedByIndex ( rebuild , charset ) ) ; wffBinaryMessageOutputStreamer . write ( nameValue ) ; // explicitly dereferenced right after use // because it's a recursive method. nameValue = null ; // final Set<AbstractHtml> childrenOfChildren = child.children; // declaring a separate local variable childrenOfChildren will // consume stack space so directly passed it as argument recurChildrenToWffBinaryMessageOutputStream ( child . children , rebuild ) ; NameValue closingTagNameValue = new NameValue ( ) ; closingTagNameValue . setName ( closingTagNameConvertedBytes ) ; closingTagNameValue . setValues ( new byte [ 0 ] [ 0 ] ) ; wffBinaryMessageOutputStreamer . write ( closingTagNameValue ) ; // explicitly dereferenced right after use // because it's a recursive method. closingTagNameValue = null ; closingTagNameConvertedBytes = null ; // outputStream.write(child.closingTag.getBytes(charset)); } } }
to form html string from the children

@param children
@param rebuild
TODO
@since 2.0.0
@author WFF
@throws IOException
to form html string from the children