1 /*****************************************************/
\r
2 /* This java file is a part of the */
\r
4 /* - Plouf's Java IRC Client - */
\r
6 /* Copyright (C) 2002 - 2004 Philippe Detournay */
\r
8 /* All contacts : theplouf@yahoo.com */
\r
10 /* PJIRC is free software; you can redistribute */
\r
11 /* it and/or modify it under the terms of the GNU */
\r
12 /* General Public License as published by the */
\r
13 /* Free Software Foundation; version 2 or later of */
\r
16 /* PJIRC is distributed in the hope that it will */
\r
17 /* be useful, but WITHOUT ANY WARRANTY; without */
\r
18 /* even the implied warranty of MERCHANTABILITY or */
\r
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
\r
20 /* General Public License for more details. */
\r
22 /* You should have received a copy of the GNU */
\r
23 /* General Public License along with PJIRC; if */
\r
24 /* not, write to the Free Software Foundation, */
\r
25 /* Inc., 59 Temple Place, Suite 330, Boston, */
\r
26 /* MA 02111-1307 USA */
\r
28 /*****************************************************/
\r
33 * The URLRecognizer.
\r
35 public class URLRecognizer implements WordRecognizer {
\r
36 private boolean isAlpha(String s) {
\r
37 s = s.toLowerCase(java.util.Locale.ENGLISH);
\r
38 for (int i = 0; i < s.length(); i++)
\r
39 if ((s.charAt(i) < 'a') || (s.charAt(i) > 'z'))
\r
45 public boolean recognize(String word) {
\r
46 if (word.startsWith("http://"))
\r
48 if (word.startsWith("ftp://"))
\r
50 if (word.startsWith("www."))
\r
52 if (word.startsWith("ftp."))
\r
54 int a = word.indexOf('.');
\r
57 int b = word.lastIndexOf('.');
\r
60 String ext = word.substring(b + 1);
\r
63 if ((ext.length() == 2) || (ext.length() == 3))
\r
69 public String getType() {
\r