Changeset 6631
- Timestamp:
- 2004-01-28T14:38:38+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/URLField.java
r6622 r6631 11 11 implements DocumentListener { 12 12 13 //static final public Pattern URL_PATTERN = Pattern.compile("(h|ht|htt|http|http:|http:/|http://|http://)?(([a-zA-Z]([a-zA-Z]|[0-9]|[\\$\\-_\\&\\+]|[!\\*\"\'\\(\\)]|(%[0-9A-Fa-f][0-9A-Fa-f]))*(\\.[a-zA-Z]([a-zA-Z]|[0-9]|[\\$\\-_\\&\\+]|[!\\*\"\'\\(\\)]|(%[0-9A-Fa-f][0-9A-Fa-f]))*)*)|(([0-9])+\\.([0-9])+\\.([0-9])+\\.([0-9])+))(:([0-9])+)?(/([a-zA-Z]|[0-9]|[\\$\\-_\\.\\&\\+]|[!\\*\"\'\\(\\),]|(%[0-9A-Fa-f][0-9A-Fa-f]))*)*");13 static final public Pattern URL_PATTERN = Pattern.compile("(h|ht|htt|http|http:|http:/|http://|http://)?(([a-zA-Z]([a-zA-Z]|[0-9]|[\\$\\-_\\&\\+]|[!\\*\"\'\\(\\)]|(%[0-9A-Fa-f][0-9A-Fa-f]))*(\\.[a-zA-Z]([a-zA-Z]|[0-9]|[\\$\\-_\\&\\+]|[!\\*\"\'\\(\\)]|(%[0-9A-Fa-f][0-9A-Fa-f]))*)*)|(([0-9])+\\.([0-9])+\\.([0-9])+\\.([0-9])+))(:([0-9])+)?(/([a-zA-Z]|[0-9]|[\\$\\-_\\.\\&\\+]|[!\\*\"\'\\(\\),]|(%[0-9A-Fa-f][0-9A-Fa-f]))*)*"); 14 14 15 15 // Crap RegEx that matches everything dammit … … 18 18 //static final public Pattern URL_PATTERN = Pattern.compile("(h|ht|htt|http|http:|http:/|http://|http://)?[a-zA-Z0-9-]*(\.[a-zA-Z0-9-])*"); 19 19 20 static final public Pattern URL_PATTERN = Pattern.compile("(h|ht|htt|http|http:|http:/|http://|http://)?[\\w]+(\\.[\\w]+)([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?");20 //static final public Pattern URL_PATTERN = Pattern.compile("(h|ht|htt|http|http:|http:/|http://|http://)?[\\w]+(\\.[\\w]+)([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?"); 21 21 22 22 private Color background; … … 72 72 73 73 public boolean validateURL() { 74 boolean result; 75 String text = getText(); 76 Matcher m = URL_PATTERN.matcher(text); 77 if(text.length() == 0 || m.matches()) { 78 setBackground(background); 79 setForeground(foreground); 80 result = true; 81 } 82 else { 83 setBackground(invalid_background); 84 setForeground(invalid_foreground); 85 result = false; 86 } 87 m = null; 88 return result; 74 return true; 75 // boolean result; 76 // String text = getText(); 77 // Matcher m = URL_PATTERN.matcher(text); 78 // if(text.length() == 0 || m.matches()) { 79 // setBackground(background); 80 // setForeground(foreground); 81 // result = true; 82 // } 83 // else { 84 // setBackground(invalid_background); 85 // setForeground(invalid_foreground); 86 // result = false; 87 // } 88 // m = null; 89 // System.err.println("Validating: " + text + " -> " + (result ? "GOOD" : "BAD")); 90 // text = null; 91 // return result; 89 92 } 90 93
Note:
See TracChangeset
for help on using the changeset viewer.