Java Code Examples for java.util.regex.PatternSyntaxException#printStackTrace()
The following examples show how to use
java.util.regex.PatternSyntaxException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IllegalRequestParameterFilter.java From development with Apache License 2.0 | 6 votes |
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()]); }
Example 2
Source File: ImportsUtilBase.java From KodeBeagle with Apache License 2.0 | 6 votes |
public final Map<String, Set<String>> excludeConfiguredImports( final Map<String, Set<String>> importsVsMethods, final Set<String> excludeImports) { Map<String, Set<String>> finalImportsVsMethods = new HashMap<>(); finalImportsVsMethods.putAll(importsVsMethods); Set<Map.Entry<String, Set<String>>> entrySet = importsVsMethods.entrySet(); for (String importStatement : excludeImports) { Pattern pattern = Pattern.compile(importStatement); for (Map.Entry<String, Set<String>> entry : entrySet) { try { String entryImport = entry.getKey(); Matcher matcher = pattern.matcher(entryImport); if (matcher.find()) { finalImportsVsMethods.remove(entryImport); } } catch (PatternSyntaxException e) { KBNotification.getInstance().error(e); e.printStackTrace(); } } } return finalImportsVsMethods; }
Example 3
Source File: KeywordHighlght.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
static private void addKeyword( String regexp , int color ) { if ( color != 0 && !TextUtils.isEmpty(regexp) ){ try{ sList.add( new KeywordHighlght(regexp , color|0xFF000000) ); } catch( PatternSyntaxException e) { e.printStackTrace(); } } }
Example 4
Source File: EosEcUtil.java From EosProxyServer with GNU Lesser General Public License v3.0 | 5 votes |
public static String[] safeSplitEosCryptoString( String cryptoStr ) { if ( StringUtils.isEmpty( cryptoStr)) { return new String[]{ cryptoStr }; } try { return cryptoStr.split( EOS_CRYPTO_STR_SPLITTER ); } catch (PatternSyntaxException e){ e.printStackTrace(); return new String[]{ cryptoStr }; } }
Example 5
Source File: EosEcUtil.java From PocketEOS-Android with GNU Lesser General Public License v3.0 | 5 votes |
public static String[] safeSplitEosCryptoString( String cryptoStr ) { if ( StringUtils.isEmpty( cryptoStr)) { return new String[]{ cryptoStr }; } try { return cryptoStr.split( EOS_CRYPTO_STR_SPLITTER ); } catch (PatternSyntaxException e){ e.printStackTrace(); return new String[]{ cryptoStr }; } }
Example 6
Source File: TestGlobPattern.java From hadoop with Apache License 2.0 | 5 votes |
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); } }
Example 7
Source File: EosEcUtil.java From EosCommander with MIT License | 5 votes |
public static String[] safeSplitEosCryptoString( String cryptoStr ) { if ( StringUtils.isEmpty( cryptoStr)) { return new String[]{ cryptoStr }; } try { return cryptoStr.split( EOS_CRYPTO_STR_SPLITTER ); } catch (PatternSyntaxException e){ e.printStackTrace(); return new String[]{ cryptoStr }; } }
Example 8
Source File: TestGlobPattern.java From big-c with Apache License 2.0 | 5 votes |
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); } }
Example 9
Source File: KeywordHighlght.java From JotaTextEditor with Apache License 2.0 | 5 votes |
static private void addKeyword( String regexp , int color ) { if ( color != 0 && !TextUtils.isEmpty(regexp) ){ try{ sList.add( new KeywordHighlght(regexp , color|0xFF000000) ); } catch( PatternSyntaxException e) { e.printStackTrace(); } } }
Example 10
Source File: MatchingStringsCollection.java From BungeeTabListPlus with GNU General Public License v3.0 | 5 votes |
private boolean compute(String s) { for (String pattern : patterns) { try { if (s.matches(pattern)) { return true; } } catch (PatternSyntaxException e) { e.printStackTrace(); } } return false; }
Example 11
Source File: EndPointsSetter.java From carbon-commons with Apache License 2.0 | 5 votes |
public String getEndPoints(String str) { String retVal = "<select name='pn' class='toolsClass' id='id_pn'>"; try { String[] splitArray = str.split(","); for (String st : splitArray) { if (!st.toLowerCase().contains("local")) { retVal += "<option value='" + st + "'>" + st + "</option>"; } } } catch (PatternSyntaxException ex) { ex.printStackTrace(); } retVal += "</select>"; return retVal; }
Example 12
Source File: DepLoader.java From WirelessRedstone with MIT License | 5 votes |
private void loadJson(JsonObject node) throws IOException { boolean obfuscated = ((LaunchClassLoader) DepLoader.class.getClassLoader()) .getClassBytes("net.minecraft.world.World") == null; String testClass = node.get("class").getAsString(); if (DepLoader.class.getResource("/" + testClass.replace('.', '/') + ".class") != null) return; String repo = node.get("repo").getAsString(); String filename = node.get("file").getAsString(); if (!obfuscated && node.has("dev")) filename = node.get("dev").getAsString(); boolean coreLib = node.has("coreLib") && node.get("coreLib").getAsBoolean(); Pattern pattern = null; try { if(node.has("pattern")) pattern = Pattern.compile(node.get("pattern").getAsString()); } catch (PatternSyntaxException e) { System.err.println("Invalid filename pattern: "+node.get("pattern")); e.printStackTrace(); } if(pattern == null) pattern = Pattern.compile("(\\w+).*?([\\d\\.]+)[-\\w]*\\.[^\\d]+"); VersionedFile file = new VersionedFile(filename, pattern); if (!file.matches()) throw new RuntimeException("Invalid filename format for dependency: " + filename); addDep(new Dependency(repo, file, coreLib)); }
Example 13
Source File: RepSearchEngine.java From scelight with Apache License 2.0 | 4 votes |
/** * Evaluates the text operator. * * @param fvalue filter value * @param operator operator to be evaluated * @param value operand to evaluate * @return true if evaluation is true; false otherwise */ private boolean evalTextOp( String fvalue, final Operator operator, String value ) { if ( value == null ) return false; value = value.toLowerCase(); if ( operator != Operator.MATCHES ) // Regexp is case sensitive! fvalue = fvalue.toLowerCase(); switch ( operator ) { case CONTAINS : return value.contains( fvalue ); case ENDS_WITH : return value.endsWith( fvalue ); case EQUAL : return value.equals( fvalue ); case GREATER_THAN : return value.compareTo( fvalue ) > 0; case GREATER_THAN_OR_EQUAL : return value.compareTo( fvalue ) >= 0; case LESS_THAN : return value.compareTo( fvalue ) < 0; case LESS_THAN_OR_EQUAL : return value.compareTo( fvalue ) <= 0; case MATCHES : { // Cache compiled regular expressions. // If a pattern is invalid, store a null value so we don't try to compile it again. Pattern pattern = regexpPatternMap.get( fvalue ); if ( pattern == null && !regexpPatternMap.containsKey( fvalue ) ) { try { pattern = Pattern.compile( fvalue ); } catch ( final PatternSyntaxException pse ) { // Do nothing, pattern value will remain null pse.printStackTrace(); } regexpPatternMap.put( fvalue, pattern ); } return pattern != null && pattern.matcher( value ).matches(); } case NOT_CONTAINS : return !value.contains( fvalue ); case NOT_ENDS_WITH : return !value.endsWith( fvalue ); case NOT_EQUAL : return !value.equals( fvalue ); case NOT_STARTS_WITH : return !value.startsWith( fvalue ); case STARTS_WITH : return value.startsWith( fvalue ); default : throw new RuntimeException( "Unhandled operator: " + operator ); } }
Example 14
Source File: MobiComConversationFragment.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 4 votes |
protected void processSendMessage() { if (!TextUtils.isEmpty(messageEditText.getText().toString().trim()) || !TextUtils.isEmpty(filePath)) { String inputMessage = messageEditText.getText().toString(); String[] inputMsg = inputMessage.toLowerCase().split(" "); List<String> userInputList = Arrays.asList(inputMsg); boolean disjointResult = (restrictedWords == null) || disjoint(restrictedWords, userInputList); boolean restrictedWordMatches; try { String dynamicRegex = ApplozicSetting.getInstance(getContext()).getRestrictedWordsRegex(); String pattern = !TextUtils.isEmpty(dynamicRegex) ? dynamicRegex : (alCustomizationSettings != null && !TextUtils.isEmpty(alCustomizationSettings.getRestrictedWordRegex()) ? alCustomizationSettings.getRestrictedWordRegex() : ""); restrictedWordMatches = !TextUtils.isEmpty(pattern) && Pattern.compile(pattern).matcher(inputMessage.trim()).matches(); } catch (PatternSyntaxException e) { e.printStackTrace(); createInvalidPatternExceptionDialog(); return; } if (disjointResult && !restrictedWordMatches) { sendMessage(messageEditText.getText().toString().trim()); messageEditText.setText(""); } else { final AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity()). setPositiveButton(R.string.ok_alert, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { handleSendAndRecordButtonView(true); } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { handleSendAndRecordButtonView(true); } }); alertDialog.setTitle(alCustomizationSettings.getRestrictedWordMessage()); alertDialog.setCancelable(true); alertDialog.create().show(); } } }
Example 15
Source File: MobiComAttachmentSelectorActivity.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 4 votes |
boolean validateCaptionTextAndShowDialog() { if (!TextUtils.isEmpty(messageEditText.getText().toString().trim())) { String inputMessage = messageEditText.getText().toString(); String[] inputMsg = inputMessage.toLowerCase().split(" "); List<String> userInputList = Arrays.asList(inputMsg); boolean disjointResult = (restrictedWords == null) || disjoint(restrictedWords, userInputList); boolean restrictedWordMatches; try { String dynamicRegex = ApplozicSetting.getInstance(this).getRestrictedWordsRegex(); String pattern = !TextUtils.isEmpty(dynamicRegex) ? dynamicRegex : (alCustomizationSettings != null && !TextUtils.isEmpty(alCustomizationSettings.getRestrictedWordRegex()) ? alCustomizationSettings.getRestrictedWordRegex() : ""); restrictedWordMatches = !TextUtils.isEmpty(pattern) && Pattern.compile(pattern).matcher(inputMessage.trim()).matches(); } catch (PatternSyntaxException e) { Utils.printLog(this, TAG, "The Regex to match message is invalid"); e.printStackTrace(); return false; } if (!(disjointResult && !restrictedWordMatches)) { final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this). setPositiveButton(R.string.ok_alert, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { } }); alertDialog.setTitle(alCustomizationSettings.getRestrictedWordMessage()); alertDialog.setCancelable(true); alertDialog.create().show(); return false; } } return true; }