01: //The Salmon Open Framework for Internet Applications (SOFIA)
02: //Copyright (C) 1999 - 2002, Salmon LLC
03: //
04: //This program is free software; you can redistribute it and/or
05: //modify it under the terms of the GNU General Public License version 2
06: //as published by the Free Software Foundation;
07: //
08: //This program is distributed in the hope that it will be useful,
09: //but WITHOUT ANY WARRANTY; without even the implied warranty of
10: //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11: //GNU General Public License for more details.
12: //
13: //You should have received a copy of the GNU General Public License
14: //along with this program; if not, write to the Free Software
15: //Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16: //
17: //For more information please visit http://www.salmonllc.com
18:
19: package com.salmonllc.examples.example8;
20:
21: import com.salmonllc.sql.DataStoreExpression;
22: import com.salmonllc.sql.DataStoreBuffer;
23: import com.salmonllc.sql.DataStoreException;
24:
25: /**
26: * An object that does simple email address validation. It can be attached to an HtmlValidator Text or DataStore validation rule
27: */
28: public class EMailValidation implements java.io.Serializable,
29: DataStoreExpression {
30: private String _colName;
31:
32: public EMailValidation(String colName) {
33: _colName = colName;
34: }
35:
36: public Object evaluateExpression(DataStoreBuffer dsBuf, int row)
37: throws DataStoreException {
38: String address = dsBuf.getString(row, _colName);
39: if (address != null)
40: if (address.indexOf('@') == -1 || address.startsWith("@")
41: || address.endsWith("@"))
42: return Boolean.FALSE;
43: return Boolean.TRUE;
44: }
45:
46: }
|