Here you can find the source of wasNull(ResultSet rs, T value)
null
.
Parameter | Description |
---|---|
rs | The data source from which a value was read |
value | The value that was read |
value
or null
if the is true
public static final <T> T wasNull(ResultSet rs, T value) throws SQLException
//package com.java2s; /**/*from w w w .j a va2 s .co m*/ * Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com) * All rights reserved. * * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Other licenses: * ----------------------------------------------------------------------------- * Commercial licenses for this work are available. These replace the above * ASL 2.0 and offer limited warranties, support, maintenance, and commercial * database integrations. * * For more information, please visit: http://www.jooq.org/licenses * * * * * * * * * * * * * * * * */ import java.sql.CallableStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.SQLInput; public class Main { /** * Convenient way to check if a JDBC-originated record was <code>null</code>. * <p> * This is useful to check if primitive types obtained from the JDBC API * were actually SQL NULL values. * * @param stream The data source from which a value was read * @param value The value that was read * @return The <code>value</code> or <code>null</code> if the * {@link SQLInput#wasNull()} is <code>true</code> */ public static final <T> T wasNull(SQLInput stream, T value) throws SQLException { return (value == null || stream.wasNull()) ? null : value; } /** * Convenient way to check if a JDBC-originated record was <code>null</code>. * <p> * This is useful to check if primitive types obtained from the JDBC API * were actually SQL NULL values. * * @param stream The data source from which a value was read * @param value The value that was read * @return The <code>value</code> or <code>null</code> if the * {@link SQLInput#wasNull()} is <code>true</code> */ public static final <T extends Number> T wasNull(SQLInput stream, T value) throws SQLException { return (value == null || (value.intValue() == 0 && stream.wasNull())) ? null : value; } /** * Convenient way to check if a JDBC-originated record was <code>null</code>. * <p> * This is useful to check if primitive types obtained from the JDBC API * were actually SQL NULL values. * * @param stream The data source from which a value was read * @param value The value that was read * @return The <code>value</code> or <code>null</code> if the * {@link SQLInput#wasNull()} is <code>true</code> */ public static final Boolean wasNull(SQLInput stream, Boolean value) throws SQLException { return (value == null || (value.booleanValue() == false && stream.wasNull())) ? null : value; } /** * Convenient way to check if a JDBC-originated record was <code>null</code>. * <p> * This is useful to check if primitive types obtained from the JDBC API * were actually SQL NULL values. * * @param rs The data source from which a value was read * @param value The value that was read * @return The <code>value</code> or <code>null</code> if the * {@link ResultSet#wasNull()} is <code>true</code> */ public static final <T> T wasNull(ResultSet rs, T value) throws SQLException { return (value == null || rs.wasNull()) ? null : value; } /** * Convenient way to check if a JDBC-originated record was <code>null</code>. * <p> * This is useful to check if primitive types obtained from the JDBC API * were actually SQL NULL values. * * @param rs The data source from which a value was read * @param value The value that was read * @return The <code>value</code> or <code>null</code> if the * {@link ResultSet#wasNull()} is <code>true</code> */ public static final <T extends Number> T wasNull(ResultSet rs, T value) throws SQLException { return (value == null || (value.intValue() == 0 && rs.wasNull())) ? null : value; } /** * Convenient way to check if a JDBC-originated record was <code>null</code>. * <p> * This is useful to check if primitive types obtained from the JDBC API * were actually SQL NULL values. * * @param rs The data source from which a value was read * @param value The value that was read * @return The <code>value</code> or <code>null</code> if the * {@link ResultSet#wasNull()} is <code>true</code> */ public static final Boolean wasNull(ResultSet rs, Boolean value) throws SQLException { return (value == null || (value.booleanValue() == false && rs.wasNull())) ? null : value; } /** * Convenient way to check if a JDBC-originated record was <code>null</code>. * <p> * This is useful to check if primitive types obtained from the JDBC API * were actually SQL NULL values. * * @param statement The data source from which a value was read * @param value The value that was read * @return The <code>value</code> or <code>null</code> if the * {@link CallableStatement#wasNull()} is <code>true</code> */ public static final <T> T wasNull(CallableStatement statement, T value) throws SQLException { return (value == null || statement.wasNull()) ? null : value; } /** * Convenient way to check if a JDBC-originated record was <code>null</code>. * <p> * This is useful to check if primitive types obtained from the JDBC API * were actually SQL NULL values. * * @param statement The data source from which a value was read * @param value The value that was read * @return The <code>value</code> or <code>null</code> if the * {@link CallableStatement#wasNull()} is <code>true</code> */ public static final <T extends Number> T wasNull(CallableStatement statement, T value) throws SQLException { return (value == null || (value.intValue() == 0 && statement.wasNull())) ? null : value; } /** * Convenient way to check if a JDBC-originated record was <code>null</code>. * <p> * This is useful to check if primitive types obtained from the JDBC API * were actually SQL NULL values. * * @param statement The data source from which a value was read * @param value The value that was read * @return The <code>value</code> or <code>null</code> if the * {@link CallableStatement#wasNull()} is <code>true</code> */ public static final Boolean wasNull(CallableStatement statement, Boolean value) throws SQLException { return (value == null || (value.booleanValue() == false && statement.wasNull())) ? null : value; } }