當前位置: 首頁>>代碼示例>>Java>>正文


Java Matcher.regionStart方法代碼示例

本文整理匯總了Java中java.util.regex.Matcher.regionStart方法的典型用法代碼示例。如果您正苦於以下問題:Java Matcher.regionStart方法的具體用法?Java Matcher.regionStart怎麽用?Java Matcher.regionStart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.regex.Matcher的用法示例。


在下文中一共展示了Matcher.regionStart方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import java.util.regex.Matcher; //導入方法依賴的package包/類
/**
 * Initialize derived fields from defining fields.
 * This is called from constructor and from readObject (de-serialization)
 *
 * @param definingCalendar the {@link java.util.Calendar} instance used to initialize this FastDateParser
 */
private void init(Calendar definingCalendar) {

    final StringBuilder regex = new StringBuilder();
    final List<Strategy> collector = new ArrayList<Strategy>();

    final Matcher patternMatcher = formatPattern.matcher(pattern);
    if (!patternMatcher.lookingAt()) {
        throw new IllegalArgumentException(
                "Illegal pattern character '" + pattern.charAt(patternMatcher.regionStart()) + "'");
    }

    currentFormatField = patternMatcher.group();
    Strategy currentStrategy = getStrategy(currentFormatField, definingCalendar);
    for (; ; ) {
        patternMatcher.region(patternMatcher.end(), patternMatcher.regionEnd());
        if (!patternMatcher.lookingAt()) {
            nextStrategy = null;
            break;
        }
        final String nextFormatField = patternMatcher.group();
        nextStrategy = getStrategy(nextFormatField, definingCalendar);
        if (currentStrategy.addRegex(this, regex)) {
            collector.add(currentStrategy);
        }
        currentFormatField = nextFormatField;
        currentStrategy = nextStrategy;
    }
    if (patternMatcher.regionStart() != patternMatcher.regionEnd()) {
        throw new IllegalArgumentException("Failed to parse \"" + pattern + "\" ; gave up at index " + patternMatcher.regionStart());
    }
    if (currentStrategy.addRegex(this, regex)) {
        collector.add(currentStrategy);
    }
    currentFormatField = null;
    strategies = collector.toArray(new Strategy[collector.size()]);
    parsePattern = Pattern.compile(regex.toString());
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:44,代碼來源:FastDateParser.java

示例2: init

import java.util.regex.Matcher; //導入方法依賴的package包/類
/**
 * Initialize derived fields from defining fields.
 * This is called from constructor and from readObject (de-serialization)
 *
 * @param definingCalendar the {@link Calendar} instance used to initialize this FastDateParser
 */
private void init(Calendar definingCalendar) {

    final StringBuilder regex = new StringBuilder();
    final List<Strategy> collector = new ArrayList<Strategy>();

    final Matcher patternMatcher = formatPattern.matcher(pattern);
    if (!patternMatcher.lookingAt()) {
        throw new IllegalArgumentException(
                "Illegal pattern character '" + pattern.charAt(patternMatcher.regionStart()) + "'");
    }

    currentFormatField = patternMatcher.group();
    Strategy currentStrategy = getStrategy(currentFormatField, definingCalendar);
    for (; ; ) {
        patternMatcher.region(patternMatcher.end(), patternMatcher.regionEnd());
        if (!patternMatcher.lookingAt()) {
            nextStrategy = null;
            break;
        }
        final String nextFormatField = patternMatcher.group();
        nextStrategy = getStrategy(nextFormatField, definingCalendar);
        if (currentStrategy.addRegex(this, regex)) {
            collector.add(currentStrategy);
        }
        currentFormatField = nextFormatField;
        currentStrategy = nextStrategy;
    }
    if (patternMatcher.regionStart() != patternMatcher.regionEnd()) {
        throw new IllegalArgumentException("Failed to parse \"" + pattern + "\" ; gave up at index " + patternMatcher.regionStart());
    }
    if (currentStrategy.addRegex(this, regex)) {
        collector.add(currentStrategy);
    }
    currentFormatField = null;
    strategies = collector.toArray(new Strategy[collector.size()]);
    parsePattern = Pattern.compile(regex.toString());
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:44,代碼來源:FastDateParser.java

示例3: HivePath

import java.util.regex.Matcher; //導入方法依賴的package包/類
public HivePath(final ObjectInspector oi, final String path) {
	this.oi = oi;
	this.accessors = new ArrayList<>();

	final Matcher m = STRUCT_ACCESS_PATTERN.matcher(path);

	while (m.usePattern(STRUCT_ACCESS_PATTERN).find()) {
		accessors.add(new StructAccessor(m.group("field")));
		m.region(m.end(), m.regionEnd());

		boolean match;
		do {
			match = false;
			if (m.usePattern(ARRAY_ACCESS_PATTERN).find()) {
				accessors.add(new ArrayAccessor(Integer.parseInt(m.group("index"))));
				m.region(m.end(), m.regionEnd());
				match = true;
			}
			if (m.usePattern(MAP_ACCESS_PATTERN).find()) {
				final String key;
				try {
					key = MAPPER.readValue(m.group("keyjson"), String.class);
				} catch (IOException e) {
					throw new IllegalArgumentException(e);
				}
				accessors.add(new MapAccessor(key));
				m.region(m.end(), m.regionEnd());
				match = true;
			}
		} while (match);
	}

	if (!m.hitEnd())
		throw new IllegalArgumentException("error at " + m.regionStart());
}
 
開發者ID:CyberAgent,項目名稱:hive-jq-udtf,代碼行數:36,代碼來源:HivePath.java


注:本文中的java.util.regex.Matcher.regionStart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。