當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。