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:com.liveramp.hank.test.ZkTestCase.java

private void dumpZk(String parentPath, String nodeName, int depth) throws Exception {
    System.err.print(StringUtils.repeat("  ", depth));
    System.err.print("/" + nodeName);
    String nodePath = ZkPath.append(parentPath, nodeName);
    nodePath = nodePath.replace("//", "/");
    byte[] data = zk.getData(nodePath, false, null);
    if (data == null) {
        System.err.print(" -> null");
    } else {//w  w w  .  j  av a  2s.c  om
        System.err.print(" -> [bytes]");
    }
    System.err.println();
    List<String> children = zk.getChildren(nodePath, false);
    for (String child : children) {
        dumpZk(nodePath, child, depth + 1);
    }
}

From source file:adalid.core.DisplayField.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 + "display" + faa + _display + foo;
            string += fee + tab + "dataArtifact" + faa + _dataArtifact + foo;
            if (_parent != null) {
                string += fee + tab + "parent" + faa + _parent + foo;
                string += fee + tab + "foreignCode" + faa + _foreignCode + foo;
                string += fee + tab + "foreignName" + faa + _foreignName + foo;
            }/* www  .  j  a  v  a 2 s .  com*/
        }

    }
    return string;
}

From source file:adalid.core.ReportGroup.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 + "sequence" + faa + _sequence + foo;
            string += fee + tab + "detail" + faa + _detail + foo;
        }//from   w  ww.j  av  a  2 s . co m
    }
    return string;
}

From source file:de.codesourcery.jasm16.ast.ASTUtils.java

public static final void printAST(ASTNode n, int depth) {
    final String indent = StringUtils.repeat(" ", depth * 2);
    System.out.println(indent + n.toString());
    for (ASTNode child : n.getChildren()) {
        printAST(child, depth + 1);//from w w  w.  jav a2s  .  c o m
    }
}

From source file:ch.systemsx.cisd.openbis.generic.shared.util.WebClientFilesUpdater.java

/**
 * Updates {@link DefaultClientPluginFactoryProvider} class up to the technologies found.
 *//*from   ww w.  j av  a 2s.c  o  m*/
public final void updateClientPluginProvider() {
    final File clientPluginProviderJavaFile = new File(workingDirectory,
            CLIENT_PLUGIN_PROVIDER_CLASS.replace(".", "/") + ".java");
    final String response = FileUtilities.checkFileFullyAccessible(clientPluginProviderJavaFile, "java");
    if (response != null) {
        throw new RuntimeException(response);
    }
    final StringBuilder builder = new StringBuilder(JAVA_MARKER_START);
    builder.append("\n");
    final String indent = StringUtils.repeat(" ", 8);
    for (final String technology : technologies) {
        if (technology.equals("generic")) {
            continue;
        }
        try {
            Class.forName(String.format(PLUGIN_FACTORY_CLASS_NAME_TEMPLATE, technology));
        } catch (final ClassNotFoundException ex) {
            throw CheckedExceptionTunnel.wrapIfNecessary(ex);
        }
        builder.append(indent);
        builder.append(String.format(PLUGIN_FACTORY_REGISTRATION_TEMPLATE, technology));
        builder.append("\n");
    }
    builder.append(indent);
    String content = FileUtilities.loadToString(clientPluginProviderJavaFile);
    content = content.substring(0, content.indexOf(JAVA_MARKER_START)) + builder.toString()
            + content.substring(content.indexOf(JAVA_MARKER_END), content.length());
    FileUtilities.writeToFile(clientPluginProviderJavaFile, content);
}

From source file:net.bpelunit.framework.ui.command.BPELUnitCommandLineRunner.java

void run() {
    String bpelUnitRunner = Messages
            .getString("BPELUnitCommandLineRunner.MSG_TITLE_BPELUNIT_COMMANDLINE_RUNNER");
    screen.println(bpelUnitRunner); //$NON-NLS-1$
    screen.println(StringUtils.repeat("-", bpelUnitRunner.length())); //$NON-NLS-1$

    try {// w w  w  .ja  v a  2s .c  o  m
        Map<String, String> options;
        options = BPELUnitConstants.NULL_OPTIONS;

        initialize(options);

        screen.println(Messages.getString("BPELUnitCommandLineRunner.MSG_PROGRESS_LOADING_TESTSUITE")); //$NON-NLS-1$
        TestSuite suite = loadTestSuite(testSuiteFile);

        // Test if all the test names are ok
        for (String testCaseName : testCaseNames) {
            if (!suite.hasTestCase(testCaseName)) {
                abort(String.format(Messages.getString("BPELUnitCommandLineRunner.MSG_ERROR_UNKNOWN_TESTCASE"), //$NON-NLS-1$
                        testCaseName));
            }
        }

        screen.println(Messages.getString("BPELUnitCommandLineRunner.MSG_PROGRESS_TESTSUITE_LOADED")); //$NON-NLS-1$
        screen.println(Messages.getString("BPELUnitCommandLineRunner.MSG_PROGRESS_DEPLOYING_SERVICES")); //$NON-NLS-1$

        try {
            suite.setUp();
        } catch (DeploymentException e) {
            try {
                suite.shutDown();
            } catch (DeploymentException e1) {
                // do nothing
            }
            abort(Messages.getString("BPELUnitCommandLineRunner.MSG_ERROR_DEPLOYMENT_ERROR"), e); //$NON-NLS-1$
        }

        screen.println(Messages.getString("BPELUnitCommandLineRunner.MSG_PROGRESS_DEPLOYMENT_DONE")); //$NON-NLS-1$
        screen.println(Messages.getString("BPELUnitCommandLineRunner.MSG_PROGRESS_RUNNING_TEST_CASES")); //$NON-NLS-1$

        suite.addResultListener(this);
        if (testCaseNames.size() > 0) {
            try {
                suite.setFilter(testCaseNames);
            } catch (TestCaseNotFoundException e1) {
                // tested before, should not happen.
            }
        }

        suite.run();

        suite.removeResultListener(this);
        screen.println(Messages.getString("BPELUnitCommandLineRunner.MSG_PROGRESS_TESTCASES_FINISHED")); //$NON-NLS-1$

        if (xmlFileName != null) {
            try {
                XMLResultProducer.writeXML(new FileOutputStream(xmlFileName), suite);
            } catch (Exception e) {
                abort(String.format(
                        Messages.getString("BPELUnitCommandLineRunner.MSG_ERROR_ERROR_WRITING_XML_FILE"), //$NON-NLS-1$
                        xmlFileName), e);
            }
        }

        screen.println(Messages.getString("BPELUnitCommandLineRunner.MSG_PROGRESS_UNDEPLOY")); //$NON-NLS-1$

        try {
            suite.shutDown();
        } catch (DeploymentException e) {
            abort(Messages.getString("BPELUnitCommandLineRunner.MSG_ERROR_UNDEPLOY"), e); //$NON-NLS-1$
        }
        screen.println(Messages.getString("BPELUnitCommandLineRunner.MSG_PROGRESS_UNDEPLOYED")); //$NON-NLS-1$
        screen.println(Messages.getString("BPELUnitCommandLineRunner.MSG_BYE")); //$NON-NLS-1$
    } catch (ConfigurationException e) {
        abort(Messages.getString("BPELUnitCommandLineRunner.MSG_ERROR_COFIGURATION_ERROR"), e); //$NON-NLS-1$
    } catch (SpecificationException e) {
        abort(Messages.getString("BPELUnitCommandLineRunner.MSG_ERROR_BPTS_ERROR"), e); //$NON-NLS-1$
    }
}

From source file:com.twinsoft.convertigo.engine.util.CarUtils.java

private static Document exportProject(Project project, final List<TestCase> selectedTestCases)
        throws EngineException {
    try {//from  w ww. j a  v a  2s.c  om
        final Document document = XMLUtils.getDefaultDocumentBuilder().newDocument();
        //            ProcessingInstruction pi = document.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");
        //            document.appendChild(pi);
        final Element rootElement = document.createElement("convertigo");

        rootElement.setAttribute("version", com.twinsoft.convertigo.engine.Version.fullProductVersion);
        rootElement.setAttribute("engine", com.twinsoft.convertigo.engine.Version.version);
        rootElement.setAttribute("beans", com.twinsoft.convertigo.beans.Version.version);
        String studioVersion = "";
        try {
            Class<?> c = Class.forName("com.twinsoft.convertigo.eclipse.Version");
            studioVersion = (String) c.getDeclaredField("version").get(null);
        } catch (Exception e) {
        } catch (Throwable th) {
        }

        rootElement.setAttribute("studio", studioVersion);
        document.appendChild(rootElement);

        new WalkHelper() {
            protected Element parentElement = rootElement;

            @Override
            protected void walk(DatabaseObject databaseObject) throws Exception {
                Element parentElement = this.parentElement;

                Element element = parentElement;
                element = databaseObject.toXml(document);
                String name = " : " + databaseObject.getName();
                try {
                    name = CachedIntrospector.getBeanInfo(databaseObject.getClass()).getBeanDescriptor()
                            .getDisplayName() + name;
                } catch (IntrospectionException e) {
                    name = databaseObject.getClass().getSimpleName() + name;
                }
                Integer depth = (Integer) document.getUserData("depth");
                if (depth == null) {
                    depth = 0;
                }

                String openpad = StringUtils.repeat("   ", depth);
                String closepad = StringUtils.repeat("   ", depth);
                parentElement.appendChild(document.createTextNode("\n"));
                parentElement.appendChild(
                        document.createComment(StringUtils.rightPad(openpad + "<" + name + ">", 150)));

                if (databaseObject instanceof TestCase && selectedTestCases.size() > 0) {
                    if (selectedTestCases.contains((TestCase) databaseObject)) {
                        parentElement.appendChild(element);
                    }
                } else {
                    parentElement.appendChild(element);
                }

                document.setUserData("depth", depth + 1, null);

                this.parentElement = element;
                super.walk(databaseObject);

                element.appendChild(document.createTextNode("\n"));
                element.appendChild(
                        document.createComment(StringUtils.rightPad(closepad + "</" + name + ">", 150)));
                document.setUserData("depth", depth, null);

                databaseObject.hasChanged = false;
                databaseObject.bNew = false;

                this.parentElement = parentElement;
            }

        }.init(project);

        return document;
    } catch (Exception e) {
        throw new EngineException("Unable to export the project \"" + project.getName() + "\".", e);
    }
}

From source file:com.netprogs.minecraft.plugins.social.command.help.HelpBook.java

private String createHeader(String pluginName, List<HelpPage> helpPageList, int pageNumber) {

    ResourcesConfig resources = SocialNetworkPlugin.getResources();

    // create our header
    String helpTitle = resources.getResource("social.help.header");
    helpTitle = " " + helpTitle + " ";
    helpTitle = helpTitle.replaceAll("<plugin>", pluginName);

    if (helpPageList.size() > 0) {
        helpTitle += " (" + pageNumber + "/" + helpPageList.size() + ") ";
    }/*from  w  ww.ja  v  a2 s  .co m*/

    String headerSpacer = StringUtils.repeat("-", 52);

    int midPoint = ((headerSpacer.length() / 2) - (helpTitle.length() / 2));
    String start = headerSpacer.substring(0, midPoint);
    String middle = helpTitle;
    String end = headerSpacer.substring(midPoint + helpTitle.length());

    // combine it all into the final header
    String displayHeader = SPACER_COLOR + start + TITLE_COLOR + middle + SPACER_COLOR + end;

    return displayHeader;
}

From source file:com.datatorrent.stram.plan.logical.LogicalPlanConfigurationTest.java

private void printTopology(OperatorMeta operator, DAG tplg, int level) {
    String prefix = "";
    if (level > 0) {
        prefix = StringUtils.repeat(" ", 20 * (level - 1)) + "   |" + StringUtils.repeat("-", 17);
    }/*w  ww  .  j a v a2 s .c  om*/
    logger.debug(prefix + operator.getName());
    for (StreamMeta downStream : operator.getOutputStreams().values()) {
        if (!downStream.getSinks().isEmpty()) {
            for (LogicalPlan.InputPortMeta targetNode : downStream.getSinks()) {
                printTopology(targetNode.getOperatorWrapper(), tplg, level + 1);
            }
        }
    }
}

From source file:com.qcadoo.model.integration.FieldModuleIntegrationTest.java

License:asdf

@Test
public void shouldCallAndFailDefaultMaxScaleValueLenFieldValidators() throws Exception {
    // given//from w  w  w  .j a v  a2 s  .  c o m
    BigDecimal tooPreciseDecimal = new BigDecimal("0." + StringUtils.repeat("9", 20));

    // when & then
    Entity savedPart = performFieldValidationTestOnPart("price", tooPreciseDecimal, false);
    Assert.assertEquals("qcadooView.validate.field.error.invalidScale.max",
            savedPart.getError("price").getMessage());
}