KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mckoi > database > ProcedureName


1 /**
2  * com.mckoi.database.ProcedureName 27 Feb 2003
3  *
4  * Mckoi SQL Database ( http://www.mckoi.com/database )
5  * Copyright (C) 2000, 2001, 2002 Diehl and Associates, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * Version 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License Version 2 for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * Version 2 along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  *
20  * Change Log:
21  *
22  *
23  */

24
25 package com.mckoi.database;
26
27 /**
28  * The name of a procedure as understood by a ProcedureManager.
29  */

30
31 public class ProcedureName {
32
33   /**
34    * The schema of this procedure.
35    */

36   private final String JavaDoc schema;
37   
38   /**
39    * The name of this procedure.
40    */

41   private final String JavaDoc name;
42   
43   /**
44    * Constructs the ProcedureName.
45    */

46   public ProcedureName(String JavaDoc schema, String JavaDoc name) {
47     this.schema = schema;
48     this.name = name;
49   }
50
51   /**
52    * Constructs the ProcedureName from a TableName.
53    */

54   public ProcedureName(TableName table_name) {
55     this(table_name.getSchema(), table_name.getName());
56   }
57   
58   /**
59    * Returns the schema of this procedure.
60    */

61   public String JavaDoc getSchema() {
62     return schema;
63   }
64   
65   /**
66    * Returns the name of this procedure.
67    */

68   public String JavaDoc getName() {
69     return name;
70   }
71
72   /**
73    * Returns this procedure name as a string.
74    */

75   public String JavaDoc toString() {
76     return schema + "." + name;
77   }
78
79   /**
80    * Returns a version of this procedure qualified to the given schema (unless
81    * the schema is present).
82    */

83   public static ProcedureName qualify(String JavaDoc current_schema, String JavaDoc proc_name) {
84     int delim = proc_name.indexOf(".");
85     if (delim == -1) {
86       return new ProcedureName(current_schema, proc_name);
87     }
88     else {
89       return new ProcedureName(proc_name.substring(0, delim),
90                            proc_name.substring(delim + 1, proc_name.length()));
91     }
92   }
93
94   /**
95    * Equality test.
96    */

97   public boolean equals(Object JavaDoc ob) {
98     ProcedureName src_ob = (ProcedureName) ob;
99     return (schema.equals(src_ob.schema) &&
100             name.equals(src_ob.name));
101   }
102
103   /**
104    * The hash key.
105    */

106   public int hashCode() {
107     return schema.hashCode() + name.hashCode();
108   }
109   
110 }
111
112
Popular Tags