当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.substringBefore方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.StringUtils.substringBefore方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.substringBefore方法的具体用法?Java StringUtils.substringBefore怎么用?Java StringUtils.substringBefore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.StringUtils的用法示例。


在下文中一共展示了StringUtils.substringBefore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateMapType

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static Object generateMapType(ServiceDefinition def, TypeDefinition td, MetadataType metadataType,
                                      Set<String> resolvedTypes) {
    String keyType = StringUtils.substringAfter(td.getType(), "<");
    keyType = StringUtils.substringBefore(keyType, ",");
    keyType = StringUtils.strip(keyType);
    keyType = StringUtils.isNotEmpty(keyType) ? keyType : "java.lang.Object";
    Object key = generateType(def, keyType, metadataType, resolvedTypes);

    String valueType = StringUtils.substringAfter(td.getType(), ",");
    valueType = StringUtils.substringBefore(valueType, ">");
    valueType = StringUtils.strip(valueType);
    valueType = StringUtils.isNotEmpty(valueType) ? valueType : "java.lang.Object";
    Object value = generateType(def, valueType, metadataType, resolvedTypes);

    Map<Object, Object> map = new HashMap<>();
    map.put(key, value);
    return map;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:19,代码来源:GenericInvokeUtils.java

示例2: fromString

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static MarkPos fromString(@Nullable String str) {
	if (str != null) {
		String commit = StringUtils.substringBefore(str, ":");
		String path = null;
		TextRange mark = null;
		String pathAndMark = StringUtils.substringAfter(str, ":");
		if (pathAndMark.length() != 0) {
			path = StringUtils.substringBefore(pathAndMark, ":");
			String markStr = StringUtils.substringAfter(pathAndMark, ":");
			if (markStr.length() != 0)
				mark = new TextRange(markStr);
		}
		return new MarkPos(commit, path, mark);
	} else {
		return null;
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:18,代码来源:MarkPos.java

示例3: StatementAnalyzer

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Constructor.
 * 
 * @param sql
 *            the string content of the SQL statement.
 * @param parameterValues
 *            the parameter values of a prepared statement in the natural order,
 *            empty list for a (non prepared) statement
 */
public StatementAnalyzer(String sql, List<Object> parameterValues) {

	if (sql == null) {
		throw new IllegalArgumentException(Tag.PRODUCT_PRODUCT_FAIL + "sql can not be null!");
	}

	if (parameterValues == null) {
		throw new IllegalArgumentException(Tag.PRODUCT_PRODUCT_FAIL + "parameterValues can not be null!");
	}

	sql = sql.trim();

	// Remove last ";" because may cause a problem for getting table
	// name with getTableNameFromDmlStatement()

	sql = removeTrailingSemicolons(sql);
	this.sql = sql;

	// Remove tab on input parameter only for testing statement types
	sql = sql.replace('\t', ' ');
	sql = sql.trim(); // re-trim!
	this.statementType = StringUtils.substringBefore(sql, BLANK);

	this.parameterValues = parameterValues;
}
 
开发者ID:kawansoft,项目名称:aceql-http,代码行数:35,代码来源:StatementAnalyzer.java

示例4: normalizePath

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Normalize the path of a service by removing the query string and everything after a semi-colon.
 *
 * @param service the service to normalize
 * @return the normalized path
 */
private static String normalizePath(final Service service) {
    String path = service.getId();
    path = StringUtils.substringBefore(path, "?");
    path = StringUtils.substringBefore(path, ";");
    path = StringUtils.substringBefore(path, "#");
    return path;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:14,代码来源:TicketGrantingTicketImpl.java

示例5: getType

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Reflection to get the type of a given field, even nested or in a superclass.
 * @param rootClass
 * @param attributePath field name like "surname" or even a path like "friend.name"
 * @return
 * @throws NoSuchFieldException if the field is not found in the class hierarchy
 * @throws SecurityException
 */
public Class getType(Class rootClass, String attributePath) throws NoSuchFieldException, SecurityException {
	if (StringUtils.isBlank(attributePath)) {
		return rootClass;
	}
	String attributeName = StringUtils.substringBefore(attributePath, ".");
	Field field = null;
	NoSuchFieldException exception = null;
	while (field==null && rootClass!=null) {
		try {
			field = rootClass.getDeclaredField(attributeName);
		} catch (NoSuchFieldException e) {
			if (exception==null) {
				exception=e;
			}
			rootClass = rootClass.getSuperclass();
		}
	}
	if (field==null) {
		if (exception!=null) {
			throw exception;
		} else {
			throw new NoSuchFieldException("No field " + attributeName + " found in hierarchy");
		}
	}
	Class attributeType = field.getType();
	// If it's a list, look for the list type
	if (attributeType == java.util.List.class) {
		// TODO check if the attributeType is an instance of java.util.Collection
		ParameterizedType parameterizedType = (ParameterizedType)field.getGenericType();
		if (parameterizedType!=null) {
			Type[] types = parameterizedType.getActualTypeArguments();
			if (types.length==1) {
				attributeType = (Class<?>) types[0];
			}
		}
	}
	return getType(attributeType, StringUtils.substringAfter(attributePath, "."));
}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:47,代码来源:YadaUtil.java

示例6: TextRange

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public TextRange(String markStr) {
	String begin = StringUtils.substringBefore(markStr, "-");
	String end = StringUtils.substringAfter(markStr, "-");
	beginLine = Integer.parseInt(StringUtils.substringBefore(begin, "."))-1;
	beginChar = Integer.parseInt(StringUtils.substringAfter(begin, "."));
	endLine = Integer.parseInt(StringUtils.substringBefore(end, "."))-1;
	endChar = Integer.parseInt(StringUtils.substringAfter(end, "."));
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:9,代码来源:TextRange.java

示例7: extractVariableName

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String extractVariableName(String path, int start, int end, Set<String> variables) {
    String substring = StringUtils.substring(path, start, end);
    String stripped = StringUtils.strip(substring, "{}");
    String variable = StringUtils.substringBefore(stripped, ":");
    variables.add(variable);
    return String.format("${%s}", variable);
}
 
开发者ID:sdadas,项目名称:spring2ts,代码行数:8,代码来源:ServicePath.java

示例8: getClassName

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static String getClassName(String code) {
    String className = StringUtils.substringBefore(code, "{");
    if (StringUtils.isBlank(className)) {
        return className;
    }
    if (StringUtils.contains(code, " class ")) {
        className = StringUtils.substringAfter(className, " class ");
        if (StringUtils.contains(className, " extends ")) {
            className = StringUtils.substringBefore(className, " extends ").trim();
        } else if (StringUtils.contains(className, " implements ")) {
            className = StringUtils.trim(StringUtils.substringBefore(className, " implements "));
        } else {
            className = StringUtils.trim(className);
        }
    } else if (StringUtils.contains(code, " interface ")) {
        className = StringUtils.substringAfter(className, " interface ");
        if (StringUtils.contains(className, " extends ")) {
            className = StringUtils.substringBefore(className, " extends ").trim();
        } else {
            className = StringUtils.trim(className);
        }
    } else if (StringUtils.contains(code, " enum ")) {
        className = StringUtils.trim(StringUtils.substringAfter(className, " enum "));
    } else {
        return StringUtils.EMPTY;
    }
    return className;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:29,代码来源:DynaCode.java

示例9: getRootPackagePath

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static Path getRootPackagePath(final Class<?> suiteClass) throws URISyntaxException {
	final String rootPackage = StringUtils.substringBefore(suiteClass.getName(), ".");
	final URL url = XTFTestSuite.class.getResource("/" + suiteClass.getName().replace('.', '/') + ".class");

	Path rootPackagePath = Paths.get(url.toURI());

	// get the root package
	while (!rootPackage.equals(rootPackagePath.getFileName().toString())) {
		rootPackagePath = rootPackagePath.getParent();
	}

	// return test class location (parent of root package)
	return rootPackagePath.getParent();
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:15,代码来源:XTFTestSuiteHelper.java

示例10: onCreate

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_appoinments);

    if(isNetworkAvailable()) {
        //Retrieve data from LocalDB
        fullName = LocalDB.getFullName();
        email = LocalDB.getEmail();
        phoneNumber = LocalDB.getEmail();
        profilePicUrl = LocalDB.getProfilePicUri();

        //View declerations
        profilePic = findViewById(R.id.appoinmentProfilePic);
        fullNameTextView = findViewById(R.id.userNameTextView);
        appointmentTextView = findViewById(R.id.appoinmentTextView);
        verticalLayout = findViewById(R.id.verticalLayout);

        //Set the name of the user
        fullName = StringUtils.substringBefore(fullName, " ");
        fullNameTextView.setText(fullName);


        //Set the profile pic of the user
        Picasso.with(this).
                load(profilePicUrl)
                .placeholder(R.drawable.profpic)
                .error(R.drawable.profpic)
                .transform(new CircleTransform())
                .into(profilePic);
    }

    else
    {
        Toasty.warning(Appoinments.this,"Please Check Your Internet Connection and Try Again", Toast.LENGTH_SHORT).show();
    }

}
 
开发者ID:Nihal369,项目名称:Amaro,代码行数:39,代码来源:Appoinments.java

示例11: parseRespond

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * 解析弹幕服务器接收到的协议数据
 * @param data
 * @return
 */
public Map<String, Object> parseRespond(String data){
	Map<String, Object> rtnMsg = new HashMap<String, Object>();
	
	//处理数据字符串末尾的'/0字符'
	data = StringUtils.substringBeforeLast(data, "/");
	
	//对数据字符串进行拆分
	String[] buff = data.split("/");
	
	//分析协议字段中的key和value值
	for(String tmp : buff){
		//获取key值
		String key = StringUtils.substringBefore(tmp, "@=");
		//获取对应的value值
		Object value = StringUtils.substringAfter(tmp, "@=");
		
		//如果value值中包含子序列化值,则进行递归分析
		if(StringUtils.contains((String)value, "@A")){
			value = ((String)value).replaceAll("@S", "/").replaceAll("@A", "@");
			value = this.parseRespond((String)value);
		}
		
		//将分析后的键值对添加到信息列表中
		rtnMsg.put(key, value);
	}
	
	return rtnMsg;
	
}
 
开发者ID:lslxy1021,项目名称:DYB,代码行数:35,代码来源:MsgView.java

示例12: stripPackage

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String stripPackage(String name) {
    String canonicalName = StringUtils.substringBefore(name, "<");
    if(StringUtils.contains(canonicalName, '.')) {
        return StringUtils.substringAfterLast(canonicalName, ".");
    } else {
        return canonicalName;
    }
}
 
开发者ID:sdadas,项目名称:spring2ts,代码行数:9,代码来源:JavaTypescriptTypeMapping.java

示例13: fromString

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public void fromString(String host) {
    if (StringUtils.isBlank(host)) {
        throw new IllegalArgumentException("host should not be blank");
    }

    String[] ips = StringUtils.split(host, ",");
    if (ips.length > 1) {
        ipv6 = ips[1];
    }
    ipv4 = StringUtils.substringBefore(ips[0], ":");
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:12,代码来源:StackSnapshot.java

示例14: getMethod

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Return the method to call according to the url.
 *
 * @param request the incoming http request
 * @return the method to call according to the url
 */
private String getMethod(final HttpServletRequest request) {
    String method = request.getRequestURI();
    if (method.indexOf('?') >= 0) {
        method = StringUtils.substringBefore(method, "?");
    }
    final int pos = method.lastIndexOf('/');
    if (pos >= 0) {
        method = method.substring(pos + 1);
    }
    return method;
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:18,代码来源:BaseOAuthWrapperController.java

示例15: getPrincipalWithoutEmailTail

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String getPrincipalWithoutEmailTail(String principalName) {
	return StringUtils.substringBefore(principalName, "@");
}
 
开发者ID:daflockinger,项目名称:poppynotes,代码行数:4,代码来源:NoteEncryptionServiceImpl.java


注:本文中的org.apache.commons.lang3.StringUtils.substringBefore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。