📄 sysaliasesrowfactory.java
字号:
/* Derby - Class org.apache.derby.impl.sql.catalog.SYSALIASESRowFactory Copyright 1997, 2004 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.impl.sql.catalog;import org.apache.derby.iapi.types.TypeId;import org.apache.derby.iapi.sql.dictionary.SystemColumn;import org.apache.derby.catalog.TypeDescriptor;import org.apache.derby.iapi.types.DataValueDescriptor;import org.apache.derby.iapi.types.DataValueFactory;import org.apache.derby.iapi.types.RowLocation;import org.apache.derby.iapi.sql.dictionary.CatalogRowFactory;import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;import org.apache.derby.iapi.sql.dictionary.AliasDescriptor;import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator;import org.apache.derby.iapi.sql.dictionary.DataDictionary;import org.apache.derby.iapi.sql.dictionary.DataDictionaryContext;import org.apache.derby.iapi.sql.dictionary.TupleDescriptor;import org.apache.derby.iapi.sql.execute.ExecutionContext;import org.apache.derby.iapi.sql.execute.ExecIndexRow;import org.apache.derby.iapi.sql.execute.ExecRow;import org.apache.derby.iapi.sql.execute.ExecutionFactory;import org.apache.derby.iapi.error.StandardException;import org.apache.derby.iapi.services.sanity.SanityManager;import org.apache.derby.iapi.services.uuid.UUIDFactory;import org.apache.derby.catalog.AliasInfo;import org.apache.derby.catalog.UUID;/** * Factory for creating a SYSALIASES row. * * Here are the directions for adding a new system supplied alias. * Misc: * All system supplied aliases are class aliases at this point. * Additional arrays will need to be added if we supply system * aliases of other types. * The preloadAliasIDs array is an array of hard coded UUIDs * for the system supplied aliases. * The preloadAliases array is the array of aliases * for the system supplied aliases. This array is in alphabetical * order by package and class in Xena. Each alias is the uppercase * class name of the alias. * The preloadJavaClassNames array is the array of full package.class * names for the system supplied aliases. This array is in alphabetical * order by package and class in Xena. * SYSALIASES_NUM_BOOT_ROWS is the number of boot rows in sys.sysaliases * in a new database. * * * @author jerry */class SYSALIASESRowFactory extends CatalogRowFactory{ private static final int SYSALIASES_COLUMN_COUNT = 9; private static final int SYSALIASES_ALIASID = 1; private static final int SYSALIASES_ALIAS = 2; private static final int SYSALIASES_SCHEMAID = 3; private static final int SYSALIASES_JAVACLASSNAME = 4; private static final int SYSALIASES_ALIASTYPE = 5; private static final int SYSALIASES_NAMESPACE = 6; private static final int SYSALIASES_SYSTEMALIAS = 7; public static final int SYSALIASES_ALIASINFO = 8; private static final int SYSALIASES_SPECIFIC_NAME = 9; protected static final int SYSALIASES_INDEX1_ID = 0; protected static final int SYSALIASES_INDEX2_ID = 1; protected static final int SYSALIASES_INDEX3_ID = 2; // null means all unique. private static final boolean[] uniqueness = null; private static int[][] indexColumnPositions = { {SYSALIASES_SCHEMAID, SYSALIASES_ALIAS, SYSALIASES_NAMESPACE}, {SYSALIASES_ALIASID}, {SYSALIASES_SCHEMAID, SYSALIASES_SPECIFIC_NAME}, }; private static String[][] indexColumnNames = { {"SCHEMAID", "ALIAS", "NAMESPACE"}, {"ALIASID"}, {"SCHEMAID", "SPECIFICNAME"}, }; private static final String[] uuids = { "c013800d-00d7-ddbd-08ce-000a0a411400" // catalog UUID ,"c013800d-00d7-ddbd-75d4-000a0a411400" // heap UUID ,"c013800d-00d7-ddbe-b99d-000a0a411400" // SYSALIASES_INDEX1 ,"c013800d-00d7-ddbe-c4e1-000a0a411400" // SYSALIASES_INDEX2 ,"c013800d-00d7-ddbe-34ae-000a0a411400" // SYSALIASES_INDEX3 }; ///////////////////////////////////////////////////////////////////////////// // // CONSTRUCTORS // ///////////////////////////////////////////////////////////////////////////// public SYSALIASESRowFactory(UUIDFactory uuidf, ExecutionFactory ef, DataValueFactory dvf, boolean convertIdToLower) { super(uuidf,ef,dvf,convertIdToLower); initInfo(SYSALIASES_COLUMN_COUNT, "SYSALIASES", indexColumnPositions, indexColumnNames, uniqueness, uuids); } ///////////////////////////////////////////////////////////////////////////// // // METHODS // ///////////////////////////////////////////////////////////////////////////// /** * Make a SYSALIASES row * * @param emptyRow Make an empty row if this parameter is true * @param ad Alias descriptor * @param dvf A DataValueFactory * * @return Row suitable for inserting into SYSALIASES. * * @exception StandardException thrown on failure */ public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent) throws StandardException { DataValueDescriptor col; String schemaID = null; String javaClassName = null; String sAliasType = null; String aliasID = null; String aliasName = null; String specificName = null; char cAliasType = AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR; char cNameSpace = AliasInfo.ALIAS_NAME_SPACE_PROCEDURE_AS_CHAR; boolean systemAlias = false; AliasInfo aliasInfo = null; if (td != null) { AliasDescriptor ad = (AliasDescriptor)td; aliasID = ad.getUUID().toString(); aliasName = ad.getDescriptorName(); schemaID = ad.getSchemaUUID().toString(); javaClassName = ad.getJavaClassName(); cAliasType = ad.getAliasType(); cNameSpace = ad.getNameSpace(); systemAlias = ad.getSystemAlias(); aliasInfo = ad.getAliasInfo(); specificName = ad.getSpecificName(); char[] charArray = new char[1]; charArray[0] = cAliasType; sAliasType = new String(charArray); if (SanityManager.DEBUG) { switch (cAliasType) { case AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR: case AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR: case AliasInfo.ALIAS_TYPE_SYNONYM_AS_CHAR: break; default: SanityManager.THROWASSERT( "Unexpected value (" + cAliasType + ") for aliasType"); } } } /* Insert info into sysaliases */ /* RESOLVE - It would be nice to require less knowledge about sysaliases * and have this be more table driven. */ /* Build the row to insert */ ExecRow row = getExecutionFactory().getValueRow(SYSALIASES_COLUMN_COUNT); /* 1st column is ALIASID (UUID - char(36)) */ row.setColumn(SYSALIASES_ALIASID, dvf.getCharDataValue(aliasID)); /* 2nd column is ALIAS (varchar(128))) */ row.setColumn(SYSALIASES_ALIAS, dvf.getVarcharDataValue(aliasName)); // System.out.println(" added row-- " + aliasName); /* 3rd column is SCHEMAID (UUID - char(36)) */ row.setColumn(SYSALIASES_SCHEMAID, dvf.getCharDataValue(schemaID)); /* 4th column is JAVACLASSNAME (longvarchar) */ row.setColumn(SYSALIASES_JAVACLASSNAME, dvf.getLongvarcharDataValue(javaClassName)); /* 5th column is ALIASTYPE (char(1)) */ row.setColumn(SYSALIASES_ALIASTYPE, dvf.getCharDataValue(sAliasType)); /* 6th column is NAMESPACE (char(1)) */ String sNameSpace = new String(new char[] { cNameSpace }); row.setColumn (SYSALIASES_NAMESPACE, dvf.getCharDataValue(sNameSpace)); /* 7th column is SYSTEMALIAS (boolean) */ row.setColumn (SYSALIASES_SYSTEMALIAS, dvf.getDataValue(systemAlias)); /* 8th column is ALIASINFO (org.apache.derby.catalog.AliasInfo) */ row.setColumn(SYSALIASES_ALIASINFO, dvf.getDataValue(aliasInfo)); /* 9th column is specific name */ row.setColumn (SYSALIASES_SPECIFIC_NAME, dvf.getVarcharDataValue(specificName)); return row; } /** * Builds an empty index row. * * @param indexNumber Index to build empty row for. * @param rowLocation Row location for last column of index row * * @return corresponding empty index row * @exception StandardException thrown on failure */ public ExecIndexRow buildEmptyIndexRow( int indexNumber, RowLocation rowLocation) throws StandardException { int ncols = getIndexColumnCount(indexNumber); ExecIndexRow row = getExecutionFactory().getIndexableRow(ncols + 1); row.setColumn(ncols + 1, rowLocation);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -