本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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, "."));
}
示例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, "."));
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
}
示例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;
}
示例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;
}
}
示例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], ":");
}
示例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;
}
示例15: getPrincipalWithoutEmailTail
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String getPrincipalWithoutEmailTail(String principalName) {
return StringUtils.substringBefore(principalName, "@");
}