com.ibm.as400.access.JDNullableIntegerFieldMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jt400 Show documentation
Show all versions of jt400 Show documentation
The Open Source version of the IBM Toolbox for Java
The newest version!
///////////////////////////////////////////////////////////////////////////////
//
// JTOpen (IBM Toolbox for Java - OSS version)
//
// Filename: JDNullableIntegerFieldMap.java
//
// The source code contained herein is licensed under the IBM Public License
// Version 1.0, which has been approved by the Open Source Initiative.
// Copyright (C) 1997-2001 International Business Machines Corporation and
// others. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
package com.ibm.as400.access;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
/**
The JDNullableIntgerFieldMap class converts
a character value for null capable
to the integer value required by JDBC.
**/
class JDNullableIntegerFieldMap
extends JDSimpleFieldMap
implements JDFieldMap
{
static final String copyright = "Copyright (C) 1997-2001 International Business Machines Corporation and others.";
// fromIndex is the index of the data received from the system.
JDNullableIntegerFieldMap (int fromIndex)
{
super (fromIndex);
}
/**
Returns the nullable indicator in JDBC format.
**/
public Object getValue (JDRow row)
throws SQLException
{
Object serverData = super.getValue (row); // gets data from correct column
// using fromIndex
// if serverData == "Y", return columnNullable
// == "N", return columnNoNulls
// else return columnNullableUnknown
String serverDataAsString = serverData.toString();
if(serverDataAsString.length () > 0)
{
switch(serverDataAsString.charAt (0))
{
case 'N':
return Integer.valueOf(DatabaseMetaData.columnNoNulls);
case 'Y':
return Integer.valueOf(DatabaseMetaData.columnNullable);
default:
return Integer.valueOf(DatabaseMetaData.columnNullableUnknown);
}
}
else
return Integer.valueOf(DatabaseMetaData.columnNullableUnknown);
}
/**
Indicates if the value was a data mapping error.
**/
public boolean isDataMappingError(JDRow row)
throws SQLException
{
return false;
}
/**
Indicates if value is null.
**/
public boolean isNull (JDRow row)
throws SQLException
{
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy