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

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

Introduction

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

Prototype

public static String removeEnd(String str, String remove) 

Source Link

Document

Removes a substring only if it is at the end of a source string, otherwise returns the source string.

Usage

From source file:com.hangum.tadpole.rdb.core.actions.oracle.TableSapceManageEditor.java

private void makeAddDatafileScript() {
    StringBuffer script = new StringBuffer();

    script.append("ALTER TABLESPACE " + tablespaceDao.getTablespace_name()).append("\n");
    script.append(" ADD DATAFILE \n");

    if (this.btnDatafileName.getSelection()) {
        script.append(" '").append(this.textDataFileName.getText().trim()).append("' \n");
    }/*from  ww  w .  ja  va2  s  . c om*/

    script.append(" SIZE " + this.textDatafileSize.getText() + "M ");
    if (this.btnReuse.getSelection()) {
        script.append(" REUSE \n");
    } else {
        script.append(" \n");
    }

    if (this.btnAutoExtend.getSelection()) {
        script.append(" AUTOEXTEND ON \n");
        script.append(" NEXT ").append(this.textAutoExtendSize.getText().trim()).append("M \n");
        if (this.btnMaximumSize.getSelection()) {
            script.append(" MAXSIZE UNLIMITED \n");

        } else {
            script.append(" MAXSIZE ").append(this.textMaximumSize.getText().trim()).append("M \n");
        }
    }
    textScript.setText(StringUtils.removeEnd(script.toString(), ";"));
}

From source file:adalid.commons.util.StrUtils.java

public static String getQualifiedShortName(String name, String qualifier) {
    String n, q;//from w w w  .j a v  a2  s .  com
    if (StringUtils.isNotBlank(name)) {
        n = name.trim();
        if (StringUtils.isNotBlank(qualifier)) {
            q = qualifier.trim();
            n = StringUtils.removeStart(n, q + ".");
            n = StringUtils.removeStart(n, q + "_");
            n = StringUtils.removeEnd(n, "_" + q);
            return q + "." + n;
        }
        return n;
    }
    return null;
}

From source file:com.hangum.tadpole.mongodb.core.query.MongoDBQuery.java

/**
 * bucket list  .//from   w  w  w. j  a  va2s  . c o m
 * 
 * @param userDB
 * @return
 * @throws Exception
 */
public static List<String> getGridFSBucketList(UserDBDAO userDB) throws Exception {
    List<String> listStr = new ArrayList<String>();

    DB mongoDb = findDB(userDB);
    Set<String> colNames = mongoDb.getCollectionNames();
    for (String name : colNames) {
        if (StringUtils.contains(name, ".chunks"))
            listStr.add(StringUtils.removeEnd(name, ".chunks"));
    }

    return listStr;
}

From source file:adalid.commons.util.StrUtils.java

public static String getUnqualifiedShortName(String name, String qualifier) {
    String n, q;// w  w  w  .  ja  v a2 s . c o  m
    if (StringUtils.isNotBlank(name)) {
        n = name.trim();
        if (StringUtils.isNotBlank(qualifier)) {
            q = qualifier.trim();
            n = StringUtils.removeStart(n, q + ".");
            n = StringUtils.removeStart(n, q + "_");
            n = StringUtils.removeEnd(n, "_" + q);
        }
        return n;
    }
    return null;
}

From source file:mvm.rya.indexing.accumulo.freetext.AccumuloFreeTextIndexer.java

/**
 * Checks to see if the provided term appears in other documents.
 * @param term the term to search for./*from   w ww.  jav  a  2  s .  c om*/
 * @param currentDocId the current document ID that the search term exists in.
 * @return {@code true} if the term was found in other documents. {@code false} otherwise.
 */
private boolean doesTermExistInOtherDocs(String term, int currentDocId, Text docIdText) {
    try {
        String freeTextDocTableName = ConfigUtils.getFreeTextDocTablename(conf);
        Scanner scanner = getScanner(freeTextDocTableName);

        String t = StringUtils.removeEnd(term, "*").toLowerCase();
        Text queryTerm = ColumnPrefixes.getTermColFam(t);

        // perform query and read results
        scanner.fetchColumnFamily(queryTerm);

        for (Entry<Key, Value> entry : scanner) {
            Key key = entry.getKey();
            Text row = key.getRow();
            int rowId = Integer.parseInt(row.toString());
            // We only want to check other documents from the one we're deleting
            if (rowId != currentDocId) {
                Text columnFamily = key.getColumnFamily();
                String columnFamilyValue = columnFamily.toString();
                // Check that the value has the term prefix
                if (columnFamilyValue.startsWith(ColumnPrefixes.TERM_CF_PREFIX.toString())) {
                    Text text = ColumnPrefixes.removePrefix(columnFamily);
                    String value = text.toString();
                    if (value.equals(term)) {
                        return true;
                    }
                }
            }
        }
    } catch (IOException e) {
        logger.error("Error searching for the existance of the term in other documents", e);
    }
    return false;
}

From source file:adalid.core.AbstractArtifact.java

@Override
public String toString(int n, String key, boolean verbose, boolean fields, boolean maps) {
    String r4n = StringUtils.repeat(" ", 4 * n);
    String tab = verbose ? StringUtils.repeat(" ", 4) : "";
    String fee = verbose ? StringUtils.repeat(tab, n) : "";
    //      String faa = " = ";
    String foo = verbose ? EOL : "";
    String eol = verbose ? EOL : ", ";
    String string = EOL;/*www.j a  v  a2  s . co m*/
    String c = classToString(n, key, verbose);
    String f = fieldsToString(n, key, verbose, fields, maps);
    String m = mapsToString(n, key, verbose, fields, maps);
    string += c;
    string += " " + "{" + " " + this + eol;
    string += f;
    string += m;
    if (!verbose) {
        string = StringUtils.removeEnd(string, eol);
        if (c.contains(EOL) || f.contains(EOL) || m.contains(EOL)) {
            fee = r4n;
        }
    }
    string += fee + "}" + EOL;
    return string.replaceAll(EOL + EOL, EOL);
}

From source file:adalid.core.AbstractArtifact.java

protected String classToString(int n, String key, boolean verbose) {
    String tab = StringUtils.repeat(" ", 4);
    String fee = StringUtils.repeat(tab, n);
    //      String faa = " = ";
    //      String foo = EOL;
    String string = "";
    String s1 = getDeclaringField() == null ? "" : getDeclaringField().getType().getSimpleName();
    String s2 = getNamedClass().getSimpleName();
    String s3 = StringUtils.isBlank(s1) || s1.equals(s2) ? s2
            : StringUtils.removeEnd(s1, "[]") + " " + "(" + s2 + ")";
    String s4 = StringUtils.isBlank(key) ? "" : " " + key;
    //      String s5 = "@" + Integer.toHexString(hashCode());
    //      string += fee + s3 + s4 + s5;
    string += fee + s3 + s4;//from   w w w . j  a va 2  s .  co m
    return string;
}

From source file:com.google.gdt.eclipse.designer.model.widgets.support.GwtState.java

/**
 * @return the number of pixels from given size style string.
 *//*from  w  w w  .  ja  va2 s. c o m*/
public static int getValuePx(String styleString) {
    if (styleString != null && styleString.endsWith("px") /*"0px"*/) {
        styleString = StringUtils.removeEnd(styleString, "px");
        try {
            return (int) Double.parseDouble(styleString);
        } catch (NumberFormatException e) {
            return 0;
        }
    }
    // no style set or browser can't return it for designer
    return 0;
}

From source file:ips1ap101.lib.base.util.StrUtils.java

public static String removeWords(String string, String remove, char affixType) {
    if (remove != null) {
        String separatorChars = ", ";
        String[] tokens = StringUtils.split(remove, separatorChars);
        for (String token : tokens) {
            remove = StrUtils.getWordyString(token);
            if (affixType == 'p') {
                string = StringUtils.removeStart(string, remove + " ");
            } else if (affixType == 's') {
                string = StringUtils.removeEnd(string, " " + remove);
            } else {
                string = StringUtils.remove(string, " " + remove + " ");
            }/*from w ww .jav  a 2 s.  c  o  m*/
        }
    }
    return string;
}

From source file:com.snowplowanalytics.snowplow.hadoop.hive.SnowPlowEventStruct.java

/**
 * Cleans a string to try and make it parsable by URLDecoder.decode.
 *
 * @param s The String to clean/*  w  w w  . j  a v  a 2  s.c o  m*/
 * @return The cleaned string
 */
static String cleanUrlString(String s) {
    // The '%' character seems to be appended to the end of some URLs in
    // the CloudFront logs, causing Exceptions when using URLDecoder.decode
    // Perhaps a CloudFront bug?
    return StringUtils.removeEnd(s, "%");
}