📄 datavaluefactoryimpl.java
字号:
/* Derby - Class org.apache.derby.iapi.types.DataValueFactoryImpl Copyright 1999, 2005 The Apache Software Foundation or its licensors, as applicable. 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. */package org.apache.derby.iapi.types;import org.apache.derby.iapi.types.NumberDataValue;import org.apache.derby.iapi.types.BooleanDataValue;import org.apache.derby.iapi.types.BitDataValue;import org.apache.derby.iapi.types.DateTimeDataValue;import org.apache.derby.iapi.types.StringDataValue;import org.apache.derby.iapi.types.UserDataValue;import org.apache.derby.iapi.types.RefDataValue;import org.apache.derby.iapi.types.DataValueFactory;import org.apache.derby.iapi.types.DataValueDescriptor;import org.apache.derby.iapi.types.RowLocation;import org.apache.derby.iapi.error.StandardException;import org.apache.derby.iapi.services.sanity.SanityManager;import org.apache.derby.iapi.services.i18n.LocaleFinder;import org.apache.derby.iapi.services.io.RegisteredFormatIds;import org.apache.derby.iapi.services.io.StoredFormatIds;import org.apache.derby.iapi.services.monitor.ModuleControl;import java.sql.Date;import java.sql.Time;import java.sql.Timestamp;import java.util.Properties;import org.apache.derby.iapi.db.DatabaseContext;import org.apache.derby.iapi.services.context.ContextService;/** * Core implementation of DataValueFactory. Does not implement * methods required to generate DataValueDescriptor implementations * for the DECIMAL datatype. J2ME and J2SE require different implementations. * * @see DataValueFactory */abstract class DataValueFactoryImpl implements DataValueFactory, ModuleControl{ LocaleFinder localeFinder; DataValueFactoryImpl() { } /* ** ModuleControl methods. */ /* (non-Javadoc) * @see org.apache.derby.iapi.services.monitor.ModuleControl#boot(boolean, java.util.Properties) */ public void boot(boolean create, Properties properties) throws StandardException { DataValueDescriptor decimalImplementation = getNullDecimal(null); TypeId.decimalImplementation = decimalImplementation; RegisteredFormatIds.TwoByte[StoredFormatIds.SQL_DECIMAL_ID] = decimalImplementation.getClass().getName(); // Generate a DECIMAL value represetentation of 0 decimalImplementation = decimalImplementation.getNewNull(); decimalImplementation.setValue(0L); NumberDataType.ZERO_DECIMAL = decimalImplementation; } /* (non-Javadoc) * @see org.apache.derby.iapi.services.monitor.ModuleControl#stop() */ public void stop() { } /** * @see DataValueFactory#getDataValue * */ public NumberDataValue getDataValue(int value) { return new SQLInteger(value); } public NumberDataValue getDataValue(int value, NumberDataValue previous) throws StandardException { if (previous == null) return new SQLInteger(value); previous.setValue(value); return previous; } public NumberDataValue getDataValue(Integer value) { if (value != null) return new SQLInteger(value.intValue()); else return new SQLInteger(); } public NumberDataValue getDataValue(Integer value, NumberDataValue previous) throws StandardException { if (previous == null) { return getDataValue(value); } previous.setValue(value); return previous; } public NumberDataValue getDataValue(char value) { return new SQLInteger(value); } public NumberDataValue getDataValue(char value, NumberDataValue previous) throws StandardException { if (previous == null) return new SQLInteger(value); previous.setValue(value); return previous; } public NumberDataValue getDataValue(short value) { return new SQLSmallint(value); } public NumberDataValue getDataValue(short value, NumberDataValue previous) throws StandardException { if (previous == null) return new SQLSmallint(value); previous.setValue(value); return previous; } public NumberDataValue getDataValue(Short value) { if (value != null) return new SQLSmallint(value.shortValue()); else return new SQLSmallint(); } public NumberDataValue getDataValue(Short value, NumberDataValue previous) throws StandardException { if (previous == null) return getDataValue(value); previous.setValue(value); return previous; } public NumberDataValue getDataValue(byte value) { return new SQLTinyint(value); } public NumberDataValue getDataValue(byte value, NumberDataValue previous) throws StandardException { if (previous == null) return new SQLTinyint(value); previous.setValue(value); return previous; } public NumberDataValue getDataValue(Byte value) { if (value != null) return new SQLTinyint(value.byteValue()); else return new SQLTinyint(); } public NumberDataValue getDataValue(Byte value, NumberDataValue previous) throws StandardException { if (previous == null) return getDataValue(value); previous.setValue(value); return previous; } public NumberDataValue getDataValue(long value) { return new SQLLongint(value); } public NumberDataValue getDataValue(long value, NumberDataValue previous) throws StandardException { if (previous == null) return new SQLLongint(value); previous.setValue(value); return previous; } public NumberDataValue getDataValue(Long value) { if (value != null) return new SQLLongint(value.longValue()); else return new SQLLongint(); } public NumberDataValue getDataValue(Long value, NumberDataValue previous) throws StandardException { if (previous == null) return getDataValue(value); previous.setValue(value); return previous; } public NumberDataValue getDataValue(float value) throws StandardException { return new SQLReal(value); } public NumberDataValue getDataValue(float value, NumberDataValue previous) throws StandardException { if (previous == null) return new SQLReal(value); previous.setValue(value); return previous; } public NumberDataValue getDataValue(Float value) throws StandardException { if (value != null) return new SQLReal(value.floatValue()); else return new SQLReal(); } public NumberDataValue getDataValue(Float value, NumberDataValue previous) throws StandardException { if (previous == null) return getDataValue(value); previous.setValue(value); return previous; } public NumberDataValue getDataValue(double value) throws StandardException { return new SQLDouble(value); } public NumberDataValue getDataValue(double value, NumberDataValue previous) throws StandardException { if (previous == null) return new SQLDouble(value); previous.setValue(value); return previous; } public NumberDataValue getDataValue(Double value) throws StandardException { if (value != null) return new SQLDouble(value.doubleValue()); else return new SQLDouble(); } public NumberDataValue getDataValue(Double value, NumberDataValue previous) throws StandardException { if (previous == null) return getDataValue(value); previous.setValue(value); return previous; } public final NumberDataValue getDecimalDataValue(Number value) throws StandardException { NumberDataValue ndv = getNullDecimal((NumberDataValue) null); ndv.setValue(value); return ndv; } public final NumberDataValue getDecimalDataValue(Number value, NumberDataValue previous) throws StandardException { if (previous == null) return getDecimalDataValue(value); previous.setValue(value); return previous; } public final NumberDataValue getDecimalDataValue(String value, NumberDataValue previous) throws StandardException { if (previous == null) return getDecimalDataValue(value); previous.setValue(value); return previous; } public BooleanDataValue getDataValue(boolean value) { return new SQLBoolean(value); } public BooleanDataValue getDataValue(boolean value, BooleanDataValue previous) throws StandardException { if (previous == null) return new SQLBoolean(value); previous.setValue(value); return previous; } public BooleanDataValue getDataValue(Boolean value) { if (value != null) return new SQLBoolean(value.booleanValue()); else return new SQLBoolean(); } public BooleanDataValue getDataValue(Boolean value,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -