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


Java StrSubstitutor.replace方法代码示例

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


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

示例1: getMessage

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
private String getMessage(ApprovalStatusUpdateEvent event, IOrderApprovalMapping orderApproval,
                          IUserAccount requester, IKiosk kiosk, IUserAccount updatedBy) {

  String message = getMessage(event.getStatus(), requester);
  Map<String, String> values = new HashMap<>();
  values.put("approvalType", ApprovalUtils.getApprovalType(orderApproval.getApprovalType()));
  values.put("requestorName", requester.getFullName());
  values.put("requestorPhone", requester.getMobilePhoneNumber());
  values.put("eName", kiosk.getName());
  values.put("eCity", kiosk.getCity());
  values.put("orderId", event.getTypeId());
  values.put("statusChangedTime", LocalDateUtil.format(event.getUpdatedAt(),
      requester.getLocale(), requester.getTimezone()));
  values.put("updatedBy", updatedBy.getFullName());
  values.put("updatedByPhone", updatedBy.getMobilePhoneNumber());

  StrSubstitutor sub = new StrSubstitutor(values);

  return sub.replace(message);
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:21,代码来源:ApprovalStatusUpdateEventProcessor.java

示例2: interpolate

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
public static void interpolate(File file)  {
	String content;
	try {
		content = new String(Files.readAllBytes(file.toPath()));
		String replace = StrSubstitutor.replace(content, new ConfigurationMap( configuration()));
		Files.write(file.toPath(), replace.getBytes());

	} catch (IOException e) {
		LOGGER.error( file  +  " interpolation error ", e);
		
	}
	
}
 
开发者ID:rockitconsulting,项目名称:test.rockitizer,代码行数:14,代码来源:PayloadReplacer.java

示例3: resolveJsonPaths

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
@Override
public String resolveJsonPaths(String jsonString, String scenarioState) {
    List<String> jsonPaths = getAllJsonPathTokens(jsonString);
    Map<String, String> paramMap = new HashMap<>();

    jsonPaths.forEach(thisPath -> {
        try {
            paramMap.put(thisPath, JsonPath.read(scenarioState, thisPath));
        } catch (Exception e) {
            throw new RuntimeException("\nJSON:" + jsonString + "\nPossibly comments in the JSON found or bad JSON path found: " + thisPath + ", Details: " + e);
        }
    });

    StrSubstitutor sub = new StrSubstitutor(paramMap);

    return sub.replace(jsonString);
}
 
开发者ID:authorjapps,项目名称:zerocode,代码行数:18,代码来源:ZeroCodeJsonTestProcesorImpl.java

示例4: createStepWith

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
protected String createStepWith(String stepName) {
    Map<String, String> parammap = new HashMap<>();

    parammap.put("STEP.NAME", stepName);
    parammap.put("STEP.REQUEST", "{\n" +
            "    \"customer\": {\n" +
            "        \"firstName\": \"FIRST_NAME\"\n" +
            "    }\n" +
            "}");
    parammap.put("STEP.RESPONSE", "{\n" +
            "    \"id\" : 10101\n" +
            "}");

    StrSubstitutor sub = new StrSubstitutor(parammap);

    return sub.replace((new StepExecutionState()).getRequestResponseState());
}
 
开发者ID:authorjapps,项目名称:zerocode,代码行数:18,代码来源:ScenarioExecutionStateTest.java

示例5: getFileName

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
/**
 * Get the final filename of the generated .ass subtitle
 * 
 * @return the name of the first subtitle
 */
private String getFileName() {

	String filename = this.userConfig.getFilename();
	if (StringUtils.isEmpty(filename)) {
		filename = this.userConfig.getFirstSubtitle().getFileName();
		filename = FilenameUtils.getBaseName(filename);
	} else {
		Map<String, String> substitutes = new HashMap<>();

		String oneN = FilenameUtils.getBaseName(this.userConfig.getFirstSubtitle().getFileName());
		String twoN = FilenameUtils.getBaseName(this.userConfig.getSecondSubtitle().getFileName());

		substitutes.put("one", oneN);
		substitutes.put("two", twoN);
		substitutes.put("baseOne", StringUtils.substringBeforeLast(oneN, "."));
		substitutes.put("baseTwo", StringUtils.substringBeforeLast(twoN, "."));

		StrSubstitutor substitutor = new StrSubstitutor(substitutes);
		filename = substitutor.replace(filename);
	}
	return filename;
}
 
开发者ID:dnbn,项目名称:submerge,代码行数:28,代码来源:IndexBean.java

示例6: replaceProperties

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
private void replaceProperties(Properties props) {
    StrSubstitutor substitutor = new StrSubstitutor(sqlProperties);

    // we must delete slash(it is added to the ${sql.url}) from connection string -> ${sql.url}/database
    if (props.getProperty(CONNECTION_URL_KEY) != null) {
        String connectionUrl = parseConnectionString(props.getProperty(CONNECTION_URL_KEY));
        props.put(CONNECTION_URL_KEY, connectionUrl);
    }

    for (Map.Entry<Object, Object> entry : props.entrySet()) {
        if (entry.getValue() instanceof String) {
            String substituted = substitutor.replace(entry.getValue());
            entry.setValue(substituted);
        }
    }
}
 
开发者ID:motech,项目名称:motech,代码行数:17,代码来源:SqlDBManagerImpl.java

示例7: goArtifact

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
private Function<File, GoArtifact> goArtifact(final UriConfig config, final Map<String, String> properties, final TaskExecutionContext context) {
    return new Function<File, GoArtifact>() {
        @Override
        public GoArtifact apply(File file) {
            GoArtifact artifact = new GoArtifact(file.getAbsolutePath(), artifactUri(file.getName()));
            artifact.properties(properties);
            return artifact;
        }

        private String artifactUri(String artifactName) {
            String uri = config.isFolder() ? config.uri() + "/" + artifactName : config.uri();
            StrSubstitutor sub = new StrSubstitutor(context.environment().asMap());
            return sub.replace(uri);
        }
        
    };
}
 
开发者ID:tusharm,项目名称:go-artifactory-plugin,代码行数:18,代码来源:GoArtifactFactory.java

示例8: testProperty

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
private void testProperty( String propertyName, boolean containsSubstitution ) {
    String propertyValue = setup.get( propertyName );
    assertTrue( propertyName + " was not found", isNotBlank( propertyValue ) );
    logger.info( propertyName + "=" + propertyValue );

    if ( containsSubstitution ) {
        Map<String, String> valuesMap = new HashMap<String, String>();
        valuesMap.put( "reset_url", "test-url" );
        valuesMap.put( "organization_name", "test-org" );
        valuesMap.put( "activation_url", "test-url" );
        valuesMap.put( "confirmation_url", "test-url" );
        valuesMap.put( "user_email", "test-email" );
        valuesMap.put( "pin", "test-pin" );
        StrSubstitutor sub = new StrSubstitutor( valuesMap );
        String resolvedString = sub.replace( propertyValue );
        assertNotSame( propertyValue, resolvedString );
    }
}
 
开发者ID:apache,项目名称:usergrid,代码行数:19,代码来源:EmailFlowIT.java

示例9: getCommitMessage

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
private String getCommitMessage(final Project project) {
    String templateString = TemplateFileHandler.loadFile(project);

    Map<String, String> valuesMap = new HashMap<>();
    String branchName = CommitMessage.extractBranchName(project);
    String[] branchParts = CommitMessage.splitBranchName(branchName);
    if (branchParts.length > 1) {
        valuesMap.put(Consts.TICKET, branchParts[1]);
    }
    valuesMap.put(Consts.SHORT_DESCRIPTION, "");
    valuesMap.put(Consts.LONG_DESCRIPTION, "");
    StrSubstitutor sub = new StrSubstitutor(valuesMap);
    return sub.replace(templateString);
}
 
开发者ID:JanGatting,项目名称:GitCommitMessage,代码行数:15,代码来源:GetCommitMessageAction.java

示例10: getCommitMessage

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
String getCommitMessage(Project project) {
    String templateString = TemplateFileHandler.loadFile(project);

    Map<String, String> valuesMap = new HashMap<>();
    valuesMap.put(Consts.TICKET, getBranch());
    valuesMap.put(Consts.SHORT_DESCRIPTION, panel.getShortDescription());
    valuesMap.put(Consts.LONG_DESCRIPTION, getLongDescription(templateString));
    StrSubstitutor sub = new StrSubstitutor(valuesMap);
    return sub.replace(templateString);
}
 
开发者ID:JanGatting,项目名称:GitCommitMessage,代码行数:11,代码来源:PanelDialog.java

示例11: generate

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
/** @return the source for the generated file. */
public final String generate() {
  StrSubstitutor substitutor = new StrSubstitutor(templateValuesMap);
  String newFile = substitutor.replace(templateString);
  System.out.println(newFile);
  return newFile;
}
 
开发者ID:uber,项目名称:RIBs,代码行数:8,代码来源:Generator.java

示例12: expandCommand

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
/**
 * Expands variables in a command.
 * Replaces any variables in form ${propertyName} to the value defined by {@link MCRConfiguration#getString(String)}.
 * If the property is not defined not variable replacement takes place.
 * @param command a CLI command that should be expanded
 * @return expanded command
 */
public static String expandCommand(final String command) {
    StrSubstitutor strSubstitutor = new StrSubstitutor(MCRConfiguration.instance().getPropertiesMap());
    String expandedCommand = strSubstitutor.replace(command);
    if (!expandedCommand.equals(command)) {
        LOGGER.info("{} --> {}", command, expandedCommand);
    }
    return expandedCommand;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:16,代码来源:MCRCommandLineInterface.java

示例13: expandPropertyValues

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
/**
 * Expands all property place holders to actual values. For example
 * suppose you have a property defined as follows: root.dir=/usr/home
 * Expanding following ${root.dir}/somesubdir
 * will then give following result: /usr/home/somesubdir
 *
 * @param properties The properties, not null
 */
protected void expandPropertyValues(Properties properties) {
    for (Object key : properties.keySet()) {
        Object value = properties.get(key);
        try {
            String expandedValue = StrSubstitutor.replace(value, properties);
            properties.put(key, expandedValue);
        } catch (Exception e) {
            throw new UnitilsException("Unable to load unitils configuration. Could not expand property value for key: " + key + ", value " + value, e);
        }
    }

}
 
开发者ID:linux-china,项目名称:unitils,代码行数:21,代码来源:ConfigurationLoader.java

示例14: getTransformedMessage

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
@Override
public String getTransformedMessage(FormatterData formatterData, String input) {
    final IJenkinsDescriptor jenkinsDescriptor = formatterData.getDataForType(IJenkinsDescriptor.class);
    if (jenkinsDescriptor != null) {
        final Map<String, String> vars = jenkinsDescriptor.getMasterEnvironmentVariables();
        final StrSubstitutor strSubstitutor = new StrSubstitutor(vars);
        return strSubstitutor.replace(input);
    } else {
        return input;
    }
}
 
开发者ID:inFullMobile,项目名称:restricted-register-plugin,代码行数:12,代码来源:EnvVariablesDecorator.java

示例15: getTransformedMessage

import org.apache.commons.lang.text.StrSubstitutor; //导入方法依赖的package包/类
@Override
public String getTransformedMessage(FormatterData formatterData, String input) {
    final LocalVariables localVariables = formatterData.getDataForType(LocalVariables.class);
    if (localVariables != null) {
        final Map<String, String> vars = localVariables.getVariables();
        final StrSubstitutor strSubstitutor = new StrSubstitutor(vars);
        return strSubstitutor.replace(input);
    } else {
        return input;
    }
}
 
开发者ID:inFullMobile,项目名称:restricted-register-plugin,代码行数:12,代码来源:LocalVariablesDecorator.java


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