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:fitnesse.slim.test.TestSlim.java

public String returnHugeString() {
    return StringUtils.repeat("x", 999999 + 10);
}

From source file:com.kelveden.rastajax.representation.flat.FlatRepresentationBuilder.java

@Override
public Set<FlatResource> buildRepresentationFor(final ResourceClass resourceClass) {

    final TreeSet<FlatResource> result = new TreeSet<FlatResource>(RESOURCE_COMPARATOR);

    LOGGER.debug(StringUtils.repeat("-", UNDERLINE_LENGTH));
    LOGGER.debug("Building representation for resource with URI template {}...",
            resourceClass.getUriTemplate());
    LOGGER.debug(StringUtils.repeat("-", UNDERLINE_LENGTH));

    if (resourceClass.isRootResource()) {

        LOGGER.debug("This resource is a root resource.");
        LOGGER.debug("Analyzing methods...");

        final MultiValuedMap<String, ResourceClassMethod> resourceClassMethodsByPath = groupResourceClassMethodsByUriTemplate(
                resourceClass, " |-");

        final List<FlatResource> methodsAsResources = representResourceClassMethods(resourceClass,
                resourceClassMethodsByPath);
        result.addAll(methodsAsResources);

        LOGGER.debug(/*from  w w  w  .ja v a 2 s .  c om*/
                "Finished analyzing methods: flattened methods to {} distinct resource(s) in representation.",
                methodsAsResources.size());

    } else {
        LOGGER.debug("This resource is NOT a root resource - skipping.");
    }

    return result;
}

From source file:ddf.catalog.validation.impl.SizeValidatorTest.java

@Test
public void testInvalidStringValue() {
    validateWithErrors(new AttributeImpl("test", StringUtils.repeat("a", 33)), 40, 50, 1);
}

From source file:mitm.common.dlp.impl.matchfilter.MaskingFilter.java

@Override
public String filter(String input) {
    if (input != null) {
        input = StringUtils.repeat("*", input.length());
    }/*from  w ww  . j  a  va 2  s .c o  m*/

    return input;
}

From source file:com.github.capone.protocol.crypto.VerifyKeyTest.java

@Test(expected = VerifyKey.InvalidKeyException.class)
public void keyFromInvalidStringCharsFails() throws VerifyKey.InvalidKeyException {
    VerifyKey.fromString(StringUtils.repeat("x", SigningKey.BYTES * 2));
}

From source file:com.agapsys.utils.console.printer.tables.Cell.java

public String getDisplayString() {
    String displayString = getValue();
    StringBuilder sb = new StringBuilder();

    int delta = cellProperties.getWrapLength() - displayString.length();

    String padding;//from   w  w  w  . ja va 2  s.c  o  m
    if (delta > 0) {
        padding = StringUtils.repeat(" ", delta);
    } else {
        padding = "";
    }

    if (cellProperties.getCellAlignment() == CellAlignment.LEFT) {
        displayString = displayString + padding;
    } else {
        displayString = padding + displayString;
    }

    displayString = ConsolePrinter.toString(cellProperties.getFgColor(), cellProperties.getBgColor(),
            displayString);
    sb.append(displayString);

    return sb.toString();
}

From source file:com.kelveden.rastajax.core.ResourceClassLoader.java

public ResourceClass loadResourceClassFrom(final Class<?> candidateResourceClass) {

    LOGGER.debug(StringUtils.repeat("-", UNDERLINE_LENGTH));
    LOGGER.debug("Attempting to load class {} as a JAX-RS resource class...", candidateResourceClass.getName());
    LOGGER.debug(StringUtils.repeat("-", UNDERLINE_LENGTH));

    final Set<Annotation> resourceAnnotations = JaxRsAnnotationScraper
            .scrapeJaxRsAnnotationsFrom(candidateResourceClass);
    LOGGER.debug("Found class annotations {}.", resourceAnnotations.toString());

    String uriTemplate = null;/*w w w.  j a va2  s.  c  o  m*/
    String[] produces = null;
    String[] consumes = null;

    for (Annotation annotation : resourceAnnotations) {
        if (annotation.annotationType() == Path.class) {
            uriTemplate = ((Path) annotation).value();

            LOGGER.debug("Class URI template is '{}'.", uriTemplate);

        } else if (annotation.annotationType() == Produces.class) {
            produces = ((Produces) annotation).value();

            LOGGER.debug("Class produces: {}.", StringUtils.join(produces, ","));

        } else if (annotation.annotationType() == Consumes.class) {
            consumes = ((Consumes) annotation).value();

            LOGGER.debug("Class consumes: {}.", StringUtils.join(consumes, ","));
        }
    }

    LOGGER.debug("Finding resource methods...");

    final List<ResourceClassMethod> methodsOnResource = loadMethods(candidateResourceClass);
    LOGGER.debug("Found {} resource methods.", methodsOnResource.size());

    if (methodsOnResource.size() == 0) {
        LOGGER.debug("Class is NOT a resource class.");

        return null;
    }

    LOGGER.debug("Class is a resource class.");

    LOGGER.debug("Finding fields...");
    final List<Parameter> fields = loadClassFields(candidateResourceClass);
    LOGGER.debug("Found {} fields.", fields.size());

    LOGGER.debug("Finding properties...");
    final List<Parameter> properties = loadClassProperties(candidateResourceClass);
    LOGGER.debug("Found {} properties.", properties.size());

    fields.addAll(properties);

    return new ResourceClass(candidateResourceClass, uriTemplate, methodsOnResource, arrayAsList(consumes),
            arrayAsList(produces), fields);
}

From source file:de.innovationgate.webgate.api.jdbc.PortletRegistryImplV4.java

public static String buildNamespacePrefix(String dbkey) {

    dbkey = dbkey.toLowerCase();/*from w  w  w . j  a v a2 s.  c  om*/
    String prefix = StringUtils.left(dbkey, 1) + StringUtils.right(dbkey, 2);
    if (prefix.length() < 3) {
        prefix += StringUtils.repeat("x", 3 - prefix.length());
    }

    // Escape non alphanumeric characters as x
    char[] chars = prefix.toCharArray();
    for (int i = 0; i < chars.length; i++) {
        if (!Character.isLetterOrDigit(chars[i])) {
            chars[i] = 'x';
        }
    }

    return new String(chars);

}

From source file:musite.prediction.feature.InstanceUtil.java

/**
 *
 * @param instance/*from  w w  w.ja  va  2s .co  m*/
 * @param windowOffset
 * @param appendTerminals
 * @param markSites mart all sites as X#
 * @return
 */
public static String extractSurroundingSequence(Instance instance, int leftOffset, int rightOffset,
        boolean appendTerminals, boolean markSites, PTM ptm) {
    if (instance == null)
        throw new IllegalArgumentException();

    if (leftOffset < 0 || rightOffset < 0)
        throw new IllegalArgumentException();

    InstanceTag tag = instance.getInstanceTag();
    if (!(tag instanceof ProteinResidueInstannceTag))
        return null;

    ProteinResidueInstannceTag prTag = (ProteinResidueInstannceTag) tag;
    Protein protein = prTag.getProtein();
    int site = prTag.getPosition();

    String proSeq = protein.getSequence();
    if (proSeq == null)
        return null;

    int s = site - leftOffset;
    int t = site + rightOffset + 1;

    String ret = new String();

    if (s < 0) {
        if (appendTerminals) {
            ret += StringUtils.repeat("*", -s);
            s = 0;
        } else {
            return null;
        }
    }

    if (t > proSeq.length()) {
        if (appendTerminals) {
            if (markSites) {
                ret += extractMarkedPeptide(protein, ptm, s, proSeq.length());
            } else {
                ret += proSeq.substring(s);
            }
            ret += StringUtils.repeat("*", t - proSeq.length());
        } else {
            return null;
        }
    } else {
        if (markSites) {
            ret += extractMarkedPeptide(protein, ptm, s, t);
        } else {
            ret += proSeq.substring(s, t);
        }
    }

    return ret;
}

From source file:com.hortonworks.registries.storage.impl.jdbc.provider.sql.query.AbstractSqlQuery.java

/**
 * @param num number of times to repeat the pattern
 * @return bind variables repeated num times
 *//*from w w w  .  j av  a 2s  . c  o  m*/
protected String getBindVariables(String pattern, int num) {
    return StringUtils.chop(StringUtils.repeat(pattern, num));
}