Renders the CSS pseudo classes for required fields and for the error levels.

@param input
@param rw
@param clientId
@throws IOException
425786
protected void generateErrorAndRequiredClass(UIInput input, ResponseWriter rw, String clientId,
			String additionalClass1, String additionalClass2, String additionalClass3) throws IOException {
		String styleClass = getErrorAndRequiredClass(input, clientId);
		if (null != additionalClass1) {
			additionalClass1 = additionalClass1.trim();
			if (additionalClass1.trim().length() > 0) {
				styleClass += " " + additionalClass1;
			}
		}
		if (null != additionalClass2) {
			additionalClass2 = additionalClass2.trim();
			if (additionalClass2.trim().length() > 0) {
				styleClass += " " + additionalClass2;
			}
		}
		if (null != additionalClass3) {
			additionalClass3 = additionalClass3.trim();
			if (additionalClass3.trim().length() > 0) {
				styleClass += " " + additionalClass3;
			}
		}
		rw.writeAttribute("class", styleClass, "class");
	}
142647
public static void write(InputStream in, int bufferSize) {
		ServletOutputStream out = null;
		try {
			out = getOutputStream();
			IoUtil.copy(in, out, bufferSize);
		} catch (IOException e) {
			throw new RenderException("Error when output to client!", e);
		} finally {
			IoUtil.close(out);
			IoUtil.close(in);
		}
	}
1365485
void writeJavascriptHandlers() throws IOException {
        reset();

        if (cspState.getEventHandlers() == null || cspState.getEventHandlers().isEmpty()) {
            return;
        }

        startElement("script", null);
        StringBuilder javascriptBuilder = new StringBuilder(cspState.getEventHandlers().size() * 25);

        for (Map.Entry<String, Map<String, String>> elements : cspState.getEventHandlers().entrySet()) {
            String id = elements.getKey();

            for (Map.Entry<String, String> events : elements.getValue().entrySet()) {
                String event = events.getKey();
                String javascript = events.getValue();

                javascriptBuilder.append("PrimeFaces.csp.register('");
                javascriptBuilder.append(EscapeUtils.forJavaScript(id));
                javascriptBuilder.append("','");
                javascriptBuilder.append(event);
                javascriptBuilder.append("',function(event){");
                javascriptBuilder.append(javascript);
                javascriptBuilder.append("});");
            }
        }

        String javascript = javascriptBuilder.toString();
        writeText(javascript, null);
        endElement("script");

        cspState.getEventHandlers().clear();
    }
767266
public String getErrorAndRequiredClass(UIInput input, String clientId) {
		String[] levels = { "bf-no-message", "bf-info", "bf-warning", "bf-error", "bf-fatal" };
		int level = 0;
		Iterator<FacesMessage> messages = FacesContext.getCurrentInstance().getMessages(clientId);
		if (null != messages) {
			while (messages.hasNext()) {
				FacesMessage message = messages.next();
				if (message.getSeverity().equals(FacesMessage.SEVERITY_INFO))
					if (level < 1)
						level = 1;
				if (message.getSeverity().equals(FacesMessage.SEVERITY_WARN))
					if (level < 2)
						level = 2;
				if (message.getSeverity().equals(FacesMessage.SEVERITY_ERROR))
					if (level < 3)
						level = 3;
				if (message.getSeverity().equals(FacesMessage.SEVERITY_FATAL))
					if (level < 4)
						level = 4;
			}
		}
		String styleClass = levels[level];
		if (input.isRequired()) {
			styleClass += " bf-required";
		}
		return styleClass;
	}
1214463
@Override
	public void render() {
		if(null == this.in){
			throw new RenderException("InputStream is null !");
		}
		
		Response.setContentType(this.contentType);
		Response.write(this.in, this.bufferSize);
	}
402277
private void paint(ServletRequest pReq, Graphics2D pRes, int pWidth, int pHeight)
            throws ImageServletException {

        // Get parameters
        String text = pReq.getParameter(PARAM_TEXT);
        String[] lines = StringUtil.toStringArray(text, "\n\r");

        String fontFamily = pReq.getParameter(PARAM_FONT_FAMILY);
        String fontSize = pReq.getParameter(PARAM_FONT_SIZE);
        String fontStyle = pReq.getParameter(PARAM_FONT_STYLE);

        String bgcolor = pReq.getParameter(PARAM_BGCOLOR);
        String fgcolor = pReq.getParameter(PARAM_FGCOLOR);

        // TODO: Make them static..
        pRes.addRenderingHints(new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
        pRes.addRenderingHints(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
        pRes.addRenderingHints(new RenderingHints(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY));
        //    	pRes.addRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));

        //System.out.println(pRes.getBackground());

        // Clear area with bgcolor
        if (!StringUtil.isEmpty(bgcolor)) {
            pRes.setBackground(StringUtil.toColor(bgcolor));
            pRes.clearRect(0, 0, pWidth, pHeight);

            //System.out.println(pRes.getBackground());
        }

        // Create and set font
        Font font = new Font(
                fontFamily != null ? fontFamily : "Helvetica",
                getFontStyle(fontStyle),
                fontSize != null ? Integer.parseInt(fontSize) : 12
        );
        pRes.setFont(font);

        // Set rotation
        double angle = getAngle(pReq);
        pRes.rotate(angle, pWidth / 2.0, pHeight / 2.0);

        // Draw string in fgcolor
        pRes.setColor(fgcolor != null ? StringUtil.toColor(fgcolor) : Color.black);

        float x = ServletUtil.getFloatParameter(pReq, PARAM_MARGIN_LEFT, Float.MIN_VALUE);
        Rectangle2D[] bounds = new Rectangle2D[lines.length];
        if (x <= Float.MIN_VALUE) {
            // Center
            float longest = 0f;
            for (int i = 0; i < lines.length; i++) {
                bounds[i] = font.getStringBounds(lines[i], pRes.getFontRenderContext());
                if (bounds[i].getWidth() > longest) {
                    longest = (float) bounds[i].getWidth();
                }
            }

            //x = (float) ((pWidth - bounds.getWidth()) / 2f);
            x = (float) ((pWidth - longest) / 2f);

            //System.out.println("marginLeft: " + x);
        }
        //else {
        //System.out.println("marginLeft (from param): " + x);
        //}

        float y = ServletUtil.getFloatParameter(pReq, PARAM_MARGIN_TOP, Float.MIN_VALUE);
        float lineHeight = (float) (bounds[0] != null ?
                bounds[0].getHeight() : font.getStringBounds(lines[0], pRes.getFontRenderContext()).getHeight());

        if (y <= Float.MIN_VALUE) {
            // Center
            y = (float) ((pHeight - lineHeight) / 2f)
                    - (lineHeight * (lines.length - 2.5f) / 2f);

            //System.out.println("marginTop: " + y);
        }
        else {
            // Todo: Correct for font height?
            y += font.getSize2D();
            //System.out.println("marginTop (from param):" + y);

        }

        //System.out.println("Font size: " + font.getSize2D());
        //System.out.println("Line height: " + lineHeight);

        // Draw
        for (int i = 0; i < lines.length; i++) {
            pRes.drawString(lines[i], x, y + lineHeight * i);
        }
    }
431026
public static void generateJSEventHandlers(ResponseWriter rw, UIComponent component) throws IOException {
		Map<String, Object> attributes = component.getAttributes();
		String[] eventHandlers = {"onclick", "onblur", "onmouseover"};
        for (String event:eventHandlers) {
        	String handler = A.asString(attributes.get(event));
        	if (null != handler) {
        		rw.writeAttribute(event, handler, event);
        	}
        }
	}
732333
public static void renderAutoScrollHiddenInput(FacesContext facesContext,
            ResponseWriter writer) throws IOException
    {
        writer.startElement(HTML.INPUT_ELEM, null);
        writer.writeAttribute(HTML.TYPE_ATTR, "hidden", null);
        writer.writeAttribute(HTML.NAME_ATTR, AUTO_SCROLL_PARAM, null);
        writer.endElement(HTML.INPUT_ELEM);
    }
124464
protected void renderRowStart(
        FacesContext facesContext,
        ResponseWriter writer,
        UIData uiData,
        Styles styles, int rowStyleIndex) throws IOException
    {
        writer.startElement(HTML.TR_ELEM, null); // uiData);
        
        renderRowStyle(facesContext, writer, uiData, styles, rowStyleIndex);
        
        Object rowId = uiData.getAttributes().get(org.apache.myfaces.shared.renderkit.JSFAttr.ROW_ID);

        if (rowId != null)
        {
            writer.writeAttribute(HTML.ID_ATTR, rowId.toString(), null);
        }
    }
498278
private void showErrorPage(HttpServletResponse resp, String message) throws IOException {
		resp.setStatus(HttpServletResponse.SC_OK);
		resp.setContentType(GUIServletStub.CONTENT_TYPE_HTML);

		PrintWriter writer = resp.getWriter();

		writer
			.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n        \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
		writer.println("<html>");
		writer.println("<head>");
		writer.println("  <title>Launch Job - Error</title>");
		writer.println("  <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />");
		writer.println("  <link rel=\"stylesheet\" type=\"text/css\" href=\"css/nephelefrontend.css\" />");
		writer.println("</head>");

		writer.println("<body>");
		writer.println("  <div class=\"mainHeading\">");
		writer
			.println("    <h1><img src=\"img/StratosphereLogo.png\" width=\"326\" height=\"100\" alt=\"Stratosphere Logo\" align=\"middle\"/>Nephele and PACTs Query Interface</h1>");
		writer.println("  </div>");
		writer.println("  <div style=\"margin-top: 50px; text-align: center;\">");
		writer.println("    <p class=\"error_text\" style=\"font-size: 18px;\">");
		writer.println(message);
		writer.println("    </p><br/><br/>");
		writer.println("    <form action=\"launch.html\" method=\"GET\">");
		writer.println("      <input type=\"submit\" value=\"back\">");
		writer.println("    </form>");
		writer.println("  </div>");
		writer.println("</body>");
		writer.println("</html>");
	}
34813
@Override
	public void render() {
		uri = ActionContext.getContextPath() + uri;
		try {
			Response.getServletResponse().sendRedirect(uri);
		} catch (IOException e) {
			throw new RenderException("Redirect to [" + uri + "] error!", e);
		}
	}
340672
private static InputStream render(final Node dom,
        final XeSource src) throws IOException {
        final Node copy = cloneNode(dom);
        final ByteArrayOutputStream baos =
            new ByteArrayOutputStream();
        final Node node = new Xembler(src.toXembly()).applyQuietly(copy);
        try {
            TransformerFactory.newInstance().newTransformer().transform(
                new DOMSource(node),
                new StreamResult(
                    new Utf8OutputStreamContent(baos)
                )
            );
        } catch (final TransformerException ex) {
            throw new IllegalStateException(ex);
        }
        return new ByteArrayInputStream(baos.toByteArray());
    }
1241552
public void render(@NonNull Resource output) throws IOException {
      render(output, GraphViz.Format.PNG);
   }
794861
protected void renderDummyMarkup(FacesContext context, UIComponent component, String clientId) throws IOException {
        ResponseWriter writer = context.getResponseWriter();

        writer.startElement("div", null);
        writer.writeAttribute("id", clientId, null);
        writer.writeAttribute("style", "display: none;", null);

        renderPassThruAttributes(context, component, null);

        writer.endElement("div");
    }
286635
private void renderJQueryAfterComponent(ResponseWriter rw, String clientId, SelectOneMenu menu) throws IOException {
		Boolean select2 = menu.isSelect2();
		if (select2 != null && select2) {
			rw.startElement("script", menu);
			rw.writeAttribute("type", "text/javascript", "script");
			
			StringBuilder buf = new StringBuilder("$(document).ready(function(){");
			buf.append("\n");
			// jquery selector for the ID of the select component
			buf.append("  $(\"[id='").append(clientId).append("']\")");
			// select2 command to enable filtering
			buf.append(".select2();");
			buf.append("\n");
			buf.append("});");
			
			rw.writeText(buf.toString(), "script");
			rw.endElement("script");
		}
	}
100485
private void checkAsCss(InputSource is) throws IOException, SAXException {
        String charset = "UTF-8";
        if (is.getEncoding() != null) {
            charset = is.getEncoding();
        }
        List<InputStream> streamsList = new ArrayList<>();
        streamsList.add(new ByteArrayInputStream(CSS_CHECKING_PROLOG));
        streamsList.add(is.getByteStream());
        streamsList.add(new ByteArrayInputStream(CSS_CHECKING_EPILOG));
        Enumeration<InputStream> streams = Collections.enumeration(streamsList);
        is.setByteStream(new SequenceInputStream(streams));
        is.setEncoding(charset);
        sourceCode.setIsCss();
        sourceCode.initialize(is);
        try {
            htmlReader.parse(is);
        } catch (SAXParseException e) {
        }
    }
626103
function SettingsErrorRenderer(err, req, res) {
    SettingsRenderer.call(this, req, res);
    Object.defineProperties(this, {
        err: {
            value: err || new Error()
        }
    });
    req.attrs.isErrorPage = true;
}