svn-gvsig-desktop / trunk / build / distribution / IzPack / src / lib / com / izforge / izpack / util / IsPortValidator.java @ 21757
History | View | Annotate | Download (1.63 KB)
1 |
/*
|
---|---|
2 |
* Copyright (C) 2004 Thorsten Kamann
|
3 |
*
|
4 |
* File : IsPortValidator.java
|
5 |
* Description : Checks whether the given port is a valid port in the range
|
6 |
* from 0 until 32000
|
7 |
* Author's email : thorsten.kamann@planetes.de
|
8 |
* Author's Website : http://www.izforge.com
|
9 |
*
|
10 |
* This program is free software; you can redistribute it and/or
|
11 |
* modify it under the terms of the GNU General Public License
|
12 |
* as published by the Free Software Foundation; either version 2
|
13 |
* of the License, or any later version.
|
14 |
*
|
15 |
* This program is distributed in the hope that it will be useful,
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
* GNU General Public License for more details.
|
19 |
*
|
20 |
* You should have received a copy of the GNU General Public License
|
21 |
* along with this program; if not, write to the Free Software
|
22 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
23 |
*/
|
24 |
|
25 |
package com.izforge.izpack.util; |
26 |
|
27 |
import com.izforge.izpack.panels.ProcessingClient; |
28 |
import com.izforge.izpack.panels.Validator; |
29 |
|
30 |
/**
|
31 |
* A validator to check whether the field content is a port .
|
32 |
*
|
33 |
* @author thorque
|
34 |
*/
|
35 |
public class IsPortValidator implements Validator |
36 |
{ |
37 |
|
38 |
public boolean validate(ProcessingClient client){ |
39 |
int port = 0; |
40 |
|
41 |
if (client.getFieldContents(0).equals("")){ |
42 |
return false; |
43 |
} |
44 |
|
45 |
try{
|
46 |
port = Integer.parseInt(client.getFieldContents(0)); |
47 |
if (port > 0 && port < 32000){ |
48 |
return true; |
49 |
} |
50 |
}catch (Exception ex){ |
51 |
return false; |
52 |
} |
53 |
|
54 |
return false; |
55 |
} |
56 |
|
57 |
} |