/** * Outputs the contents of the specified {@linkplain #populateMap(Map,boolean) attributes map} as HTML attribute name/value pairs to the specified <code>Appendable</code> object. * <p> * Each attribute is preceded by a single space, and all values are * {@linkplain CharacterReference#encode(CharSequence) encoded} and enclosed in double quotes. * * @param appendable the <code>Appendable</code> object to which the output is to be sent. * @param attributesMap a map containing attribute name/value pairs. * @throws IOException if an I/O exception occurs. * @see #populateMap(Map attributesMap, boolean convertNamesToLowerCase) */ static void appendHTML(final Appendable appendable, final Map<String,String> attributesMap) throws IOException { for (Map.Entry<String,String> entry : attributesMap.entrySet()) { Attribute.appendHTML(appendable,entry.getKey(),entry.getValue()); } }
final String getDisplayValueHTML(final CharSequence text, final boolean whiteSpaceFormatting) { final StringBuilder sb=new StringBuilder((text==null ? 0 : text.length()*2)+50); sb.append('<').append(FormControlOutputStyle.ConfigDisplayValue.ElementName); try { for (String attributeName : FormControlOutputStyle.ConfigDisplayValue.AttributeNames) { final CharSequence attributeValue=elementContainer.getAttributeValue(attributeName); if (attributeValue==null) continue; Attribute.appendHTML(sb,attributeName,attributeValue); } sb.append('>'); if (text==null || text.length()==0) { sb.append(FormControlOutputStyle.ConfigDisplayValue.EmptyHTML); } else { if (whiteSpaceFormatting) { sb.append(CharacterReference.encodeWithWhiteSpaceFormatting(text)); } else { CharacterReference.appendEncode(sb,text,false); } } } catch (IOException ex) {throw new RuntimeException(ex);} // never happens sb.append(EndTagType.START_DELIMITER_PREFIX).append(FormControlOutputStyle.ConfigDisplayValue.ElementName).append('>'); return sb.toString(); }