當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtils.substringBetween方法代碼示例

本文整理匯總了Java中org.apache.commons.lang.StringUtils.substringBetween方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.substringBetween方法的具體用法?Java StringUtils.substringBetween怎麽用?Java StringUtils.substringBetween使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang.StringUtils的用法示例。


在下文中一共展示了StringUtils.substringBetween方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getColumnLengthAndPrecision

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public static int[] getColumnLengthAndPrecision(Column column){
	int[] ret = new int[2];
	String data = StringUtils.substringBetween(column.getMysqlType(), "(",")");
	String length = StringUtils.substringBefore(data, ",");
	String precision = StringUtils.substringAfter(data, ",");
	String type = getColumnType(column).toUpperCase();
	if("SET".equals(type) || "ENUM".equals(type)){
		ret[0] = 0;
		ret[1] = 0;
	}else{
		if(StringUtils.isEmpty(length)){
			ret[0] = 0;
		}else{
			ret[0] = Integer.parseInt(length);
		}
		if(StringUtils.isEmpty(precision)){
			ret[1] = 0;
		}else{
			ret[1] = Integer.parseInt(precision);
		}
	}
	return ret;
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:24,代碼來源:Support.java

示例2: subHexArray

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
 * 根據hex文本數組截取數據,返回截獲的hex數組
 * @param data 類型:[0, 7, -63, -108]
 * @param startHexStr 類型:["0C", "B6", "05", "00"]
 * @param endHexStr 類型:["0C", "B6", "05", "00"]
 * @return 類型:["0C", "B6", "05", "00"] 失敗返回null
 */
public String[] subHexArray(byte[] data,String[] startHexStr,String[] endHexStr)
{
	if(data==null||data.length<=0)
	{
		System.out.println("data數據無效!");
		return null;
	}
	String[] result=null;
	String[] hexarray=toHexArray(data);
	String hexstr=Arrays.toString(hexarray);
	hexstr=StringUtils.substringBetween(hexstr, "[", "]").replaceAll("\\s", "");//原數據字符串去括號空格
	String start=Arrays.toString(startHexStr);//轉換為字符串
	start=StringUtils.substringBetween(start, "[", "]").replaceAll("\\s", "");//去括號空格
	String end=Arrays.toString(endHexStr);
	end=StringUtils.substringBetween(end, "[", "]").replaceAll("\\s", "");//去括號空格
	String resultHex=StringUtils.substringBetween(hexstr, start, end);//取中間數據
	if(resultHex==null)
	{
		//System.out.println("注意:截取內容為空,無數據!");
		return null;
	}
	result=StringUtils.split(resultHex, ',');//重組為hexstr數組
	return result;
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:32,代碼來源:HexStrBytes.java

示例3: SubHexArrays

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
 * 失敗返回null
 * 根據hex字符數組截取數據,返回截獲數據的hex數組
 * @param data 類型:[0, 7, -63, -108]
 * @param startHexStr 類型:["0C", "B6", "05", "00"]
 * @param endHexStr 類型:["0C", "B6", "05", "00"]
 * @return 類型:["0C", "B6", "05", "00"]
 */
public String[] SubHexArrays(byte[] data,String[] startHexStr,String[] endHexStr)
{
	if(data==null||data.length<=0)
	{
		System.out.println("data數據無效!");
		return null;
	}
	String[] result=null;
	String[] hexarray=byteArrayToHexArray(data);
	String hexstr=Arrays.toString(hexarray);
	hexstr=StringUtils.substringBetween(hexstr, "[", "]").replaceAll("\\s", "");//原數據字符串去括號空格
	String start=Arrays.toString(startHexStr);//轉換為字符串
	start=StringUtils.substringBetween(start, "[", "]").replaceAll("\\s", "");//去括號空格
	String end=Arrays.toString(endHexStr);
	end=StringUtils.substringBetween(end, "[", "]").replaceAll("\\s", "");//去括號空格
	String resultHex=StringUtils.substringBetween(hexstr, start, end);//取中間數據
	if(resultHex==null)
	{
		//System.out.println("注意:截取內容為空,無數據!");
		return null;
	}
	result=StringUtils.split(resultHex, ',');//重組為hexstr數組
	return result;
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:33,代碼來源:DataTools.java

示例4: getRootElementName

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
private String getRootElementName(String rowTag) {

		String rootElementName = null;

		if (StringUtils.isBlank(rowTag) || !rowTag.startsWith("/")) {
			return null;
		}

		// TODO: Ask for requirement how row tag will be come
		if (rowTag.startsWith("/")) {
			rootElementName = StringUtils.substringBetween(rowTag, "/", "/");
		}
		if (StringUtils.isBlank(rootElementName)) {
			rootElementName = StringUtils.substringAfter(rowTag, "/");
		}

		return rootElementName;
	}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:19,代碼來源:ExportXSDWidget.java

示例5: getParamValue

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
	 * 
	 * checking the parameter in paramsMap
	 * @param value
	 * @return value of Parameter if found in Map otherwise Parameter not found
	 */
 public String getParamValue(String value){
	 Optional<String> optional = Optional.of(value);
	 if(jobProps != null && !jobProps.isEmpty() && optional.isPresent() && value.contains("@{")){
		String param = "";
		String[] splitString = value.split("/");
		for(String field : splitString){
			if(field.startsWith("@{")){
				field = StringUtils.substringBetween(field, "@{", "}");
				for (Map.Entry<String, String> entry : paramsMap.entrySet()){
					if(StringUtils.equals(entry.getKey(), field)){
						if(entry.getValue().endsWith("/")){
							param = param == null ? entry.getValue() : param.concat(entry.getValue() + "/");
						}
						param = param == null ? entry.getValue() : param.concat(entry.getValue() + "/");
					}
				}
			}else{
				param += field + "/";
			}
		}
		return getResult(param);
	}
		return PARAMETER_NOT_FOUND;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:31,代碼來源:Utils.java

示例6: getWorkflowIdAndKeyFromUrl

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public static Pair<String, String> getWorkflowIdAndKeyFromUrl(String url)
{
    //url example: http://localhost:8081/share/page/reset-password?key=164e37bf-2590-414e-94db-8b8cfe5be790&id=activiti$156
    assertNotNull(url);

    String id = StringUtils.trimToNull(
                StringUtils.substringAfter(url, "id="));
    String key = StringUtils.substringBetween(url, "key=", "&id=");

    Pair<String, String> pair = new Pair<>(id, key);
    return pair;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:13,代碼來源:ResetPasswordServiceImplTest.java

示例7: toHexStr

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
 * 將一個裝有16進製的string數組變成一個16進製字符串
 * "[01, 16, 1F, 0E]" ==> 01161F0E
 * @param hexStringArray
 * @return
 */
public String toHexStr(String[] hexStringArray)
{
	String hexStr=Arrays.toString(hexStringArray);
	hexStr=StringUtils.substringBetween(hexStr, "[", "]");
	hexStr=hexStr.replaceAll("\\s", "");//去空格
	hexStr=hexStr.replaceAll(",", "");
	return hexStr;
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:15,代碼來源:HexStrBytes.java

示例8: toHexStrArray

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
 * 將一個16進製文本數組字符串轉為16進製文本數組
 * "[01, 16, 1F, 0E]" ==> [01, 16, 1F, 0E]
 * @param hexArrayStr
 * @return
 */
public String[] toHexStrArray(String hexArrayStr)
{
	String hexStr=StringUtils.substringBetween(hexArrayStr, "[", "]");
	hexStr=hexStr.replaceAll("\\s", "");//去空格
	String[] hexStrArray=hexStr.split(",");
	return hexStrArray;
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:14,代碼來源:HexStrBytes.java

示例9: hexStringArrayToHexStr

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
/**
 * 將數組形式的16進製文本替換為普通文本
 * @param str
 * @return
 */
public String hexStringArrayToHexStr(String[] str)
{
	String hexStr=Arrays.toString(str);
	hexStr=StringUtils.substringBetween(hexStr, "[", "]");
	hexStr=hexStr.replaceAll("\\s", "");//去空格
	hexStr=hexStr.replaceAll(",", "");
	return hexStr;
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:14,代碼來源:DataTools.java

示例10: getLongDescription

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
private String getLongDescription(String templateString) {
    String longDescription = panel.getLongDescription();
    // Get the empty Spaces in templates in new Line and the longDescription Variable
    String searchString = "${" + Consts.LONG_DESCRIPTION + "}";
    String emptySpaces =
            StringUtils.substringBetween(templateString, identifyLineDelimiter(templateString), searchString);
    String lineDelimiter = identifyLineDelimiter(longDescription);
    return StringUtils.replace(longDescription, lineDelimiter, lineDelimiter + emptySpaces).trim();
}
 
開發者ID:JanGatting,項目名稱:GitCommitMessage,代碼行數:10,代碼來源:PanelDialog.java

示例11: main

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
public static void main(String[] args){
	String str="int";
	String length = StringUtils.substringBetween(str, "(",")");
	String precision = StringUtils.substringBefore(length, ",");
	String scale = StringUtils.substringAfter(length, ",");
}
 
開發者ID:BriData,項目名稱:DBus,代碼行數:7,代碼來源:Support.java

示例12: retrieve

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
@Override
   public Object retrieve(IDataSource snDataSource, Object object) throws RetrieverException {
                               
       HttpClient client = (HttpClient)snDataSource.connect();
       
       // We should use an encoded query in this case because URL parameters do not support the full semantics of a filter.        
       String serviceUrl     = AppProperties.getProperty("service_url");
       String restPath       = AppProperties.getProperty("rest_path");
       String resultLimit    = AppProperties.getProperty("result_limit");
       String period_of_time = AppProperties.getProperty("period_of_time");
       String url1           = "?sysparm_query=active%3Dtrue%5Estate!%3D6%5Esys_created_onRELATIVEGE%40hour%40ago%40" + period_of_time;
       String url2           = "%5Eassignment_group%3D81db147e2b5c79444dde23f119da153b&sysparm_display_value=true&sysparm_fields=sys_id%2Cnumber%2Cshort_description%2Cdescription&sysparm_limit=" + resultLimit;
       
       String finalUrl = serviceUrl + restPath + url1 + url2;
       
       HttpMethod method = new GetMethod(finalUrl);
       method.addRequestHeader("Accept", "application/json");
       String message = "";
       try {
           int status = client.executeMethod(method);
           log.info("Status:" + status);
           BufferedReader rd = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));     
           message = org.apache.commons.io.IOUtils.toString(rd);
       } catch (IOException ioe) {
           throw new RetrieverException(ioe.toString());
       }
       
       // remove leading and ending "{"
       int index = message.indexOf("\"result\":");
       message = message.substring(index+9, message.length()-1);
       
Gson gson = new Gson(); 
       ServiceNowTicket[] wrapper = null;
       try {
           wrapper = gson.fromJson(message, ServiceNowTicket[].class);   
       } catch (Exception e) {
           log.error(e.toString());
       }
       
       if (wrapper == null) {
           log.error("Problem retrieving information from ServiceNow");
           return null;
       }
       log.info("number of fetched tickets: " + wrapper.length);
       List<ServiceNowTicket> ticketList = Arrays.asList(wrapper);  
       
       for (Iterator<ServiceNowTicket> it = ticketList.iterator(); it.hasNext();) {
           ServiceNowTicket ticket = it.next();
           log.info("Fetching IP address and date");
           String source    = StringUtils.substringBetween(ticket.getDescription(), "<Source>", "</Source>");
           String timeStamp = StringUtils.substringBetween(source, "<TimeStamp>", "</TimeStamp>");
           String ipAddress = StringUtils.substringBetween(source, "<IP_Address>", "</IP_Address>");
           log.info("--------------------------");
           log.info("Sys_Id:    " + ticket.getSysId());
           log.info("Number:    " + ticket.getNumber());
           log.info("Timestamp: " + timeStamp);
           log.info("IPAddress: " + ipAddress);      
           log.info("--------------------------");
           log.info("");
           ClaimService service = new ClaimService();
           try {
               // fixing timestamp
               timeStamp = fixTimeStampFormat(timeStamp);
               
               // Sends data to ElasticSearch to find CWL
               IDataSource esDataSource = new ElasticSearchDataSource();
               esDataSource.connect();
               
               // Sends data to CWL database to find email address, first and last name
               
               
               
               
               // save data in the database
               service.addTicket(ticket.getNumber(), ticket.getDescription(), java.sql.Timestamp.valueOf(timeStamp), ipAddress);
           } catch (Exception de) {
               log.error(de.toString());
           }
       }
       return null;
   }
 
開發者ID:armenak,項目名稱:uDetective,代碼行數:82,代碼來源:ServiceNowRetriever.java

示例13: getDecodedAuthnRequest

import org.apache.commons.lang.StringUtils; //導入方法依賴的package包/類
private String getDecodedAuthnRequest(final String content) throws Exception {
    assertTrue(content.contains("<form"));
    final String samlRequestField = StringUtils.substringBetween(content, "SAMLRequest", "</div");
    final String value = StringUtils.substringBetween(samlRequestField, "value=\"", "\"");
    return new String(Base64.getDecoder().decode(value), HttpConstants.UTF8_ENCODING);
}
 
開發者ID:yaochi,項目名稱:pac4j-plus,代碼行數:7,代碼來源:PostSAML2ClientTests.java


注:本文中的org.apache.commons.lang.StringUtils.substringBetween方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。