List of usage examples for java.lang Appendable append
Appendable append(char c) throws IOException;
From source file:org.openlaszlo.sc.ScriptCompiler.java
/** Writes a LaszloScript expression that evaluates to a * LaszloScript representation of the object. * * @param elt an element//from www . j a v a2s. c o m * @param writer an appendable * @throws java.io.IOException if an error occurs */ @SuppressWarnings("unchecked") public static void writeObject(Object object, Appendable writer) throws IOException { if (object instanceof Map) { writeMap((Map<String, Object>) object, writer); } else if (object instanceof List) { writeList((List<Object>) object, writer); } else if (object != null) { writer.append(object.toString()); } else { // A declared property with no intial value writer.append("void 0"); } }
From source file:org.ofbiz.widget.WidgetWorker.java
public static void makeHiddenFormLinkForm(Appendable writer, String target, String targetType, String targetWindow, Map<String, String> parameterMap, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException { writer.append("<form method=\"post\""); writer.append(" action=\""); // note that this passes null for the parameterList on purpose so they won't be put into the URL WidgetWorker.buildHyperlinkUrl(writer, target, targetType, null, null, false, false, true, request, response, context);/* w w w . j av a 2 s . co m*/ writer.append("\""); if (UtilValidate.isNotEmpty(targetWindow)) { writer.append(" target=\""); writer.append(targetWindow); writer.append("\""); } writer.append(" onsubmit=\"javascript:submitFormDisableSubmits(this)\""); writer.append(" name=\""); writer.append(makeLinkHiddenFormName(context, modelFormField)); writer.append("\">"); for (Map.Entry<String, String> parameter : parameterMap.entrySet()) { if (parameter.getValue() != null) { writer.append("<input name=\""); writer.append(parameter.getKey()); writer.append("\" value=\""); writer.append(StringUtil.htmlEncoder.encode(parameter.getValue())); writer.append("\" type=\"hidden\"/>"); } } writer.append("</form>"); }
From source file:org.apache.ofbiz.widget.WidgetWorker.java
public static void makeHiddenFormLinkAnchor(Appendable writer, String linkStyle, String description, String confirmation, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context) throws IOException { if (UtilValidate.isNotEmpty(description) || UtilValidate.isNotEmpty(request.getAttribute("image"))) { writer.append("<a"); if (UtilValidate.isNotEmpty(linkStyle)) { writer.append(" class=\""); writer.append(linkStyle);/*from www . j av a 2 s.c o m*/ writer.append("\""); } writer.append(" href=\"javascript:document."); writer.append(makeLinkHiddenFormName(context, modelFormField)); writer.append(".submit()\""); if (UtilValidate.isNotEmpty(modelFormField.getEvent()) && UtilValidate.isNotEmpty(modelFormField.getAction(context))) { writer.append(" "); writer.append(modelFormField.getEvent()); writer.append("=\""); writer.append(modelFormField.getAction(context)); writer.append('"'); } if (UtilValidate.isNotEmpty(confirmation)) { writer.append(" onclick=\"return confirm('"); writer.append(confirmation); writer.append("')\""); } writer.append('>'); if (UtilValidate.isNotEmpty(request.getAttribute("image"))) { writer.append("<img src=\""); writer.append(request.getAttribute("image").toString()); writer.append("\"/>"); } writer.append(description); writer.append("</a>"); } }
From source file:de.schildbach.wallet.ui.ReportIssueDialogFragment.java
private static void appendDeviceInfo(final Appendable report, final Context context) throws IOException { final Resources res = context.getResources(); final android.content.res.Configuration config = res.getConfiguration(); final ActivityManager activityManager = (ActivityManager) context .getSystemService(Context.ACTIVITY_SERVICE); final DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context .getSystemService(Context.DEVICE_POLICY_SERVICE); report.append("Device Model: " + Build.MODEL + "\n"); report.append("Android Version: " + Build.VERSION.RELEASE + "\n"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) report.append("Android security patch level: ").append(Build.VERSION.SECURITY_PATCH).append("\n"); report.append("ABIs: ") .append(Joiner.on(", ").skipNulls() .join(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? supportedAbisLollipop() : supportedAbisKitKat())) .append("\n"); report.append("Board: " + Build.BOARD + "\n"); report.append("Brand: " + Build.BRAND + "\n"); report.append("Device: " + Build.DEVICE + "\n"); report.append("Display: " + Build.DISPLAY + "\n"); report.append("Finger Print: " + Build.FINGERPRINT + "\n"); report.append("Host: " + Build.HOST + "\n"); report.append("ID: " + Build.ID + "\n"); report.append("Product: " + Build.PRODUCT + "\n"); report.append("Tags: " + Build.TAGS + "\n"); report.append("Time: " + Build.TIME + "\n"); report.append("Type: " + Build.TYPE + "\n"); report.append("User: " + Build.USER + "\n"); report.append("Configuration: " + config + "\n"); report.append("Screen Layout: size " + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_SIZE_MASK) + " long " + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_LONG_MASK) + "\n"); report.append("Display Metrics: " + res.getDisplayMetrics() + "\n"); report.append(/*from w ww .j ava 2s .co m*/ "Memory Class: " + activityManager.getMemoryClass() + "/" + activityManager.getLargeMemoryClass() + (activityManager.isLowRamDevice() ? " (low RAM device)" : "") + "\n"); report.append("Storage Encryption Status: " + devicePolicyManager.getStorageEncryptionStatus() + "\n"); report.append("Bluetooth MAC: " + bluetoothMac() + "\n"); report.append("Runtime: ").append(System.getProperty("java.vm.name")).append(" ") .append(System.getProperty("java.vm.version")).append("\n"); }
From source file:de.schildbach.wallet.util.CrashReporter.java
public static void appendDeviceInfo(final Appendable report, final Context context) throws IOException { final Resources res = context.getResources(); final android.content.res.Configuration config = res.getConfiguration(); final ActivityManager activityManager = (ActivityManager) context .getSystemService(Context.ACTIVITY_SERVICE); final DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context .getSystemService(Context.DEVICE_POLICY_SERVICE); report.append("Device Model: " + Build.MODEL + "\n"); report.append("Android Version: " + Build.VERSION.RELEASE + "\n"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) report.append("Android security patch level: ").append(Build.VERSION.SECURITY_PATCH).append("\n"); report.append("ABIs: ").append(Joiner.on(", ").skipNulls().join(Strings.emptyToNull(Build.CPU_ABI), Strings.emptyToNull(Build.CPU_ABI2))).append("\n"); report.append("Board: " + Build.BOARD + "\n"); report.append("Brand: " + Build.BRAND + "\n"); report.append("Device: " + Build.DEVICE + "\n"); report.append("Display: " + Build.DISPLAY + "\n"); report.append("Finger Print: " + Build.FINGERPRINT + "\n"); report.append("Host: " + Build.HOST + "\n"); report.append("ID: " + Build.ID + "\n"); report.append("Product: " + Build.PRODUCT + "\n"); report.append("Tags: " + Build.TAGS + "\n"); report.append("Time: " + Build.TIME + "\n"); report.append("Type: " + Build.TYPE + "\n"); report.append("User: " + Build.USER + "\n"); report.append("Configuration: " + config + "\n"); report.append("Screen Layout: size " + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_SIZE_MASK) + " long " + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_LONG_MASK) + "\n"); report.append("Display Metrics: " + res.getDisplayMetrics() + "\n"); report.append("Memory Class: " + activityManager.getMemoryClass() + "/" + activityManager.getLargeMemoryClass() + (ActivityManagerCompat.isLowRamDevice(activityManager) ? " (low RAM device)" : "") + "\n"); report.append("Storage Encryption Status: " + devicePolicyManager.getStorageEncryptionStatus() + "\n"); report.append("Bluetooth MAC: " + bluetoothMac() + "\n"); report.append("Runtime: ").append(System.getProperty("java.vm.name")).append(" ") .append(System.getProperty("java.vm.version")).append("\n"); }
From source file:org.diorite.cfg.system.Template.java
/** * Append comment to given {@link Appendable} * * @param writer {@link Appendable} to use, all data will be added here. * @param string comment string to add, may be multi-line. * @param level current indent level. * @param addSpace if true, additional space will be added before first # and no indent for first line. * * @throws IOException from {@link Appendable} *//*from w w w . j a va 2s .c om*/ static void appendComment(final Appendable writer, final String string, final int level, final boolean addSpace) throws IOException { if (string != null) { final String[] split = StringUtils.split(string, '\n'); boolean first = true; for (int i = 0, splitLength = split.length; i < splitLength; i++) { final String str = split[i]; if (!first || !addSpace) { spaces(writer, level); writer.append("# "); } else { first = false; writer.append(" # "); } writer.append(str); if ((i + 1) < splitLength) { writer.append('\n'); } } } }
From source file:de.schildbach.wallet.util.CrashReporter.java
public static void appendInstalledPackages(final Appendable report, final Context context) throws IOException { final PackageManager pm = context.getPackageManager(); final List<PackageInfo> installedPackages = pm.getInstalledPackages(0); // sort by package name Collections.sort(installedPackages, new Comparator<PackageInfo>() { @Override//from w w w . j a v a2 s . c o m public int compare(final PackageInfo lhs, final PackageInfo rhs) { return lhs.packageName.compareTo(rhs.packageName); } }); for (final PackageInfo p : installedPackages) report.append(String.format(Locale.US, "%s %s (%d) - %tF %tF\n", p.packageName, p.versionName, p.versionCode, p.firstInstallTime, p.lastUpdateTime)); }
From source file:org.apache.ofbiz.widget.WidgetWorker.java
public static void makeHyperlinkString(Appendable writer, String linkStyle, String targetType, String target, Map<String, String> parameterMap, String description, String confirmation, ModelFormField modelFormField, HttpServletRequest request, HttpServletResponse response, Map<String, Object> context, String targetWindow) throws IOException { if (UtilValidate.isNotEmpty(description) || UtilValidate.isNotEmpty(request.getAttribute("image"))) { writer.append("<a"); if (UtilValidate.isNotEmpty(linkStyle)) { writer.append(" class=\""); writer.append(linkStyle);/*w w w . j a va 2s .c om*/ writer.append("\""); } writer.append(" href=\""); buildHyperlinkUrl(writer, target, targetType, parameterMap, null, false, false, true, request, response, context); writer.append("\""); if (UtilValidate.isNotEmpty(targetWindow)) { writer.append(" target=\""); writer.append(targetWindow); writer.append("\""); } if (UtilValidate.isNotEmpty(modelFormField.getEvent()) && UtilValidate.isNotEmpty(modelFormField.getAction(context))) { writer.append(" "); writer.append(modelFormField.getEvent()); writer.append("=\""); writer.append(modelFormField.getAction(context)); writer.append('"'); } if (UtilValidate.isNotEmpty(confirmation)) { writer.append(" onclick=\"return confirm('"); writer.append(confirmation); writer.append("')\""); } writer.append('>'); if (UtilValidate.isNotEmpty(request.getAttribute("image"))) { writer.append("<img src=\""); writer.append(request.getAttribute("image").toString()); writer.append("\"/>"); } writer.append(description); writer.append("</a>"); } }
From source file:org.apache.hadoop.hive.ql.plan.PlanUtils.java
public static void addExprToStringBuffer(ExprNodeDesc expr, Appendable sb) { try {/* w w w .ja v a 2 s . c o m*/ sb.append(expr.getExprString()); sb.append(" (type: "); sb.append(expr.getTypeString()); sb.append(")"); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:org.shredzone.cilla.site.renderer.CommentRendererStrategyImpl.java
@Override public void noCommentHeader(Appendable out) throws IOException { out.append("<p>").append(bundle.getString("comment.nocomments")).append("</p>"); }