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

📄 propertyfilevti.java

📁 derby数据库源码。。。。。。。。。。。。。
💻 JAVA
字号:
/*Derby - Class org.apache.derbyDemo.vtis.example.PropertyFileVTILicensed 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.example;import java.io.*;import java.sql.*;import java.text.SimpleDateFormat;import org.apache.derbyDemo.vtis.core.*;/** * <p> * This VTI makes a table out of a property file. * </p> */public    class   PropertyFileVTI  extends FlatFileVTI{    ///////////////////////////////////////////////////////////////////////////////////    //    // CONSTANTS    //    ///////////////////////////////////////////////////////////////////////////////////    private static  final   String[]    COLUMN_NAMES =    {        "propKey", "propValue"    };    private static  final   int PROPERTY_KEY = 0;    private static  final   int PROPERTY_VALUE = PROPERTY_KEY + 1;    ///////////////////////////////////////////////////////////////////////////////////    //    // STATE    //    ///////////////////////////////////////////////////////////////////////////////////        ///////////////////////////////////////////////////////////////////////////////////    //    // CONSTRUCTORS    //    ///////////////////////////////////////////////////////////////////////////////////    /**     * <p>     * Build a PropertyFileVTI given the name of a Derby message file in the     * source tree.     * </p>     */    public  PropertyFileVTI( String propertyFileName )    {        super( COLUMN_NAMES, propertyFileName );    }    ///////////////////////////////////////////////////////////////////////////////////    //    // TABLE FUNCTION METHOD    //    ///////////////////////////////////////////////////////////////////////////////////    /**     * <p>     * This is the method which is registered as a table function.     * </p>     */    public  static  ResultSet   propertyFileVTI( String propertyFileName )        throws SQLException    {        return new PropertyFileVTI( propertyFileName );    }    ///////////////////////////////////////////////////////////////////////////////////    //    // FlatFileVTI BEHAVIOR TO BE IMPLEMENTED BY SUBCLASSES    //    ///////////////////////////////////////////////////////////////////////////////////    /**     * <p>     * Parse the next chunk of text, using readLine(), and return the next row.     * Returns null if the file is exhausted.     * </p>     */    protected  String[]  parseRow( ) throws SQLException    {        String[]    newRow = new String[ COLUMN_NAMES.length ];        String      nextLine = null;        String      oldLine = "";        while( true )        {            boolean     isContinuationLine = ( oldLine.length() != 0 );                        nextLine = readLine();            // if at EOF, get out of here            if ( nextLine == null )            {                if ( !isContinuationLine ) { return null; }                else { nextLine = oldLine; }            }            nextLine = nextLine.trim();            // skip blank lines and lines which start with the comment character            if ( nextLine.startsWith( "#" ) ) { continue; }            else if ( nextLine.length() == 0 )            {                if ( !isContinuationLine ) { continue; }            }            // handle continuation lines            nextLine = oldLine + nextLine;            if ( nextLine.endsWith( "\\" ) )            {                oldLine = nextLine.substring( 0, nextLine.length() - 1 );                continue;            }            break;        }        int         equalsIdx = nextLine.indexOf( '=' );        try {            if ( equalsIdx >= 0 )            {                newRow[ PROPERTY_KEY ] = nextLine.substring( 0, equalsIdx );                newRow[ PROPERTY_VALUE ] = nextLine.substring( equalsIdx + 1, nextLine.length() );            }            else            {                newRow[ PROPERTY_KEY ] = nextLine;                newRow[ PROPERTY_VALUE ] = "";            }        }        catch (Throwable t)        {            SQLException    se = new SQLException                (                 "Unparseable line number " + getLineNumber() + " in file " + getTextFileName() + ": " + nextLine                 );            se.initCause( t );            throw se;        }        return newRow;    }    ///////////////////////////////////////////////////////////////////////////////////    //    // ResultSet METHODS    //    ///////////////////////////////////////////////////////////////////////////////////    ///////////////////////////////////////////////////////////////////////////////////    //    // MINIONS    //    ///////////////////////////////////////////////////////////////////////////////////}

⌨️ 快捷键说明

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