예제 #1
0
	/**
	 * 判断方法是否与当前方法匹配
	 * 注意:本方法已经不考虑老版系统管理中直接通过方法名称指定同步方法的使用模式,因此如果
	 * 老版迁移到新版时,需要明确地指定方法的名称和方法的参数才能正常运行
	 * @param method 方法对象,如果method为null,将报空指针异常
	 * @param methodUUID 方法惟一标识
	 * @return true-匹配上
	 *         false-没有匹配上
	 *         
	 */
	public boolean match(Method method,String methodUUID)
	{
		try
		{			
	    	boolean match = false;
			if(isPattern())
			{
				if(pattern.equals("*")) //如果模式为*,表示匹配所有的方法
					return true;
				String methodname = method.getName();
				match = RegexUtil.isMatch(methodname, this.getPattern());	
				return match;
			}
			if(methodUUID == null)
				methodUUID = SynchronizedMethod.buildMethodUUID(method);
			if(this.getUUID().equals(methodUUID))
			{
				match = true;
			}
			return match;
		}
		catch(Exception e)
		{
//			e.printStackTrace();
			log.error(e.getMessage(),e);
			return false;
		}
    	
	}
예제 #2
0
	public static String[] parserValues(String values)
	{
		
		String patternStr = "([^\\,]*)[\\,]?"; // 解析字段值
		
		String patternStr1 = "('?[^\\,]*'?)[\\,]?"; // 解析字段值

		/**
		 * 编译正则表达式patternStr,并用该表达式与传入的sql语句进行模式匹配,
		 * 如果匹配正确,则从匹配对象中提取出以上定义好的6部分,存放到数组中并返回 该数组
		 */
		String[] ret = RegexUtil.containWithPatternMatcherInput(values,patternStr1);

		PatternCompiler compiler = new Perl5Compiler();
		Pattern pattern = null;
		try
		{
			pattern = compiler.compile(patternStr,
					Perl5Compiler.CASE_INSENSITIVE_MASK);
		}
		catch (MalformedPatternException e)
		{
			e.printStackTrace();

			return null;
		}
		PatternMatcher matcher = new Perl5Matcher();
		MatchResult result = null;
		String[] tokens = null;
		boolean match = matcher.matches(values.trim(), pattern);
		System.out.println(match);
		if (match)
		{
			result = matcher.getMatch();
			tokens = new String[6];
			for (int i = 0; i < 6; i++)
			{
				tokens[i] = result.group(i + 1).trim();
				System.out.println(tokens[i]);
			}
		}

		return tokens;
	}
예제 #3
0
	public static String[] parseField(String fieldStr)
	{
        
        
        // ( soundCode , soundName , soundFileName )
		//fieldStr = fieldStr.trim();
		// String regx = "\\([\\s*([^\\,]+)\\,?]+\\)";
		String regx = "([^\\,^\\(^\\)]+)\\s*\\,?\\s*";
        return RegexUtil.containWithPatternMatcherInput(fieldStr,regx);
//		PatternCompiler compiler = new Perl5Compiler();
//		Pattern pattern = null;
//		try
//		{
//			pattern = compiler.compile(regx,
//					Perl5Compiler.CASE_INSENSITIVE_MASK);
//		}
//		catch (MalformedPatternException e)
//		{
//			e.printStackTrace();
//			return null;
//		}
//		PatternMatcher matcher = new Perl5Matcher();
//		MatchResult result = null;
//		String[] tokens = null;
//		if (matcher.matches(fieldStr, pattern))
//		{
//			result = matcher.getMatch();
//
//			tokens = new String[result.groups()];
//			for (int i = 0; i < result.groups(); i++)
//			{
//				tokens[i] = result.group(i + 1).trim();
//			}
//		}
//		return tokens;
	}