Example usage for java.lang Appendable append

List of usage examples for java.lang Appendable append

Introduction

In this page you can find the example usage for java.lang Appendable append.

Prototype

Appendable append(char c) throws IOException;

Source Link

Document

Appends the specified character to this Appendable .

Usage

From source file:org.diorite.cfg.system.elements.StringTemplateElement.java

@Override
public void appendValue(final Appendable writer, final CfgEntryData field, final Object source,
        final Object elementRaw, final int level, final ElementPlace elementPlace) throws IOException {
    StringStyle style = field.getOption(FieldOptions.STRING_STYLE, StringStyle.DEFAULT);
    if ((style == StringStyle.ALWAYS_MULTI_LINE) && (elementPlace == ElementPlace.SIMPLE_LIST_OR_MAP)) // multi line strings don't works in simple lists/maps.
    {//from  w ww  .  j a  va 2s. com
        style = StringStyle.DEFAULT;
    }
    final String element = Enum.class.isAssignableFrom(elementRaw.getClass()) ? ((Enum<?>) elementRaw).name()
            : elementRaw.toString();
    switch (style) {
    case ALWAYS_QUOTED: {
        writeQuoted(writer, element);
        break;
    }
    case ALWAYS_SINGLE_QUOTED: {
        writeSingleQuoted(writer, StringUtils.replaceEach(element, REP_PREV_1, REP_PREV_2));
        break;
    }
    case ALWAYS_MULTI_LINE: {
        writeMultiLine(writer, element, level, elementPlace);
        break;
    }
    default: {
        final boolean haveNewLines = StringUtils.contains(element, '\n');
        if ((elementPlace != ElementPlace.SIMPLE_LIST_OR_MAP) && haveNewLines) {
            writeMultiLine(writer, element, level, elementPlace);
            return;
        }
        boolean needQuote = false;
        if (element.isEmpty()) {
            writeSingleQuoted(writer, element);
            return;
        }
        final char f = element.charAt(0);
        if (StringUtils.containsAny(element, ':', '#')) {
            needQuote = true;
        } else {
            for (final char c : CANT_BE_FIRST) {
                if (c == f) {
                    needQuote = true;
                    break;
                }
            }
        }
        if (needQuote) {
            writeQuoted(writer, element);
            return;
        }
        if (StringUtils.isNumeric(element)) {
            writeQuoted(writer, element);
        } else {
            writer.append(StringUtils.replace(element, "\n", "\\n"));
        }
        break;
    }
    }
}

From source file:org.ramadda.data.services.PointFormHandler.java

/**
 * add to form//from   www  . j  a  v a2 s  . c  om
 *
 * @param request request
 * @param entry _more_
 * @param sb buffer
 * @param forGroup for group
 * @param recordEntry the entry
 * @param extraSubset _more_
 *
 * @throws Exception On badness
 */
public void addSelectForm(Request request, Entry entry, Appendable sb, boolean forGroup,
        RecordEntry recordEntry, String extraSubset) throws Exception {

    long numRecords = forGroup ? 0 : recordEntry.getNumRecords();

    List<HtmlUtils.Selector> pointFormats = new ArrayList<HtmlUtils.Selector>();
    List<HtmlUtils.Selector> gridFormats = new ArrayList<HtmlUtils.Selector>();

    //Do this so we get the LidarOutputHandler in case of a lidar entry
    ((PointEntry) recordEntry).getPointOutputHandler().getPointFormats(pointFormats, forGroup);
    getGridFormats(gridFormats, forGroup);
    List<List<HtmlUtils.Selector>> formatLists = new ArrayList<List<HtmlUtils.Selector>>();
    formatLists.add(pointFormats);
    formatLists.add(gridFormats);

    sb.append(HtmlUtils.formTable(HtmlUtils.cssClass("formtable") + HtmlUtils.attrs(HtmlUtils.ATTR_CELLPADDING,
            "0", HtmlUtils.ATTR_CELLSPACING, "0", HtmlUtils.ATTR_WIDTH, "100%")));
    sb.append("<tr><td width=15%>");
    sb.append(HtmlUtils.submit(msg("Get Data"), ARG_GETDATA));
    sb.append("</td><td></td></tr>");
    sb.append(HtmlUtils.hidden(ARG_OUTPUT, getPointOutputHandler().OUTPUT_PRODUCT.getId()));

    StringBuffer productSB = new StringBuffer();
    HashSet<String> selectedFormat = getFormats(request);
    StringBuffer formats = new StringBuffer("<table border=0 cellpadding=4 cellspacing=0><tr valign=top>");

    int cnt = 0;
    StringBuffer formatCol;
    StringBuffer gridsCol = new StringBuffer();
    gridsCol.append(HtmlUtils.b(msg("Select Grids")));
    gridsCol.append(HtmlUtils.p());
    for (int i = 0; i < GRID_ARGS.length; i++) {
        String helpImg = HtmlUtils.img(getRepository().iconUrl(ICON_HELP), GRID_HELP[i]);
        gridsCol.append(helpImg);
        gridsCol.append(HtmlUtils.checkbox(GRID_ARGS[i], "true", false));
        gridsCol.append(msg(GRID_LABELS[i]));
        gridsCol.append(HtmlUtils.p());
    }

    for (int i = 0; i < formatLists.size(); i++) {
        List<HtmlUtils.Selector> formatList = formatLists.get(i);
        formatCol = new StringBuffer();
        if (i == 0) {
            formatCol.append(HtmlUtils.b(msg("Point Products")));
        } else {
            if (!recordEntry.isCapable(PointFile.ACTION_GRID)) {
                continue;
            }
            formats.append(HtmlUtils.col(HtmlUtils.space(5)));
            formats.append(HtmlUtils.col(HtmlUtils.img(getRepository().fileUrl("/icons/blank.gif")),
                    HtmlUtils.style("border-left:1px #000000 solid")));
            formats.append(HtmlUtils.col(HtmlUtils.space(4)));
            formats.append(HtmlUtils.col(gridsCol.toString()));
            String middle = "<br><br><br>&nbsp;&nbsp;&nbsp;to make&nbsp;&nbsp;&nbsp;<br>"
                    + HtmlUtils.img(getRepository().fileUrl("/point/rightarrow.jpg"));
            formats.append(HtmlUtils.col(middle, HtmlUtils.attr(HtmlUtils.ATTR_ALIGN, "center")));
            formatCol.append(HtmlUtils.b(msg("Select Products")));
        }
        formatCol.append(HtmlUtils.p());

        for (HtmlUtils.Selector selector : formatList) {
            formatCol.append(HtmlUtils.checkbox(ARG_PRODUCT, selector.getId(),
                    selectedFormat.contains(selector.getId())));
            formatCol.append(" ");
            if (selector.getIcon() != null) {
                formatCol.append(HtmlUtils.img(selector.getIcon()));
                formatCol.append(" ");
            }
            formatCol.append(selector.getLabel());
            formatCol.append(HtmlUtils.p());
        }
        formats.append(HtmlUtils.col(formatCol.toString()));
    }
    formats.append("</tr></table>");
    productSB.append(HtmlUtils.row(HtmlUtils.colspan(formats.toString(), 2)));

    StringBuffer subsetSB = new StringBuffer();
    if (numRecords > 0) {
        subsetSB.append(HtmlUtils.formEntry("# " + msgLabel("Points"), formatPointCount(numRecords)));
    }

    MapInfo map = getRepository().getMapManager().createMap(request, true, null);
    List<Metadata> metadataList = getMetadataManager().getMetadata(entry);
    boolean didMetadata = map.addSpatialMetadata(entry, metadataList);
    if (!didMetadata) {
        map.addBox(entry, new MapBoxProperties(MapInfo.DFLT_BOX_COLOR, false, true));
    } else {
        map.centerOn(entry);
    }
    SessionManager sm = getRepository().getSessionManager();
    String mapSelector = map.makeSelector(ARG_AREA, true,
            new String[] { request.getStringOrSession(ARG_AREA_NORTH, getSessionPrefix(), ""),
                    request.getStringOrSession(ARG_AREA_WEST, getSessionPrefix(), ""),
                    request.getStringOrSession(ARG_AREA_SOUTH, getSessionPrefix(), ""),
                    request.getStringOrSession(ARG_AREA_EAST, getSessionPrefix(), ""), },
            "", "");

    subsetSB.append(HtmlUtils.formEntryTop(msgLabel("Region"), mapSelector));

    if (recordEntry != null) {
        String help = "Probablity a point will be included 0.-1.0";
        String probHelpImg = HtmlUtils.img(getRepository().iconUrl(ICON_HELP), help);
        String prob = HtmlUtils.space(3) + msgLabel("Or use probability") + " "
                + HtmlUtils.input(ARG_PROBABILITY, request.getString(ARG_PROBABILITY, ""), 4) + probHelpImg;
        if (recordEntry.isCapable(PointFile.ACTION_TIME)) {

            boolean showTime = true;
            subsetSB.append(formEntry(request, msgLabel("Date Range"),
                    getPageHandler().makeDateInput(request, ARG_FROMDATE, "entryform", null, null, showTime)
                            + HtmlUtils.space(1) + HtmlUtils.img(iconUrl(ICON_RANGE)) + HtmlUtils.space(1)
                            + getPageHandler().makeDateInput(request, ARG_TODATE, "entryform", null, null,
                                    showTime)));
        }

        subsetSB.append(HtmlUtils.formEntry(msgLabel("Max"),
                HtmlUtils.input(ARG_MAX, request.getString(ARG_MAX, ""), 4)));

        if (recordEntry.isCapable(PointFile.ACTION_DECIMATE)) {
            subsetSB.append(HtmlUtils.formEntry(msgLabel("Decimate"), msgLabel("Skip every") + " "
                    + HtmlUtils.input(ARG_RECORD_SKIP, request.getString(ARG_RECORD_SKIP, ""), 4) + prob));
        }

        if (recordEntry.isCapable(PointFile.ACTION_TRACKS)) {
            subsetSB.append(HtmlUtils.formEntry(msgLabel("GLAS Tracks"),
                    HtmlUtils.input(ARG_TRACKS, request.getString(ARG_TRACKS, ""), 20) + " "
                            + msg("Comma separated list of track numbers")));
        }
    }

    // Look for searchable fields
    List<RecordField> allFields = null;
    List<RecordField> searchableFields = null;
    if (recordEntry != null) {
        searchableFields = recordEntry.getRecordFile().getSearchableFields();
        allFields = recordEntry.getRecordFile().getFields();
    } else if (forGroup && (entry.getTypeHandler() instanceof RecordCollectionTypeHandler)) {
        //Its a Collection
        RecordEntry childEntry = ((RecordCollectionTypeHandler) entry.getTypeHandler())
                .getChildRecordEntry(entry);
        if (childEntry != null) {
            searchableFields = childEntry.getRecordFile().getSearchableFields();
            allFields = childEntry.getRecordFile().getFields();
        }
    }

    if (allFields != null) {
        StringBuffer paramSB = null;
        for (RecordField attr : allFields) {

            //Skip arrays
            if (attr.getArity() > 1) {
                continue;
            }
            if (paramSB == null) {
                paramSB = new StringBuffer();
                paramSB.append(HtmlUtils.formTable());
            }
            String label = attr.getName();
            if (attr.getDescription().length() > 0) {
                label = label + " - " + attr.getDescription();
            }
            paramSB.append(HtmlUtils.formEntry("",
                    HtmlUtils.checkbox(ARG_FIELD_USE, attr.getName(), false) + " " + label));
        }
        if (paramSB != null) {
            paramSB.append(HtmlUtils.formTableClose());
            subsetSB.append(HtmlUtils.formEntryTop(msgLabel("Select Fields"),
                    HtmlUtils.makeShowHideBlock(msg(""), paramSB.toString(), false)));

        }
    }

    if (searchableFields != null) {
        StringBuffer paramSB = null;
        for (RecordField field : searchableFields) {
            List<String[]> enums = field.getEnumeratedValues();
            String searchSuffix = field.getSearchSuffix();
            if (searchSuffix == null) {
                searchSuffix = "";
            } else {
                searchSuffix = "  " + searchSuffix;
            }
            if (field.isBitField()) {
                if (paramSB == null) {
                    paramSB = new StringBuffer();
                    paramSB.append(HtmlUtils.formTable());
                }
                String[] bitFields = field.getBitFields();
                StringBuffer widgets = new StringBuffer();
                paramSB.append(HtmlUtils.row(HtmlUtils.colspan(formHeader(field.getName()), 2)));
                List values = new ArrayList();
                values.add(new TwoFacedObject("--", ""));
                values.add(new TwoFacedObject("true", "true"));
                values.add(new TwoFacedObject("false", "false"));
                String urlArgPrefix = ARG_SEARCH_PREFIX + field.getName() + "_" + ARG_BITFIELD + "_";
                for (int bitIdx = 0; bitIdx < bitFields.length; bitIdx++) {
                    String bitField = bitFields[bitIdx].trim();
                    if (bitField.length() == 0) {
                        continue;
                    }
                    String value = request.getString(urlArgPrefix + bitIdx, "");
                    paramSB.append(HtmlUtils.formEntry(bitField + ":",
                            HtmlUtils.select(urlArgPrefix + bitIdx, values, value, "")));
                }
            } else if (enums != null) {
                List values = new ArrayList();
                values.add(new TwoFacedObject("--", ""));
                for (String[] tuple : enums) {
                    values.add(new TwoFacedObject(tuple[1], tuple[0]));
                }
                String attrWidget = HtmlUtils.select(ARG_SEARCH_PREFIX + field.getName(), values, "", "");
                if (paramSB == null) {
                    paramSB = new StringBuffer();
                    paramSB.append(HtmlUtils.formTable());
                }
                paramSB.append(HtmlUtils.formEntry(msgLabel(field.getLabel()), attrWidget + searchSuffix));
            } else {
                String attrWidget = HtmlUtils.input(ARG_SEARCH_PREFIX + field.getName() + "_min", "",
                        HtmlUtils.SIZE_8) + " - "
                        + HtmlUtils.input(ARG_SEARCH_PREFIX + field.getName() + "_max", "", HtmlUtils.SIZE_8);
                if (paramSB == null) {
                    paramSB = new StringBuffer();
                    paramSB.append(HtmlUtils.formTable());
                }
                paramSB.append(
                        HtmlUtils.formEntry(msgLabel(field.getLabel() + " range"), attrWidget + searchSuffix));
            }

        }
        if (paramSB != null) {
            paramSB.append(HtmlUtils.formTableClose());
            subsetSB.append(HtmlUtils.formEntryTop(msgLabel("Search Fields"),
                    HtmlUtils.makeShowHideBlock(msg(""), paramSB.toString(), false)));

        }
    }

    subsetSB.append(extraSubset);
    sb.append(HtmlUtils.row(HtmlUtils.colspan(formHeader("Subset Data"), 2)));
    sb.append(subsetSB);
    sb.append(HtmlUtils.row(HtmlUtils.colspan(formHeader("Select Products"), 2)));
    sb.append(productSB);

}

From source file:sadl.models.pdrta.PDRTA.java

public void toDOTLang(Appendable ap, double minP, boolean withInput, StateColoring sc) {

    // Write transitions with high probability
    final StringBuilder sb = new StringBuilder();
    final Queue<PDRTAState> q = new ArrayDeque<>();
    final Set<PDRTAState> found = new HashSet<>();
    q.add(root);//from  w  w  w. j  a  v  a 2  s . com
    found.add(root);
    while (!q.isEmpty()) {
        final PDRTAState s = q.remove();
        for (int i = 0; i < input.getAlphSize(); i++) {
            final Set<Entry<Integer, Interval>> ins = s.getIntervals(i).entrySet();
            for (final Entry<Integer, Interval> eIn : ins) {
                final Interval in = eIn.getValue();
                final double p = s.getStat().getTransProb(i, in);
                final PDRTAState t = in.getTarget();
                if (t != null && p >= minP) {
                    if (!found.contains(t)) {
                        q.add(t);
                        found.add(t);
                    }
                    // Write transition
                    sb.append(s.getIndex());
                    sb.append(" -> ");
                    sb.append(t.getIndex());
                    sb.append(" [ label = \"");
                    sb.append(getSymbol(i));
                    sb.append(" [");
                    sb.append(in.getBegin());
                    sb.append(", ");
                    sb.append(in.getEnd());
                    sb.append("] p=");
                    sb.append(p);
                    if (withInput) {
                        sb.append(" n=");
                        sb.append(in.getTails().size());
                    }
                    sb.append("\" ];\n");
                }
            }
        }
    }

    try {
        writeStatData(ap, found);

        // Write automaton in DOT language
        ap.append("digraph PDRTA {\n");
        ap.append("rankdir=LR;\n");
        ap.append("node[style = filled, fillcolor = white, shape = circle];\n");
        ap.append("\"\"[style = invis, shape = none, margin = 0, width = 0, heigth = 0];\n");
        ap.append("\"\" -> 0;\n");

        // Write states
        for (final PDRTAState s : states.valueCollection()) {
            if (found.contains(s)) {
                ap.append(Integer.toString(s.getIndex()));
                ap.append(" [ xlabel = \"");
                ap.append(Double.toString(s.getStat().getTailEndProb()));
                ap.append("\"");
                if (sc != null) {
                    if (sc.isRed(s)) {
                        ap.append(", fillcolor = \"#FFA9A9\"");
                    } else if (sc.isBlue(s)) {
                        ap.append(", fillcolor = \"#A9D1FF\"");
                    }
                }
                ap.append(" ];\n");
            }
        }

        // Add transitions
        ap.append(sb.toString());

        ap.append("}");
    } catch (final IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.apache.ofbiz.content.data.DataResourceWorker.java

public static void writeDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale,
        Map<String, Object> templateContext, Delegator delegator, Appendable out, boolean cache)
        throws IOException, GeneralException {
    Map<String, Object> context = UtilGenerics.checkMap(templateContext.get("context"));
    if (context == null) {
        context = new HashMap<String, Object>();
    }/*from w  w w. j a v a  2 s.co m*/
    String webSiteId = (String) templateContext.get("webSiteId");
    if (UtilValidate.isEmpty(webSiteId)) {
        if (context != null)
            webSiteId = (String) context.get("webSiteId");
    }

    String https = (String) templateContext.get("https");
    if (UtilValidate.isEmpty(https)) {
        if (context != null)
            https = (String) context.get("https");
    }

    String rootDir = (String) templateContext.get("rootDir");
    if (UtilValidate.isEmpty(rootDir)) {
        if (context != null)
            rootDir = (String) context.get("rootDir");
    }

    String dataResourceId = dataResource.getString("dataResourceId");
    String dataResourceTypeId = dataResource.getString("dataResourceTypeId");

    // default type
    if (UtilValidate.isEmpty(dataResourceTypeId)) {
        dataResourceTypeId = "SHORT_TEXT";
    }

    // text types
    if ("SHORT_TEXT".equals(dataResourceTypeId) || "LINK".equals(dataResourceTypeId)) {
        String text = dataResource.getString("objectInfo");
        writeText(dataResource, text, templateContext, mimeTypeId, locale, out);
    } else if ("ELECTRONIC_TEXT".equals(dataResourceTypeId)) {
        GenericValue electronicText = EntityQuery.use(delegator).from("ElectronicText")
                .where("dataResourceId", dataResourceId).cache(cache).queryOne();
        if (electronicText != null) {
            String text = electronicText.getString("textData");
            writeText(dataResource, text, templateContext, mimeTypeId, locale, out);
        }

        // object types
    } else if (dataResourceTypeId.endsWith("_OBJECT")) {
        String text = (String) dataResource.get("dataResourceId");
        writeText(dataResource, text, templateContext, mimeTypeId, locale, out);

        // resource type
    } else if (dataResourceTypeId.equals("URL_RESOURCE")) {
        String text = null;
        URL url = FlexibleLocation.resolveLocation(dataResource.getString("objectInfo"));

        if (url.getHost() != null) { // is absolute
            InputStream in = url.openStream();
            int c;
            StringWriter sw = new StringWriter();
            while ((c = in.read()) != -1) {
                sw.write(c);
            }
            sw.close();
            text = sw.toString();
        } else {
            String prefix = DataResourceWorker.buildRequestPrefix(delegator, locale, webSiteId, https);
            String sep = "";
            if (url.toString().indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) {
                sep = "/";
            }
            String fixedUrlStr = prefix + sep + url.toString();
            URL fixedUrl = new URL(fixedUrlStr);
            text = (String) fixedUrl.getContent();
        }
        out.append(text);

        // file types
    } else if (dataResourceTypeId.endsWith("_FILE_BIN")) {
        writeText(dataResource, dataResourceId, templateContext, mimeTypeId, locale, out);
    } else if (dataResourceTypeId.endsWith("_FILE")) {
        String dataResourceMimeTypeId = dataResource.getString("mimeTypeId");
        String objectInfo = dataResource.getString("objectInfo");

        if (dataResourceMimeTypeId == null || dataResourceMimeTypeId.startsWith("text")) {
            renderFile(dataResourceTypeId, objectInfo, rootDir, out);
        } else {
            writeText(dataResource, dataResourceId, templateContext, mimeTypeId, locale, out);
        }
    } else {
        throw new GeneralException("The dataResourceTypeId [" + dataResourceTypeId
                + "] is not supported in renderDataResourceAsText");
    }
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

private void appendWhitespace(Appendable writer) throws IOException {
    // appending line ends for now, but this could be replaced with a simple space or something
    writer.append("\r\n");
    //writer.append(' ');
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void appendContentUrl(Appendable writer, String location) throws IOException {
    StringBuilder buffer = new StringBuilder();
    ContentUrlTag.appendContentPrefix(this.request, buffer);
    writer.append(buffer.toString());
    writer.append(location);//ww w .  ja  v  a 2  s . c o m
}

From source file:org.ofbiz.content.data.DataResourceWorker.java

public static void writeDataResourceText(GenericValue dataResource, String mimeTypeId, Locale locale,
        Map<String, Object> templateContext, Delegator delegator, Appendable out, boolean cache)
        throws IOException, GeneralException {
    Map<String, Object> context = UtilGenerics.checkMap(templateContext.get("context"));
    if (context == null) {
        context = FastMap.newInstance();
    }//from  ww  w. j a  v  a 2s. c o  m
    String webSiteId = (String) templateContext.get("webSiteId");
    if (UtilValidate.isEmpty(webSiteId)) {
        if (context != null)
            webSiteId = (String) context.get("webSiteId");
    }

    String https = (String) templateContext.get("https");
    if (UtilValidate.isEmpty(https)) {
        if (context != null)
            https = (String) context.get("https");
    }

    String rootDir = (String) templateContext.get("rootDir");
    if (UtilValidate.isEmpty(rootDir)) {
        if (context != null)
            rootDir = (String) context.get("rootDir");
    }

    String dataResourceId = dataResource.getString("dataResourceId");
    String dataResourceTypeId = dataResource.getString("dataResourceTypeId");

    // default type
    if (UtilValidate.isEmpty(dataResourceTypeId)) {
        dataResourceTypeId = "SHORT_TEXT";
    }

    // text types
    if ("SHORT_TEXT".equals(dataResourceTypeId) || "LINK".equals(dataResourceTypeId)) {
        String text = dataResource.getString("objectInfo");
        writeText(dataResource, text, templateContext, mimeTypeId, locale, out);
    } else if ("ELECTRONIC_TEXT".equals(dataResourceTypeId)) {
        GenericValue electronicText = EntityQuery.use(delegator).from("ElectronicText")
                .where("dataResourceId", dataResourceId).cache(cache).queryOne();
        if (electronicText != null) {
            String text = electronicText.getString("textData");
            writeText(dataResource, text, templateContext, mimeTypeId, locale, out);
        }

        // object types
    } else if (dataResourceTypeId.endsWith("_OBJECT")) {
        String text = (String) dataResource.get("dataResourceId");
        writeText(dataResource, text, templateContext, mimeTypeId, locale, out);

        // resource type
    } else if (dataResourceTypeId.equals("URL_RESOURCE")) {
        String text = null;
        URL url = FlexibleLocation.resolveLocation(dataResource.getString("objectInfo"));

        if (url.getHost() != null) { // is absolute
            InputStream in = url.openStream();
            int c;
            StringWriter sw = new StringWriter();
            while ((c = in.read()) != -1) {
                sw.write(c);
            }
            sw.close();
            text = sw.toString();
        } else {
            String prefix = DataResourceWorker.buildRequestPrefix(delegator, locale, webSiteId, https);
            String sep = "";
            if (url.toString().indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) {
                sep = "/";
            }
            String fixedUrlStr = prefix + sep + url.toString();
            URL fixedUrl = new URL(fixedUrlStr);
            text = (String) fixedUrl.getContent();
        }
        out.append(text);

        // file types
    } else if (dataResourceTypeId.endsWith("_FILE_BIN")) {
        writeText(dataResource, dataResourceId, templateContext, mimeTypeId, locale, out);
    } else if (dataResourceTypeId.endsWith("_FILE")) {
        String dataResourceMimeTypeId = dataResource.getString("mimeTypeId");
        String objectInfo = dataResource.getString("objectInfo");

        if (dataResourceMimeTypeId == null || dataResourceMimeTypeId.startsWith("text")) {
            renderFile(dataResourceTypeId, objectInfo, rootDir, out);
        } else {
            writeText(dataResource, dataResourceId, templateContext, mimeTypeId, locale, out);
        }
    } else {
        throw new GeneralException("The dataResourceTypeId [" + dataResourceTypeId
                + "] is not supported in renderDataResourceAsText");
    }
}

From source file:org.ofbiz.widget.form.MacroFormRenderer.java

public void makeHyperlinkString(Appendable writer, ModelFormField.SubHyperlink subHyperlink,
        Map<String, Object> context) throws IOException {
    if (subHyperlink == null) {
        return;/*from ww w. j a  va 2  s .c om*/
    }
    if (subHyperlink.shouldUse(context)) {
        writer.append(' ');
        makeHyperlinkByType(writer, subHyperlink.getLinkType(), subHyperlink.getLinkStyle(),
                subHyperlink.getTargetType(), subHyperlink.getTarget(context),
                subHyperlink.getParameterMap(context), subHyperlink.getDescription(context),
                subHyperlink.getTargetWindow(context), subHyperlink.getConfirmation(context),
                subHyperlink.getModelFormField(), this.request, this.response, context);
    }
}

From source file:org.ramadda.util.HtmlUtils.java

/**
 * _more_//  w w w.j  av  a  2s  . com
 *
 * @param sb _more_
 */
public static void dangleClose(Appendable sb) {
    try {
        sb.append(">");
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

}

From source file:org.ramadda.util.HtmlUtils.java

/**
 * _more_//from   ww  w .ja  v a  2 s.  c  o  m
 *
 * @param sb _more_
 * @param s _more_
 *
 * @return _more_
 */
public static Appendable padLeft(Appendable sb, String s) {
    try {
        sb.append(space(1));
        sb.append(s);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

    return sb;
}