Java Code Examples for org.apache.commons.lang3.StringUtils.trim()

The following are Jave code examples for showing how to use trim() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: mumu-core   File: DataUtil.java   View Source Code Vote up 6 votes
/**
 * 分别去空格
 * 
 * @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;
}
 
Example 2
Project: cyberduck   File: BrowserController.java   View Source Code Vote up 6 votes
@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));
}
 
Example 3
Project: BaseClient   File: ShaderLoader.java   View Source Code Vote up 5 votes
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;
}
 
Example 4
Project: mumu   File: DataUtil.java   View Source Code Vote up 5 votes
/**
 * 分别去空格
 * 
 * @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;
}
 
Example 5
Project: aem-vltsync   File: InitialRegistrationImpl.java   View Source Code Vote up 5 votes
@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);
}
 
Example 6
Project: JAVA-   File: DataUtil.java   View Source Code Vote up 5 votes
/**
 * 分别去空格
 * 
 * @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;
}
 
Example 7
Project: qfii-tracker   File: ShanghaiConnectParser.java   View Source Code Vote up 5 votes
@Override
public String adjustName(String name) {
  name = StringUtils.trim(name);
  if (name.equals(" 片仔?")) {
    return "片仔癀";
  }
  return name;
}
 
Example 8
Project: tianti   File: ExcelUtils.java   View Source Code Vote up 5 votes
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);
}
 
Example 9
Project: CustomWorldGen   File: ShaderLoader.java   View Source Code Vote up 5 votes
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;
}
 
Example 10
Project: automat   File: DataUtil.java   View Source Code Vote up 5 votes
/**
 * 分别去空格
 * 
 * @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;
}
 
Example 11
Project: Backmemed   File: ShaderLoader.java   View Source Code Vote up 5 votes
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;
}
 
Example 12
Project: qfii-tracker   File: ShenzhenConnectParser.java   View Source Code Vote up 4 votes
@Override
public String adjustName(String name) {
  return StringUtils.trim(name);
}
 
Example 13
Project: mybatis-generator-tool   File: StatusTextPlugin.java   View Source Code Vote up 4 votes
/**
 * 解析处理注释,增加 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;
}
 
Example 14
Project: vscrawler   File: Trim.java   View Source Code Vote up 4 votes
@Override
protected String handleSingleStr(String input) {
    return StringUtils.trim(input);
}
 
Example 15
Project: Yidu   File: ArticleListAction.java   View Source Code Vote up 4 votes
public void setKey(String key) {
    this.key = StringUtils.trim(key);
}
 
Example 16
Project: Yidu   File: ReviewListAction.java   View Source Code Vote up 2 votes
/**
 * 
 * 设置review
 * 
 * 
 * @param review
 *            review
 */
public void setReview(String review) {
    this.review = StringUtils.trim(review);
}
 
Example 17
Project: Yidu   File: SearchAction.java   View Source Code Vote up 2 votes
/**
 * 
 * 设置key
 * 
 * @param key
 *            key
 */
public void setKey(String key) {
    this.key = StringUtils.trim(key);
}
 
Example 18
Project: YiDu-Novel   File: IndexAction.java   View Source Code Vote up 2 votes
/**
 * 
 * 设置password
 * 
 * 
 * @param password
 *            password
 */
public void setPassword(String password) {
    this.password = StringUtils.trim(password);
}
 
Example 19
Project: Yidu   File: IndexAction.java   View Source Code Vote up 2 votes
/**
 * 
 * 设置username
 * 
 * 
 * @param username
 *            username
 */
public void setUsername(String username) {
    this.username = StringUtils.trim(username);
}
 
Example 20
Project: Yidu   File: MobileSearchAction.java   View Source Code Vote up 2 votes
/**
 * 
 * 设置key
 * 
 * 
 * @param key
 *            key
 */
public void setKey(String key) {
    this.key = StringUtils.trim(key);
}