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


Java StrLookup类代码示例

本文整理汇总了Java中org.apache.commons.lang3.text.StrLookup的典型用法代码示例。如果您正苦于以下问题:Java StrLookup类的具体用法?Java StrLookup怎么用?Java StrLookup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: incomingRequestPostProcessed

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
@Override
public boolean incomingRequestPostProcessed(RequestDetails theRequestDetails, HttpServletRequest theRequest, HttpServletResponse theResponse) throws AuthenticationException {

    Enumeration<String> headers = theRequest.getHeaderNames();
    while (headers.hasMoreElements()) {
        String header = headers.nextElement();
        log.debug("Header  = "+ header + "="+ theRequest.getHeader(header));
    }
    // Perform any string substitutions from the message format
    StrLookup<?> lookup = new MyLookup(theRequest, theRequestDetails);
    StrSubstitutor subs = new StrSubstitutor(lookup, "${", "}", '\\');

    // Actually log the line
    String myMessageFormat = "httpVerb[${requestVerb}] Source[${remoteAddr}] Operation[${operationType} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] RequestId[${requestHeader.x-request-id}] ForwardedFor[${requestHeader.x-forwarded-for}] ForwardedHost[${requestHeader.x-forwarded-host}] CorrelationId[] ProcessingTime[]  ResponseCode[]";

    String line = subs.replace(myMessageFormat);
    log.info(line);

    return true;
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:21,代码来源:ServerInterceptor.java

示例2: processingCompletedNormally

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
@Override
public void processingCompletedNormally(ServletRequestDetails theRequestDetails) {
    // Perform any string substitutions from the message format

    StrLookup<?> lookup = new MyLookup(theRequestDetails.getServletRequest(), theRequestDetails);
    StrSubstitutor subs = new StrSubstitutor(lookup, "${", "}", '\\');

    for (String header : theRequestDetails.getServletResponse().getHeaderNames()) {
        log.debug("Header  = " + header + "=" + theRequestDetails.getServletResponse().getHeader(header));
    }

    String myMessageFormat = "httpVerb[${requestVerb}] Source[${remoteAddr}] Operation[${operationType} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] RequestId[${requestHeader.x-request-id}] ForwardedFor[${requestHeader.x-forwarded-for}] ForwardedHost[${requestHeader.x-forwarded-host}] CorrelationId[${requestHeader.x-request-id}] ProcessingTime[${processingTimeMillis}]";

    String line = subs.replace(myMessageFormat);
    log.info(line+" ResponseCode["+theRequestDetails.getServletResponse().getStatus()+"]");
}
 
开发者ID:nhsconnect,项目名称:careconnect-reference-implementation,代码行数:17,代码来源:ServerInterceptor.java

示例3: loadConfigFromEnv

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
public static <T> T loadConfigFromEnv(Class<T> configurationClass, final String path)
    throws IOException {
    LOGGER.info("Parsing configuration file from {} ", path);
    logProcessEnv();
    final Path configPath = Paths.get(path);
    final File file = configPath.toAbsolutePath().toFile();
    final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());

    final StrSubstitutor sub = new StrSubstitutor(new StrLookup<Object>() {
        @Override
        public String lookup(String key) {
            return System.getenv(key);
        }
    });
    sub.setEnableSubstitutionInVariables(true);

    final String conf = sub.replace(FileUtils.readFileToString(file));
    return mapper.readValue(conf, configurationClass);
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:20,代码来源:YAMLConfigurationLoader.java

示例4: resolve

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
private String resolve(final String configurationWithPlaceholders, final Properties placeholderValues)
        throws IOException {

  return new StrSubstitutor(
          new StrLookup<String>() {
            @Override
            public String lookup(final String key) {
              Preconditions.checkNotNull(placeholderValues.getProperty(key),
                                         "placeholder: \"${%s}\" was not assigned",
                                         key);
              return placeholderValues.getProperty(key);
            }
          },
          "${",
          "}",
          '#')
          .replace(configurationWithPlaceholders);
}
 
开发者ID:outbrain,项目名称:Aletheia,代码行数:19,代码来源:AletheiaConfig.java

示例5: substituteRelationships

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
String substituteRelationships(String query, final Multimap<String, Object> valueMap) {
  StrSubstitutor substitutor = new StrSubstitutor(new StrLookup<String>() {
    @Override
    public String lookup(String key) {
      Collection<String> resolvedRelationshipTypes =
          transform(valueMap.get(key), new Function<Object, String>() {
            @Override
            public String apply(Object input) {
              if (input.toString().matches(".*(\\s).*")) {
                throw new IllegalArgumentException(
                    "Cypher relationship templates must not contain spaces");
              }
              return curieUtil.getIri(input.toString()).orElse(input.toString());
            }

          });
      return on("|").join(resolvedRelationshipTypes);
    }
  });
  return substitutor.replace(query);
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:22,代码来源:CypherUtil.java

示例6: Element

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
/**
 * Construct with the execution context.
 *
 * @param context Execution context
 */
protected Element(final Context context) {
  this.context = context;

  // Initialise string substituter for token replacement in variables
  this.substitutor = new StrSubstitutor(new StrLookup<String>() {
    @Override
    public String lookup(final String key) {
      final Object value = context.getVar(key);
      if (value == null) {
        return null;
      } else {
        return String.valueOf(value);
      }
    }
  });
  this.substitutor.setEnableSubstitutionInVariables(true);
}
 
开发者ID:venushka,项目名称:jmxeval,代码行数:23,代码来源:Element.java

示例7: replacePlaceholdersWithWhiteSpace

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
public static String replacePlaceholdersWithWhiteSpace(final String templateContent,
    final Map<String, String> values) {
    StrSubstitutor sub = new StrSubstitutor(values);
    sub.setVariableResolver(new StrLookup<Object>() {
        @Override
        public String lookup(String key) {
            if (values == null) {
                return "";
            }
            Object obj = values.get(key);
            if (obj == null) {
                return "";
            }
            return obj.toString();
        }
    });
    return sub.replace(templateContent);
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:19,代码来源:IOUtil.java

示例8: replaceVariableReferences

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
public static String replaceVariableReferences(final Evaluator evaluator, final String body,
                                               final ResultRecorder resultRecorder) {
  if (body == null) {
    return null;
  }
  StrSubstitutor sub = new StrSubstitutor(new StrLookup<Object>() {
    @Override
    public String lookup(String name) {
      try {
        Object value = evaluator.evaluate(name);
        if (value == null) {
          return "";
        } else {
          return value.toString();
        }
      } catch (Exception e) {
        resultRecorder.record(Result.FAILURE);
        return "<span class=\"failure\">" + e.toString() + "</span>";
      }
    }
  }, "$(", ")", '\\');

  return sub.replace(body);
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:25,代码来源:Utils.java

示例9: DefaultConfigSubstitutor

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
@Inject
public DefaultConfigSubstitutor(Iterable<ConfigVariableValueProvider> configVariableValueProviders) {
    this.configVariableValueProviders = configVariableValueProviders;
    this.strSubstitutor = new StrSubstitutor(
            new StrLookup<Object>() {
                @Override
                public String lookup(String key) {
                    return value(key);
                }
            },
            VARIABLE_PREFIX,
            VARIABLE_SUFFIX,
            ESCAPE);
}
 
开发者ID:joeyb,项目名称:undercarriage,代码行数:15,代码来源:DefaultConfigSubstitutor.java

示例10: initialize

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
@Override
public void initialize(final Bootstrap<AugmentedConfiguration> bootstrap) {

    // Enable configuration variable substitution with system property values
    final StrSubstitutor systemPropertyStrSubstitutor = new StrSubstitutor(StrLookup.systemPropertiesLookup());
    bootstrap.setConfigurationSourceProvider(
            new SubstitutingSourceProvider(bootstrap.getConfigurationSourceProvider(), systemPropertyStrSubstitutor));

    // setup guice builder
    final Builder<AugmentedConfiguration> guiceConfiguration = GuiceBundle.<AugmentedConfiguration>newBuilder() //
            .addModule(new AugmentedModule()) //
            .addModule(new OpenDataClientModule()) //
            .enableAutoConfig(getClass().getPackage().getName()) //
            .setConfigClass(AugmentedConfiguration.class);

    // setup db backend based - choice i based on system property value
    if (isDbTypeSetToMongodb(systemPropertyStrSubstitutor.getVariableResolver().lookup(DBTYPE_PROPERTY_NAME))) {
        guiceConfiguration.addModule(new MongodbModule());
    } else {
        bootstrap.addBundle(createMigrationBundle());
        guiceConfiguration.addModule(new RdbmsModule<AugmentedConfiguration>(bootstrap) {
            @Override
            public DataSourceFactory getRealDataSourceFactory(final AugmentedConfiguration configuration) {
                return configuration.getRdbmsConfig();
            }

            @Override
            public String getPackagesToScanForEntities() {
                return RDBMS_ENTITIES_PACKAGE;
            }
        });
    }

    // eagerly inject all dependencies: note Stage.DEVELOPMENT it's a hack
    final GuiceBundle<AugmentedConfiguration> guiceBundle = guiceConfiguration.build(Stage.DEVELOPMENT);
    bootstrap.addBundle(guiceBundle);

    injector = guiceBundle.getInjector();
}
 
开发者ID:blstream,项目名称:AugumentedSzczecin_java,代码行数:40,代码来源:AugmentedApplication.java

示例11: incomingRequestPostProcessed

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
@Override
public boolean incomingRequestPostProcessed(final RequestDetails theRequestDetails, final HttpServletRequest theRequest, HttpServletResponse theResponse) throws AuthenticationException {

	// Perform any string substitutions from the message format
	StrLookup<?> lookup = new MyLookup(theRequest, theRequestDetails);
	StrSubstitutor subs = new StrSubstitutor(lookup, "${", "}", '\\');

	// Actuall log the line
	String line = subs.replace(myMessageFormat);
	myLogger.info(line);

	return true;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:14,代码来源:LoggingInterceptor.java

示例12: substitute

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
public static String substitute( String s, Function<String, Object> mapper ) {
    return new StrSubstitutor( new StrLookup<Object>() {
        @Override
        public String lookup( String key ) {
            Object value = mapper.apply( key );
            return value == null ? "" : String.valueOf( value );
        }
    } ).replace( s );
}
 
开发者ID:oaplatform,项目名称:oap,代码行数:10,代码来源:Strings.java

示例13: addResponseIssueHeader

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
private void addResponseIssueHeader(RequestDetails theRequestDetails, SingleValidationMessage theNext) {
	// Perform any string substitutions from the message format
	StrLookup<?> lookup = new MyLookup(theNext);
	StrSubstitutor subs = new StrSubstitutor(lookup, "${", "}", '\\');

	// Log the header
	String headerValue = subs.replace(myResponseIssueHeaderValue);
	ourLog.trace("Adding header to response: {}", headerValue);

	theRequestDetails.getResponse().addHeader(myResponseIssueHeaderName, headerValue);
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:12,代码来源:BaseValidatingInterceptor.java

示例14: handleException

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
@Override
public boolean handleException(RequestDetails theRequestDetails, BaseServerResponseException theException, HttpServletRequest theServletRequest, HttpServletResponse theServletResponse) throws ServletException, IOException {
	if (myLogExceptions) {
		// Perform any string substitutions from the message format
		StrLookup<?> lookup = new MyLookup(theServletRequest, theException, theRequestDetails);
		StrSubstitutor subs = new StrSubstitutor(lookup, "${", "}", '\\');

		// Actuall log the line
		String line = subs.replace(myErrorMessageFormat);
		myLogger.info(line);

	}
	return true;
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:15,代码来源:LoggingInterceptor.java

示例15: processingCompletedNormally

import org.apache.commons.lang3.text.StrLookup; //导入依赖的package包/类
@Override
public void processingCompletedNormally(ServletRequestDetails theRequestDetails) {
	// Perform any string substitutions from the message format
	StrLookup<?> lookup = new MyLookup(theRequestDetails.getServletRequest(), theRequestDetails);
	StrSubstitutor subs = new StrSubstitutor(lookup, "${", "}", '\\');

	// Actually log the line
	String line = subs.replace(myMessageFormat);
	myLogger.info(line);
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:11,代码来源:LoggingInterceptor.java


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