本文整理匯總了Java中org.apache.commons.lang.StringUtils.removeEnd方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.removeEnd方法的具體用法?Java StringUtils.removeEnd怎麽用?Java StringUtils.removeEnd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang.StringUtils
的用法示例。
在下文中一共展示了StringUtils.removeEnd方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSonArrays
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* 根據字節數組拆分若幹個字字節數組
* @param data 待拆分數組
* @param separator 分割數組
* @return
*/
public byte[][] getSonArrays(byte[] data,byte[] separator)
{
if(data==null||data.length<=0||separator==null||separator.length<=0)
{
System.out.println("data||separator數據無效!");
return null;
}
String[] dataHexArray=toHexArray(data);
String dataHexStr=StringUtils.substringBetween(Arrays.toString(dataHexArray), "[", "]").replaceAll("\\s","");
//System.out.println("待拆分字符串:"+dataHexStr);
String[] separatorHexhArray=toHexArray(separator);
String separatorHexStr=StringUtils.substringBetween(Arrays.toString(separatorHexhArray), "[", "]").replaceAll("\\s","");
//System.out.println("字符串拆分符:"+separatorHexStr);
//得到拆分後的數組
String[] arrays=StringUtils.splitByWholeSeparator(dataHexStr, separatorHexStr);
//System.out.println("拆分後的數組:"+Arrays.toString(arrays));
if(arrays==null||arrays.length<=0)
{
System.out.println("注意:數組拆分為0");
return null;
}
byte[][] result=new byte[arrays.length][];
//對子數組進行重組
for(int i=0;i<arrays.length;i++)
{
String arrayStr=arrays[i];
arrayStr=StringUtils.removeStart(arrayStr, ",");//去掉兩端的逗號
arrayStr=StringUtils.removeEnd(arrayStr, ",");//去掉兩端的逗號
String[] array=arrayStr.split(",");//根據子字符串中間剩餘的逗號重組為hex字符串
result[i]=toBtyeArray(array);
}
return result;
}
示例2: getsonArrays
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* 根據字節數組拆分若幹個字字節數組
* @param data
* @param separator
* @return
*/
public byte[][] getsonArrays(byte[] data,byte[] separator)
{
if(data==null||data.length<=0||separator==null||separator.length<=0)
{
System.out.println("data||separator數據無效!");
return null;
}
String[] dataHexArray=byteArrayToHexArray(data);
String dataHexStr=StringUtils.substringBetween(Arrays.toString(dataHexArray), "[", "]").replaceAll("\\s","");
//System.out.println("待拆分字符串:"+dataHexStr);
String[] separatorHexhArray=byteArrayToHexArray(separator);
String separatorHexStr=StringUtils.substringBetween(Arrays.toString(separatorHexhArray), "[", "]").replaceAll("\\s","");
//System.out.println("字符串拆分符:"+separatorHexStr);
//得到拆分後的數組
String[] arrays=StringUtils.splitByWholeSeparator(dataHexStr, separatorHexStr);
//System.out.println("拆分後的數組:"+Arrays.toString(arrays));
if(arrays==null||arrays.length<=0)
{
System.out.println("注意:數組拆分為0");
return null;
}
byte[][] result=new byte[arrays.length][];
//對子數組進行重組
for(int i=0;i<arrays.length;i++)
{
String arrayStr=arrays[i];
arrayStr=StringUtils.removeStart(arrayStr, ",");//去掉兩端的逗號
arrayStr=StringUtils.removeEnd(arrayStr, ",");//去掉兩端的逗號
String[] array=arrayStr.split(",");//根據子字符串中間剩餘的逗號重組為hex字符串
result[i]=hexArrayToBtyeArray(array);
}
return result;
}
示例3: unpackFile
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
private File unpackFile(HttpPipeKey key) {
Pipeline pipeline = configClientService.findPipeline(key.getIdentity().getPipelineId());
DataRetriever dataRetriever = dataRetrieverFactory.createRetriever(pipeline.getParameters().getRetriever(),
key.getUrl(), downloadDir);
File archiveFile = null;
try {
dataRetriever.connect();
dataRetriever.doRetrieve();
archiveFile = dataRetriever.getDataAsFile();
} catch (Exception e) {
dataRetriever.abort();
throw new PipeException("download_error", e);
} finally {
dataRetriever.disconnect();
}
// 處理下有加密的數據
if (StringUtils.isNotEmpty(key.getKey()) && StringUtils.isNotEmpty(key.getCrc())) {
decodeFile(archiveFile, key.getKey(), key.getCrc());
}
// 去除末尾的.gzip後綴,做為解壓目錄
String dir = StringUtils.removeEnd(archiveFile.getPath(),
FilenameUtils.EXTENSION_SEPARATOR_STR
+ FilenameUtils.getExtension(archiveFile.getPath()));
File unpackDir = new File(dir);
// 開始解壓
getArchiveBean().unpack(archiveFile, unpackDir);
return unpackDir;
}
示例4: getLoadTypePrimaryKeyUIValue
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* Appends primary keys using a comma
* @param newTable
*/
private String getLoadTypePrimaryKeyUIValue(TypePrimaryKeys newTable) {
StringBuffer stringBuffer = new StringBuffer();
if(newTable !=null && newTable.getPrimaryKeys() !=null){
TypeKeyFields typeKeyFields = newTable.getPrimaryKeys();
for(TypeFieldName typeFieldName : typeKeyFields.getField()){
stringBuffer.append(typeFieldName.getName());
stringBuffer.append(",");
}
}
return StringUtils.removeEnd(stringBuffer.toString(), ",");
}
示例5: getLoadTypeUpdateKeyUIValue
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* Appends update keys using a comma
* @param update
*/
private String getLoadTypeUpdateKeyUIValue(TypeUpdateKeys update) {
StringBuffer buffer=new StringBuffer();
if(update!=null && update.getUpdateByKeys()!=null){
TypeKeyFields keyFields=update.getUpdateByKeys();
for(TypeFieldName fieldName:keyFields.getField()){
buffer.append(fieldName.getName());
buffer.append(",");
}
}
return StringUtils.removeEnd(buffer.toString(), ",");
}
示例6: getLoadTypeUpdateKeyUIValue
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* Appends update keys using a comma
* @param update
*/
private String getLoadTypeUpdateKeyUIValue(TypeUpdateKeys update) {
StringBuffer buffer=new StringBuffer();
if(update!=null && update.getUpdateByKeys()!=null){
TypeKeyFields keyFields=update.getUpdateByKeys();
for(TypeFieldName fieldName:keyFields.getField()){
buffer.append(fieldName.getName());
buffer.append(",");
}
}
return StringUtils.removeEnd(buffer.toString(), ",");
}
示例7: getLoadTypePrimaryKeyUIValue
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* Appends primary keys using a comma
* @param newTable
* @return
*/
private String getLoadTypePrimaryKeyUIValue(TypePrimaryKeys newTable) {
StringBuffer stringBuffer = new StringBuffer();
if(newTable !=null && newTable.getPrimaryKeys() !=null){
TypeKeyFields typeKeyFields = newTable.getPrimaryKeys();
for(TypeFieldName typeFieldName : typeKeyFields.getField()){
stringBuffer.append(typeFieldName.getName());
stringBuffer.append(",");
}
}
return StringUtils.removeEnd(stringBuffer.toString(), ",");
}
示例8: getLoadTypeUpdateKeyUIValue
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* Appends update keys using a comma
* @param update
* @return
*/
private String getLoadTypeUpdateKeyUIValue(TypeUpdateKeys update) {
StringBuffer buffer=new StringBuffer();
if(update!=null && update.getUpdateByKeys()!=null){
TypeKeyFields keyFields=update.getUpdateByKeys();
for(TypeFieldName fieldName:keyFields.getField()){
buffer.append(fieldName.getName());
buffer.append(",");
}
}
return StringUtils.removeEnd(buffer.toString(), ",");
}
示例9: getUpdateKeyUIValue
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* Appends update keys using a comma
* @param typeUpdateKeys
*/
private String getUpdateKeyUIValue(TypeUpdateKeys typeUpdateKeys) {
StringBuffer buffer=new StringBuffer();
if(typeUpdateKeys!=null && typeUpdateKeys.getUpdateByKeys()!=null){
TypeKeyFields keyFields=typeUpdateKeys.getUpdateByKeys();
for(TypeFieldName fieldName:keyFields.getField()){
buffer.append(fieldName.getName());
buffer.append(",");
}
}
return StringUtils.removeEnd(buffer.toString(), ",");
}
示例10: getReleaseVersion
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
public VersionPolicyResult getReleaseVersion(final VersionPolicyRequest versionPolicyRequest)
throws PolicyException, VersionParseException {
final String version = versionPolicyRequest.getVersion();
final String cleanedVersion = StringUtils.removeEnd(version, snapshotPostfix);
final String majorVersionComponent = StringUtils.substringBefore(cleanedVersion, ".");
final String releaseVersion = matchesYear(majorVersionComponent, currentYear) ? cleanedVersion : firstOfYear();
return new VersionPolicyResult()
.setVersion(releaseVersion);
}
示例11: getWhereClause
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* Build the where clause part of a SugarCRM query.
*
* @param predicates The json predicates.
* @return The formatted query.
*/
public static String getWhereClause(List<JsonPredicate> predicates) {
if ((predicates == null) || (predicates.size() == 0)) {
return StringUtils.EMPTY;
}
StringBuilder queryBuilder = new StringBuilder();
String subQuery = StringUtils.EMPTY;
for (JsonPredicate predicate : predicates)
{
switch(predicate.operator) {
case Equal:
subQuery = predicate.isNumeric ? String.format("%s = %s", predicate.jsonName, predicate.value) : String.format("%s = '%s'", predicate.jsonName, predicate.value);
break;
case GreaterThan:
subQuery = predicate.isNumeric ? String.format("%s > %s", predicate.jsonName, predicate.value) : String.format("%s > '%s'", predicate.jsonName, predicate.value);
break;
case GreaterThanOrEqualTo:
subQuery = predicate.isNumeric ? String.format("%s >= %s", predicate.jsonName, predicate.value) : String.format("%s >= '%s'", predicate.jsonName, predicate.value);
break;
case LessThan:
subQuery = predicate.isNumeric ? String.format("%s < %s", predicate.jsonName, predicate.value) : String.format("%s < '%s'", predicate.jsonName, predicate.value);
break;
case LessThanOrEqualTo:
subQuery = predicate.isNumeric ? String.format("%s <= %s", predicate.jsonName, predicate.value) : String.format("%s <= '%s'", predicate.jsonName, predicate.value);
break;
case Contains:
subQuery = predicate.jsonName + " LIKE '%" + predicate.value + "%'";
break;
case StartsWith:
subQuery = predicate.jsonName + " LIKE '" + predicate.value + "%'";
break;
case EndsWith:
subQuery = predicate.jsonName + " LIKE '%" + predicate.value + "'";
break;
case Between:
subQuery = predicate.isNumeric ? String.format("%s BETWEEN %s AND %s", predicate.jsonName, predicate.fromValue, predicate.toValue) : String.format("%s BETWEEN '%s' AND '%s'", predicate.jsonName, predicate.fromValue, predicate.toValue);
break;
case WhereIn:
subQuery = String.format("%s IN (%s)", predicate.jsonName, predicate.value);
break;
}
queryBuilder.append(subQuery);
queryBuilder.append(" AND ");
}
String query = queryBuilder.toString();
if (!StringUtils.isNotBlank(query))
{
return StringUtils.EMPTY;
}
query = StringUtils.removeEnd(query.trim(),"AND");
query = " " + query.trim() + " ";
return query;
}
示例12: readBulkWithQuery2Test
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
@Test
public void readBulkWithQuery2Test() {
SugarRestRequest request = new SugarRestRequest("Leads", RequestType.BulkRead);
request.setUrl(TestAccount.Url);
request.setUsername(TestAccount.Username);
request.setPassword(TestAccount.Password);
request.getOptions().setMaxResult(10);
SugarRestClient client = new SugarRestClient();
SugarRestResponse response = client.execute(request);
assertNotNull(response);
assertEquals(response.getStatusCode(), HttpStatus.SC_OK);
List<Leads> readLeads = (List<Leads>)response.getData();
assertNotNull(readLeads);
// Read back with query
// Get all identifiers
List<String> identifiers = new ArrayList<String>();
for (Leads lead : readLeads) {
identifiers.add(lead.getId());
}
// Reset options
request.setOptions(new Options());
List<QueryPredicate> queryPredicates = new ArrayList<QueryPredicate>();
// Set query in this format:
// "leads.id IN('10d82d59-08eb-8f0d-28e0-5777b57af47c', '12037cd0-ead2-402e-e1d0-5777b5dfb965', '13d4109d-c5ca-7dd1-99f1-5777b57ef30f', '14c136e5-1a67-eeba-581c-5777b5c8c463', '14e4825e-9573-4d75-2dbe-5777b5b7ee85', '1705b33a-3fad-aa70-77ef-5777b5b081f1', '171c1d8b-e34f-3a1f-bef7-5777b5ecc823', '174a8fc4-56e6-3471-46d8-5777b565bf5b', '17c9c496-90a1-02f5-87bd-5777b51ab086', '1d210352-7a1f-2c5d-04ae-5777b5a3312f')");
StringBuilder builder = new StringBuilder();
for (String id : identifiers) {
builder.append(" '" + id + "', ");
}
String builderResult = builder.toString().trim();
builderResult = StringUtils.removeEnd(builderResult, ",");
String query = "leads.id IN(" + builderResult + ")";
// Since query is set, the query predicates will be ignore.
request.getOptions().setQuery(query);
queryPredicates.add(new QueryPredicate("last_name", Equal, "Johnson"));
request.getOptions().setQueryPredicates(queryPredicates);
response = client.execute(request);
assertNotNull(response);
assertEquals(response.getStatusCode(), HttpStatus.SC_OK);
List<Leads> readLeadsWithQuery = (List<Leads>)response.getData();
assertNotNull(readLeadsWithQuery);
assertEquals(identifiers.size(), readLeads.size());
assertEquals(identifiers.size(), readLeadsWithQuery.size());
assertEquals(readLeads.size(), readLeadsWithQuery.size());
}
示例13: trim
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
*
* This function will trim the given input string. It will not only remove the spaces and tabs at
* the end but also compress multiple spaces and tabs to a single space
*
* @param input The input string on which the trim operation needs to be performed
* @param retainLineSeparator whether to retain the line separator.
*
* @return String
*/
public static TrimmedInput trim(final String input, final boolean retainLineSeparator) {
if (input != null) {
String inputCopy = input;
StringBuffer output = new StringBuffer();
// First remove the trailing white spaces, we do not need those
inputCopy = StringUtils.stripEnd(inputCopy, null);
// As this parser is for optionParsing, we also need to remove
// the trailing optionSpecifiers provided it has previous
// options. Remove the trailing LONG_OPTION_SPECIFIERs
// in a loop. It is necessary to check for previous options for
// the case of non-mandatory arguments.
// "^(.*)(\\s-+)$" - something that ends with a space followed by a series of hyphens.
while (Pattern.matches("^(.*)(\\s-+)$", inputCopy)) {
inputCopy = StringUtils.removeEnd(inputCopy, SyntaxConstants.SHORT_OPTION_SPECIFIER);
// Again we need to trim the trailing white spaces
// As we are in a loop
inputCopy = StringUtils.stripEnd(inputCopy, null);
}
// Here we made use of the String class function trim to remove the
// space and tabs if any at the
// beginning and the end of the string
int noOfSpacesRemoved = 0;
{
int length = inputCopy.length();
inputCopy = inputCopy.trim();
noOfSpacesRemoved += length - inputCopy.length();
}
// Now we need to compress the multiple spaces and tabs to single space
// and tabs but we also need to ignore the white spaces inside the
// quotes and parentheses
StringBuffer buffer = new StringBuffer();
boolean startWhiteSpace = false;
for (int i = 0; i < inputCopy.length(); i++) {
char ch = inputCopy.charAt(i);
buffer.append(ch);
if (PreprocessorUtils.isWhitespace(ch)) {
if (PreprocessorUtils.isSyntaxValid(buffer.toString())) {
if (startWhiteSpace) {
noOfSpacesRemoved++;
} else {
startWhiteSpace = true;
if (ch == '\n') {
if (retainLineSeparator) {
output.append("\n");
}
} else {
output.append(" ");
}
}
buffer.delete(0, buffer.length());
} else {
output.append(ch);
}
} else {
startWhiteSpace = false;
output.append(ch);
}
}
return new TrimmedInput(output.toString(), noOfSpacesRemoved);
} else {
return null;
}
}
示例14: trim
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* Trims a suffix/prefix from the given string. For example if
* s is given as "/xy" and toTrim is "/", this method returns "xy"
*/
private static String trim(String s, String toTrim) {
return StringUtils.removeEnd(StringUtils.removeStart(s, toTrim),
toTrim);
}
示例15: setSpecificDocletOptions
import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
* Depending upon the command line options provided by the user, set
* configure the output generation environment.
*
* @param options
* The array of option names and values.
*/
public void setSpecificDocletOptions(String[][] options) {
for (int oi = 0; oi < options.length; ++oi) {
String[] os = options[oi];
String opt = os[0].toLowerCase();
if (opt.equals("-charset")) {
charset = os[1];
} else if (opt.equals("-noframe")) {
noframe = true;
} else if (opt.equals("-dubboconfigpath")) {
dubboconfigpath = os[1];
} else if (opt.equals("-springcontextconfigpath")) {
springcontextconfigpath = os[1];
} else if (opt.equals("-excludedurlsxpath")) {
excludedurlsxpath = os[1];
} else if (opt.equals("-systemname")) {
systemname = os[1];
} else if (opt.equals("-branchname")) {
branchname = os[1];
} else if (opt.equals("-searchengine")) {
searchengine = os[1];
} else if (opt.equals("-codeurl")) {
codeurl = os[1];
} else if (opt.equals("-buildid")) {
buildid = os[1];
}
}
// if branchname is not specified, try to resolve it from codeurl.
if (StringUtils.isEmpty(branchname) && StringUtils.isNotEmpty(codeurl)) {
codeurl = StringUtils.removeEnd(codeurl, "/");
String[] parts = StringUtils.split(codeurl, '/');
branchname = parts[parts.length - 1];
}
if (root.specifiedClasses().length > 0) {
Map<String, PackageDoc> map = new HashMap<String, PackageDoc>();
PackageDoc pd;
ClassDoc[] classes = root.classes();
for (int i = 0; i < classes.length; i++) {
pd = classes[i].containingPackage();
if (!map.containsKey(pd.name())) {
map.put(pd.name(), pd);
}
}
}
}