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


Java StringUtils.replace方法代码示例

本文整理汇总了Java中org.apache.commons.lang.StringUtils.replace方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.replace方法的具体用法?Java StringUtils.replace怎么用?Java StringUtils.replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.StringUtils的用法示例。


在下文中一共展示了StringUtils.replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processToken

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private String processToken(TokenData data, String template) {
    template = StringUtils.replace(template, EmailTemplateToken.ManageUrl.getToken(), data.getManageUrl());
    template = StringUtils.replace(template, EmailTemplateToken.MsgTimeHour.getToken(), data.getTimeHour());
    template = StringUtils.replace(template, EmailTemplateToken.MsgTimeMin.getToken(), data.getTimeMin());
    template = StringUtils.replace(template, EmailTemplateToken.MsgTimeSec.getToken(), data.getTimeSec());
    template = StringUtils.replace(template, EmailTemplateToken.ReceiverAddress.getToken(), data.getReceiverAddress());
    template = StringUtils.replace(template, EmailTemplateToken.SenderAddress.getToken(), data.getSenderAddress());
    template = StringUtils.replace(template, EmailTemplateToken.SenderName.getToken(), data.getSenderName());
    template = StringUtils.replace(template, EmailTemplateToken.SenderAvatar.getToken(), senderAvatarId);
    template = StringUtils.replace(template, EmailTemplateToken.Sender.getToken(), data.getSender());
    template = StringUtils.replace(template, EmailTemplateToken.RoomAddress.getToken(), data.getRoomAddress());
    template = StringUtils.replace(template, EmailTemplateToken.RoomName.getToken(), data.getRoomName());
    template = StringUtils.replace(template, EmailTemplateToken.Room.getToken(), data.getRoom());

    return template;
}
 
开发者ID:kamax-io,项目名称:matrix-appservice-email,代码行数:17,代码来源:EmailFormatterOutboud.java

示例2: closeEditorIfAlreadyOpen

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private boolean closeEditorIfAlreadyOpen(IPath jobFilePath, String fileName) {

		String jobPathRelative = StringUtils.removeStart(jobFilePath.toString(), "..");
		jobPathRelative = StringUtils.removeStart(jobPathRelative, "/");
		String jobPathAbsolute = StringUtils.replace(jobPathRelative, "/", "\\");
		IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		if (activeWorkbenchWindow != null) {
			IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
			for (IEditorReference editorRefrence : activePage.getEditorReferences()) {
				if (StringUtils.equals(editorRefrence.getTitleToolTip(), jobPathRelative)
						|| StringUtils.equals(editorRefrence.getTitleToolTip(), jobPathAbsolute)
						|| fileName.equals(editorRefrence.getTitleToolTip())) {
					IEditorPart editor = editorRefrence.getEditor(true);
					if (!activePage.closeEditor(editor, true)) {
						LOGGER.debug("Editor not closed");
					}
					LOGGER.debug("Editor closed");
					return true;
				}
			}
		}
		return false;
	}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:24,代码来源:ExternalSchemaUpdaterHandler.java

示例3: updateClasspath

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/** Remove the jar file to the classpath in the MANIFEST.MF file */
   @Override
   protected void updateClasspath(Manifest manifest) throws DeployException {
Attributes mainAttributes = manifest.getMainAttributes();
String classpath = null;
if (mainAttributes != null) {
    classpath = mainAttributes.getValue(Attributes.Name.CLASS_PATH);
}

String newJar = getJarFileNameWithDotSlash();
String newClasspath = null;
if (classpath != null) {
    newClasspath = StringUtils.replace(classpath, newJar, "");
    mainAttributes.put(Attributes.Name.CLASS_PATH, newClasspath);
    if (classpath.length() < newClasspath.length()) {
	System.out.println("Removed " + newJar + " from classpath");
    }
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:RemoveToolContextClasspathTask.java

示例4: sqlInject

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * SQL注入过滤
 *
 * @param str 待验证的字符串
 */
public static String sqlInject(String str) {
    if (StringUtils.isBlank(str)) {
        return null;
    }
    //去掉'|"|;|\字符
    str = StringUtils.replace(str, "'", "");
    str = StringUtils.replace(str, "\"", "");
    str = StringUtils.replace(str, ";", "");
    str = StringUtils.replace(str, "\\", "");

    //转换成小写
    str = str.toLowerCase();

    //非法字符
    String[] keywords = {"master", "truncate", "insert", "select", "delete", "update", "declare", "alert", "drop"};
    String finalStr = str;
    //判断是否包含非法字符
    return Arrays.stream(keywords).filter(finalStr::contains).findFirst().orElseThrow(() -> new RRException("包含非法字符"));
}
 
开发者ID:davichi11,项目名称:my-spring-boot-project,代码行数:25,代码来源:SQLFilter.java

示例5: sqlInject

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * SQL注入过滤
 * @param str  待验证的字符串
 */
public static String sqlInject(String str){
    if(StringUtils.isBlank(str)){
        return null;
    }
    //去掉'|"|;|\字符
    str = StringUtils.replace(str, "'", "");
    str = StringUtils.replace(str, "\"", "");
    str = StringUtils.replace(str, ";", "");
    str = StringUtils.replace(str, "\\", "");

    //转换成小写
    str = str.toLowerCase();

    //非法字符
    String[] keywords = {"master", "truncate", "insert", "select", "delete", "update", "declare", "alert", "drop"};

    //判断是否包含非法字符
    for(String keyword : keywords){
        if(str.indexOf(keyword) != -1){
            throw new RRException("包含非法字符");
        }
    }

    return str;
}
 
开发者ID:guolf,项目名称:pds,代码行数:30,代码来源:SQLFilter.java

示例6: isJobAlreadyOpen

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private boolean isJobAlreadyOpen(IPath jobFilePath) {
	
	String jobPathRelative = StringUtils.removeStart(jobFilePath.toString(), "..");
	jobPathRelative=StringUtils.removeStart(jobPathRelative, "/");
	String jobPathAbsolute = StringUtils.replace(jobPathRelative, "/", "\\");
	for (IEditorReference editorRefrence : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
			.getEditorReferences()) {
		if (StringUtils.equals(editorRefrence.getTitleToolTip(), jobPathRelative)) {
			return true;
		}else if (StringUtils.equals(editorRefrence.getTitleToolTip(), jobPathAbsolute)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:16,代码来源:SubJobOpenAction.java

示例7: CheckRedstone

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
@EventHandler
public void CheckRedstone(BlockRedstoneEvent event){
	if(ConfigOptimize.AntiRedstoneenable){
		if(event.getOldCurrent() > event.getNewCurrent()){
            return;
        }
        final Block block = event.getBlock();
        Location loc = block.getLocation();
        if(CheckedTimes.get(loc) == null){
            CheckedTimes.put(loc, 0);
        }
        CheckedTimes.put(loc, CheckedTimes.get(loc) + 1);

        if(CheckedTimes.get(loc) > ConfigOptimize.AntiRedstoneTimes){
            if(ConfigOptimize.AntiRedstoneRemoveBlockList.contains(block.getType().name())){
	Bukkit.getScheduler().runTaskLater(EscapeLag.MainThis,new Runnable(){
		public void run(){
			block.setType(Material.AIR);
		}
	},1);
                String message = ConfigOptimize.AntiRedstoneMessage;
                message = StringUtils.replace(message, "%location%", loc.toString());
                AzureAPI.bc(message);
            }
        }
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:28,代码来源:AntiRedstone.java

示例8: populateUIDataFromExternalData

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * initialize ui object from external file data.
 * 
 * @param filterLogicDataStructure
 * @param typeTransformOpertaionList
 */
public void populateUIDataFromExternalData(FilterLogicDataStructure filterLogicDataStructure,
		List<JAXBElement<?>> typeTransformOpertaionList) {
	TypeExternalSchema typeExternalSchema=(TypeExternalSchema) filter
			.getOperationOrExpressionOrIncludeExternalOperation().get(0).getValue();
	String filePath = typeExternalSchema.getUri();
	filePath = StringUtils.replace(filePath, "../","");
	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	 IPath relativePath=null;
		 relativePath=workspace.getRoot().getFile(new Path(filePath)).getLocation();
	 if(StringUtils.equals("includeExternalExpression", ((JAXBElement<?>) typeTransformOpertaionList.get(0)).getName().getLocalPart()))
	 {
		 	ExpressionData expressionData=FilterLogicExternalOperationExpressionUtil.INSTANCE
			 .importExpression(new File(relativePath.toString()), null, false, uiComponent.getComponentName());
			expressionData.getExternalExpressionData().setExternal(true);
			expressionData.getExternalExpressionData().setFilePath(filePath);
			filterLogicDataStructure.setExpressionEditorData(expressionData);
	 }
	 else {
			OperationClassData operationClassData=FilterLogicExternalOperationExpressionUtil.INSTANCE
		    		 .importOperation(new File(relativePath.toString()), null, false, uiComponent.getComponentName());
		    operationClassData.getExternalOperationClassData().setExternal(true);
		    operationClassData.getExternalOperationClassData().setFilePath(filePath);
		    filterLogicDataStructure.setOperationClassData(operationClassData);
			 
	 }
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:33,代码来源:FilterUiConverter.java

示例9: strip

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
/**
 * @param value 待处理内容
 * @return
 * @Description MongoDB防注入
 */
@Override
public String strip(String value) {


    for (int i=0;i<blackList.length;i++){
        value=StringUtils.replace(value,blackList[i],"");
    }
    return value;
}
 
开发者ID:T-baby,项目名称:ICEWall,代码行数:15,代码来源:MongoInjection.java

示例10: parseTime

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
private DateTime parseTime(String time) {
    String reformatTime = StringUtils.replace(StringUtils.replace(time, "T", " "), "Z", "");
    DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
    return formatter.parseDateTime(reformatTime);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:6,代码来源:DefaultInfluxMetric.java

示例11: AliPayBaseResponseParser

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public AliPayBaseResponseParser(Class<? extends RESPONSE> clazz, String methodName) {
    if (clazz == null) {
        throw new NullArgumentException("clazz");
    }
    if (StringUtils.isBlank(methodName)) {
        throw new NullArgumentException("methodName");
    }
    __class = clazz;
    __methodName = StringUtils.replace(methodName, ".", "_") + IAliPay.Const.RESPONSE_SUFFIX;
}
 
开发者ID:suninformation,项目名称:ymate-payment-v2,代码行数:11,代码来源:AliPayBaseResponseParser.java

示例12: getHtmlOriginalContent

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public String getHtmlOriginalContent(String originalContent) {
    originalContent = StringUtils.replace(originalContent, "\n", "<br>");
    originalContent = StringUtils.replace(originalContent, "\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
    return StringEscapeUtils.escapeJavaScript(originalContent);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:6,代码来源:NumberFormatUtil.java

示例13: getHtmlOriginalContent

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public String getHtmlOriginalContent() {
    return StringUtils.replace(originalContent, "\n", "<br>");
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:4,代码来源:AutoKeeperStat.java

示例14: musicGetInfoItunes

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public static LinkedList<MusicInfo> musicGetInfoItunes(String name, String max_result, String orderBy, String artist, String year) throws UnirestException
    {
        String name_request = name.replace(" ", "%20");
        String artist_request = artist.trim().replace(" ", "%20");
        LinkedList<MusicInfo> lis = new LinkedList<MusicInfo>();
        String urlRequest = "";
        if (!artist_request.equals("")) urlRequest="https://itunes.apple.com/search" + "?term=" + name_request+"%20"+artist_request+"&media=music";
        else urlRequest="https://itunes.apple.com/search" + "?term=" + name_request+"&media=music";
        String year_request=year;
        if (year_request.trim().equals("") || year.length()<4) year_request="";
        HttpResponse<JsonNode> jsonResponse = Unirest.get(urlRequest).asJson();
        //System.out.println(jsonResponse.getBody());
        JSONObject jsonObject = new JSONObject(jsonResponse.getBody());
        JSONArray jArray = jsonObject.getJSONArray("array");

        int iteration = 0;
        //Generate list of results
        for (int i = 0; i < jArray.length(); i++) {
            JSONArray resultInfo = jArray.getJSONObject(i).getJSONArray("results");
            for (int k = 0; k < resultInfo.length(); k++) {
                JSONObject result = resultInfo.getJSONObject(k);
                MusicInfo b = new MusicInfo();
                b.setTitle(result.getString("trackName"));
                if (result.has("artistName")) b.setArtist(result.getString("artistName"));
                if (result.has("primaryGenreName")) b.setGenre(result.getString("primaryGenreName"));
                if (result.has("releaseDate")) {
                    String y=result.getString("releaseDate");
                    b.setReleaseDate(y.substring(0,y.indexOf("T")));
                }
                if(result.has("artworkUrl100")) {
                    String link_reverse=StringUtils.reverse(result.getString("artworkUrl100"));
                    link_reverse=StringUtils.replace(link_reverse,"001","215",2);
                    b.setLinkImage(StringUtils.reverse(link_reverse));
                    //iTunes cover link doesn't support HTTPS
                }
                if (result.has("collectionName")) b.setCollection(result.getString("collectionName"));
                if (result.has("description")) b.setOverview(result.getString("description"));
                if (result.has("previewUrl")) b.setLinkpreview(result.getString("previewUrl"));
                if(b.getReleaseDate().substring(0,4).equals(year) || year_request.equals("")) lis.add(b);
                //System.out.println(b);
                if (!max_result.equals("all") && iteration == Integer.parseInt(max_result) - 1) break;
                iteration++;
            }
        }

    if (lis.size() > 0 && (!orderBy.equals("relevance") && !orderBy.equals(""))) {
        Collections.sort(lis, new Comparator<MusicInfo>() {
            @Override
            public int compare(final MusicInfo object1, final MusicInfo object2) {
                if (orderBy.equals("newest")) return object2.getReleaseDate().compareTo(object1.getReleaseDate());
                else return object1.getReleaseDate().compareTo(object2.getReleaseDate());
            }
        });
    }
    return lis;
}
 
开发者ID:LithiumSR,项目名称:media_information_service,代码行数:57,代码来源:APIOperations.java

示例15: setManagerAddress

import org.apache.commons.lang.StringUtils; //导入方法依赖的package包/类
public void setManagerAddress(String managerAddress) {
    String server = StringUtils.replace(managerAddress, ";", ",");
    String[] servers = StringUtils.split(server, ',');
    this.managerAddress = Arrays.asList(servers);
    this.index = RandomUtils.nextInt(this.managerAddress.size()); // 随机选择一台机器
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:7,代码来源:NodeCommmunicationClient.java


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