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:net.sourceforge.seqware.pipeline.plugins.batchmetadatainjection.SampleInfo.java

public void print(Appendable writer, Metadata metadata) throws IOException {
    String organism = "<null>";
    if (organismId != null && !organismId.trim().isEmpty() && StringUtils.isNumeric(organismId)) {
        for (Organism st : metadata.getOrganisms()) {
            if (st.getOrganismId().equals(Integer.parseInt(organismId))) {
                organism = st.getName();
            }/* ww w . ja v  a2 s.  c om*/
        }
    }

    writer.append("\n\t\tSampleInfo {");
    writer.append("\n\t\t\t projectCode=" + projectCode);
    writer.append("\n\t\t\t individualNumber=" + individualNumber);
    writer.append("\n\t\t\t sampleName=" + name);
    writer.append("\n\t\t\t sampleDescription=" + sampleDescription);
    writer.append("\n\t\t\t barcode=" + barcode);
    writer.append("\n\t\t\t barcodeName=" + iusName);
    writer.append("\n\t\t\t barcodeDescription=" + iusDescription);
    writer.append("\n\t\t\t tissueType=" + tissueType);
    writer.append("\n\t\t\t tissueOrigin=" + tissueOrigin);
    writer.append("\n\t\t\t tissuePreparation=" + tissuePreparation);
    writer.append("\n\t\t\t librarySizeCode=" + librarySizeCode);
    writer.append("\n\t\t\t organism=" + organism);
    writer.append("\n\t\t\t librarySourceTemplateType=" + librarySourceTemplateType);
    writer.append("\n\t\t\t libraryType=" + libraryType);
    writer.append("\n\t\t\t pairedEnd=" + pairedEnd);
    writer.append("\n\t\t\t targetedResequencing=" + targetedResequencing);
    writer.append("\n\t\t\t skipBarcode=" + iusSkip);

    writer.append("\n\t\t}");
}

From source file:org.apache.cayenne.access.translator.select.QualifierTranslator.java

@Override
public void finishedChild(Expression node, int childIndex, boolean hasMoreChildren) {

    if (waitingForEndNode != null) {
        return;/*from  w  ww .  j  a  v  a2s .c  o  m*/
    }

    if (!hasMoreChildren) {
        return;
    }

    Appendable out = (matchingObject) ? new StringBuilder() : this.out;

    try {
        switch (node.getType()) {
        case Expression.AND:
            out.append(" AND ");
            break;
        case Expression.OR:
            out.append(" OR ");
            break;
        case Expression.EQUAL_TO:
            // translate NULL as IS NULL
            if (childIndex == 0 && node.getOperandCount() == 2 && node.getOperand(1) == null) {
                out.append(" IS ");
            } else {
                out.append(" = ");
            }
            break;
        case Expression.NOT_EQUAL_TO:
            // translate NULL as IS NOT NULL
            if (childIndex == 0 && node.getOperandCount() == 2 && node.getOperand(1) == null) {
                out.append(" IS NOT ");
            } else {
                out.append(" <> ");
            }
            break;
        case Expression.LESS_THAN:
            out.append(" < ");
            break;
        case Expression.GREATER_THAN:
            out.append(" > ");
            break;
        case Expression.LESS_THAN_EQUAL_TO:
            out.append(" <= ");
            break;
        case Expression.GREATER_THAN_EQUAL_TO:
            out.append(" >= ");
            break;
        case Expression.IN:
            out.append(" IN ");
            break;
        case Expression.NOT_IN:
            out.append(" NOT IN ");
            break;
        case Expression.LIKE:
            out.append(" LIKE ");
            break;
        case Expression.NOT_LIKE:
            out.append(" NOT LIKE ");
            break;
        case Expression.LIKE_IGNORE_CASE:
            if (caseInsensitive) {
                out.append(" LIKE ");
            } else {
                out.append(") LIKE UPPER(");
            }
            break;
        case Expression.NOT_LIKE_IGNORE_CASE:
            if (caseInsensitive) {
                out.append(" NOT LIKE ");
            } else {
                out.append(") NOT LIKE UPPER(");
            }
            break;
        case Expression.ADD:
            out.append(" + ");
            break;
        case Expression.SUBTRACT:
            out.append(" - ");
            break;
        case Expression.MULTIPLY:
            out.append(" * ");
            break;
        case Expression.DIVIDE:
            out.append(" / ");
            break;
        case Expression.BETWEEN:
            if (childIndex == 0)
                out.append(" BETWEEN ");
            else if (childIndex == 1)
                out.append(" AND ");
            break;
        case Expression.NOT_BETWEEN:
            if (childIndex == 0)
                out.append(" NOT BETWEEN ");
            else if (childIndex == 1)
                out.append(" AND ");
            break;
        case Expression.BITWISE_OR:
            out.append(" ").append(operandForBitwiseOr()).append(" ");
            break;
        case Expression.BITWISE_AND:
            out.append(" ").append(operandForBitwiseAnd()).append(" ");
            break;
        case Expression.BITWISE_XOR:
            out.append(" ").append(operandForBitwiseXor()).append(" ");
            break;
        case Expression.BITWISE_LEFT_SHIFT:
            out.append(" ").append(operandForBitwiseLeftShift()).append(" ");
            break;
        case Expression.BITWISE_RIGHT_SHIFT:
            out.append(" ").append(operandForBitwiseRightShift()).append("");
            break;
        }
    } catch (IOException ioex) {
        throw new CayenneRuntimeException("Error appending content", ioex);
    }

    if (matchingObject) {
        objectMatchTranslator.setOperation(out.toString());
        objectMatchTranslator.setExpression(node);
    }
}

From source file:org.omnaest.utils.table.impl.serializer.CsvMarshallerImpl.java

@Override
public Table<E> to(Appendable appendable) {
    ///*from  w ww  .j  a  v  a  2  s. c  o  m*/
    try {
        //
        if (appendable != null) {
            //
            boolean hasColumnTitles = this.table.hasColumnTitles();
            boolean hasRowTitles = this.table.hasRowTitles();
            boolean hasTableName = this.table.hasTableName();

            //
            boolean processColumnTitles = this.configuration.hasEnabledColumnTitles() && hasColumnTitles;
            boolean processRowTitles = this.configuration.hasEnabledRowTitles() && hasRowTitles;
            boolean processTableName = this.configuration.hasEnabledTableName() && hasTableName;

            //
            if (processTableName) {
                //
                appendable.append(String.valueOf(this.table.getTableName()) + "\n");
            }

            //
            if (processColumnTitles) {
                //
                if (processRowTitles) {
                    //
                    appendable.append(this.configuration.getDelimiter());
                }

                //
                boolean first = true;
                for (Object columnTitleValue : this.table.getColumnTitleList()) {
                    //
                    appendable.append(!first ? this.configuration.getDelimiter() : "");
                    appendable.append(String.valueOf(columnTitleValue));
                    first = false;
                }

                //
                appendable.append("\n");
            }

            //
            for (Row<E> row : this.table.rows()) {
                //
                if (processRowTitles) {
                    //
                    appendable.append(row.getTitle());
                    appendable.append(this.configuration.getDelimiter());
                }

                //
                boolean first = true;
                for (Cell<E> cell : row.cells()) {
                    //
                    appendable.append(!first ? this.configuration.getDelimiter() : "");

                    //
                    final E element = cell.getElement();
                    appendable.append(this.encodeIntoCellString(element));
                    first = false;
                }

                //
                appendable.append("\n");
            }
        }
    } catch (Exception e) {
        this.exceptionHandler.handleException(e);
    }

    // 
    return this.table;
}

From source file:org.opensingular.form.SType.java

private void debugTypeHeaderNormalType(Appendable appendable) throws IOException {
    appendable.append("def ").append(getNameSimple()).append('@').append(Integer.toString(getTypeId()));
    if (superType == null || superType.getClass() != getClass()) {
        appendable.append(" (").append(getClass().getSimpleName());
        if (instanceClass != null && (superType == null || !instanceClass.equals(superType.instanceClass))) {
            appendable.append(":").append(instanceClass.getSimpleName());
        }/*w  w  w  .j a  v  a2s .c o  m*/
        appendable.append(")");
    }
}

From source file:org.opensingular.form.SType.java

private void debugTypeHeaderAttribute(Appendable appendable) throws IOException {
    appendable.append("defAtt ").append(getNameSimple()).append('@').append(Integer.toString(getTypeId()));
    SType<?> owner = getAttrInternalRef().getOwner();
    if (owner != null && owner != getParentScope()) {
        appendable.append(" for ");
        appendNameAndId(appendable, owner);
    }/*  w w w  . jav  a2s .c o  m*/
    if (isSelfReference()) {
        appendable.append(" (SELF)");
    }
}

From source file:org.opensingular.form.SType.java

private void appendNameAndId(Appendable appendable, SType<?> type) throws IOException {
    appendable.append(suppressPackage(type.getName())).append('@').append(Integer.toString(type.getTypeId()));
}

From source file:org.opensingular.form.SType.java

private void debugAttribute(Appendable appendable, SInstance attr) {
    try {//from  ww w.  j  a va 2  s .  co  m
        if (!attr.getAttributeInstanceInfo().getRef().isResolved()) {
            appendable.append('?');
        }
        appendable.append(suppressPackage(attr.getAttributeInstanceInfo().getName(), true)).append("=")
                .append(attr.toStringDisplay()).append("; ");
    } catch (IOException ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
    }
}

From source file:org.opensingular.form.SType.java

private void debugAttributes(Appendable appendable) {
    try {//from ww w  . ja  v  a 2 s. c om
        Collection<SInstance> attrs = getAttributes();
        if (!attrs.isEmpty()) {
            appendable.append(" {");
            attrs.forEach(attr -> debugAttribute(appendable, attr));
            appendable.append("}");
        }
    } catch (IOException ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
    }
}

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

/**
 * Wrtie header/footer comments, field name (key) and value to slected writer ({@link Appendable}) using this template.
 *
 * @param writer             {@link Appendable} to use, all data will be added here.
 * @param field              config field with basic field data and options.
 * @param object             object contains this field.
 * @param invoker            getter for field value.
 * @param level              current indent level.
 * @param addComments        if comments should be added to node.
 * @param elementPlace       element place, used in many templates to check current style and choose valid format.
 * @param forceDefaultValues if true, all values will be set to default ones.
 *
 * @throws IOException from {@link Appendable}
 *//*from   ww w . j  a  v  a  2  s.  co m*/
public void write(final Appendable writer, final ConfigField field, final Object object,
        final ReflectGetter<?> invoker, final int level, final boolean addComments,
        final ElementPlace elementPlace, final boolean forceDefaultValues) throws IOException {
    Object element = invoker.get(object);
    if ((forceDefaultValues || (element == null)) && field.hasDefaultValue()) {
        final Object def = field.getDefaultValue();
        if (def != null) {
            element = def;
        }
    }
    if (element != null) {
        //            writer.append('\n');
        if (addComments && (field.getHeader() != null)) {
            Template.appendComment(writer, field.getHeader(), level, false);
            writer.append('\n');
        }

        appendElement(writer, level, field.getName());
        writer.append(": ");
        this.appendValue(writer, field, object, this.validateType(element), level, elementPlace);

        if (addComments && (field.getFooter() != null)) {
            if (field.getOption(FieldOptions.OTHERS_FOOTER_NO_NEW_LINE, false)) {
                Template.appendComment(writer, field.getFooter(), level, true);
            } else {
                //                    writer.append('\n');
                Template.appendComment(writer, field.getFooter(), level, false);
            }
        }
        writer.append('\n');
    }
}

From source file:org.opensingular.form.SType.java

@Override
void debug(Appendable appendable, int level) {
    try {/*from   w  w w .j  ava  2 s  .c  o  m*/
        pad(appendable, level);
        debugTypeHeader(appendable);
        debugAttributes(appendable);
        appendable.append('\n');

        if (this instanceof STypeSimple && asAtrProvider().getProvider() != null) {
            pad(appendable, level + 2).append("selection of ").append(asAtrProvider().getProvider().toString())
                    .append('\n');
        }

        debugAttributesDefined(appendable, level);

        super.debug(appendable, level + 1);
    } catch (IOException ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
    }
}