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


Java PatternSyntaxException.printStackTrace方法代碼示例

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


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

示例1: toPatterns

import java.util.regex.PatternSyntaxException; //導入方法依賴的package包/類
Pattern[] toPatterns(String[] regexStrings) {
    if (regexStrings == null)
        return new Pattern[0];
    List<Pattern> patterns = new ArrayList<Pattern>();
    for (String pattern : regexStrings) {
        try {
            patterns.add(Pattern.compile(pattern));
        } catch (PatternSyntaxException pse) {
            ByteArrayOutputStream bs = new ByteArrayOutputStream();
            PrintStream ps = new PrintStream(bs);
            try {
                pse.printStackTrace(ps);
                logger.logDebug(String.format("%s: %s", this.getClass()
                        .getName(), bs.toString()));
            } finally {
                ps.close();
            }
        }
    }
    return patterns.toArray(new Pattern[patterns.size()]);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:22,代碼來源:IllegalRequestParameterFilter.java

示例2: getParameters

import java.util.regex.PatternSyntaxException; //導入方法依賴的package包/類
@Override
public List<String> getParameters(String template) {

    List<String> parameters = new ArrayList<>();
    try {
        Pattern regex = Pattern.compile(REGEX);
        Matcher matcher = regex.matcher(template);
        while (matcher.find())
        {
            parameters.add(matcher.group(1));
        }
    }catch (PatternSyntaxException e)
    {
        e.printStackTrace();
    }
    return parameters;
}
 
開發者ID:PestaKit,項目名稱:microservice-email,代碼行數:18,代碼來源:TemplateServiceImp.java

示例3: cmdSplit

import java.util.regex.PatternSyntaxException; //導入方法依賴的package包/類
private void cmdSplit(String cmd){
	
	try {
		cmds = cmd.split("\\n+");
	} catch (PatternSyntaxException e) {
		e.printStackTrace();
	}
	
}
 
開發者ID:ivangundampc,項目名稱:SleepOnLan,代碼行數:10,代碼來源:Commander.java

示例4: shouldThrow

import java.util.regex.PatternSyntaxException; //導入方法依賴的package包/類
private void shouldThrow(String... globs) {
  for (String glob : globs) {
    try {
      GlobPattern.compile(glob);
    }
    catch (PatternSyntaxException e) {
      e.printStackTrace();
      continue;
    }
    assertTrue("glob "+ glob +" should throw", false);
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:13,代碼來源:TestGlobPattern.java

示例5: wildcardToPattern

import java.util.regex.PatternSyntaxException; //導入方法依賴的package包/類
/**
 * Creates a regular expression pattern that matches a "wildcard" pattern.
 *
 * @param wildcard The wildcard pattern.
 * @param matchCase Whether the pattern should be case sensitive.
 * @param escapeStartChar Whether to escape a starting <code>'^'</code>
 *        character.
 * @return The pattern.
 */
public static Pattern wildcardToPattern(String wildcard, boolean matchCase,
		boolean escapeStartChar) {

	int flags = RSyntaxUtilities.getPatternFlags(matchCase, 0);

	StringBuilder sb = new StringBuilder();
	for (int i=0; i<wildcard.length(); i++) {
		char ch = wildcard.charAt(i);
		switch (ch) {
			case '*':
				sb.append(".*");
				break;
			case '?':
				sb.append('.');
				break;
			case '^':
				if (i>0 || escapeStartChar) {
					sb.append('\\');
				}
				sb.append('^');
				break;
			case '\\':
			case '.': case '|':
			case '+': case '-':
			case '$':
			case '[': case ']':
			case '{': case '}':
			case '(': case ')':
				sb.append('\\').append(ch);
				break;
			default:
				sb.append(ch);
				break;
		}
	}

	Pattern p = null;
	try {
		p = Pattern.compile(sb.toString(), flags);
	} catch (PatternSyntaxException pse) {
		pse.printStackTrace();
		p = Pattern.compile(".+");
	}

	return p;

}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:57,代碼來源:RSyntaxUtilities.java

示例6: listCustomizations

import java.util.regex.PatternSyntaxException; //導入方法依賴的package包/類
/** This method will list the customizations added to a code generated file.
 * @param file the code generated file.
 * @param writer the customizations will be written to this writer.
 * @param customizationFilter the customizations will be filtered based on this paramter. If no value is passed, then all the customizations will be listed.
 * @throws IOException if any IO error occurs.
 * @throws SourceDecomposerException if the file is malformed or if it cannot be decomposed.
 */
public static void listCustomizations(File file, BufferedWriter writer, String customizationFilter)
throws IOException, SourceDecomposerException {
    System.out.println("Processing file... " + file);
    SourceDecomposer sd = new SourceDecomposer(new BufferedReader(new FileReader(file)));
    Collection elements = sd.getCollection();
    boolean headerWritten = false;
    if (elements != null) {
        for (Iterator itr = elements.iterator(); itr.hasNext();) {
            Object obj = itr.next();
            if (obj instanceof SourceDecomposer.GuardedBorder) {
                SourceDecomposer.GuardedBorder gb = (SourceDecomposer.GuardedBorder) obj;
                
                // Check the name of the customization block against the filter
                if (customizationFilter != null && customizationFilter.length() > 0) {
                    try {
                        // Ignore this customization, if it does not match the filter
                        if (!Pattern.matches(customizationFilter, gb.getKey()))
                            continue;
                    } catch (PatternSyntaxException e) {
                        e.printStackTrace();
                        throw new IllegalArgumentException("Invalid customizationFilter passed: " + customizationFilter);
                    }
                }
                
                // Strip the borders from the contents
                StringHelper.Line line = null;
                StringBuffer buf = new StringBuffer();
                PushbackReader reader = new PushbackReader(new StringReader(gb.getContents()));
                while ((line = StringHelper.readLine(reader)) != null) {
                    if (line.getContents().indexOf(SourceDecomposer.FIRST) < 0 && line.getContents().indexOf(SourceDecomposer.LAST) < 0)
                        buf.append(line);
                }
                String contents = buf.toString().trim();
                
                // Only write if the contents are not empty
                if (contents.length() > 0) {
                    if (!headerWritten) {
                        writer.write("===============================================================================\n");
                        writer.write(file.getPath());
                        writer.write("\n===============================================================================\n");
                        headerWritten = true;
                    }
                    writer.write("* " + gb.getKey() + '\n');
                    writer.write(contents);
                    writer.write("\n\n");
                    writer.flush();
                }
            }
        }
    }
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:59,代碼來源:SourceDecomposerUtils.java


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