wffweb/src/main/java/com/webfirmframework/wffweb/tag/html/attribute/core/AbstractAttribute.java
protected byte[] getBinaryStructureCompressedByIndex(final boolean rebuild)
            throws IOException {

        final String attributeValue = this.attributeValue;

        final Charset charset = this.charset;
        // TODO review code

        final ByteArrayOutputStream compressedByIndexBytes = new ByteArrayOutputStream();

        byte[] compressedBytes = new byte[0];

        // String result = "";
        if (rebuild || isRebuild() || isModified()) {

            beforePrintStructureCompressedByIndex();
            // tagBuildzer.append(' ');

            final int attributeNameIndex = AttributeRegistry.getAttributeNames()
                    .indexOf(attributeName);

            if (attributeNameIndex == -1) {

                compressedByIndexBytes.write(new byte[] { (byte) 0 });

                compressedByIndexBytes
                        .write(attributeName.concat("=").getBytes(charset));

                if (LOGGER.isLoggable(Level.WARNING)) {
                    LOGGER.warning(attributeName
                            + " is not indexed, please register it with AttributeRegistrar");
                }
            } else {

                final byte[] optimizedBytesFromInt = WffBinaryMessageUtil
                        .getOptimizedBytesFromInt(attributeNameIndex);
                compressedByIndexBytes.write(
                        new byte[] { (byte) optimizedBytesFromInt.length });
                compressedByIndexBytes.write(optimizedBytesFromInt);
            }

            if (attributeValue != null) {

                compressedByIndexBytes.write(attributeValue.getBytes(charset));
                compressedBytes = compressedByIndexBytes.toByteArray();
            } else if (attributeValueMap != null
                    && attributeValueMap.size() > 0) {
                final Set<Entry<String, String>> entrySet = getAttributeValueMap()
                        .entrySet();
                for (final Entry<String, String> entry : entrySet) {

                    compressedByIndexBytes
                            .write(entry.getKey().getBytes(charset));
                    compressedByIndexBytes.write(new byte[] { ':' });
                    compressedByIndexBytes
                            .write(entry.getValue().getBytes(charset));
                    compressedByIndexBytes.write(new byte[] { ';' });
                }
                compressedBytes = compressedByIndexBytes.toByteArray();
            } else if (attributeValueSet != null
                    && attributeValueSet.size() > 0) {
                for (final String each : getAttributeValueSet()) {

                    compressedByIndexBytes.write(each.getBytes(charset));
                    compressedByIndexBytes.write(new byte[] { ' ' });
                }
                compressedBytes = compressedByIndexBytes.toByteArray();
            } else {
                compressedBytes = compressedByIndexBytes.toByteArray();
            }

            setRebuild(false);
        }
        return compressedBytes;
    }
protected byte[] getBinaryStructureCompressedByIndex(final boolean rebuild)
            throws IOException {

        final String attributeValue = this.attributeValue;

        final Charset charset = this.charset;
        // TODO review code

        final ByteArrayOutputStream compressedByIndexBytes = new ByteArrayOutputStream();

        byte[] compressedBytes = new byte[0];

        // String result = "";
        if (rebuild || isRebuild() || isModified()) {

            beforePrintStructureCompressedByIndex();
            // tagBuildzer.append(' ');

            final int attributeNameIndex = AttributeRegistry.getAttributeNames()
                    .indexOf(attributeName);

            if (attributeNameIndex == -1) {

                compressedByIndexBytes.write(new byte[] { (byte) 0 });

                compressedByIndexBytes
                        .write(attributeName.concat("=").getBytes(charset));

                if (LOGGER.isLoggable(Level.WARNING)) {
                    LOGGER.warning(attributeName
                            + " is not indexed, please register it with AttributeRegistrar");
                }
            } else {

                final byte[] optimizedBytesFromInt = WffBinaryMessageUtil
                        .getOptimizedBytesFromInt(attributeNameIndex);
                compressedByIndexBytes.write(
                        new byte[] { (byte) optimizedBytesFromInt.length });
                compressedByIndexBytes.write(optimizedBytesFromInt);
            }

            if (attributeValue != null) {

                compressedByIndexBytes.write(attributeValue.getBytes(charset));
                compressedBytes = compressedByIndexBytes.toByteArray();
            } else if (attributeValueMap != null
                    && attributeValueMap.size() > 0) {
                final Set<Entry<String, String>> entrySet = getAttributeValueMap()
                        .entrySet();
                for (final Entry<String, String> entry : entrySet) {

                    compressedByIndexBytes
                            .write(entry.getKey().getBytes(charset));
                    compressedByIndexBytes.write(new byte[] { ':' });
                    compressedByIndexBytes
                            .write(entry.getValue().getBytes(charset));
                    compressedByIndexBytes.write(new byte[] { ';' });
                }
                compressedBytes = compressedByIndexBytes.toByteArray();
            } else if (attributeValueSet != null
                    && attributeValueSet.size() > 0) {
                for (final String each : getAttributeValueSet()) {

                    compressedByIndexBytes.write(each.getBytes(charset));
                    compressedByIndexBytes.write(new byte[] { ' ' });
                }
                compressedBytes = compressedByIndexBytes.toByteArray();
            } else {
                compressedBytes = compressedByIndexBytes.toByteArray();
            }

            setRebuild(false);
        }
        return compressedBytes;
    }
protected byte [ ] getBinaryStructureCompressedByIndex ( final boolean rebuild ) throws IOException { final String attributeValue = this . attributeValue ; final Charset charset = this . charset ; // TODO review code final ByteArrayOutputStream compressedByIndexBytes = new ByteArrayOutputStream ( ) ; byte [ ] compressedBytes = new byte [ 0 ] ; // String result = ""; if ( rebuild || isRebuild ( ) || isModified ( ) ) { beforePrintStructureCompressedByIndex ( ) ; // tagBuildzer.append(' '); final int attributeNameIndex = AttributeRegistry . getAttributeNames ( ) . indexOf ( attributeName ) ; if ( attributeNameIndex == - 1 ) { compressedByIndexBytes . write ( new byte [ ] { ( byte ) 0 } ) ; compressedByIndexBytes . write ( attributeName . concat ( "=" ) . getBytes ( charset ) ) ; if ( LOGGER . isLoggable ( Level . WARNING ) ) { LOGGER . warning ( attributeName + " is not indexed, please register it with AttributeRegistrar" ) ; } } else { final byte [ ] optimizedBytesFromInt = WffBinaryMessageUtil . getOptimizedBytesFromInt ( attributeNameIndex ) ; compressedByIndexBytes . write ( new byte [ ] { ( byte ) optimizedBytesFromInt . length } ) ; compressedByIndexBytes . write ( optimizedBytesFromInt ) ; } if ( attributeValue != null ) { compressedByIndexBytes . write ( attributeValue . getBytes ( charset ) ) ; compressedBytes = compressedByIndexBytes . toByteArray ( ) ; } else if ( attributeValueMap != null && attributeValueMap . size ( ) > 0 ) { final Set < Entry < String , String > > entrySet = getAttributeValueMap ( ) . entrySet ( ) ; for ( final Entry < String , String > entry : entrySet ) { compressedByIndexBytes . write ( entry . getKey ( ) . getBytes ( charset ) ) ; compressedByIndexBytes . write ( new byte [ ] { ' ' } ) ; compressedByIndexBytes . write ( entry . getValue ( ) . getBytes ( charset ) ) ; compressedByIndexBytes . write ( new byte [ ] { ' ' } ) ; } compressedBytes = compressedByIndexBytes . toByteArray ( ) ; } else if ( attributeValueSet != null && attributeValueSet . size ( ) > 0 ) { for ( final String each : getAttributeValueSet ( ) ) { compressedByIndexBytes . write ( each . getBytes ( charset ) ) ; compressedByIndexBytes . write ( new byte [ ] { ' ' } ) ; } compressedBytes = compressedByIndexBytes . toByteArray ( ) ; } else { compressedBytes = compressedByIndexBytes . toByteArray ( ) ; } setRebuild ( false ) ; } return compressedBytes ; }
gives compressed by index bytes for the attribute and value. The first
byte represents the attribute name index bytes length, the next bytes
represent the attribute name index bytes and the remaining bytes
represent attribute value without <i>=</i> and <i>"</i>.

@param rebuild
@return the compressed by index bytes.
@throws IOException
@since 1.1.3
@author WFF
gives compressed by index bytes for the attribute and value . The first byte represents the attribute name index bytes length the next bytes represent the attribute name index bytes and the remaining bytes represent attribute value without <i > = < / i > and <i > < / i > .