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

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

Introduction

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

Prototype

public static String deleteWhitespace(String str) 

Source Link

Document

Deletes all whitespaces from a String as defined by Character#isWhitespace(char) .

Usage

From source file:org.jasig.ssp.util.liquibase.UpdateMessageTemplateAndChecksum.java

@Override
public SqlStatement[] generateStatements(Database database) throws CustomChangeException {
    List<SqlStatement> statements = new ArrayList<SqlStatement>();
    if (resetChecksum) {
        final String query = "select " + columnName + " from message_template where id = '" + messageTemplateId
                + "'";
        columnValue = processQuery(database, query);
    } else {/*from w w  w  .  j  a  va  2s  .c o m*/
        //UPDATE COLUMN
        statements.add(new RawSqlStatement("update message_template set " + columnName + " = '" + columnValue
                + "' where id = '" + messageTemplateId + "'"));
    }
    try {
        String newColumnCheckSum = getCheckSum(StringUtils.deleteWhitespace(columnValue));

        //UPDATE CHECKSUM
        statements.add(new RawSqlStatement("update message_template set " + columnName + "_checksum = '"
                + newColumnCheckSum + "' where id = '" + messageTemplateId + "'"));
        final SimpleDateFormat df = new SimpleDateFormat(DATE_TIME_FORMAT);
        String newFormattedDate = df.format(new Date());
        statements.add(new RawSqlStatement("update message_template set modified_date = '" + newFormattedDate
                + "' where id = '" + messageTemplateId + "'"));

    } catch (NoSuchAlgorithmException exp) {
        throw new CustomChangeException("Jave version does not support Message Digest type SHA1", exp);
    }

    return statements.toArray(new SqlStatement[statements.size()]);
}

From source file:org.jboss.cdi.tck.test.shrinkwrap.descriptors.Beans11DescriptorImplTest.java

private String prepare(String text) {
    return StringUtils.deleteWhitespace(text);
}

From source file:org.jboss.richfaces.integrationTest.dataTable.DataTableTestCase.java

/**
 * Get a whole table text content and compare it to expected value
 *//*from www . jav  a2  s.  co  m*/
@Test
public void testWholeDataTableContentTest() {
    openTab(MSG_TAB_TO_OPEN);
    scrollIntoView(LOC_FIELDSET_HEADER, true);

    String tableText = selenium.getText(LOC_TABLE);
    tableText = StringUtils.deleteWhitespace(tableText);
    assertEquals(tableText, MSG_TABLE_TEXT_CONTENT, "Table doesn't contain expected text");
}

From source file:org.jongo.jdbc.OrderParam.java

public OrderParam(String col) {
    if (StringUtils.isBlank(col))
        throw new IllegalArgumentException("Invalid column parameter");

    if (ASC.equalsIgnoreCase(col) || DESC.equalsIgnoreCase(col))
        throw new IllegalArgumentException("Invalid column parameter");

    this.column = StringUtils.deleteWhitespace(col);
    this.direction = ASC;
}

From source file:org.jongo.jdbc.OrderParam.java

public OrderParam(String col, String dir) {
    if (StringUtils.isBlank(dir) || StringUtils.isBlank(col))
        throw new IllegalArgumentException("Invalid order parameters");

    if (ASC.equalsIgnoreCase(dir)) {
        this.direction = ASC;
    } else if (DESC.equalsIgnoreCase(dir)) {
        this.direction = DESC;
    } else {//  w w w  . ja  v a 2 s .  co  m
        throw new IllegalArgumentException("Invalid direction parameter");
    }
    this.column = StringUtils.deleteWhitespace(col);
}

From source file:org.jts.protocolvalidator.Guard.java

/**
 * Retrieve a list of condition elements, since a condition can contain
 * any number of elements combined with logical operators.
 * @param msgData - message data instance name
 * @return - list of condition elements/*w ww.  j a  va  2  s  .  c  o m*/
 */
public List<String> getConditionElement() {
    List<String> output = new ArrayList<String>();
    String tmpcond = Util.formatConditionString(condition);

    // get rid of some of the whitespace
    // remove all logical operators, since we are concerned with just the elemenats.
    tmpcond = tmpcond.replace(" && ", " \t ");
    tmpcond = tmpcond.replace(" || ", " \t ");
    tmpcond = tmpcond.replaceAll("!", "");
    // if the comments are too long, then break them up
    // on multiple lines.  at the same time remove additional spaces.
    // The assumption is that these conditions don't normally contain tabs within the element.

    String[] tmpstr = tmpcond.split("[\t]+");
    for (String element : tmpstr) {
        element = StringUtils.strip(element);
        element = StringUtils.deleteWhitespace(element);
        output.add(element);
    }

    return output;
}

From source file:org.jts.protocolvalidator.Guard.java

/**
 * Retrieve a list of Promela guard function definitions
 * @return - the list of Promela code for definitions
 *//*ww w  .  j  av a  2s .c  o m*/
public List<String> getConditionList() {
    List<String> output = new ArrayList<String>();
    String tmpcond = Util.formatConditionString(condition);
    tmpcond = tmpcond.replaceAll("(msg)", "incoming_pid, " + messageData);
    tmpcond = tmpcond.replace("transportData", "incoming_pid");

    // get rid of some of the whitespace
    // remove all logical operators, since we are concerned with just the elemenats.
    tmpcond = tmpcond.replace(" && ", " \t ");
    tmpcond = tmpcond.replace(" || ", " \t ");
    tmpcond = tmpcond.replaceAll("!", "");
    // if the comments are too long, then break them up
    // on multiple lines.  at the same time remove additional spaces.
    // The assumption is that these conditions don't normally contain tabs within the element.

    String[] tmpstr = tmpcond.split("[\t]+");
    for (String element : tmpstr) {
        element = StringUtils.strip(element);
        element = StringUtils.deleteWhitespace(element);
        // add prefix to make this defintion unique
        if (messageData.length() > INST_LEN && element.contains(messageData)) {
            element = messageData.substring(0, messageData.length() - INST_LEN) + "_" + element;
        }
        output.add("#define " + element + " (true)");
    }

    return output;
}

From source file:org.kuali.kfs.gl.batch.EnterpriseFeederFileSetType.java

/**
 * Return the file name based on information from user and file user identifier
 * /*from w  w w  .  j av  a2  s .  com*/
 * @param user Person object representing user who uploaded file
 * @param fileUserIdentifer String representing user who uploaded file
 * @return String enterprise feeder formated file name string using information from user and file user identifier
 * @see org.kuali.kfs.sys.batch.BatchInputFileSetType#getFileName(java.lang.String, org.kuali.rice.kim.api.identity.Person,
 *      java.lang.String)
 */
public String getFileName(String fileType, String principalName, String fileUserIdentifer, Date creationDate) {
    DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
    StringBuilder buf = new StringBuilder();
    fileUserIdentifer = StringUtils.deleteWhitespace(fileUserIdentifer);
    fileUserIdentifer = StringUtils.remove(fileUserIdentifer, FILE_NAME_PART_DELIMITER);
    buf.append(FILE_NAME_PREFIX).append(FILE_NAME_PART_DELIMITER).append(principalName)
            .append(FILE_NAME_PART_DELIMITER).append(fileUserIdentifer).append(FILE_NAME_PART_DELIMITER)
            .append(dateTimeService.toDateTimeStringForFilename(creationDate))
            .append(getFileExtension(fileType));
    return buf.toString();
}

From source file:org.kuali.kfs.gl.batch.EnterpriseFeederFileSetType.java

/**
 * Returns done file name for a specific user and file user identifier
 * //w  ww. j  ava 2s.co m
 * @param user the user who uploaded or will upload the file
 * @param fileUserIdentifier the file identifier
 * @return String done file name
 * @see org.kuali.kfs.sys.batch.BatchInputFileSetType#getDoneFileName(org.kuali.rice.kim.api.identity.Person, java.lang.String)
 */
public String getDoneFileName(Person user, String fileUserIdentifer, Date creationDate) {
    DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
    StringBuilder buf = new StringBuilder();
    fileUserIdentifer = StringUtils.deleteWhitespace(fileUserIdentifer);
    fileUserIdentifer = StringUtils.remove(fileUserIdentifer, FILE_NAME_PART_DELIMITER);
    buf.append(FILE_NAME_PREFIX).append(FILE_NAME_PART_DELIMITER).append(user.getPrincipalName())
            .append(FILE_NAME_PART_DELIMITER).append(fileUserIdentifer).append(FILE_NAME_PART_DELIMITER)
            .append(dateTimeService.toDateTimeStringForFilename(creationDate)).append(getDoneFileExtension());
    return buf.toString();
}

From source file:org.kuali.kfs.module.purap.util.ItemParserBase.java

/**
 * @see org.kuali.kfs.module.purap.util.ItemParser#parseItem(org.apache.struts.upload.FormFile,java.lang.Class,java.lang.String)
 *//*from www  .  j av  a 2 s  . c  o m*/
public List<PurApItem> importItems(FormFile itemFile, Class<? extends PurApItem> itemClass,
        String documentNumber) {
    // check input parameters
    try {
        checkItemClass(itemClass);
        checkItemFile(itemFile);
    } catch (IllegalArgumentException e) {
        throw new InfrastructureException("unable to import items.", e);
    }

    // open input stream
    List<PurApItem> importedItems = new ArrayList<PurApItem>();
    InputStream is;
    BufferedReader br;
    try {
        is = itemFile.getInputStream();
        br = new BufferedReader(new InputStreamReader(is));
    } catch (IOException e) {
        throw new InfrastructureException("unable to open import file in ItemParserBase.", e);
    }

    // parse items line by line
    lineNo = 0;
    boolean failed = false;
    String itemLine = null;
    try {
        while ((itemLine = br.readLine()) != null) {
            lineNo++;

            if (StringUtils
                    .isBlank(StringUtils.remove(StringUtils.deleteWhitespace(itemLine), KFSConstants.COMMA))) {
                continue;
            }

            try {
                PurApItem item = parseItem(itemLine, itemClass, documentNumber);
                importedItems.add(item);
            } catch (ItemParserException e) {
                // continue to parse the rest of the items after the current item fails
                // error messages are already dealt with inside parseItem, so no need to do anything here
                failed = true;
            }
        }

        if (failed) {
            throw new ItemParserException("errors in parsing item lines in file " + itemFile.getFileName(),
                    ERROR_ITEMPARSER_ITEM_LINE, itemFile.getFileName());
        }
    } catch (IOException e) {
        throw new InfrastructureException("unable to read line from BufferReader in ItemParserBase", e);
    } finally {
        try {
            br.close();
        } catch (IOException e) {
            throw new InfrastructureException("unable to close BufferReader in ItemParserBase", e);
        }
    }

    return importedItems;
}