001: /*
002:
003: Derby - Class org.apache.derby.iapi.types.BooleanDataValue
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.iapi.types;
023:
024: import org.apache.derby.iapi.error.StandardException;
025:
026: public interface BooleanDataValue extends DataValueDescriptor {
027: public boolean getBoolean();
028:
029: /**
030: * The SQL AND operator. This provides SQL semantics for AND with unknown
031: * truth values - consult any standard SQL reference for an explanation.
032: *
033: * @param otherValue The other BooleanDataValue to AND with this one
034: *
035: * @return this AND otherValue
036: *
037: */
038: public BooleanDataValue and(BooleanDataValue otherValue);
039:
040: /**
041: * The SQL OR operator. This provides SQL semantics for OR with unknown
042: * truth values - consult any standard SQL reference for an explanation.
043: *
044: * @param otherValue The other BooleanDataValue to OR with this one
045: *
046: * @return this OR otherValue
047: *
048: */
049: public BooleanDataValue or(BooleanDataValue otherValue);
050:
051: /**
052: * The SQL IS operator - consult any standard SQL reference for an explanation.
053: *
054: * Implements the following truth table:
055: *
056: * otherValue
057: * | TRUE | FALSE | UNKNOWN
058: * this |----------------------------
059: * |
060: * TRUE | TRUE | FALSE | FALSE
061: * FALSE | FALSE | TRUE | FALSE
062: * UNKNOWN | FALSE | FALSE | TRUE
063: *
064: *
065: * @param otherValue BooleanDataValue to compare to. May be TRUE, FALSE, or UNKNOWN.
066: *
067: * @return whether this IS otherValue
068: *
069: */
070: public BooleanDataValue is(BooleanDataValue otherValue);
071:
072: /**
073: * Implements NOT IS. This reverses the sense of the is() call.
074: *
075: *
076: * @param otherValue BooleanDataValue to compare to. May be TRUE, FALSE, or UNKNOWN.
077: *
078: * @return NOT( this IS otherValue )
079: *
080: */
081: public BooleanDataValue isNot(BooleanDataValue otherValue);
082:
083: /**
084: * Throw an exception with the given SQLState if this BooleanDataValue
085: * is false. This method is useful for evaluating constraints.
086: *
087: * @param SQLState The SQLState of the exception to throw if
088: * this SQLBoolean is false.
089: * @param tableName The name of the table to include in the exception
090: * message.
091: * @param constraintName The name of the failed constraint to include
092: * in the exception message.
093: *
094: * @return this
095: *
096: * @exception StandardException Thrown if this BooleanDataValue
097: * is false.
098: */
099: public BooleanDataValue throwExceptionIfFalse(String SQLState,
100: String tableName, String constraintName)
101: throws StandardException;
102:
103: /*
104: ** NOTE: The NOT operator is translated to "= FALSE", which does the same
105: ** thing.
106: */
107:
108: /**
109: * Set the value of this BooleanDataValue.
110: *
111: * @param theValue Contains the boolean value to set this BooleanDataValue
112: * to. Null means set this BooleanDataValue to null.
113: */
114: public void setValue(Boolean theValue);
115:
116: /**
117: * Tell whether a BooleanDataValue has the given value. This is useful
118: * for short-circuiting.
119: *
120: * @param value The value to look for
121: *
122: * @return true if the BooleanDataValue contains the given value.
123: */
124: public boolean equals(boolean value);
125:
126: /**
127: * Return an immutable BooleanDataValue with the same value as this.
128: * @return An immutable BooleanDataValue with the same value as this.
129: */
130: public BooleanDataValue getImmutable();
131: }
|