本文整理汇总了Java中org.apache.commons.lang3.StringUtils.trim方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.trim方法的具体用法?Java StringUtils.trim怎么用?Java StringUtils.trim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.trim方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: trim
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* 分别去空格
*
* @param paramArray
* @return
*/
public static final String[] trim(String[] paramArray) {
if (ArrayUtils.isEmpty(paramArray)) {
return paramArray;
}
String[] resultArray = new String[paramArray.length];
for (int i = 0; i < paramArray.length; i++) {
String param = paramArray[i];
resultArray[i] = StringUtils.trim(param);
}
return resultArray;
}
示例2: quickConnectSelectionChanged
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Action
public void quickConnectSelectionChanged(final NSComboBox sender) {
final String input = StringUtils.trim(sender.stringValue());
if(StringUtils.isBlank(input)) {
return;
}
// First look for equivalent bookmarks
for(Host h : bookmarks) {
if(BookmarkNameProvider.toString(h).equals(input)) {
this.mount(h);
return;
}
}
// Try to parse the input as a URL and extract protocol, hostname, username and password if any.
this.mount(HostParser.parse(input));
}
示例3: loadShader
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static ShaderLoader loadShader(IResourceManager resourceManager, ShaderLoader.ShaderType type, String filename) throws IOException
{
ShaderLoader shaderloader = (ShaderLoader)type.getLoadedShaders().get(filename);
if (shaderloader == null)
{
ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + filename + type.getShaderExtension());
BufferedInputStream bufferedinputstream = new BufferedInputStream(resourceManager.getResource(resourcelocation).getInputStream());
byte[] abyte = toByteArray(bufferedinputstream);
ByteBuffer bytebuffer = BufferUtils.createByteBuffer(abyte.length);
bytebuffer.put(abyte);
bytebuffer.position(0);
int i = OpenGlHelper.glCreateShader(type.getShaderMode());
OpenGlHelper.glShaderSource(i, bytebuffer);
OpenGlHelper.glCompileShader(i);
if (OpenGlHelper.glGetShaderi(i, OpenGlHelper.GL_COMPILE_STATUS) == 0)
{
String s = StringUtils.trim(OpenGlHelper.glGetShaderInfoLog(i, 32768));
JsonException jsonexception = new JsonException("Couldn\'t compile " + type.getShaderName() + " program: " + s);
jsonexception.func_151381_b(resourcelocation.getResourcePath());
throw jsonexception;
}
shaderloader = new ShaderLoader(type, i, filename);
type.getLoadedShaders().put(filename, shaderloader);
}
return shaderloader;
}
示例4: modelGetterMethodGenerated
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* 解析处理注释,增加 getXxxText() 方法
* 注释格式范例:
* @enum 0: 有效期; 1: 无效
*/
@Override
public boolean modelGetterMethodGenerated(Method method, TopLevelClass topLevelClass,
IntrospectedColumn introspectedColumn,
IntrospectedTable introspectedTable,
ModelClassType modelClassType) {
String remarks = introspectedColumn.getRemarks();
int jdbcType = introspectedColumn.getJdbcType();
remarks = StringUtils.trimToNull(remarks);
if (remarks == null) {
return true;
}
if (!remarks.contains("@enum")) {
return true;
}
String annotation = remarks.substring(remarks.indexOf("@enum") + 5);
String[] items = StringUtils.split(annotation, ';');
StringBuilder mapInitSb = new StringBuilder("new HashMap<Object, String>(){{");
for (String item : items) {
if (!item.contains(":")) {
continue;
}
String[] kv = item.split(":");
String k = StringUtils.trim(kv[0]);
String v = StringUtils.trim(kv[1]);
mapInitSb.append("put(");
if (jdbcType == Types.TINYINT) {
mapInitSb.append("(byte)");
}
mapInitSb.append(k).append(",")
.append("\"").append(v).append("\");");
}
mapInitSb.append("}}");
// 增加常量
String fieldName = String.format("%sMap", introspectedColumn.getJavaProperty());
Field field = new Field(
fieldName,
new FullyQualifiedJavaType("java.util.HashMap<Object, String>")
);
field.setVisibility(JavaVisibility.PRIVATE);
field.setStatic(true);
field.setFinal(true);
field.setInitializationString(mapInitSb.toString());
topLevelClass.addField(field);
// 增加方法
Method textMethod = new Method(String.format("%sText", method.getName()));
textMethod.setReturnType(new FullyQualifiedJavaType(String.class.getCanonicalName()));
textMethod.setVisibility(JavaVisibility.PUBLIC);
if (jdbcType == Types.TINYINT) {
textMethod.addBodyLine(String.format("return %s.get((byte)this.%s);", fieldName, introspectedColumn.getJavaProperty()));
} else {
textMethod.addBodyLine(String.format("return %s.get(this.%s);", fieldName, introspectedColumn.getJavaProperty()));
}
remarks = remarks.replaceAll("\n", "\\\\n").replaceAll("\"", "\\\\\"");
textMethod.addAnnotation(
String.format("@ApiModelProperty(value = \"%s\")", remarks)
);
topLevelClass.addImportedType(new FullyQualifiedJavaType(HashMap.class.getCanonicalName()));
topLevelClass.addMethod(textMethod);
return true;
}
示例5: activate
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Activate
protected void activate(final Map<String, Object> props) throws ServiceException {
logger.debug("activate(): props = {}", props);
this.filterRoots = PropertiesUtil.toStringArray(props.get(PROP_FILTER_ROOTS), null);
if (this.filterRoots == null) {
throw new ServiceException(PROP_FILTER_ROOTS + " is mandatory!");
}
final String localDirValue = StringUtils.trim(PropertiesUtil.toString(props.get(PROP_LOCAL_PATH), null));
if (localDirValue == null) {
throw new ServiceException(PROP_LOCAL_PATH + " is mandatory!");
}
this.localDir = new File(localDirValue);
this.overwriteConfigFiles = PropertiesUtil.toBoolean(props.get(PROP_OVERWRITE_CONFIG_FILES),
DEFAULT_OVERWRITE_CONFIG_FILES);
this.syncOnceType = PropertiesUtil.toString(props.get(PROP_SYNC_ONCE_TYPE), SYNC_ONCE_DISABLED);
generateFiles();
Long expectedSyncOnceTime = null;
if (this.willSyncOnce) {
expectedSyncOnceTime = PropertiesUtil.toLong(props.get(PROP_SYNC_ONCE_EXPECTED_TIME),
DEFAULT_SYNC_ONCE_EXPECTED_TIME);
}
this.serviceSettings.addSyncRoot(this.localDir, expectedSyncOnceTime);
}
示例6: adjustName
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public String adjustName(String name) {
name = StringUtils.trim(name);
if (name.equals(" 片仔?")) {
return "片仔癀";
}
return name;
}
示例7: getValue
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static String getValue(XSSFCell xssFCell) {
String str = null;
if(xssFCell == null){
return str;
}
if (xssFCell.getCellType() == XSSFCell.CELL_TYPE_BOOLEAN) {
str = String.valueOf(xssFCell.getBooleanCellValue());
} else if (xssFCell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) {
str = String.valueOf(new DecimalFormat("#").format(xssFCell.getNumericCellValue()));
} else {
str = String.valueOf(xssFCell.getStringCellValue());
}
return StringUtils.trim(str);
}
示例8: loadShader
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static ShaderLoader loadShader(IResourceManager resourceManager, ShaderLoader.ShaderType type, String filename) throws IOException
{
ShaderLoader shaderloader = (ShaderLoader)type.getLoadedShaders().get(filename);
if (shaderloader == null)
{
ResourceLocation resourcelocation = new ResourceLocation("shaders/program/" + filename + type.getShaderExtension());
IResource iresource = resourceManager.getResource(resourcelocation);
try
{
byte[] abyte = IOUtils.toByteArray((InputStream)(new BufferedInputStream(iresource.getInputStream())));
ByteBuffer bytebuffer = BufferUtils.createByteBuffer(abyte.length);
bytebuffer.put(abyte);
bytebuffer.position(0);
int i = OpenGlHelper.glCreateShader(type.getShaderMode());
OpenGlHelper.glShaderSource(i, bytebuffer);
OpenGlHelper.glCompileShader(i);
if (OpenGlHelper.glGetShaderi(i, OpenGlHelper.GL_COMPILE_STATUS) == 0)
{
String s = StringUtils.trim(OpenGlHelper.glGetShaderInfoLog(i, 32768));
JsonException jsonexception = new JsonException("Couldn\'t compile " + type.getShaderName() + " program: " + s);
jsonexception.setFilenameAndFlush(resourcelocation.getResourcePath());
throw jsonexception;
}
shaderloader = new ShaderLoader(type, i, filename);
type.getLoadedShaders().put(filename, shaderloader);
}
finally
{
IOUtils.closeQuietly((Closeable)iresource);
}
}
return shaderloader;
}
示例9: adjustName
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public String adjustName(String name) {
return StringUtils.trim(name);
}
示例10: handleSingleStr
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
protected String handleSingleStr(String input) {
return StringUtils.trim(input);
}
示例11: setKey
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public void setKey(String key) {
this.key = StringUtils.trim(key);
}
示例12: setReview
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
*
* 设置review
*
*
* @param review
* review
*/
public void setReview(String review) {
this.review = StringUtils.trim(review);
}
示例13: setKey
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
*
* 设置key
*
* @param key
* key
*/
public void setKey(String key) {
this.key = StringUtils.trim(key);
}
示例14: setPassword
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
*
* 设置password
*
*
* @param password
* password
*/
public void setPassword(String password) {
this.password = StringUtils.trim(password);
}
示例15: setUsername
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
*
* 设置username
*
*
* @param username
* username
*/
public void setUsername(String username) {
this.username = StringUtils.trim(username);
}