[Idrs-commit] CVS: Idrs/dev/src/net/sourceforge/idrs/utils Validators.java,NONE,1.1 CleanUp.java,1.2
Brought to you by:
bigman921
|
From: Marc B. <big...@us...> - 2002-12-29 04:02:00
|
Update of /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/utils
In directory sc8-pr-cvs1:/tmp/cvs-serv25385
Modified Files:
CleanUp.java DB.java
Added Files:
Validators.java
Log Message:
add a validator class
--- NEW FILE: Validators.java ---
package net.sourceforge.idrs.utils.*;
/*
Validators.java
Copyright (C) 2002 Marc Boorshtein
The contents of this file are subject to the Mozilla Public License Version 1.0 (the License);
you may not use this file except in compliance with the License. You may obtain a copy of the
License at http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License.
*/
import java.sql.*;
import net.sourceforge.idrs.utils.*;
import java.io.*;
import net.sourceforge.idrs.utils.*;
import net.sourceforge.idrs.script.*;
/* Class to store basic form validation */
public class Validators implements Serializable {
protected transient IDRSScript idrs;
public Validators() {
}
/**
*Must be executed in the reInit() of the subclassed object
*@param idrs The current script context
*/
public setContext(IDRSScript idrs) {
this.idrs = idrs;
}
/**
*Function for determining if a value has been given.
*If no value has been given (null or empty) then an error is created.
*@param name The Name of the field
*@param val The value to be tested
*/
protected String requiredVal(String name, String val) {
if (val != null && val.trim().length() != 0) {
return val;
}
else {
idrs.createError("The " + name + " is required");
}
return "";
}
/**
*Function for determining if a value has been given and is an Integer.
*If no value has been given (null or empty), or the value given is not an integer then an error is created.
*@param name The Name of the field
*@param val The value to be tested
*/
protected int requiredValInt(String name, String val) {
try {
if (val != null && val.trim().length() != 0) {
int tmp = Integer.parseInt(val);
if (tmp != 0) {
return tmp;
}
else {
idrs.createError("The " + name + " is required");
}
}
else {
idrs.createError("The " + name + " is required");
}
}
catch (Exception e) {
idrs.createError("The " + name + " " + e.toString());
}
return -1;
}
/**
*Function for determining if a value has been given and is a non zero Integer.
*If no value has been given (null or empty), or the value given is not a non zero integer then an error is created.
*@param name The Name of the field
*@param val The value to be tested
*/
protected int requiredValIntZero(String name, String val) {
try {
if (val != null && val.trim().length() != 0) {
int tmp = Integer.parseInt(val);
return tmp;
}
else {
idrs.createError("The " + name + " is required");
}
}
catch (Exception e) {
idrs.createError("The " + name + " " + e.toString());
}
return -1;
}
}
Index: CleanUp.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/utils/CleanUp.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CleanUp.java 22 Aug 2002 20:06:37 -0000 1.2
--- CleanUp.java 29 Dec 2002 04:01:56 -0000 1.3
***************
*** 4,29 ****
import java.util.*;
! public class CleanUp {
protected transient LinkedList statements;
!
public CleanUp() {
this.statements = new LinkedList();
}
!
public void reset() {
statements.clear();
}
!
public void regStatement(Statement s) throws Exception {
statements.add(s);
}
!
public void cleanUp() throws Exception {
Iterator i = statements.iterator();
while (i.hasNext()) {
! ((Statement) i.next()).close();
}
}
}
--- 4,31 ----
import java.util.*;
! public class CleanUp extends Validators {
protected transient LinkedList statements;
!
public CleanUp() {
this.statements = new LinkedList();
}
!
public void reset() {
statements.clear();
}
!
public void regStatement(Statement s) throws Exception {
statements.add(s);
}
!
public void cleanUp() throws Exception {
Iterator i = statements.iterator();
while (i.hasNext()) {
! ((Statement) i.next()).close();
}
}
+
+
}
Index: DB.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/utils/DB.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** DB.java 13 Oct 2002 15:04:10 -0000 1.12
--- DB.java 29 Dec 2002 04:01:56 -0000 1.13
***************
*** 1,914 ****
! package net.sourceforge.idrs.utils;
! /*
! DB.java
! Copyright (C) 2001 Marc Boorshtein
!
! The contents of this file are subject to the Mozilla Public License Version 1.0 (the License);
! you may not use this file except in compliance with the License. You may obtain a copy of the
! License at http://www.mozilla.org/MPL/
!
! Software distributed under the License is distributed on an "AS IS" basis,
[...1765 lines suppressed...]
! cache.setPosition(this.cursurLocation);
!
! return cache;
! }
!
! public void setCache(DbCache cache) {
! this.cursur = DB.CLIENT;
! this.cache = cache;
! this.cursurLocation = cache.getPosition();
! this.rows = cache.getRows();
! this.beginWith = this.cursurLocation;
! this.wasCached = true;
! }
*/
!
public void setTransactionType(int type) {
! this.transactionType = type;
}
! }
!
|