Example usage for org.apache.commons.lang3 StringUtils remove

List of usage examples for org.apache.commons.lang3 StringUtils remove

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils remove.

Prototype

public static String remove(final String str, final char remove) 

Source Link

Document

Removes all occurrences of a character from within the source string.

A null source string will return null .

Usage

From source file:com.adobe.acs.commons.mcp.impl.ProcessErrorReportExcelServlet.java

@SuppressWarnings("squid:S3776")
protected Workbook createSpreadsheet(ManagedProcess report) {
    Workbook wb = new XSSFWorkbook();

    String name = report.getName();
    for (char ch : new char[] { '\\', '/', '*', '[', ']', ':', '?' }) {
        name = StringUtils.remove(name, ch);
    }//from   ww  w.  j av a2  s  . co  m
    Sheet sheet = wb.createSheet(name);
    sheet.createFreezePane(0, 1, 0, 1);

    Row headerRow = sheet.createRow(0);
    CellStyle headerStyle = createHeaderStyle(wb);
    CellStyle dateStyle = wb.createCellStyle();
    CreationHelper createHelper = wb.getCreationHelper();
    dateStyle.setDataFormat(createHelper.createDataFormat().getFormat("yyy/mm/dd h:mm:ss"));

    for (String columnName : Arrays.asList("Time", "Path", "Error", "Stack trace")) {
        Cell headerCell = headerRow.createCell(headerRow.getPhysicalNumberOfCells());
        headerCell.setCellValue(columnName);
        headerCell.setCellStyle(headerStyle);
    }

    Collection<ArchivedProcessFailure> rows = report.getReportedErrorsList();
    //make rows, don't forget the header row
    for (ArchivedProcessFailure error : rows) {
        Row row = sheet.createRow(sheet.getPhysicalNumberOfRows());
        Cell c;

        c = row.createCell(0);
        c.setCellValue(error.time);
        c.setCellStyle(dateStyle);
        c = row.createCell(1);
        c.setCellValue(error.nodePath);
        c = row.createCell(2);
        c.setCellValue(error.error);
        c = row.createCell(3);
        c.setCellValue(error.stackTrace);
    }
    autosize(sheet, 4);
    sheet.setAutoFilter(new CellRangeAddress(0, 1 + rows.size(), 0, 3));
    return wb;
}

From source file:io.bitsquare.gui.util.validation.AccountNrValidator.java

@Override
public ValidationResult validate(String input) {
    int length;// www.  j  a va2s.  c  o m
    String input2;
    switch (countryCode) {
    case "GB":
        length = 8;
        if (isNumberWithFixedLength(input, length))
            return super.validate(input);
        else
            return new ValidationResult(false, BSResources.get("validation.accountNr", length));
    case "US":
        if (isNumberInRange(input, 4, 17))
            return super.validate(input);
        else
            return new ValidationResult(false, BSResources.get("validation.accountNr", "4 - 17"));
    case "BR":
        if (isStringInRange(input, 1, 20))
            return super.validate(input);
        else
            return new ValidationResult(false, BSResources.get("validation.accountNrChars", "1 - 20"));
    case "NZ":
        input2 = input != null ? input.replaceAll("-", "") : null;
        if (isNumberInRange(input2, 15, 16))
            return super.validate(input);
        else
            return new ValidationResult(false, "Account number must be of format: 03-1587-0050000-00");
    case "AU":
        if (isNumberInRange(input, 4, 10))
            return super.validate(input);
        else
            return new ValidationResult(false, BSResources.get("validation.accountNr", "4 - 10"));
    case "CA":
        if (isNumberInRange(input, 7, 12))
            return super.validate(input);
        else
            return new ValidationResult(false, BSResources.get("validation.accountNr", "7 - 12"));
    case "MX":
        length = 18;
        if (isNumberWithFixedLength(input, length))
            return super.validate(input);
        else
            return new ValidationResult(false,
                    BSResources.get("validation.sortCodeNumber", getLabel(), length));
    case "HK":
        input2 = input != null ? input.replaceAll("-", "") : null;
        if (isNumberInRange(input2, 9, 12))
            return super.validate(input);
        else
            return new ValidationResult(false, "Account number must be of format: 005-231289-112");
    case "NO":
        if (input != null) {
            length = 11;
            // Provided by sturles:
            // https://github.com/bitsquare/bitsquare/pull/707

            // https://no.wikipedia.org/wiki/MOD11#Implementasjoner_i_forskjellige_programmeringspr.C3.A5k
            // https://en.wikipedia.org/wiki/International_Bank_Account_Number#Generating_IBAN_check_digits6

            // 11 digits, last digit is checksum.  Checksum algoritm is 
            // MOD11 with weights 2,3,4,5,6,7,2,3,4,5 right to left.
            // First remove whitespace and periods.  Normal formatting is: 
            // 1234.56.78903
            input2 = StringUtils.remove(input, " ");
            input2 = StringUtils.remove(input2, ".");
            // 11 digits, numbers only
            if (input2.length() != length || !StringUtils.isNumeric(input2))
                return new ValidationResult(false,
                        BSResources.get("validation.sortCodeNumber", getLabel(), length));
            int lastDigit = Character.getNumericValue(input2.charAt(input2.length() - 1));
            if (getMod11ControlDigit(input2) != lastDigit)
                return new ValidationResult(false, "Kontonummer har feil sjekksum");
            else
                return super.validate(input);
        } else {
            return super.validate(input);
        }
    default:
        return super.validate(input);
    }

}

From source file:com.jayway.restassured.itest.java.CustomObjectMappingITest.java

@Test
public void using_custom_object_mapper_statically() {
    final Message message = new Message();
    message.setMessage("A message");
    final ObjectMapper mapper = new ObjectMapper() {
        public Object deserialize(ObjectMapperDeserializationContext context) {
            final String toDeserialize = context.getDataToDeserialize().asString();
            final String unquoted = StringUtils.remove(toDeserialize, "##");
            final Message message = new Message();
            message.setMessage(unquoted);
            customDeserializationUsed.set(true);
            return message;
        }//from   w w  w  . j  a v  a 2s. c o  m

        public Object serialize(ObjectMapperSerializationContext context) {
            final Message objectToSerialize = context.getObjectToSerializeAs(Message.class);
            final String message = objectToSerialize.getMessage();
            customSerializationUsed.set(true);
            return "##" + message + "##";
        }
    };
    RestAssured.config = RestAssuredConfig.config().objectMapperConfig(new ObjectMapperConfig(mapper));

    final Message returnedMessage = given().body(message).when().post("/reflect").as(Message.class);

    assertThat(returnedMessage.getMessage(), equalTo("A message"));
    assertThat(customSerializationUsed.get(), is(true));
    assertThat(customDeserializationUsed.get(), is(true));
}

From source file:com.nridge.core.base.io.xml.DataTableXML.java

/**
 * Saves the previous assigned bag/table (e.g. via constructor or set method)
 * to the print writer stream wrapped in a tag name specified in the parameter.
 *
 * @param aPW            PrintWriter stream instance.
 * @param aTagName       Tag name./*w  w w .jav a 2  s  .  c  o  m*/
 * @param anIndentAmount Indentation count.
 * @throws java.io.IOException I/O related exception.
 */
@Override
public void save(PrintWriter aPW, String aTagName, int anIndentAmount) throws IOException {
    String cellValue;
    DataField dataField;
    int columnCount, rowCount;

    rowCount = mDataTable.rowCount();
    columnCount = mDataTable.columnCount();
    String tagName = StringUtils.remove(aTagName, StrUtl.CHAR_SPACE);
    IOXML.indentLine(aPW, anIndentAmount);
    aPW.printf("<%s", tagName);
    IOXML.writeAttrNameValue(aPW, "type", IO.extractType(mDataTable.getClass().getName()));
    IOXML.writeAttrNameValue(aPW, "name", mDataTable.getName());
    IOXML.writeAttrNameValue(aPW, "dimensions", String.format("%d cols x %d rows", columnCount, rowCount));
    IOXML.writeAttrNameValue(aPW, "version", IO.DATATABLE_XML_FORMAT_VERSION);
    for (Map.Entry<String, String> featureEntry : mDataTable.getFeatures().entrySet())
        IOXML.writeAttrNameValue(aPW, featureEntry.getKey(), featureEntry.getValue());
    aPW.printf(">%n");

    if ((mContextTotal != 0) || (mContextLimit != 0)) {
        IOXML.indentLine(aPW, anIndentAmount + 2);
        aPW.printf("<Context");
        IOXML.writeAttrNameValue(aPW, "start", mContextStart);
        IOXML.writeAttrNameValue(aPW, "limit", mContextLimit);
        IOXML.writeAttrNameValue(aPW, "total", mContextTotal);
        aPW.printf("/>%n");
    }
    DataBag dataBag = new DataBag(mDataTable.getColumnBag());
    if (mSaveFieldsWithoutValues)
        dataBag.setAssignedFlagAll(true);
    DataBagXML dataBagXML = new DataBagXML(dataBag);
    dataBagXML.save(aPW, "Columns", anIndentAmount + 2);
    if (rowCount > 0) {
        IOXML.indentLine(aPW, anIndentAmount + 2);
        aPW.printf("<Rows");
        IOXML.writeAttrNameValue(aPW, "count", rowCount);
        aPW.printf(">%n");
        for (int row = 0; row < rowCount; row++) {
            IOXML.indentLine(aPW, anIndentAmount + 3);
            aPW.printf("<Row>%n");
            IOXML.indentLine(aPW, anIndentAmount + 4);
            for (int col = 0; col < columnCount; col++) {
                dataField = mDataTable.getFieldByRowCol(row, col);
                cellValue = dataField.collapse();
                if (StringUtils.isEmpty(cellValue))
                    aPW.printf("<C/>");
                else
                    aPW.printf("<C>%s</C>", StringEscapeUtils.escapeXml10(cellValue));
            }
            aPW.printf("%n");
            IOXML.indentLine(aPW, anIndentAmount + 3);
            aPW.printf("</Row>%n");
        }
        IOXML.indentLine(aPW, anIndentAmount + 2);
        aPW.printf("</Rows>%n");
    }
    IOXML.indentLine(aPW, anIndentAmount);
    aPW.printf("</%s>%n", tagName);
}

From source file:com.nridge.core.base.io.xml.DocumentXML.java

/**
 * Saves the previous assigned document (e.g. via constructor or set method)
 * to the print writer stream wrapped in a tag name specified in the parameter.
 *
 * @param aPW            PrintWriter stream instance.
 * @param aParentTag     Parent tag name.
 * @param aDocument      Document instance.
 * @param anIndentAmount Indentation count.
 *
 * @throws java.io.IOException I/O related exception.
 */// ww w .jav  a 2  s.  co  m
public void save(PrintWriter aPW, String aParentTag, Document aDocument, int anIndentAmount)
        throws IOException {
    RelationshipXML relationshipXML;
    String docType = StringUtils.remove(aDocument.getType(), StrUtl.CHAR_SPACE);
    String parentTag = StringUtils.remove(aParentTag, StrUtl.CHAR_SPACE);

    IOXML.indentLine(aPW, anIndentAmount);
    if (StringUtils.isNotEmpty(aParentTag))
        aPW.printf("<%s-%s", parentTag, docType);
    else
        aPW.printf("<%s", docType);
    if (!mIsSimple) {
        IOXML.writeAttrNameValue(aPW, "type", aDocument.getType());
        IOXML.writeAttrNameValue(aPW, "name", aDocument.getName());
        IOXML.writeAttrNameValue(aPW, "title", aDocument.getTitle());
        IOXML.writeAttrNameValue(aPW, "schemaVersion", aDocument.getSchemaVersion());
    }
    for (Map.Entry<String, String> featureEntry : aDocument.getFeatures().entrySet())
        IOXML.writeAttrNameValue(aPW, featureEntry.getKey(), featureEntry.getValue());
    aPW.printf(">%n");
    DataTableXML dataTableXML = new DataTableXML(aDocument.getTable());
    dataTableXML.setSaveFieldsWithoutValues(mSaveFieldsWithoutValues);
    dataTableXML.save(aPW, IO.XML_TABLE_NODE_NAME, anIndentAmount + 1);
    if (aDocument.relationshipCount() > 0) {
        ArrayList<Relationship> docRelationships = aDocument.getRelationships();
        IOXML.indentLine(aPW, anIndentAmount + 1);
        aPW.printf("<%s>%n", IO.XML_RELATED_NODE_NAME);
        for (Relationship relationship : docRelationships) {
            relationshipXML = new RelationshipXML(relationship);
            relationshipXML.setSaveFieldsWithoutValues(mSaveFieldsWithoutValues);
            relationshipXML.save(aPW, IO.XML_RELATIONSHIP_NODE_NAME, anIndentAmount + 2);
        }
        IOXML.indentLine(aPW, anIndentAmount + 1);
        aPW.printf("</%s>%n", IO.XML_RELATED_NODE_NAME);
    }
    HashMap<String, String> docACL = aDocument.getACL();
    if (docACL.size() > 0) {
        IOXML.indentLine(aPW, anIndentAmount + 1);
        aPW.printf("<%s>%n", IO.XML_ACL_NODE_NAME);
        for (Map.Entry<String, String> aclEntry : docACL.entrySet()) {
            IOXML.indentLine(aPW, anIndentAmount + 2);
            aPW.printf("<%s", IO.XML_ACE_NODE_NAME);
            IOXML.writeAttrNameValue(aPW, "name", aclEntry.getKey());
            aPW.printf(">%s</%s>%n", StringEscapeUtils.escapeXml10(aclEntry.getValue()), IO.XML_ACE_NODE_NAME);
        }
        IOXML.indentLine(aPW, anIndentAmount + 1);
        aPW.printf("</%s>%n", IO.XML_ACL_NODE_NAME);
    }
    IOXML.indentLine(aPW, anIndentAmount);
    if (StringUtils.isNotEmpty(aParentTag))
        aPW.printf("</%s-%s>%n", parentTag, docType);
    else
        aPW.printf("</%s>%n", docType);
}

From source file:com.commander4j.db.JDatabaseParameters.java

public String getjdbcConnectString() {

    String value = "";

    if (getjdbcDriver().equals("com.mysql.cj.jdbc.Driver")) {
        if (getjdbcPort().equals("")) {
            value = "jdbc:mysql://jdbcServer/jdbcDatabase?connectTimeout=5&socketTimeout=0&autoReconnect=true";
        } else {//from w  w w .  j av  a  2  s .  com
            value = "jdbc:mysql://jdbcServer:jdbcPort/jdbcDatabase?connectTimeout=5&socketTimeout=0&autoReconnect=true";
        }
    }

    if (getjdbcDriver().equals("oracle.jdbc.driver.OracleDriver")) {
        value = "jdbc:oracle:thin:@//jdbcServer:jdbcPort/jdbcSID";
    }

    if (getjdbcDriver().equals("com.microsoft.sqlserver.jdbc.SQLServerDriver")) {

        value = "jdbc:sqlserver://jdbcServer\\jdbcSID:jdbcPort;databaseName=jdbcDatabase;selectMethod=direct";

    }

    value = value.replaceAll("jdbcServer", getjdbcServer());

    if (getjdbcPort().equals("")) {
        value = value.replaceAll(":jdbcPort", "");
    } else {
        value = value.replaceAll("jdbcPort", getjdbcPort());
    }

    if (getjdbcSID().equals("")) {
        value = StringUtils.remove(value, "\\jdbcSID");
    } else {
        value = value.replaceAll("jdbcSID", getjdbcSID());
    }

    value = value.replaceAll("jdbcDatabase", getjdbcDatabase());

    return value;
}

From source file:org.kuali.coeus.s2sgen.impl.datetime.S2SDateTimeServiceImpl.java

public String removeTimezoneFactor(String applicationXmlText, Calendar cal) {
    int zoneOffsetMilli = cal.get(Calendar.ZONE_OFFSET);
    int zoneOffsetNow = zoneOffsetMilli / (1000 * 60 * 60);
    int zoneOffsetDST = zoneOffsetMilli / (1000 * 60 * 60) + 1;

    String timezoneIdNow = TimeZone.getTimeZone("GMT" + zoneOffsetNow).getID();
    String timezoneIdDst = TimeZone.getTimeZone("GMT" + zoneOffsetDST).getID();
    String offset = "+00:00";
    if (timezoneIdNow.length() > 6) {
        offset = timezoneIdNow.substring(timezoneIdNow.length() - 6);
        applicationXmlText = StringUtils.remove(applicationXmlText, offset);
    }/* www .  j  a  v a2s  . c  o  m*/
    if (timezoneIdDst.length() > 6) {
        offset = timezoneIdDst.substring(timezoneIdDst.length() - 6);
        applicationXmlText = StringUtils.remove(applicationXmlText, offset);
    }

    return applicationXmlText;
}

From source file:io.spotnext.maven.mojo.TransformTypesMojo.java

/** {@inheritDoc} */
@Override//from  w  w  w  . j  a  v  a 2  s. c  o  m
public void execute() throws MojoExecutionException {
    if (skip) {
        getLog().info("Skipping type transformation!");
        return;
    }

    trackExecution("start");

    final ClassLoader classLoader = getClassloader();
    final List<ClassFileTransformer> transformers = getClassFileTransformers(classLoader);

    List<File> classFiles = FileUtils.getFiles(project.getBuild().getOutputDirectory(),
            f -> f.getAbsolutePath().endsWith(".class"));
    getLog().debug("Found class files for processing: "
            + classFiles.stream().map(f -> f.getName()).collect(Collectors.joining(", ")));

    if (CollectionUtils.isNotEmpty(transformers)) {
        if (CollectionUtils.isNotEmpty(classFiles)) {
            getLog().info(String.format("Transforming %s classes", classFiles.size()));

            for (final File f : classFiles) {
                if (f.getName().endsWith(Constants.CLASS_EXTENSION)) {
                    String relativeClassFilePath = StringUtils.remove(f.getPath(),
                            project.getBuild().getOutputDirectory());
                    relativeClassFilePath = StringUtils.removeStart(relativeClassFilePath, "/");
                    final String className = relativeClassFilePath.substring(0,
                            relativeClassFilePath.length() - Constants.CLASS_EXTENSION.length());

                    trackExecution("Loading class: " + f.getAbsolutePath());

                    byte[] byteCode;
                    try {
                        byteCode = Files.readAllBytes(f.toPath());
                    } catch (final IOException e) {
                        String message = String.format("Can't read bytecode for class %s", className);
                        buildContext.addMessage(f, 0, 0, message, BuildContext.SEVERITY_ERROR, e);
                        throw new IllegalStateException(message, e);
                    }

                    trackExecution("Loaded class: " + f.getAbsolutePath());

                    for (final ClassFileTransformer t : transformers) {
                        try {

                            // log exceptions into separate folder, to be able to inspect them even if Eclipse swallows them ...
                            if (t instanceof AbstractBaseClassTransformer) {
                                ((AbstractBaseClassTransformer) t).setErrorLogger(this::logError);
                            }

                            // returns null if nothing has been transformed
                            byteCode = t.transform(classLoader, className, null, null, byteCode);
                        } catch (final Exception e) {
                            String exception = "Exception during transformation of class: "
                                    + f.getAbsolutePath() + "\n" + e.getMessage();
                            trackExecution(exception);
                            String message = String.format("Can't transform class %s, transformer %s: %s",
                                    className, t.getClass().getSimpleName(), ExceptionUtils.getStackTrace(e));
                            buildContext.addMessage(f, 0, 0, message, BuildContext.SEVERITY_ERROR, e);
                            throw new MojoExecutionException(exception, e);
                        }
                    }

                    if (byteCode != null && byteCode.length > 0) {
                        try {
                            Files.write(f.toPath(), byteCode, StandardOpenOption.CREATE,
                                    StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);

                            trackExecution("Saved transformed class: " + f.getAbsolutePath());
                        } catch (final IOException e) {
                            String message = "Could not write modified class: " + relativeClassFilePath;
                            buildContext.addMessage(f, 0, 0, message, BuildContext.SEVERITY_ERROR, e);
                            throw new IllegalStateException(message);
                        } finally {
                            buildContext.refresh(f);
                            getLog().info("Applied transformation to type: " + f.getAbsolutePath());
                        }
                    } else {
                        trackExecution("No changes made for class: " + f.getAbsolutePath());
                        getLog().debug("No transformation was applied to type: " + f.getAbsolutePath());
                    }
                }
            }
        } else {
            getLog().info("No class files found");
        }

        trackExecution("All classes in build output folder transformed");

        if (includeJars) {
            final String packaging = project.getPackaging();
            final Artifact artifact = project.getArtifact();

            if ("jar".equals(packaging) && artifact != null) {
                try {
                    final File source = artifact.getFile();

                    if (source.isFile()) {
                        final File destination = new File(source.getParent(), "instrument.jar");

                        final JarTransformer transformer = new JarTransformer(getLog(), classLoader,
                                Arrays.asList(source), transformers);
                        transformer.transform(destination);

                        final File sourceRename = new File(source.getParent(),
                                "notransform-" + source.getName());

                        if (source.renameTo(sourceRename)) {
                            throw new MojoExecutionException(String.format("Could not move %s to %s",
                                    source.toString(), sourceRename.toString()));
                        }

                        if (destination.renameTo(sourceRename)) {
                            throw new MojoExecutionException(String.format("Could not move %s to %s",
                                    destination.toString(), sourceRename.toString()));
                        }

                        buildContext.refresh(destination);
                    }
                } catch (final Exception e) {
                    buildContext.addMessage(artifact.getFile(), 0, 0, e.getMessage(),
                            BuildContext.SEVERITY_ERROR, e);
                    throw new MojoExecutionException(e.getMessage(), e);
                }
            } else {
                getLog().debug(String.format("Artifact %s not a jar file",
                        artifact != null ? (artifact.getGroupId() + ":" + artifact.getArtifactId())
                                : "<null>"));
            }
        }
    } else {
        getLog().info("No class transformers configured");
    }
}

From source file:com.mirth.connect.plugins.datatypes.hl7v2.ER7BatchAdaptor.java

private String getMessageFromReader() throws Exception {
    SplitType splitType = batchProperties.getSplitType();

    if (splitType == SplitType.MSH_Segment) {
        // TODO: The values of these parameters should come from the protocol
        // properties passed to processBatch
        // TODO: src is a character stream, not a byte stream
        byte startOfMessage = (byte) 0x0B;
        byte endOfMessage = (byte) 0x1C;

        StringBuilder message = new StringBuilder();
        if (StringUtils.isNotBlank(previousLine)) {
            message.append(previousLine);
            message.append(segmentDelimiter);
        }//w w  w.ja  v a  2s  . co  m

        while (scanner.hasNext()) {
            String line = StringUtils
                    .remove(StringUtils.remove(scanner.next(), (char) startOfMessage), (char) endOfMessage)
                    .trim();

            if ((line.length() == 0) || line.equals((char) endOfMessage) || line.startsWith("MSH")) {
                if (message.length() > 0) {
                    previousLine = line;
                    return message.toString();
                }

                while ((line.length() == 0) && scanner.hasNext()) {
                    line = scanner.next();
                }

                if (line.length() > 0) {
                    message.append(line);
                    message.append(segmentDelimiter);
                }
            } else if (line.startsWith("FHS") || line.startsWith("BHS") || line.startsWith("BTS")
                    || line.startsWith("FTS")) {
                // ignore batch headers
            } else {
                message.append(line);
                message.append(segmentDelimiter);
            }
        }

        /*
         * MIRTH-2058: Now that the file has been completely read, make sure to process anything
         * remaining in the message buffer. There could have been lines read in that were not
         * closed with an EOM.
         */
        if (message.length() > 0) {
            previousLine = null;
            return message.toString();
        }

    } else if (splitType == SplitType.JavaScript) {
        if (StringUtils.isEmpty(batchProperties.getBatchScript())) {
            throw new BatchMessageException("No batch script was set.");
        }

        try {
            final String batchScriptId = ScriptController.getScriptId(ScriptController.BATCH_SCRIPT_KEY,
                    sourceConnector.getChannelId());

            MirthContextFactory contextFactory = contextFactoryController
                    .getContextFactory(sourceConnector.getChannel().getResourceIds());
            if (!factory.getContextFactoryId().equals(contextFactory.getId())) {
                synchronized (factory) {
                    contextFactory = contextFactoryController
                            .getContextFactory(sourceConnector.getChannel().getResourceIds());
                    if (!factory.getContextFactoryId().equals(contextFactory.getId())) {
                        JavaScriptUtil.recompileGeneratedScript(contextFactory, batchScriptId);
                        factory.setContextFactoryId(contextFactory.getId());
                    }
                }
            }

            String result = JavaScriptUtil.execute(
                    new JavaScriptTask<String>(contextFactory, "HL7 v2.x Batch Adaptor", sourceConnector) {
                        @Override
                        public String doCall() throws Exception {
                            Script compiledScript = CompiledScriptCache.getInstance()
                                    .getCompiledScript(batchScriptId);

                            if (compiledScript == null) {
                                logger.error("Batch script could not be found in cache");
                                return null;
                            } else {
                                Logger scriptLogger = Logger
                                        .getLogger(ScriptController.BATCH_SCRIPT_KEY.toLowerCase());

                                try {
                                    Scriptable scope = JavaScriptScopeUtil.getBatchProcessorScope(
                                            getContextFactory(), scriptLogger, sourceConnector.getChannelId(),
                                            sourceConnector.getChannel().getName(),
                                            getScopeObjects(bufferedReader));
                                    return (String) Context.jsToJava(executeScript(compiledScript, scope),
                                            String.class);
                                } finally {
                                    Context.exit();
                                }
                            }
                        }
                    });

            if (StringUtils.isEmpty(result)) {
                return null;
            } else {
                return result;
            }
        } catch (InterruptedException e) {
            throw e;
        } catch (JavaScriptExecutorException e) {
            logger.error(e.getCause());
        } catch (Throwable e) {
            logger.error(e);
        }
    } else {
        throw new BatchMessageException("No valid batch splitting method detected");
    }

    return null;
}

From source file:ch.cyberduck.core.Archive.java

/**
 * @param files Files/*from   w  w  w .j  a  v a2 s  . c  om*/
 * @return Expanded filenames
 */
public List<Path> getExpanded(final List<Path> files) {
    final List<Path> expanded = new ArrayList<Path>();
    for (Path file : files) {
        expanded.add(new Path(file.getParent(),
                StringUtils.remove(file.getName(), String.format(".%s", this.getIdentifier())),
                EnumSet.of(Path.Type.file)));
    }
    return expanded;
}