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


Java PatternMatcher.matches方法代码示例

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


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

示例1: check

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
public boolean check(String action, String method) {
    if (!StringUtil.isBlank(action)) {
        PatternMatcher matcher = new Perl5Matcher();
        Iterator<ActionPatternHolder> iter = actionPatternList.iterator();
        while (iter.hasNext()) {
            ActionPatternHolder holder = (ActionPatternHolder) iter.next();
            if (StringUtils.isNotEmpty(action) && matcher.matches(action, holder.getActionPattern())
                && StringUtils.isNotEmpty(method) && matcher.matches(method, holder.getMethodPattern())) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Candidate is: '" + action + "|" + method + "'; pattern is "
                                 + holder.getActionName() + "|" + holder.getMethodName() + "; matched=true");
                }
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:20,代码来源:ActionProtectedImpl.java

示例2: check

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
public boolean check(String requestUrl) {
    if (StringUtils.isBlank(requestUrl)) {
        return false;
    }

    if (logger.isDebugEnabled()) {
        logger.debug("Converted URL to lowercase, from: '" + requestUrl + "'; to: '" + requestUrl + "'");
    }

    PatternMatcher matcher = new Perl5Matcher();

    Iterator<URLPatternHolder> iter = urlProtectedList.iterator();

    while (iter.hasNext()) {
        URLPatternHolder holder = (URLPatternHolder) iter.next();

        if (matcher.matches(requestUrl, holder.getCompiledPattern())) {
            if (logger.isDebugEnabled()) {
                logger.debug("Candidate is: '" + requestUrl + "'; pattern is "
                             + holder.getCompiledPattern().getPattern() + "; matched=true");
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:27,代码来源:URLProtectedImpl.java

示例3: exec

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
@Override
public void exec(Map<String, Object> inMap, Map<String, Object> results, List<Object> messages, Locale locale, ClassLoader loader) {
    Object obj = inMap.get(fieldName);
    String fieldValue = null;
    try {
        fieldValue = (String) ObjectType.simpleTypeConvert(obj, "String", null, locale);
    } catch (GeneralException e) {
        messages.add("Could not convert field value for comparison: " + e.getMessage());
        return;
    }
    if (pattern == null) {
        messages.add("Could not compile regular expression \"" + expr + "\" for validation");
        return;
    }
    PatternMatcher matcher = new Perl5Matcher();
    if (!matcher.matches(fieldValue, pattern)) {
        addMessage(messages, loader, locale);
    }
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:20,代码来源:Regexp.java

示例4: fetch

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
/**
 * 提取子串
 * @param src	输入字符串
 * @param regx	表达式
 * @return
 */
public List<List<String>> fetch(String src, String regx){
	List<List<String>> list = new ArrayList<List<String>>();
	try{
		Pattern pattern = patternCompiler.compile(regx, Perl5Compiler.CASE_INSENSITIVE_MASK);
		PatternMatcher matcher = new Perl5Matcher();
		PatternMatcherInput input = new PatternMatcherInput(src);
		while(matcher.matches(input, pattern)){
			MatchResult matchResult = matcher.getMatch();
			int groups = matchResult.groups();
			List<String> item = new ArrayList<String>();
			for(int i=0; i<=groups; i++){
				item.add(matchResult.group(i));
			}
			list.add(item);
		}
	}catch(Exception e){
		if(ConfigTable.isDebug()){
			e.printStackTrace();
		}
	}
	return list;
}
 
开发者ID:anylineorg,项目名称:anyline,代码行数:29,代码来源:RegularMatch.java

示例5: parseMode

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
/**
 * 解析DataMedia中的namespace和name,支持offer[1-128]分库的定义
 */
public static ModeValue parseMode(String value) {
    PatternMatcher matcher = new Perl5Matcher();
    if (matcher.matches(value, patterns.get(MODE_PATTERN))) {
        MatchResult matchResult = matcher.getMatch();
        String prefix = matchResult.group(1);
        String startStr = matchResult.group(3);
        String ednStr = matchResult.group(4);
        int start = Integer.valueOf(startStr);
        int end = Integer.valueOf(ednStr);
        String postfix = matchResult.group(5);

        List<String> values = new ArrayList<String>();
        for (int i = start; i <= end; i++) {
            StringBuilder builder = new StringBuilder(value.length());
            String str = String.valueOf(i);
            // 处理0001类型
            if (startStr.length() == ednStr.length() && startStr.startsWith("0")) {
                str = StringUtils.leftPad(String.valueOf(i), startStr.length(), '0');
            }

            builder.append(prefix).append(str).append(postfix);
            values.add(builder.toString());
        }
        return new ModeValue(Mode.MULTI, values);
    } else if (isWildCard(value)) {// 通配符支持
        return new ModeValue(Mode.WILDCARD, Arrays.asList(value));
    } else {
        return new ModeValue(Mode.SINGLE, Arrays.asList(value));
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:34,代码来源:ConfigHelper.java

示例6: testWildCard

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
@Test
public void testWildCard() {
    PatternMatcher matcher = new Perl5Matcher();

    Pattern pattern = null;
    PatternCompiler pc = new Perl5Compiler();
    try {
        pattern = pc.compile("havana_us_.*", Perl5Compiler.DEFAULT_MASK);
    } catch (MalformedPatternException e) {
        throw new ConfigException(e);
    }
    boolean ismatch = matcher.matches("havana_us_0001", pattern);
    System.out.println(ismatch);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:15,代码来源:ConfigHelperTest.java

示例7: compareLike

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
public static final <L,R> boolean compareLike(L lhs, R rhs) {
    PatternMatcher matcher = new Perl5Matcher();
    if (lhs == null) {
        if (rhs != null) {
            return false;
        }
    } else if (lhs instanceof String && rhs instanceof String) {
        //see if the lhs value is like the rhs value, rhs will have the pattern characters in it...
        return matcher.matches((String) lhs, makeOroPattern((String) rhs));
    }
    return true;
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:13,代码来源:EntityComparisonOperator.java

示例8: match

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
/**
 * 匹配状态
 * @param src
 * @param regx
 * @return
 */
public boolean match(String src, String regx){
	boolean result = false;
	try{
		Pattern pattern = patternCompiler.compile(regx, Perl5Compiler.CASE_INSENSITIVE_MASK);
		PatternMatcher matcher = new Perl5Matcher();
		result = matcher.matches(src, pattern);
	}catch(Exception e){
		result = false;
		if(ConfigTable.isDebug()){
			e.printStackTrace();
		}
	}
	return result;
}
 
开发者ID:anylineorg,项目名称:anyline,代码行数:21,代码来源:RegularMatch.java

示例9: regexMatches

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
public static boolean regexMatches(String str, String re) throws MalformedPatternException {
	PatternMatcher matcher = new Perl5Matcher();
	PatternCompiler compiler = new Perl5Compiler();
	PatternMatcherInput input = new PatternMatcherInput(str);

	Pattern pattern = compiler.compile(re, Perl5Compiler.SINGLELINE_MASK);
	return matcher.matches(input, pattern);
}
 
开发者ID:OpenBD,项目名称:openbd-core,代码行数:9,代码来源:string.java

示例10: matchFileNamesWithPattern

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
/**
 * compiles fileNameRegExp into a regular expression and pattern matches on
 * each file's name, and returns those that match.
 * 
 * @param files
 * @param fileNameRegExp
 * 
 * @return String[] of file names that match the expresion.
 */
public String[] matchFileNamesWithPattern(File[] files,
		String fileNameRegExp) throws SshException {
	// set up variables for regexp matching
	Pattern mpattern = null;
	PatternCompiler aPCompiler = new Perl5Compiler();
	PatternMatcher aPerl5Matcher = new Perl5Matcher();
	// Attempt to compile the pattern. If the pattern is not valid,
	// throw exception
	try {
		mpattern = aPCompiler.compile(fileNameRegExp);
	} catch (MalformedPatternException e) {
		throw new SshException("Invalid regular expression:"
				+ e.getMessage(), SshException.BAD_API_USAGE);
	}

	Vector<String> matchedNames = new Vector<String>();

	for (int i = 0; i < files.length; i++) {
		if ((!files[i].getName().equals("."))
				&& (!files[i].getName().equals(".."))
				&& (!files[i].isDirectory())) {
			if (aPerl5Matcher.matches(files[i].getName(), mpattern)) {
				// call get for each match, passing true, so that it doesnt
				// repeat the search
				matchedNames.addElement(files[i].getName());
			}
		}
	}

	// return (String[]) matchedNames.toArray(new String[0]);
	String[] matchedNamesStrings = new String[matchedNames.size()];
	matchedNames.copyInto(matchedNamesStrings);
	return matchedNamesStrings;
}
 
开发者ID:sshtools,项目名称:j2ssh-maverick,代码行数:44,代码来源:Perl5RegExpMatching.java

示例11: matchFilesWithPattern

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
/**
 * compiles fileNameRegExp into a regular expression and pattern matches on
 * each file's name, and returns those that match.
 * 
 * @param files
 * @param fileNameRegExp
 * 
 * @return SftpFile[] of files that match the expresion.
 */
public SftpFile[] matchFilesWithPattern(SftpFile[] files,
		String fileNameRegExp) throws SftpStatusException, SshException {
	// set up variables for regexp matching
	Pattern mpattern = null;
	PatternCompiler aPCompiler = new Perl5Compiler();
	PatternMatcher aPerl5Matcher = new Perl5Matcher();
	// Attempt to compile the pattern. If the pattern is not valid,
	// throw exception
	try {
		mpattern = aPCompiler.compile(fileNameRegExp);
	} catch (MalformedPatternException e) {
		throw new SshException("Invalid regular expression:"
				+ e.getMessage(), SshException.BAD_API_USAGE);
	}

	Vector<SftpFile> matchedNames = new Vector<SftpFile>();

	for (int i = 0; i < files.length; i++) {
		if ((!files[i].getFilename().equals("."))
				&& (!files[i].getFilename().equals(".."))
				&& (!files[i].isDirectory())) {
			if (aPerl5Matcher.matches(files[i].getFilename(), mpattern)) {
				// call get for each match, passing true, so that it doesnt
				// repeat the search
				matchedNames.addElement(files[i]);
			}
		}
	}

	// return (SftpFile[]) matchedNames.toArray(new SftpFile[0]);
	SftpFile[] matchedNamesSftpFiles = new SftpFile[matchedNames.size()];
	matchedNames.copyInto(matchedNamesSftpFiles);
	return matchedNamesSftpFiles;
}
 
开发者ID:sshtools,项目名称:j2ssh-maverick,代码行数:44,代码来源:Perl5RegExpMatching.java

示例12: matchFileNamesWithPattern

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
/**
 * compiles fileNameRegExp into a regular expression and pattern matches on
 * each file's name, and returns those that match.
 * 
 * @param files
 * @param fileNameRegExp
 * 
 * @return String[] of files that match the expresion.
 */
public String[] matchFileNamesWithPattern(File[] files,
		String fileNameRegExp) throws SshException {
	// set up variables for regexp matching
	Pattern mpattern = null;
	PatternCompiler aGCompiler = new GlobCompiler();
	PatternMatcher aPerl5Matcher = new Perl5Matcher();
	// Attempt to compile the pattern. If the pattern is not valid,
	// throw exception
	try {
		mpattern = aGCompiler.compile(fileNameRegExp);
	} catch (MalformedPatternException e) {
		throw new SshException("Invalid regular expression:"
				+ e.getMessage(), SshException.BAD_API_USAGE);
	}

	Vector<String> matchedNames = new Vector<String>();
	for (int i = 0; i < files.length; i++) {
		if ((!files[i].getName().equals("."))
				&& (!files[i].getName().equals(".."))) {
			if (aPerl5Matcher.matches(files[i].getName(), mpattern)) {
				// call get for each match, passing true, so that it doesnt
				// repeat the search
				matchedNames.addElement(files[i].getAbsolutePath());
			}
		}
	}

	// return (String[]) matchedNames.toArray(new String[0]);
	String[] matchedNamesStrings = new String[matchedNames.size()];
	matchedNames.copyInto(matchedNamesStrings);
	return matchedNamesStrings;
}
 
开发者ID:sshtools,项目名称:j2ssh-maverick,代码行数:42,代码来源:GlobRegExpMatching.java

示例13: matchFilesWithPattern

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
/**
 * compiles fileNameRegExp into a regular expression and pattern matches on
 * each file's name, and returns those that match.
 * 
 * @param files
 * @param fileNameRegExp
 * 
 * @return SftpFile[] of files that match the expresion.
 */
public SftpFile[] matchFilesWithPattern(SftpFile[] files,
		String fileNameRegExp) throws SftpStatusException, SshException {
	// set up variables for regexp matching
	Pattern mpattern = null;
	PatternCompiler aGCompiler = new GlobCompiler();
	PatternMatcher aPerl5Matcher = new Perl5Matcher();
	// Attempt to compile the pattern. If the pattern is not valid,
	// throw exception
	try {
		mpattern = aGCompiler.compile(fileNameRegExp);
	} catch (MalformedPatternException e) {
		throw new SshException("Invalid regular expression:"
				+ e.getMessage(), SshException.BAD_API_USAGE);
	}

	Vector<SftpFile> matchedNames = new Vector<SftpFile>();

	for (int i = 0; i < files.length; i++) {
		if ((!files[i].getFilename().equals("."))
				&& (!files[i].getFilename().equals(".."))
				&& (!files[i].isDirectory())) {
			if (aPerl5Matcher.matches(files[i].getFilename(), mpattern)) {
				// call get for each match, passing true, so that it doesnt
				// repeat the search
				matchedNames.addElement(files[i]);
			}
		}
	}

	// return (SftpFile[]) matchedNames.toArray(new SftpFile[0]);
	SftpFile[] matchedNamesSftpFiles = new SftpFile[matchedNames.size()];
	matchedNames.copyInto(matchedNamesSftpFiles);
	return matchedNamesSftpFiles;
}
 
开发者ID:sshtools,项目名称:j2ssh-maverick,代码行数:44,代码来源:GlobRegExpMatching.java

示例14: readColumn

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
/**
    * {@inheritDoc}
    */
   protected Column readColumn(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
   {
	Column column = super.readColumn(metaData, values);

	if ((column.getTypeCode() == Types.DECIMAL) && (column.getSizeAsInt() == 19) && (column.getScale() == 0))
	{
		// Back-mapping to BIGINT
		column.setTypeCode(Types.BIGINT);
	}
       else if (column.getDefaultValue() != null)
       {
   		if (column.getTypeCode() == Types.TIMESTAMP)
   		{
   			// Sybase maintains the default values for DATE/TIME jdbc types, so we have to
   			// migrate the default value to TIMESTAMP
   			PatternMatcher matcher   = new Perl5Matcher();
   			Timestamp      timestamp = null;
   
   			if (matcher.matches(column.getDefaultValue(), _isoDatePattern))
   			{
   				timestamp = new Timestamp(Date.valueOf(matcher.getMatch().group(1)).getTime());
   			}
   			else if (matcher.matches(column.getDefaultValue(), _isoTimePattern))
   			{
   				timestamp = new Timestamp(Time.valueOf(matcher.getMatch().group(1)).getTime());
   			}
   			if (timestamp != null)
   			{
   				column.setDefaultValue(timestamp.toString());
   			}
   		}
           else if (TypeMap.isTextType(column.getTypeCode()))
           {
               column.setDefaultValue(unescape(column.getDefaultValue(), "'", "''"));
           }
       }
	return column;
}
 
开发者ID:flex-rental-solutions,项目名称:apache-ddlutils,代码行数:42,代码来源:SybaseModelReader.java

示例15: isWildCardMatch

import org.apache.oro.text.regex.PatternMatcher; //导入方法依赖的package包/类
private static boolean isWildCardMatch(String matchPattern, String value) {
    PatternMatcher matcher = new Perl5Matcher();
    return matcher.matches(value, patterns.get(matchPattern));
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:5,代码来源:ConfigHelper.java


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