UniFileRecordNotFound
From Pickwiki
Here's a sample of the code I use in the "real" DAO's:
/**
* @param key the key to the record you wish to read
* @return An [[AddressView]] object, or null if
* the key is null or blank
* @exception DAOException thrown if there is a problem other than [[RecordNotFound]]
*/
public [[AddressView]] read( String key, Object conn ) throws DAOException
{
[[AddressView]] address = new [[AddressViewImpl]]();
address.setKey( key );
if ( key == null || key.equals( "" ) ) {
log.debug( "read: key is null or blank, returning null [[AddressView]]" );
return null;
}
try {
log.debug( "readAddress: key = [" + key + "]" );
[[UniSession]] uSession;
[[UniFile]] uFile;
[[UniString]] uString;
[[UniDynArray]] udArray;
uSession = ([[UniSession]]) conn;
uFile = uSession.openFile( "ADDRESS" );
try {
uString = uFile.read( key );
} catch ( [[UniFileException]] ex ) {
if ( ex.get[[ErrorCode]]() == [[UniObjectsTokens]].[[UVE_RNF]] ) {
log.debug( "read: record not found, returning immediately" );
return address;
} else {
log.debug( "read: re-throwing [[UniFileException]] other than [[RecordNotFound]]" );
throw ex;
}
}
uFile.close();
udArray = new [[UniDynArray]]( uString );
address.set[[ZipCode]]( udArray.extract( 1 ).toString() );
address.setState( udArray.extract( 2 ).toString() );
address.setCity( udArray.extract( 3 ).toString() );
address.set[[AddressLines]]( toList( udArray, 5 ) );
} catch ( [[UniException]] ex ) {
throw new DAOException( ex );
}
return address;
}
-- Wendy Smoak [email protected]