Encode the javascript code
@throws IOException
773236
private void encodeJS(FacesContext fc, ResponseWriter rw, DateTimePicker dtp, String datePickerId)
	throws IOException {
		String clientId = dtp.getClientId();
		String fieldId = dtp.getFieldId();
		if (null == fieldId) {
			fieldId = clientId + "_Input";
		} else if (fieldId.equals(dtp.getId())) {
			throw new FacesException("The field id must differ from the regular id.");
		}
		String mode = dtp.getMode();

		Object v = dtp.getSubmittedValue();
		if (v == null) {
			v = dtp.getValue();
		}

		// show all buttons
		if(dtp.isShowButtonPanel()) {
			dtp.setShowClearButton(true);
			dtp.setShowCloseButton(true);
			dtp.setShowTodayButton(true);
		}

		Locale sloc = BsfUtils.selectLocale(fc.getViewRoot().getLocale(), dtp.getLocale(), dtp);
		String format = BsfUtils.selectMomentJSDateTimeFormat(sloc, dtp.getFormat(), dtp.isShowDate(), dtp.isShowTime());
		String displayFormat = "'" + format + "'";
		String inlineDisplayDate = "'" +
				getValueAsString(v, fc, dtp) + "'";

		String fullSelector =  "#" + BsfUtils.escapeJQuerySpecialCharsInSelector(datePickerId);

		String defaultDate = BsfUtils.isStringValued(dtp.getInitialDate()) ?
			dtp.getInitialDate().contains("moment") ? dtp.getInitialDate() : "'" + dtp.getInitialDate() + "'" : "";
		String minDate = BsfUtils.isStringValued(dtp.getMinDate()) ?
							dtp.getMinDate().contains("moment") ? dtp.getMinDate() : "'" + dtp.getMinDate() + "'" :
							"";
		String maxDate = BsfUtils.isStringValued(dtp.getMaxDate()) ?
							dtp.getMaxDate().contains("moment") ? dtp.getMaxDate() : "'" + dtp.getMaxDate() + "'" :
							"";

		rw.startElement("script", dtp);
		rw.writeText("$(function () { " +
					      "$('" + fullSelector + "').datetimepicker({  " +
					        "ignoreReadonly: false, " +
					        (dtp.isAllowInputToggle()                  ?         		"allowInputToggle: true, ": "") +
					      	(dtp.isCollapse() ? 										"collapse: " + dtp.isCollapse() + ", ": "") +
					      	(BsfUtils.isStringValued(dtp.getDayViewHeaderFormat()) ? 	"dayViewHeaderFormat: '" + dtp.getDayViewHeaderFormat() + "', " : "") +
					      	(BsfUtils.isStringValued(dtp.getDisabledDates()) ?			"disabledDates: [" + dtp.getDisabledDates() + "], " : "") +
					      	(BsfUtils.isStringValued(dtp.getDisableTimeInterval()) ?	"disabledTimeIntervals: [" + dtp.getDisableTimeInterval() + "], " : "") +
					      	(BsfUtils.isStringValued(dtp.getEnabledDates()) ?			"enabledDates: [" + dtp.getDisableTimeInterval() + "], " : "") +
					      	(dtp.isFocusOnShow() ? 										"focusOnShow: " + dtp.isFocusOnShow() + ", ": "") +
					      	(BsfUtils.isStringValued(dtp.getInitialDate()) ?			"defaultDate: " + defaultDate + ", " : "") +
					      	(dtp.isKeepInvalid() ? 										"keepInvalid: " + dtp.isKeepInvalid() + ", ": "") +
					      	(dtp.isKeepOpen() ? 										"keepOpen: " + dtp.isKeepOpen() + ", ": "") +
					      	(BsfUtils.isStringValued(minDate) ?							"minDate: " + minDate + ", " : "") +
					      	(BsfUtils.isStringValued(maxDate) ?							"maxDate: " + maxDate + ", " : "") +
					      	(dtp.isShowWeek() ? 										"calendarWeeks: " + dtp.isShowWeek() + ", ": "") +
					      	(dtp.isShowClearButton() ? 									"showClear: " + dtp.isShowClearButton() + ", ": "") +
					      	(dtp.isShowCloseButton() ? 									"showClose: " + dtp.isShowCloseButton() + ", ": "") +
					      	(dtp.isShowTodayButton() ? 									"showTodayButton: " + dtp.isShowTodayButton() + ", ": "") +
					      	(dtp.isSideBySide() || "inline".equals(mode) ? 				"sideBySide: true, ": "") +
					      	(dtp.getTimeStepping() > 0 ?								"stepping: " + dtp.getTimeStepping() + ", ": "") +
					      	(BsfUtils.isStringValued(dtp.getToolbarPlacement()) ?		"toolbarPlacement: '" + dtp.getToolbarPlacement() + "', " : "") +
					      	(BsfUtils.isStringValued(dtp.getViewMode()) ?				"viewMode: '" + dtp.getViewMode() + "', " : "") +
					      	(dtp.isUseCurrent() ? 										"": "useCurrent:false,") +
					      	(dtp.isUseStrict() ? 										"useStrict: " + dtp.isUseStrict() + ", ": "") +
					      	(BsfUtils.isStringValued(dtp.getWidgetParent()) ?           "widgetParent: '" + BsfUtils.resolveSearchExpressions(dtp.getWidgetParent()) + "', " : "" ) +
					      	("inline".equals(mode) ? 									"inline: true," : "" ) +
					      	"date: moment(" + inlineDisplayDate + ", " + displayFormat + "), " +
					      	"locale: '" + sloc.getLanguage() + "', " +
					      	"format: " + displayFormat +
						  "});" +
					      // ("inline".equals(type) ? "$('" + fullSelector + "').date(" + inlineDisplayDate + ")" : "") +
					  "});", null);

		if("inline".equals(mode)) {
			rw.writeText("$('" + fullSelector + "').on('dp.change', function(e) { " +
						 "   $('#" + BsfUtils.escapeJQuerySpecialCharsInSelector(fieldId) + "').val( e.date.format(" + displayFormat + ") ); " +
						 "});", null);
		}
		rw.endElement("script");
		new AJAXRenderer().generateBootsFacesAJAXAndJavaScriptForJQuery(fc, dtp, rw, fullSelector, null, true);
	}
218790
void genCode() throws IOException {
        for (Iterator<JRecord> i = mRecList.iterator(); i.hasNext();) {
            JRecord rec = i.next();
            rec.genJavaCode(outputDirectory);
        }
    }
474024
@Override
    public String encode() throws IOException {
        FastStringWriter fsw = new FastStringWriter();

        try {
            fsw.write("{");
            fsw.write(super.encode());

            ChartUtils.writeDataValue(fsw, "beginAtZero", this.beginAtZero, true);
            ChartUtils.writeDataValue(fsw, "backdropColor", this.backdropColor, true);
            ChartUtils.writeDataValue(fsw, "backdropPaddingX", this.backdropPaddingX, true);
            ChartUtils.writeDataValue(fsw, "backdropPaddingY", this.backdropPaddingY, true);
            ChartUtils.writeDataValue(fsw, "min", this.min, true);
            ChartUtils.writeDataValue(fsw, "max", this.max, true);
            ChartUtils.writeDataValue(fsw, "maxTicksLimit", this.maxTicksLimit, true);
            ChartUtils.writeDataValue(fsw, "stepSize", this.stepSize, true);
            ChartUtils.writeDataValue(fsw, "suggestedMax", this.suggestedMax, true);
            ChartUtils.writeDataValue(fsw, "suggestedMin", this.suggestedMin, true);
            ChartUtils.writeDataValue(fsw, "showLabelBackdrop", this.showLabelBackdrop, true);

            fsw.write("}");
        }
        finally {
            fsw.close();
        }

        return fsw.toString();
    }
1104835
@Override
    public void encode(IoSession session, Object message,
            ProtocolEncoderOutput out) throws Exception {
        out.write(message);
    }
1327775
public final ByteArrayOutputStream encode() throws IOException
    {
        final ByteArrayOutputStream buffer = new ByteArrayOutputStream();

        buffer.write(type);
        buffer.write(clientId);
        buffer.write(clientDestId);
        encode(buffer);

        return buffer;
    }
951429
public void encode(AsnOutputStream aos) throws EncodeException {
        if (this.userType == null && this.providerType == null)
            throw new EncodeException("Error encoding ResultSourceDiagnostic: Value not set");

        try {
            aos.writeTag(Tag.CLASS_CONTEXT_SPECIFIC, false, _TAG);
            int pos = aos.StartContentDefiniteLength();

            if (this.userType != null) {
                aos.writeTag(Tag.CLASS_CONTEXT_SPECIFIC, false, _TAG_U);
                int pos2 = aos.StartContentDefiniteLength();
                aos.writeInteger(this.userType.getType());
                aos.FinalizeContent(pos2);
            } else {
                aos.writeTag(Tag.CLASS_CONTEXT_SPECIFIC, false, _TAG_P);
                int pos2 = aos.StartContentDefiniteLength();
                aos.writeInteger(this.providerType.getType());
                aos.FinalizeContent(pos2);
            }

            aos.FinalizeContent(pos);

        } catch (IOException e) {
            throw new EncodeException("IOException while encoding ResultSourceDiagnostic: " + e.getMessage(), e);
        } catch (AsnException e) {
            throw new EncodeException("AsnException while encoding ResultSourceDiagnostic: " + e.getMessage(), e);
        }

    }
192122
public void encode(OutputStream out) throws IOException {
        DerOutputStream tmp = new DerOutputStream();
        if (extensionValue == null) {
            extensionId = PKIXExtensions.SubjectKey_Id;
            critical = false;
            encodeThis();
        }
        super.encode(tmp);
        out.write(tmp.toByteArray());
    }
84608
private void encodeThis() throws IOException {
        if (names == null || names.isEmpty()) {
            this.extensionValue = null;
            return;
        }
        DerOutputStream os = new DerOutputStream();
        names.encode(os);
        this.extensionValue = os.toByteArray();
    }
1158279
public void encode(DerOutputStream out)
    throws IOException {
        out.write(tag);
        out.putLength(length);
        // XXX yeech, excess copies ... DerInputBuffer.write(OutStream)
        if (length > 0) {
            byte[] value = new byte[length];
            // always synchronized on data
            synchronized (data) {
                buffer.reset();
                if (buffer.read(value) != length) {
                    throw new IOException("short DER value read (encode)");
                }
                out.write(value);
            }
        }
    }
551037
@Override
	public String encodeAsString() throws IOException {
		ByteArray byteArray = encodeAsByteArray();
		if(byteArray.size == 0) return "";
		return new String(Base64Coder.encode(byteArray.array, byteArray.size));
	}
367141
public String encode() throws IOException {
        FastStringWriter fsw = new FastStringWriter();

        try {
            ChartUtils.writeDataValue(fsw, "enabled", this.enabled, false);
            ChartUtils.writeDataValue(fsw, "mode", this.mode, true);
            ChartUtils.writeDataValue(fsw, "intersect", this.intersect, true);
            ChartUtils.writeDataValue(fsw, "position", this.position, true);
            ChartUtils.writeDataValue(fsw, "backgroundColor", this.backgroundColor, true);
            ChartUtils.writeDataValue(fsw, "titleFontFamily", this.titleFontFamily, true);
            ChartUtils.writeDataValue(fsw, "titleFontSize", this.titleFontSize, true);
            ChartUtils.writeDataValue(fsw, "titleFontStyle", this.titleFontStyle, true);
            ChartUtils.writeDataValue(fsw, "titleFontColor", this.titleFontColor, true);
            ChartUtils.writeDataValue(fsw, "titleSpacing", this.titleSpacing, true);
            ChartUtils.writeDataValue(fsw, "titleMarginBottom", this.titleMarginBottom, true);
            ChartUtils.writeDataValue(fsw, "bodyFontFamily", this.bodyFontFamily, true);
            ChartUtils.writeDataValue(fsw, "bodyFontSize", this.bodyFontSize, true);
            ChartUtils.writeDataValue(fsw, "bodyFontStyle", this.bodyFontStyle, true);
            ChartUtils.writeDataValue(fsw, "bodyFontColor", this.bodyFontColor, true);
            ChartUtils.writeDataValue(fsw, "bodySpacing", this.bodySpacing, true);
            ChartUtils.writeDataValue(fsw, "footerFontFamily", this.footerFontFamily, true);
            ChartUtils.writeDataValue(fsw, "footerFontSize", this.footerFontSize, true);
            ChartUtils.writeDataValue(fsw, "footerFontStyle", this.footerFontStyle, true);
            ChartUtils.writeDataValue(fsw, "footerFontColor", this.footerFontColor, true);
            ChartUtils.writeDataValue(fsw, "footerSpacing", this.footerSpacing, true);
            ChartUtils.writeDataValue(fsw, "footerMarginTop", this.footerMarginTop, true);
            ChartUtils.writeDataValue(fsw, "xPadding", this.xpadding, true);
            ChartUtils.writeDataValue(fsw, "yPadding", this.ypadding, true);
            ChartUtils.writeDataValue(fsw, "caretPadding", this.caretPadding, true);
            ChartUtils.writeDataValue(fsw, "caretSize", this.caretSize, true);
            ChartUtils.writeDataValue(fsw, "cornerRadius", this.cornerRadius, true);
            ChartUtils.writeDataValue(fsw, "multiKeyBackground", this.multiKeyBackground, true);
            ChartUtils.writeDataValue(fsw, "displayColors", this.displayColors, true);
            ChartUtils.writeDataValue(fsw, "borderColor", this.borderColor, true);
            ChartUtils.writeDataValue(fsw, "borderWidth", this.borderWidth, true);
        }
        finally {
            fsw.close();
        }

        return fsw.toString();
    }
123409
protected JsonToken handleJavascriptWithScope() throws IOException {
		//skip size
		_in.readInt();
		String code = readString();
		Map<String, Object> doc = readDocument();
		getContext().value = new JavaScript(code, doc);
		return JsonToken.VALUE_EMBEDDED_OBJECT;
	}
59356
private void encodeScript(final FacesContext context, final Social social) throws IOException {
        final WidgetBuilder wb = getWidgetBuilder(context);
        final String clientId = social.getClientId(context);
        wb.init("ExtSocial", social.resolveWidgetVar(), clientId);
        wb.attr("showLabel", social.isShowLabel());
        wb.attr("shareIn", social.getShareIn());
        if (!LangUtils.isValueBlank(social.getUrl())) {
            wb.attr("url", social.getUrl());
        }
        if (!LangUtils.isValueBlank(social.getText())) {
            wb.attr("text", social.getText());
        }

        final boolean showCount = BooleanUtils.toBoolean(social.getShowCount());
        if (showCount) {
            wb.attr("showCount", showCount);
        }
        else {
            if (social.getShowCount().equalsIgnoreCase("inside")) {
                wb.attr("showCount", social.getShowCount());
            }
            else {
                wb.attr("showCount", showCount);
            }
        }

        // shares array
        wb.append(",shares: [");
        final String[] shares = StringUtils.split(social.getShares(), ',');
        for (int i = 0; i < shares.length; i++) {
            // { share: "pinterest", media: "http://mysite.com" },
            final String share = StringUtils.lowerCase(shares[i]);
            if (LangUtils.isValueBlank(share)) {
                continue;
            }
            if (i != 0) {
                wb.append(",");
            }
            wb.append("{");
            addShareProperty(wb, "share", share);
            if (share.equalsIgnoreCase("twitter")) {
                wb.attr("via", social.getTwitterUsername());
                wb.attr("hashtags", social.getTwitterHashtags());
            }
            if (share.equalsIgnoreCase("email")) {
                wb.attr("to", social.getEmailTo());
            }
            if (share.equalsIgnoreCase("pinterest")) {
                wb.attr("media", social.getPinterestMedia());
            }
            wb.append("}");
        }
        wb.append("]");

        // javascript
        wb.append(",on: {");
        if (social.getOnclick() != null) {
            addCallback(wb, "click", "function(e)", social.getOnclick());
        }
        if (social.getOnmouseenter() != null) {
            addCallback(wb, "mouseenter", "function(e)", social.getOnmouseenter());
        }
        if (social.getOnmouseleave() != null) {
            addCallback(wb, "mouseleave", "function(e)", social.getOnmouseleave());
        }
        wb.append("}");

        encodeClientBehaviors(context, social);

        wb.finish();
    }
1109291
private void encodeScript(final FacesContext context, final Github github) throws IOException {
        final WidgetBuilder wb = getWidgetBuilder(context);
        final String clientId = github.getClientId(context);
        wb.init("ExtGitHub", github.resolveWidgetVar(), clientId);
        wb.attr("iconForks", github.isIconForks());
        wb.attr("iconIssues", github.isIconIssues());
        wb.attr("iconStars", github.isIconStars());
        wb.finish();
    }
1262087
@Override
    public String encode() throws IOException {
        FastStringWriter fsw = new FastStringWriter();

        try {
            fsw.write("{");

            ChartUtils.writeDataValue(fsw, "type", this.getType(), false);
            ChartUtils.writeDataValue(fsw, "data", this.data, true);
            ChartUtils.writeDataValue(fsw, "label", this.label, true);
            ChartUtils.writeDataValue(fsw, "hidden", this.isHidden(), true);
            ChartUtils.writeDataValue(fsw, "xAxisID", this.xaxisID, true);
            ChartUtils.writeDataValue(fsw, "yAxisID", this.yaxisID, true);
            ChartUtils.writeDataValue(fsw, "stack", this.stack, true);
            ChartUtils.writeDataValue(fsw, "backgroundColor", this.backgroundColor, true);
            ChartUtils.writeDataValue(fsw, "borderColor", this.borderColor, true);
            ChartUtils.writeDataValue(fsw, "borderWidth", this.borderWidth, true);
            ChartUtils.writeDataValue(fsw, "borderSkipped", this.borderSkipped, true);
            ChartUtils.writeDataValue(fsw, "hoverBackgroundColor", this.hoverBackgroundColor, true);
            ChartUtils.writeDataValue(fsw, "hoverBorderColor", this.hoverBorderColor, true);
            ChartUtils.writeDataValue(fsw, "hoverBorderWidth", this.hoverBorderWidth, true);

            fsw.write("}");
        }
        finally {
            fsw.close();
        }

        return fsw.toString();
    }
282021
@Override
    public String encode() throws IOException {
        FastStringWriter fsw = new FastStringWriter();

        try {
            fsw.write(super.encode());
            ChartUtils.writeDataValue(fsw, "beginAtZero", this.beginAtZero, true);
            ChartUtils.writeDataValue(fsw, "min", this.min, true);
            ChartUtils.writeDataValue(fsw, "max", this.max, true);
            ChartUtils.writeDataValue(fsw, "maxTicksLimit", this.maxTicksLimit, true);
            ChartUtils.writeDataValue(fsw, "precision", this.precision, true);
            ChartUtils.writeDataValue(fsw, "stepSize", this.stepSize, true);
            ChartUtils.writeDataValue(fsw, "suggestedMax", this.suggestedMax, true);
            ChartUtils.writeDataValue(fsw, "suggestedMin", this.suggestedMin, true);
        }
        finally {
            fsw.close();
        }

        return fsw.toString();
    }
828029
public String encode() throws IOException {
        FastStringWriter fsw = new FastStringWriter();

        try {
            fsw.write("{");

            ChartUtils.writeDataValue(fsw, "display", this.display, false);
            ChartUtils.writeDataValue(fsw, "color", this.color, true);
            ChartUtils.writeDataValue(fsw, "lineWidth", this.lineWidth, true);

            fsw.write("}");
        }
        finally {
            fsw.close();
        }

        return fsw.toString();
    }