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


Java Pattern.pattern方法代码示例

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


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

示例1: ofMatcher

import java.util.regex.Pattern; //导入方法依赖的package包/类
public static XmEntityKey ofMatcher(String xmKey, Pattern pattern) {
    Objects.requireNonNull(xmKey, "XM entity key can't be null");

    Matcher xmKeyMatcher = pattern.matcher(xmKey);
    if (!xmKeyMatcher.matches()) {
        // add more appropriate exception ...
        throw new BusinessException("XM entity key '" + xmKey + "' doesn't match pattern: "
                                               + pattern.pattern());
    }

    int count = xmKeyMatcher.groupCount();
    String groups[] = new String[count];
    for (int i = 0; i < count; i++) {
        groups[i] = xmKeyMatcher.group(i + 1);
    }
    return new XmEntityKey(xmKey, groups);
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:18,代码来源:XmEntityKey.java

示例2: testGetParameterizedMartini

import java.util.regex.Pattern; //导入方法依赖的package包/类
@SuppressWarnings("Guava")
@Test
public void testGetParameterizedMartini() throws NoSuchMethodException {
	String id = "Parameterized_Method_Calls:A_Parameterized_Case:25";
	Martini martini = getMartini(id);
	checkState(null != martini, "no Martini found matching ID [%s]", id);

	Map<Step, StepImplementation> stepIndex = martini.getStepIndex();
	Collection<StepImplementation> implementations = stepIndex.values();
	ImmutableList<StepImplementation> filtered = FluentIterable.from(implementations)
		.filter(notNull())
		.filter(Predicates.not(Predicates.instanceOf(UnimplementedStep.class)))
		.toList();
	assertFalse(filtered.isEmpty(), "expected at least one implementation");
	StepImplementation givenImplementation = filtered.get(0);

	Pattern pattern = givenImplementation.getPattern();
	assertNotNull(pattern, "expected implementation to have a Pattern");

	String regex = pattern.pattern();
	assertEquals(regex, "^a pre-existing condition known as \"(.+)\"$", "Pattern contains wrong regex");

	Method method = givenImplementation.getMethod();
	Method expected = ParameterizedTestSteps.class.getDeclaredMethod("aPreExistingConditionKnownAs", String.class);
	assertEquals(method, expected, "implementation contains wrong Method");
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:27,代码来源:DefaultMixologistTest.java

示例3: getNoKeepAliveUserAgents

import java.util.regex.Pattern; //导入方法依赖的package包/类
public String getNoKeepAliveUserAgents() {
    Pattern p = noKeepAliveUserAgents;
    if (p == null) {
        return null;
    } else {
        return p.pattern();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:9,代码来源:SpnegoAuthenticator.java

示例4: getValueAt

import java.util.regex.Pattern; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
	final Pattern pattern = patterns.get(rowIndex);
	if (columnIndex == 0) {
		return pattern.pattern();
	}
	return "??";
}
 
开发者ID:evernat,项目名称:dead-code-detector,代码行数:10,代码来源:PatternTableModel.java

示例5: testMultipleGivenRegex

import java.util.regex.Pattern; //导入方法依赖的package包/类
@Test
public void testMultipleGivenRegex() throws NoSuchMethodException {
	MultipleGivenBean source = new MultipleGivenBean();
	ClassPathXmlApplicationContext context = getContext(source);
	process(context, source);

	MultipleGivenBean steps = context.getBean(MultipleGivenBean.class);
	Class<?> wrapped = AopUtils.getTargetClass(steps);
	Method method = wrapped.getMethod("doSomething");

	Map<String, StepImplementation> givenBeanIndex = context.getBeansOfType(StepImplementation.class);
	Collection<StepImplementation> givens = givenBeanIndex.values();

	Set<String> matches = Sets.newHashSetWithExpectedSize(2);
	for (StepImplementation given : givens) {
		Method givenMethod = given.getMethod();
		if (givenMethod.equals(method)) {
			Pattern pattern = given.getPattern();
			String regex = pattern.pattern();
			matches.add(regex);
		}
	}

	int count = matches.size();
	assertEquals(count, 2, "wrong number of GivenStep objects registered for MultipleGivenBean.getMartinis()");

	Set<String> expected = Sets.newHashSet(
		"this is regular expression one", "this is regular expression two");
	assertEquals(matches, expected, "Steps contain wrong regex Pattern objects");
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:31,代码来源:StepsAnnotationProcessorTest.java

示例6: parseStringAttr

import java.util.regex.Pattern; //导入方法依赖的package包/类
private static String parseStringAttr(String line, Pattern pattern) throws ParserException {
  Matcher matcher = pattern.matcher(line);
  if (matcher.find() && matcher.groupCount() == 1) {
    return matcher.group(1);
  }
  throw new ParserException("Couldn't match " + pattern.pattern() + " in " + line);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:8,代码来源:HlsPlaylistParser.java

示例7: getNoKeepAliveUserAgents

import java.util.regex.Pattern; //导入方法依赖的package包/类
public String getNoKeepAliveUserAgents() {
	Pattern p = noKeepAliveUserAgents;
	if (p == null) {
		return null;
	} else {
		return p.pattern();
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:9,代码来源:SpnegoAuthenticator.java

示例8: getMatch

import java.util.regex.Pattern; //导入方法依赖的package包/类
public String getMatch(Pattern p, String msg) {
	
	Matcher m = p.matcher(msg);
	if (!m.find()) throw new RuntimeException("Regexp '" + p.pattern() + "' does not match onto '" + msg + "'.");
	return m.group(0);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:7,代码来源:PatternTest.java

示例9: getAsText

import java.util.regex.Pattern; //导入方法依赖的package包/类
@Override
public String getAsText() {
	Pattern value = (Pattern) getValue();
	return (value != null ? value.pattern() : "");
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:PatternEditor.java

示例10: setPattern

import java.util.regex.Pattern; //导入方法依赖的package包/类
protected void setPattern() {
	Pattern pattern = implementation.getPattern();
	String serializedPattern = pattern.pattern();
	serialized.addProperty("pattern", serializedPattern);
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:6,代码来源:DefaultStepImplementationSerializer.java

示例11: regexFilterNew

import java.util.regex.Pattern; //导入方法依赖的package包/类
private Filter regexFilterNew(Pattern pattern) {
  return new SingleColumnValueFilter(COLUMN_FAMILY, COLUMN_QUALIFIER,
      CompareOp.EQUAL,
      new RegexStringComparator(pattern.pattern(), pattern.flags()));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:6,代码来源:TestSingleColumnValueFilter.java


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