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


Java StringUtils.trim方法代码示例

本文整理汇总了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;
}
 
开发者ID:mumucommon,项目名称:mumu-core,代码行数:18,代码来源:DataUtil.java

示例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));
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:17,代码来源:BrowserController.java

示例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;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:31,代码来源:ShaderLoader.java

示例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;
}
 
开发者ID:yinheli,项目名称:mybatis-generator-tool,代码行数:80,代码来源:StatusTextPlugin.java

示例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);
}
 
开发者ID:daniel-lima,项目名称:aem-vltsync,代码行数:31,代码来源:InitialRegistrationImpl.java

示例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;
}
 
开发者ID:longkerdandy,项目名称:qfii-tracker,代码行数:9,代码来源:ShanghaiConnectParser.java

示例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);
}
 
开发者ID:xujeff,项目名称:tianti,代码行数:15,代码来源:ExcelUtils.java

示例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;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:39,代码来源:ShaderLoader.java

示例9: adjustName

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public String adjustName(String name) {
  return StringUtils.trim(name);
}
 
开发者ID:longkerdandy,项目名称:qfii-tracker,代码行数:5,代码来源:ShenzhenConnectParser.java

示例10: handleSingleStr

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
protected String handleSingleStr(String input) {
    return StringUtils.trim(input);
}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:5,代码来源:Trim.java

示例11: setKey

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public void setKey(String key) {
    this.key = StringUtils.trim(key);
}
 
开发者ID:Chihpin,项目名称:Yidu,代码行数:4,代码来源:ArticleListAction.java

示例12: setReview

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * 
 * 设置review
 * 
 * 
 * @param review
 *            review
 */
public void setReview(String review) {
    this.review = StringUtils.trim(review);
}
 
开发者ID:Chihpin,项目名称:Yidu,代码行数:12,代码来源:ReviewListAction.java

示例13: setKey

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * 
 * 设置key
 * 
 * @param key
 *            key
 */
public void setKey(String key) {
    this.key = StringUtils.trim(key);
}
 
开发者ID:Chihpin,项目名称:Yidu,代码行数:11,代码来源:SearchAction.java

示例14: setPassword

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * 
 * 设置password
 * 
 * 
 * @param password
 *            password
 */
public void setPassword(String password) {
    this.password = StringUtils.trim(password);
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:12,代码来源:IndexAction.java

示例15: setUsername

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * 
 * 设置username
 * 
 * 
 * @param username
 *            username
 */
public void setUsername(String username) {
    this.username = StringUtils.trim(username);
}
 
开发者ID:Chihpin,项目名称:Yidu,代码行数:12,代码来源:IndexAction.java


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