Renders a html string type attribute. If the value retrieved from the component
property is "" or null, the attribute is not rendered.

@param writer
@param component
@param componentProperty
@param htmlAttrName
@return
@throws IOException
774818
public static boolean renderHTMLStringAttribute(ResponseWriter writer,
            UIComponent component, String componentProperty, String htmlAttrName)
            throws IOException
    {
        String value = (String) component.getAttributes().get(componentProperty);
        if (!isDefaultStringAttributeValue(value))
        {
            writer.writeAttribute(htmlAttrName, value, componentProperty);
            return true;
        }
        return false;
    }
619189
protected void renderStringValue(final UIComponent component,
                                     final ResponseWriter writer,
                                     final String attributeName) throws IOException {
        if (component.getAttributes().get(attributeName) != null
                && StringUtils.isNotEmpty(component.getAttributes().get(attributeName).toString())
                && shouldRenderAttribute(component.getAttributes().get(attributeName))) {
            writer.writeAttribute(attributeName, component.getAttributes().get(attributeName).toString().trim(), attributeName);
        }
    }
723151
private static void writeAttribute(String name,
                                       Object value,
                                       PrintWriter writer) {
        if (value != null) {
            String s;
            if (value instanceof String || value instanceof Boolean) {
                // for String/Boolean we can just use toString()
                s = value.toString();
            } else {
                // otherwise its a String[], so space-delimit the values
                String[] tokens = (String[]) value;
                int bufLen = tokens.length - 1;
                for (String token: tokens) bufLen += token.length();
                StringBuffer buf = new StringBuffer(bufLen);
                for (int i = 0; i < tokens.length; i++) {
                    if (i > 0) {
                        buf.append(' ');
                    }
                    buf.append(tokens[i]);
                }
                s = buf.toString();
            }
            writer.print(" " + name + "=\"" + s + "\"");
        }
    }
1318865
void write(Object value) throws IOException {
    if (clientInputSerializer != null) {
      clientInputSerializer.serialize(value);
      return;
    }

    byte[] bval;
    int valSize;
    if (value instanceof BytesWritable) {
      BytesWritable val = (BytesWritable) value;
      bval = val.getBytes();
      valSize = val.getLength();
    } else if (value instanceof Text) {
      Text val = (Text) value;
      bval = val.getBytes();
      valSize = val.getLength();
    } else {
      String sval = value.toString();
      bval = sval.getBytes("UTF-8");
      valSize = bval.length;
    }
    clientOut_.write(bval, 0, valSize);
  }
1035285
public static void write(String text, String contentType) {
		setContentType(contentType);
		Writer writer = null;
		try {
			writer = getWriter();
			writer.write(text);
			writer.flush();
		} catch (IOException e) {
			throw new RenderException("Error when output to client!", e);
		} finally {
			IoUtil.close(writer);
		}
	}
789342
public ChainWriter encodeXmlAttribute(Object value) throws IOException {
		Coercion.write(value, textInXhtmlAttributeEncoder, out);
		return this;
	}
123246
protected void renderSpacerCell(FacesContext facesContext, ResponseWriter writer, UIComponent component)
        throws IOException 
    {
        UIComponent spacer = getNewspaperTableSpacer(component);
        if(spacer == null)
        {
            return;
        }
         
         writer.startElement(HTML.TD_ELEM, null); // component);
         //RendererUtils.renderChild(facesContext, spacer);
         spacer.encodeAll(facesContext);
         writer.endElement(HTML.TD_ELEM);
     }
516621
@Override
    protected void getEndTextToRender(final FacesContext context,
                                      final UIComponent component,
                                      final String currentValue) throws IOException {
        final ResponseWriter writer = context.getResponseWriter();

        if (component instanceof UIInput) {
            writer.startElement(getHtmlTagName(), component);

            writer.writeAttribute("id", createInputClientId(context, component), "clientId");
            writer.writeAttribute("name", component.getClientId(context), "clientId");

            // TODO extract protected method
            // for text area based components the value can't be set this way
            if (!(component instanceof HtmlInputTextarea) && !(component instanceof HtmlCheckBox) && currentValue != null) {
                writer.writeAttribute("value", currentValue, "value");
            }

            // default
            this.renderBooleanValue(component, writer, "disabled");
            this.renderBooleanValue(component, writer, "ismap");
            this.renderBooleanValue(component, writer, "readonly");

            // html 5
            this.renderStringValue(component, writer, "autocomplete", "off");
            this.renderStringValue(component, writer, "placeholder");
            this.renderBooleanValue(component, writer, "autoFocus");
            this.renderBooleanValue(component, writer, "pattern");
            this.renderStringValue(component, writer, "min");
            this.renderStringValue(component, writer, "max");

            // html
            this.renderStringValue(component, writer, "alt");
            this.renderStringValue(component, writer, "dir");
            this.renderStringValue(component, writer, "lang");
            this.renderStringValue(component, writer, "maxlength");
            this.renderStringValue(component, writer, "role");
            this.renderStringValue(component, writer, "size");
            this.renderStringValue(component, writer, "style");
            this.renderStringValue(component, writer, "tabindex");
            this.renderStringValue(component, writer, "title");

            // events
            this.renderEventValue(component, writer, "onblur", "blur");
            this.renderEventValue(component, writer, "onclick", "click");
            this.renderEventValue(component, writer, "ondblclick", "dblclick");
            this.renderEventValue(component, writer, "onfocus", "focus");
            this.renderEventValue(component, writer, "onkeydown", "keydown");
            this.renderEventValue(component, writer, "onkeypress", "keypress");
            this.renderEventValue(component, writer, "onkeyup", "keyup");
            this.renderEventValue(component, writer, "onmousedown", "mousedown");
            this.renderEventValue(component, writer, "onmousemove", "mousemove");
            this.renderEventValue(component, writer, "onmouseout", "mouseout");
            this.renderEventValue(component, writer, "onmouseover", "mouseover");
            this.renderEventValue(component, writer, "onmouseup", "mouseup");
            this.renderEventValue(component, writer, "onselect", "select");
            this.renderEventValue(component, writer, "onchange", "change");

            this.renderInputStyleClass((HtmlInputComponent) component, writer);

            this.encodeTagType(component, writer);
            this.encodeAdditionalTagAttributes(component, writer, currentValue);

            this.renderAdditionalInputAttributes(context, component, writer);

            // for text area based components the value must be set this way
            if (component instanceof HtmlInputTextarea && currentValue != null) {
                writer.writeText(currentValue, null);
            }

            writer.endElement(getHtmlTagName());
        }
    }
1342528
protected void renderInputBegin(FacesContext facesContext,
            UIComponent uiComponent) throws IOException
    {
        ResponseWriter writer = facesContext.getResponseWriter();
        
        writer.startElement(HTML.INPUT_ELEM, uiComponent);
        writer.writeAttribute(HTML.TYPE_ATTR, org.apache.myfaces.shared.renderkit.html.HTML.INPUT_TYPE_PASSWORD, null);

        if (uiComponent instanceof ClientBehaviorHolder
                && !((ClientBehaviorHolder) uiComponent).getClientBehaviors().isEmpty())
        {
            writer.writeAttribute(HTML.ID_ATTR, 
                                  uiComponent.getClientId(facesContext), null);
        }
        else
        {
            HtmlRendererUtils.writeIdIfNecessary(writer, uiComponent, facesContext);
        }
        writer.writeAttribute(HTML.NAME_ATTR,
                              uiComponent.getClientId(facesContext), null);

        boolean isRedisplay;
        if (uiComponent instanceof HtmlInputSecret)
        {
            isRedisplay = ((HtmlInputSecret)uiComponent).isRedisplay();
        }
        else
        {
            isRedisplay = org.apache.myfaces.shared.renderkit.RendererUtils.getBooleanAttribute(uiComponent, 
                    JSFAttr.REDISPLAY_ATTR, false);
        }
        if (isRedisplay)
        {
            String strValue = RendererUtils.getStringValue(facesContext, uiComponent);
            writer.writeAttribute(HTML.VALUE_ATTR, strValue, JSFAttr.VALUE_ATTR);
        }

        Map<String, List<ClientBehavior>> behaviors = null;
        if (uiComponent instanceof ClientBehaviorHolder)
        {
            behaviors = ((ClientBehaviorHolder) uiComponent).getClientBehaviors();
            
            long commonPropertiesMarked = 0L;
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                commonPropertiesMarked = CommonPropertyUtils.getCommonPropertiesMarked(uiComponent);
            }
            if (behaviors.isEmpty() && isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderChangeEventProperty(writer, 
                        commonPropertiesMarked, uiComponent);
                CommonPropertyUtils.renderEventProperties(writer, 
                        commonPropertiesMarked, uiComponent);
                CommonPropertyUtils.renderFieldEventPropertiesWithoutOnchange(writer, 
                        commonPropertiesMarked, uiComponent);
            }
            else
            {
                HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, uiComponent, behaviors);
                if (isCommonEventsOptimizationEnabled(facesContext))
                {
                    Long commonEventsMarked = CommonEventUtils.getCommonEventsMarked(uiComponent);
                    CommonEventUtils.renderBehaviorizedEventHandlers(facesContext, writer, 
                            commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
                    CommonEventUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
                        facesContext, writer, commonPropertiesMarked, commonEventsMarked, uiComponent, behaviors);
                }
                else
                {
                    HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
                    HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(
                            facesContext, writer, uiComponent, behaviors);
                }
            }
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderInputPassthroughPropertiesWithoutDisabledAndEvents(writer, 
                        commonPropertiesMarked, uiComponent);
            }
            else
            {
                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
                        HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
            }
        }
        else
        {
            if (isCommonPropertiesOptimizationEnabled(facesContext))
            {
                CommonPropertyUtils.renderInputPassthroughPropertiesWithoutDisabled(writer, 
                        CommonPropertyUtils.getCommonPropertiesMarked(uiComponent), uiComponent);
            }
            else
            {
                HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, 
                        HTML.INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
            }
        }

        if (isDisabled(facesContext, uiComponent))
        {
            writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
        }

        if (isAutocompleteOff(facesContext, uiComponent))
        {
            writer.writeAttribute(HTML.AUTOCOMPLETE_ATTR, AUTOCOMPLETE_VALUE_OFF, HTML.AUTOCOMPLETE_ATTR);
        }
    }
1181889
public static void writelnTo(String html, Writer writer) throws IOException {
		writeTo(html, writer);
		writer.write('\n');
	}
865638
public static Writer renderFromStr(String templateContent, Map<String, Object> bindingMap, Writer writer) {
		return render(getStrTemplate(templateContent), bindingMap, writer);
	}
1236368
private void renderAttribute(InternalStringBuilder buf, String name, String value)
    {
        assert (name != null);
        if (value == null)
            return;

        buf.append(" ");
        buf.append(name);
        buf.append("=\"");
        buf.append(value);
        buf.append("\"");
    }
54948
@SuppressWarnings({"checkstyle:cyclomaticcomplexity", "checkstyle:magicnumber"})
	public void writeRecord(AttributeProvider element) throws IOException, AttributeException {

		if (this.columns == null) {
			throw new MustCallWriteHeaderFunctionException();
		}

		//Field deleted flag (value : 2Ah (*) => Record is deleted, 20h (blank) => Record is valid)
		this.stream.writeByte(0x20);

		for (final DBaseFileField field : this.columns) {
			// Get attribute
			final DBaseFieldType dbftype = field.getType();
			final String fieldName = field.getName();

			AttributeValue attr = element != null ? element.getAttribute(fieldName) : null;

			if (attr == null) {
				attr = new AttributeValueImpl(dbftype.toAttributeType());
				attr.setToDefault();
			} else {
				if (attr.isAssigned()) {
					attr = new AttributeValueImpl(attr);
					attr.cast(dbftype.toAttributeType());
				} else {
					attr = new AttributeValueImpl(attr);
					attr.setToDefaultIfUninitialized();
				}
			}

			// Write value
			switch (dbftype) {
			case BOOLEAN:
				writeDBFBoolean(attr.getBoolean());
				break;
			case DATE:
				writeDBFDate(attr.getDate());
				break;
			case STRING:
				writeDBFString(attr.getString(), field.getLength(), (byte) ' ');
				break;
			case INTEGER_2BYTES:
				writeDBFInteger((short) attr.getInteger());
				break;
			case INTEGER_4BYTES:
				writeDBFLong((int) attr.getInteger());
				break;
			case DOUBLE:
				writeDBFDouble(attr.getReal());
				break;
			case FLOATING_NUMBER:
			case NUMBER:
				if (attr.getType() == AttributeType.REAL) {
					writeDBFNumber(attr.getReal(), field.getLength(), field.getDecimalPointPosition());
				} else {
					writeDBFNumber(attr.getInteger(), field.getLength(), field.getDecimalPointPosition());
				}
				break;
			case BINARY:
			case GENERAL:
			case MEMORY:
			case PICTURE:
			case VARIABLE:
				// not yet supported
				writeDBFString((String) null, 10, (byte) 0);
				break;
			default:
				throw new IllegalStateException();
			}
		}

		// Be sure that the memory was not fully filled by the saving process
		if (element != null) {
			element.freeMemory();
		}
	}
1283175
@Override
    public void setAttribute(String arg0, Object arg1) {
        try {
            collaborator.preInvoke(componentMetaData);
            request.setAttribute(arg0, arg1);
        } finally {
            collaborator.postInvoke();
        }

    }
970663
private void writeBean(String currentIndent, String tagName, StringBuilder attrs, Class<?> propType, Bean value) throws IOException {
        if (value == null) {
            throw new IllegalArgumentException("Bean cannot be null");
        }
        output.append(currentIndent).append('<').append(tagName).append(attrs);
        if (value.getClass() != propType) {
            String typeStr = SerTypeMapper.encodeType(value.getClass(), settings, basePackage, knownTypes);
            appendAttribute(output, TYPE, typeStr);
        }
        if (willWriteBean(value)) {
            output.append('>').append(settings.getNewLine());
            writeBean(value, currentIndent + settings.getIndent());
            output.append(currentIndent).append('<').append('/').append(tagName).append('>').append(settings.getNewLine());
        } else {
            output.append('/').append('>').append(settings.getNewLine());
        }
    }
1356910
@Deprecated
	protected void noTemplatePaintHtml(final WComponent component, final Writer writer) {
		try {
			writer.write("<!-- Start " + url + " not found -->\n");
			new VelocityRenderer(NO_TEMPLATE_LAYOUT).paintXml(component, writer);
			writer.write("<!-- End " + url + " (template not found) -->\n");
		} catch (IOException e) {
			LOG.error("Failed to paint component", e);
		}
	}
112168
public static void write(Object value, MediaEncoder encoder, Writer out) throws IOException {
		if(encoder==null) {
			write(value, out);
		} else {
			// Otherwise, if A is null, then the result is "".
			// Write nothing
			if(value != null) {
				// Unwrap out to avoid unnecessary validation of known valid output
				while(true) {
					out = unwrap(out);
					if(out instanceof MediaValidator) {
						MediaValidator validator = (MediaValidator)out;
						if(validator.canSkipValidation(encoder.getValidMediaOutputType())) {
							// Can skip validation, write directly to the wrapped output through the encoder
							out = validator.getOut();
						} else {
							break;
						}
					} else {
						break;
					}
				}
				// Write through the given encoder
				if(value instanceof String) {
					// If A is a string, then the result is A.
					encoder.write((String)value, out);
				} else if(value instanceof Writable) {
					Writable writable = (Writable)value;
					if(writable.isFastToString()) {
						encoder.write(writable.toString(), out);
					} else {
						// Avoid intermediate String from Writable
						writable.writeTo(encoder, out);
					}
				} else if(value instanceof Node) {
					// Otherwise, if is a DOM node, serialize the output
					try {
						// Can use thread-local or pooled transformers if performance is ever an issue
						TransformerFactory transFactory = TransformerFactory.newInstance();
						Transformer transformer = transFactory.newTransformer();
						transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
						transformer.transform(
							new DOMSource((Node)value),
							new StreamResult(new MediaWriter(encoder, out))
						);
					} catch(TransformerException e) {
						throw new IOException(e);
					}
				} else {
					// Otherwise, if A.toString() throws an exception, then raise an error
					// Otherwise, the result is A.toString();
					encoder.write(value.toString(), out);
				}
			}
		}
	}