⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringcolumnvti.java

📁 derby数据库源码。。。。。。。。。。。。。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*Derby - Class org.apache.derbyDemo.vtis.core.StringColumnVTILicensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements.  See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License.  You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.*/package org.apache.derbyDemo.vtis.core;import java.io.*;import java.math.BigDecimal;import java.sql.*;import java.text.DateFormat;import java.text.ParseException;/** * <p> * This is an abstract VTI which assumes that all columns are strings and which * coerces the strings to reasonable values for various getXXX() * methods. Subclasses must implement the following ResultSet methods: * </p> * * <ul> * <li>next( )</li> * <li>close()</li> * <li>getMetaData()</li> * </ul> * * <p> * and the following protected methods introduced by this class: * </p> * * <ul> * <li>getRawColumn( int columnNumber )</li> * </ul> */public  abstract    class   StringColumnVTI extends VTITemplate{    ///////////////////////////////////////////////////////////////////////////////////    //    // CONSTANTS    //    ///////////////////////////////////////////////////////////////////////////////////    ///////////////////////////////////////////////////////////////////////////////////    //    // INNER CLASSES    //    ///////////////////////////////////////////////////////////////////////////////////    /**     * <p>     * A crude Blob implementation.     * </p>     */    public	static	final	class	SimpleBlob	implements	Blob    {        private	byte[]	_bytes;                public	SimpleBlob( byte[] bytes )        {            _bytes = bytes;        }                public	InputStream	getBinaryStream()        {            return new ByteArrayInputStream( _bytes );        }                public	byte[]	getBytes( long position, int length ) { return _bytes; }                public	long	length()        {            if ( _bytes == null ) { return 0L; }            return (long) _bytes.length;        }                public	long	position( Blob pattern, long start ) { return 0L; }        public	long	position( byte[] pattern, long start ) { return 0L; }                public	boolean	equals( Object other )        {            if ( other == null ) { return false; }            if ( !( other instanceof Blob ) ) { return false; }                        Blob	that = (Blob) other;                        try {                if ( this.length() != that.length() ) { return false; }                                InputStream	thisStream = this.getBinaryStream();                InputStream	thatStream = that.getBinaryStream();                                while( true )                {                    int		nextByte = thisStream.read();                                        if ( nextByte < 0 ) { break; }                    if ( nextByte != thatStream.read() ) { return false; }                }            }            catch (Exception e)            {                System.err.println( e.getMessage() );                e.printStackTrace();                return false;            }                        return true;        }                public int setBytes(long arg0, byte[] arg1) throws SQLException {            throw new SQLException("not implemented");        }                public int setBytes(long arg0, byte[] arg1, int arg2, int arg3) throws SQLException {            throw new SQLException("not implemented");        }        public OutputStream setBinaryStream(long arg0) throws SQLException {            throw new SQLException("not implemented");        }        public void truncate(long arg0) throws SQLException {            throw new SQLException("not implemented");        }    }        /**     * <p>     * A crude Clob implementation.     * </p>     */    public	static	final	class	SimpleClob	implements	Clob    {        private	String	_contents;        public	SimpleClob( String contents )        {            _contents = contents;        }                public	InputStream	getAsciiStream()        {            try {                return new ByteArrayInputStream( _contents.getBytes( "UTF-8" ) );            }            catch (Exception e) { return null; }        }                public	Reader	getCharacterStream()        {            return new CharArrayReader( _contents.toCharArray() );        }                public	String	getSubString( long position, int length )        {            return _contents.substring( (int) position, length );        }		        public	long	length()        {            if ( _contents == null ) { return 0L; }            return (long) _contents.length();        }                public	long	position( Clob searchstr, long start ) { return 0L; }        public	long	position( String searchstr, long start ) { return 0L; }                public	boolean	equals( Object other )        {            if ( other == null ) { return false; }            if ( !( other instanceof Clob ) ) { return false; }                        Clob	that = (Clob) other;                        try {                if ( this.length() != that.length() ) { return false; }                                InputStream	thisStream = this.getAsciiStream();                InputStream	thatStream = that.getAsciiStream();                                while( true )                {                    int		nextByte = thisStream.read();                                        if ( nextByte < 0 ) { break; }                    if ( nextByte != thatStream.read() ) { return false; }                }            }            catch (Exception e)            {                System.err.println( e.getMessage() );                e.printStackTrace();                return false;            }                        return true;        }                public int setString(long arg0, String arg1) throws SQLException {            throw new SQLException("not implemented");        }                public int setString(long arg0, String arg1, int arg2, int arg3) throws SQLException {            throw new SQLException("not implemented");        }        public OutputStream setAsciiStream(long arg0) throws SQLException {            throw new SQLException("not implemented");        }        public Writer setCharacterStream(long arg0) throws SQLException {            throw new SQLException("not implemented");        }        public void truncate(long arg0) throws SQLException {            throw new SQLException("not implemented");            }    }        ///////////////////////////////////////////////////////////////////////////////////    //    // STATE    //    ///////////////////////////////////////////////////////////////////////////////////    private String[]      _columnNames;    private boolean _lastColumnWasNull;        ///////////////////////////////////////////////////////////////////////////////////    //    // StringColumnVTI BEHAVIOR TO BE IMPLEMENTED BY SUBCLASSES    //    ///////////////////////////////////////////////////////////////////////////////////    /**     * <p>     * Get the string value of the column in the current row identified by the 1-based columnNumber.     * </p>     */    protected  abstract    String  getRawColumn( int columnNumber ) throws SQLException;        ///////////////////////////////////////////////////////////////////////////////////    //    // CONSTRUCTORS    //    ///////////////////////////////////////////////////////////////////////////////////    /**     * <p>     * Build a StringColumnVTI with the given column names     * </p>     */    public  StringColumnVTI( String[] columnNames )    {        _columnNames = columnNames;    }        ///////////////////////////////////////////////////////////////////////////////////    //    // ResultSet BEHAVIOR    //    ///////////////////////////////////////////////////////////////////////////////////    public boolean wasNull() throws SQLException { return _lastColumnWasNull; }        public int findColumn( String columnName ) throws SQLException    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -