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