AttributeUtil { public static String getAttributeHtmlString(final boolean rebuild, final AbstractAttribute... attributes) { if (attributes != null) { int capacity = attributes.length; final String[] htmlStrings = new String[attributes.length]; for (int i = 0; i < attributes.length; i++) { final String htmlString = attributes[i].toHtmlString(rebuild); htmlStrings[i] = htmlString; capacity += htmlString.length(); } final StringBuilder attributeSB = new StringBuilder(capacity); for (final String htmlString : htmlStrings) { attributeSB.append(' ').append(htmlString); } return attributeSB.toString(); } return ""; } private  AttributeUtil(); static String getAttributeHtmlString(final boolean rebuild,
            final AbstractAttribute... attributes); static String getAttributeHtmlString(final boolean rebuild,
            final Charset charset, final AbstractAttribute... attributes); static byte[][] getAttributeHtmlBytesCompressedByIndex(
            final boolean rebuild, final Charset charset,
            final AbstractAttribute... attributes); static byte[][] getWffAttributeBytes(final String charset,
            final AbstractAttribute... attributes); static byte[][] getWffAttributeBytes(final Charset charset,
            final AbstractAttribute... attributes); static AbstractAttribute[] parseExactAttributeHtmlBytesCompressedByIndex(
            final byte[][] attributesBytes, final Charset charset); static byte[] getAttrNameBytesCompressedByIndex(
            final Object accessObject, final String attrName,
            final Charset charset); static byte[] getAttrNameBytesCompressedByIndex(
            final Object accessObject, final AbstractAttribute attr,
            final Charset charset);  }
@Test public void testGetAttributeHtmlStringBooleanAbstractAttributeArray() { Style style = new Style(); style.addCssProperty("background", "green"); style.addCssProperty("align", "center"); CustomAttribute ca = new CustomAttribute("custom-attr", "testvalue1, testvalue2"); String attributeHtmlString = AttributeUtil.getAttributeHtmlString(true, style, ca); assertEquals(" style=\"background:green;align:center;\" custom-attr=\"testvalue1, testvalue2\"", attributeHtmlString); attributeHtmlString = AttributeUtil.getAttributeHtmlString(false, style, ca); assertEquals(" style=\"background:green;align:center;\" custom-attr=\"testvalue1, testvalue2\"", attributeHtmlString); }
@Test public void testGetAttributeHtmlStringBooleanCharsetAbstractAttributeArray() { Style style = new Style(); style.addCssProperty("background", "green"); style.addCssProperty("align", "center"); CustomAttribute ca = new CustomAttribute("custom-attr", "testvalue1, testvalue2"); String attributeHtmlString = AttributeUtil.getAttributeHtmlString(true, StandardCharsets.UTF_8, style, ca); assertEquals(" style=\"background:green;align:center;\" custom-attr=\"testvalue1, testvalue2\"", attributeHtmlString); attributeHtmlString = AttributeUtil.getAttributeHtmlString(false, StandardCharsets.UTF_8, style, ca); assertEquals(" style=\"background:green;align:center;\" custom-attr=\"testvalue1, testvalue2\"", attributeHtmlString); }