Example usage for org.apache.commons.lang StringUtils repeat

List of usage examples for org.apache.commons.lang StringUtils repeat

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils repeat.

Prototype

public static String repeat(String str, int repeat) 

Source Link

Document

Repeat a String repeat times to form a new String.

Usage

From source file:au.org.ala.delta.key.Key.java

private void outputBrackedKeyNode(PrintFile printFile, BracketedKeyNode node, boolean displayCharacterNumbers,
        int indexNumberIndent, int indexLineWrapIndent) {
    int outputWidth = _context.getOutputFileManager().getOutputWidth();

    // An index contains an "entry" for each group of attributes
    for (int i = 0; i < node.getNumberOfLines(); i++) {
        StringBuilder entryBuilder = new StringBuilder();

        if (i == 0) {
            entryBuilder.append(node.getNodeNumber());
            entryBuilder.append("(").append(node.getBackReference()).append(")").append(".");
            entryBuilder.append(" ");
        } else {//from  ww  w. j av a 2 s .  c  o m
            entryBuilder.append(StringUtils.repeat(" ", indexNumberIndent));
        }

        List<MultiStateAttribute> attrs = node.getAttributesForLine(i);

        for (int j = 0; j < attrs.size(); j++) {
            MultiStateAttribute attr = attrs.get(j);
            if (displayCharacterNumbers) {
                entryBuilder.append("(");
                entryBuilder.append(attr.getCharacter().getCharacterId());
                entryBuilder.append(") ");
            }

            entryBuilder.append(_charFormatter.formatCharacterDescription(attr.getCharacter()));
            entryBuilder.append(" ");
            entryBuilder.append(
                    _charFormatter.formatState(attr.getCharacter(), attr.getPresentStates().iterator().next()));

            // Don't put a space after the last attribute description
            if (j < attrs.size() - 1) {
                entryBuilder.append(" ");
            }
        }

        Object itemListOrIndexNumber = node.getDestinationForLine(i);

        if (itemListOrIndexNumber instanceof List<?>) {
            // Index references one or more taxa
            StringBuilder taxonListBuilder = new StringBuilder();
            List<Item> taxa = (List<Item>) itemListOrIndexNumber;

            for (int k = 0; k < taxa.size(); k++) {
                Item taxon = taxa.get(k);
                String taxonDescription = _itemFormatter.formatItemDescription(taxon);

                if (k == 0) {
                    printFile.outputStringPairWithPaddingCharacter(entryBuilder.toString(),
                            " " + taxonDescription, '.');
                } else {
                    printFile.outputLine(StringUtils.repeat(" ", outputWidth - taxonDescription.length())
                            + taxonDescription);

                }

            }

        } else {
            // Index references another index
            int forwardReference = (Integer) itemListOrIndexNumber;
            String forwardReferenceAsString = Integer.toString(forwardReference);
            printFile.outputStringPairWithPaddingCharacter(entryBuilder.toString(),
                    " " + forwardReferenceAsString, '.');
        }
    }
}

From source file:de.tudarmstadt.ukp.dkpro.core.treetagger.TreeTaggerPosTaggerTest.java

/**
 * Test using the same AnalysisEngine multiple times.
 *///from   ww  w  .  j a v  a  2  s .  c om
@Test
public void longTokenTest() throws Exception {
    checkModelsAndBinary("en");

    AnalysisEngine engine = createEngine(TreeTaggerPosTagger.class);
    JCas jcas = engine.newJCas();

    try {
        for (int n = 99990; n < 100000; n++) {
            System.out.println(n);
            jcas.setDocumentLanguage("en");
            JCasBuilder builder = new JCasBuilder(jcas);
            builder.add("Start", Token.class);
            builder.add("with", Token.class);
            builder.add("good", Token.class);
            builder.add("tokens", Token.class);
            builder.add(".", Token.class);
            builder.add(StringUtils.repeat("b", n), Token.class);
            builder.add("End", Token.class);
            builder.add("with", Token.class);
            builder.add("some", Token.class);
            builder.add("good", Token.class);
            builder.add("tokens", Token.class);
            builder.add(".", Token.class);
            builder.close();
            engine.process(jcas);
            jcas.reset();
        }
    } finally {
        engine.destroy();
    }
}

From source file:com.marand.thinkmed.medications.business.impl.TherapyDisplayProvider.java

public String getDecimalStringValue(final Double value, final Locale locale) throws ParseException {
    final boolean isDecimalNumber = value != null && value < 1 && value != 0;
    if (isDecimalNumber) {
        //if decimal, print until three nonzero numbers are visible
        final String[] numberSplittedByDecimalPoint = BigDecimal.valueOf(value).toPlainString().split("\\.");
        final Pattern pattern = Pattern.compile("[1-9]");
        final Matcher matcher = pattern.matcher(numberSplittedByDecimalPoint[1]);
        if (matcher.find()) {
            final int firstNonZeroNumberPosition = matcher.start();
            final String hashes = StringUtils.repeat("#", firstNonZeroNumberPosition + 3);
            return NumberFormatters.adjustableDoubleFormatter("0." + hashes, locale).valueToString(value);
        }//  ww w  .j ava  2  s.c om
    }
    return NumberFormatters.doubleFormatter3(locale).valueToString(value);
}

From source file:com.tesora.dve.tools.aitemplatebuilder.AiTemplateBuilder.java

private void log(final String message, final MessageSeverity severity, final int numIndents) {
    logger.log(severity.getLogLevel(), message);
    if (this.isVerbose && (this.outputStream != null)) {
        CLIBuilder.printInColor(StringUtils.repeat(LINE_INDENT, numIndents).concat(severity.toString())
                .concat(": ").concat(message), severity.getColor(), this.outputStream);
    }//w ww.j  a  v a2  s .c om
}

From source file:adalid.core.programmers.AbstractSqlProgrammer.java

private String getSelectColumns(QueryTable queryTable, List<Property> referencedColumns, boolean indent) {
    String string = EMPTY;/*w  w  w .  java2  s  .  c om*/
    String tab = indent ? StringUtils.repeat(TAB$, queryTable.getDepth()) : EMPTY;
    String name, alias;
    for (Property p : queryTable.getColumns()) {
        if (referencedColumns == null || referencedColumns.isEmpty() || referencedColumns.contains(p)) {
            name = getPropertySqlName(p);
            alias = getPropertySqlAlias(p, queryTable);
            string += EOL$ + tab + queryTable.getAlias() + DOT$ + name;
            if (name.equals(alias)) {
            } else {
                string += SPC$ + getAs() + SPC$ + alias;
            }
            string += SEP$;
        }
    }
    String s;
    for (QueryJoin j : queryTable.getJoins()) {
        s = getSelectColumns(j.getRightTable(), referencedColumns, indent);
        if (StringUtils.isNotBlank(s)) {
            string += s + SEP$;
        }
    }
    return StringUtils.removeEnd(string, SEP$);
}

From source file:cfa.vo.sed.science.stacker.SedStackerFrame.java

public void rename(SedStack stack, String newName) {
    List<String> names = new ArrayList();
    for (int i = 0; i < this.getStacks().size(); i++) {
        names.add(this.getStacks().get(i).getName());
    }//from  www  .  j a v  a2s  .com

    char c = '@';
    int i = 1;
    int j = 1;
    while (names.contains(newName + (c == '@' ? "" : "." + StringUtils.repeat(String.valueOf(c), j)))) {
        int val = j * 26;
        if (i % val == 0) {
            c = '@';
            j++;
        }
        c++;
        i++;
    }
    stack.setName(newName + (c == '@' ? "" : "." + StringUtils.repeat(String.valueOf(c), j)));
}

From source file:adalid.core.programmers.AbstractSqlProgrammer.java

private String getSelectJoin(QueryJoin queryJoin, List<Property> referencedColumns, boolean indent) {
    String string = EMPTY;//from w  ww  .  ja  v  a2  s  .  c om
    QueryTable lt = queryJoin.getLeftTable();
    QueryTable rt = queryJoin.getRightTable();
    String nested = getSelectJoins(rt, referencedColumns, indent);
    String joinop = getSqlJoinOperator(queryJoin.getOperator());
    boolean b = StringUtils.isNotBlank(nested);
    String tab = indent ? StringUtils.repeat(TAB$, lt.getDepth()) : EMPTY;
    string += EOL$ + tab + joinop + (b ? LRB$ : SPC$) + rt.getName();
    if (!rt.getName().equals(rt.getAlias())) {
        //          string += SPC$ + getAs() + SPC$ + rt.getAlias();
        string += SPC$ + rt.getAlias();
    }
    string += b ? nested + RRB$ + EOL$ + tab : SPC$;
    string += getOn() + SPC$ + rt.getAlias() + DOT$ + getPropertySqlName(queryJoin.getRightColumn());
    string += SPC$ + getEQ() + SPC$ + lt.getAlias() + DOT$ + getPropertySqlName(queryJoin.getLeftColumn());
    return string;
}

From source file:adalid.core.AbstractDataArtifact.java

@Override
protected String fieldsToString(int n, String key, boolean verbose, boolean fields, boolean maps) {
    String tab = verbose ? StringUtils.repeat(" ", 4) : "";
    String fee = verbose ? StringUtils.repeat(tab, n) : "";
    String faa = " = ";
    String foo = verbose ? EOL : ", ";
    String string = super.fieldsToString(n, key, verbose, fields, maps);
    if (fields || verbose) {
        if (verbose) {
            string += fee + tab + "dataType" + faa + _dataType + foo;
            if (getDeclaringField() != null && getDeclaringArtifact() != null) {
                //                  string += fee + tab + "baseField" + faa + _annotatedWithBaseField + foo;
                //                  string += fee + tab + "argumentField" + faa + _annotatedWithArgumentField + foo;
                //                  string += fee + tab + "columnField" + faa + _annotatedWithColumnField + foo;
                //                  string += fee + tab + "PropertyField" + faa + _annotatedWithPropertyField + foo;
                //                  string += fee + tab + "PrimaryKey" + faa + _annotatedWithPrimaryKey + foo;
                //                  string += fee + tab + "VersionProperty" + faa + _annotatedWithVersionProperty + foo;
                //                  string += fee + tab + "NumericKey" + faa + _annotatedWithNumericKey + foo;
                //                  string += fee + tab + "CharacterKey" + faa + _annotatedWithCharacterKey + foo;
                //                  string += fee + tab + "NameProperty" + faa + _annotatedWithNameProperty + foo;
                //                  string += fee + tab + "DescriptionProperty" + faa + _annotatedWithDescriptionProperty + foo;
                //                  string += fee + tab + "InactiveIndicator" + faa + _annotatedWithInactiveIndicator + foo;
                //                  string += fee + tab + "UrlProperty" + faa + _annotatedWithUrlProperty + foo;
                //                  string += fee + tab + "ParentProperty" + faa + _annotatedWithParentProperty + foo;
                //                  string += fee + tab + "OwnerProperty" + faa + _annotatedWithOwnerProperty + foo;
                //                  string += fee + tab + "SegmentProperty" + faa + _annotatedWithSegmentProperty + foo;
                //                  string += fee + tab + "UniqueKey" + faa + _annotatedWithUniqueKey + foo;
                //                  string += fee + tab + "BusinessKey" + faa + _annotatedWithBusinessKey + foo;
                //                  string += fee + tab + "DiscriminatorColumn" + faa + _annotatedWithDiscriminatorColumn + foo;
                if (isParameter()) {
                    string += fee + tab + "auditable" + faa + _auditable + foo;
                    string += fee + tab + "password" + faa + _password + foo;
                    string += fee + tab + "required" + faa + _required + foo;
                    string += fee + tab + "linkedFieldName" + faa + _linkedFieldName + foo;
                    string += fee + tab + "linkedField" + faa + _linkedField + foo;
                    string += fee + tab + "linkedProperty" + faa + _linkedProperty + foo;
                    string += fee + tab + "linkedColumnName" + faa + _linkedColumnName + foo;
                    string += fee + tab + "linkedColumnOperator" + faa + _linkedColumnOperator + foo;
                }//from  ww  w. ja v  a2s. c o  m
                if (isProperty()) {
                    string += fee + tab + "baseField" + faa + isBaseField() + foo;
                    string += fee + tab + "keyField" + faa + isKeyField() + foo;
                    string += fee + tab + "auditable" + faa + _auditable + foo;
                    string += fee + tab + "password" + faa + _password + foo;
                    string += fee + tab + "required" + faa + _required + foo;
                    string += fee + tab + "hiddenField" + faa + _hiddenField + foo;
                    string += fee + tab + "createField" + faa + _createField + foo;
                    string += fee + tab + "updateField" + faa + _updateField + foo;
                    string += fee + tab + "searchField" + faa + _searchField + foo;
                    string += fee + tab + "filterField" + faa + _filterField + foo;
                    string += fee + tab + "tableField" + faa + _tableField + foo;
                    string += fee + tab + "detailField" + faa + _detailField + foo;
                    string += fee + tab + "reportField" + faa + _reportField + foo;
                    string += fee + tab + "exportField" + faa + _exportField + foo;
                    string += fee + tab + "submitField" + faa + _submitField + foo;
                    string += fee + tab + "calculable" + faa + _calculable + foo;
                    string += fee + tab + "nullable" + faa + _nullable + foo;
                    string += fee + tab + "insertable" + faa + _insertable + foo;
                    string += fee + tab + "updateable" + faa + _updateable + foo;
                    string += fee + tab + "unique" + faa + _unique + foo;
                }
            }
        }
    }
    return string;
}

From source file:de.innovationgate.utils.WGUtils.java

/**
 * Tool function to log category headers to a logger
 * @param log The logger/*from ww w. j a  va2  s  .c  o  m*/
 * @param msg The title of the category header
 * @param level The level of category info, resulting in different category characters. Use 1 or 2.
 */
public static void logCategoryInfo(Logger log, String msg, int level) {

    String categoryMarker = (level == 1 ? "#" : "=");
    StringBuffer line = new StringBuffer();
    line.append(StringUtils.repeat(categoryMarker, 3));
    line.append(" ");
    line.append(msg);
    line.append(" ");

    int remainingChars = 80 - msg.length();
    if (remainingChars > 0) {
        line.append(StringUtils.repeat(categoryMarker, remainingChars));
    }
    log.info(line.toString());
}

From source file:adalid.core.AbstractEntity.java

@Override
protected String fieldsToString(int n, String key, boolean verbose, boolean fields, boolean maps) {
    String tab = verbose ? StringUtils.repeat(" ", 4) : "";
    String fee = verbose ? StringUtils.repeat(tab, n) : "";
    String faa = " = ";
    String foo = verbose ? EOL : ", ";
    String string = super.fieldsToString(n, key, verbose, fields, maps);
    if (fields || verbose) {
        string += _atlas.fieldsToString(n, key, verbose, fields, maps);
        if (verbose) {
            //              string += fee + tab + "rootInstance" + faa + _rootInstance + foo;
            string += fee + tab + "explicitlyDeclared" + faa + _explicitlyDeclared + foo;
            string += fee + tab + "implicitlyDeclared" + faa + _implicitlyDeclared + foo;
            if (isEntityReference()) {
                string += fee + tab + "extension" + faa + isExtension() + foo;
                string += fee + tab + "oneToOne" + faa + isOneToOne() + foo;
                string += fee + tab + "manyToOne" + faa + isManyToOne() + foo;
                string += fee + tab + "navigability" + faa + _navigability + foo;
                string += fee + tab + "masterDetailView" + faa + _masterDetailView + foo;
            } else {
                string += fee + tab + "abstract" + faa + _annotatedWithAbstractClass + foo;
                string += fee + tab + "baseClass" + faa + _baseClass + foo;
                string += fee + tab + "subclassesList" + faa + getMainInstanceSubclassesList() + foo;
                string += fee + tab + "primaryKeyProperty" + faa + _primaryKeyProperty + foo;
                string += fee + tab + "versionProperty" + faa + _versionProperty + foo;
                string += fee + tab + "numericKeyProperty" + faa + _numericKeyProperty + foo;
                string += fee + tab + "characterKeyProperty" + faa + _characterKeyProperty + foo;
                string += fee + tab + "nameProperty" + faa + _nameProperty + foo;
                string += fee + tab + "descriptionProperty" + faa + _descriptionProperty + foo;
                string += fee + tab + "inactiveIndicatorProperty" + faa + _inactiveIndicatorProperty + foo;
                string += fee + tab + "urlProperty" + faa + _urlProperty + foo;
                string += fee + tab + "parentProperty" + faa + _parentProperty + foo;
                string += fee + tab + "ownerProperty" + faa + _ownerProperty + foo;
                string += fee + tab + "segmentProperty" + faa + _segmentProperty + foo;
                string += fee + tab + "businessKeyProperty" + faa + _businessKeyProperty + foo;
                string += fee + tab + "businessKeyType" + faa + _businessKeyType + foo;
                string += fee + tab + "existentiallyIndependent" + faa + _existentiallyIndependent + foo;
                string += fee + tab + "resourceType" + faa + _resourceType + foo;
                string += fee + tab + "resourceGender" + faa + _resourceGender + foo;
                //                  string += fee + tab + "propertiesPrefix" + faa + _propertiesPrefix + foo;
                //                  string += fee + tab + "propertiesSuffix" + faa + _propertiesSuffix + foo;
                string += fee + tab + "selectEnabled" + faa + _selectEnabled + foo;
                //                  string += fee + tab + "selectRestricted" + faa + _selectRestricted + foo;
                string += fee + tab + "selectRowsLimit" + faa + _selectRowsLimit + foo;
                string += fee + tab + "selectSortOption" + faa + _selectSortOption + foo;
                string += fee + tab + "insertEnabled" + faa + _insertEnabled + foo;
                //                  string += fee + tab + "insertRestricted" + faa + _insertRestricted + foo;
                string += fee + tab + "updateEnabled" + faa + _updateEnabled + foo;
                //                  string += fee + tab + "updateRestricted" + faa + _updateRestricted + foo;
                string += fee + tab + "deleteEnabled" + faa + _deleteEnabled + foo;
                //                  string += fee + tab + "deleteRestricted" + faa + _deleteRestricted + foo;
                string += fee + tab + "reportEnabled" + faa + _reportEnabled + foo;
                string += fee + tab + "reportRowsLimit" + faa + _reportRowsLimit + foo;
                string += fee + tab + "reportSortOption" + faa + _reportSortOption + foo;
                string += fee + tab + "exportEnabled" + faa + _exportEnabled + foo;
                string += fee + tab + "exportRowsLimit" + faa + _exportRowsLimit + foo;
                string += fee + tab + "exportSortOption" + faa + _exportSortOption + foo;
                string += fee + tab + "tableViewEnabled" + faa + _tableViewEnabled + foo;
                string += fee + tab + "detailViewEnabled" + faa + _detailViewEnabled + foo;
                string += fee + tab + "treeViewEnabled" + faa + _treeViewEnabled + foo;
                string += fee + tab + "consoleViewEnabled" + faa + _consoleViewEnabled + foo;
                string += fee + tab + "warningsEnabled" + faa + _warningsEnabled + foo;
            }/*from   ww  w .  j  a  va  2  s.  c  o m*/
            string += fee + tab + "searchType" + faa + _searchType + foo;
            string += fee + tab + "listStyle" + faa + _listStyle + foo;
            string += fee + tab + "searchDisplayMode" + faa + _searchDisplayMode + foo;
        }
    }
    return string;
}