001: /**
002: * com.mckoi.database.ProcedureName 27 Feb 2003
003: *
004: * Mckoi SQL Database ( http://www.mckoi.com/database )
005: * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * Version 2 as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License Version 2 for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * Version 2 along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: * Change Log:
021: *
022: *
023: */package com.mckoi.database;
024:
025: /**
026: * The name of a procedure as understood by a ProcedureManager.
027: */
028:
029: public class ProcedureName {
030:
031: /**
032: * The schema of this procedure.
033: */
034: private final String schema;
035:
036: /**
037: * The name of this procedure.
038: */
039: private final String name;
040:
041: /**
042: * Constructs the ProcedureName.
043: */
044: public ProcedureName(String schema, String name) {
045: this .schema = schema;
046: this .name = name;
047: }
048:
049: /**
050: * Constructs the ProcedureName from a TableName.
051: */
052: public ProcedureName(TableName table_name) {
053: this (table_name.getSchema(), table_name.getName());
054: }
055:
056: /**
057: * Returns the schema of this procedure.
058: */
059: public String getSchema() {
060: return schema;
061: }
062:
063: /**
064: * Returns the name of this procedure.
065: */
066: public String getName() {
067: return name;
068: }
069:
070: /**
071: * Returns this procedure name as a string.
072: */
073: public String toString() {
074: return schema + "." + name;
075: }
076:
077: /**
078: * Returns a version of this procedure qualified to the given schema (unless
079: * the schema is present).
080: */
081: public static ProcedureName qualify(String current_schema,
082: String proc_name) {
083: int delim = proc_name.indexOf(".");
084: if (delim == -1) {
085: return new ProcedureName(current_schema, proc_name);
086: } else {
087: return new ProcedureName(proc_name.substring(0, delim),
088: proc_name.substring(delim + 1, proc_name.length()));
089: }
090: }
091:
092: /**
093: * Equality test.
094: */
095: public boolean equals(Object ob) {
096: ProcedureName src_ob = (ProcedureName) ob;
097: return (schema.equals(src_ob.schema) && name
098: .equals(src_ob.name));
099: }
100:
101: /**
102: * The hash key.
103: */
104: public int hashCode() {
105: return schema.hashCode() + name.hashCode();
106: }
107:
108: }
|