--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.sql.depend.BasicProviderInfo\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.impl.sql.depend;\r
+\r
+import org.apache.derby.iapi.services.io.StoredFormatIds;\r
+\r
+import org.apache.derby.iapi.sql.depend.ProviderInfo;\r
+\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+\r
+import org.apache.derby.catalog.DependableFinder;\r
+import org.apache.derby.catalog.UUID;\r
+import org.apache.derby.iapi.services.io.FormatableHashtable;\r
+\r
+import java.io.ObjectOutput;\r
+import java.io.ObjectInput;\r
+import java.io.IOException;\r
+\r
+/**\r
+ * This is the implementation of ProviderInfo in the DependencyManager.\r
+ */\r
+\r
+public class BasicProviderInfo implements ProviderInfo\r
+{\r
+ /********************************************************\r
+ **\r
+ ** This class implements Formatable. That means that it\r
+ ** can write itself to and from a formatted stream. If\r
+ ** you add more fields to this class, make sure that you\r
+ ** also write/read them with the writeExternal()/readExternal()\r
+ ** methods.\r
+ **\r
+ ** If, inbetween releases, you add more fields to this class,\r
+ ** then you should bump the version number emitted by the getTypeFormatId()\r
+ ** method.\r
+ **\r
+ ********************************************************/\r
+\r
+ public UUID uuid;\r
+ public DependableFinder dFinder;\r
+ public String providerName;\r
+\r
+ // CONSTRUCTORS\r
+\r
+ /**\r
+ * Public niladic constructor. Needed for Formatable interface to work.\r
+ *\r
+ */\r
+ public BasicProviderInfo() {}\r
+\r
+ /**\r
+ * Make one of these puppies.\r
+ *\r
+ * @param uuid UUID of Provider.\r
+ * @param dFinder DependableFinder for Provider.\r
+ * @param providerName Name of the Provider.\r
+ */\r
+ public BasicProviderInfo(\r
+ UUID uuid,\r
+ DependableFinder dFinder,\r
+ String providerName)\r
+ {\r
+ this.uuid = uuid;\r
+ this.dFinder = dFinder;\r
+ this.providerName = providerName;\r
+ }\r
+\r
+ // ProviderInfo methods\r
+\r
+ /** @see ProviderInfo#getDependableFinder */\r
+ public DependableFinder getDependableFinder()\r
+ {\r
+ return dFinder;\r
+ }\r
+\r
+ /** @see ProviderInfo#getObjectId */\r
+ public UUID getObjectId()\r
+ {\r
+ return uuid;\r
+ }\r
+\r
+ /** @see ProviderInfo#getProviderName */\r
+ public String getProviderName()\r
+ {\r
+ return providerName;\r
+ }\r
+\r
+ // Formatable methods\r
+\r
+ /**\r
+ * Read this object from a stream of stored objects.\r
+ *\r
+ * @param in read this.\r
+ *\r
+ * @exception IOException thrown on error\r
+ * @exception ClassNotFoundException thrown on error\r
+ */\r
+ public void readExternal( ObjectInput in )\r
+ throws IOException, ClassNotFoundException\r
+ {\r
+\r
+ FormatableHashtable fh = (FormatableHashtable)in.readObject();\r
+ uuid = (UUID)fh.get("uuid");\r
+ dFinder = (DependableFinder)fh.get("dFinder");\r
+ providerName = (String) fh.get("providerName");\r
+ }\r
+\r
+ /**\r
+ * Write this object to a stream of stored objects.\r
+ *\r
+ * @param out write bytes here.\r
+ *\r
+ * @exception IOException thrown on error\r
+ */\r
+ public void writeExternal( ObjectOutput out )\r
+ throws IOException\r
+ {\r
+ FormatableHashtable fh = new FormatableHashtable();\r
+ fh.put("uuid", uuid);\r
+ fh.put("dFinder", dFinder);\r
+ fh.put("providerName", providerName);\r
+ out.writeObject(fh);\r
+ }\r
+ \r
+ /**\r
+ * Get the formatID which corresponds to this class.\r
+ *\r
+ * @return the formatID of this class\r
+ */\r
+ public int getTypeFormatId() { return StoredFormatIds.PROVIDER_INFO_V02_ID; }\r
+\r
+ /*\r
+ Object methods.\r
+ */\r
+ public String toString()\r
+ {\r
+ if (SanityManager.DEBUG)\r
+ {\r
+ String traceUUID;\r
+ String traceDFinder;\r
+ String traceProviderName;\r
+\r
+ if (uuid == null)\r
+ {\r
+ traceUUID = "uuid: null ";\r
+ }\r
+ else\r
+ {\r
+ traceUUID = "uuid: "+uuid+" ";\r
+ }\r
+\r
+ if (dFinder == null)\r
+ {\r
+ traceDFinder = "dFinder: null ";\r
+ }\r
+ else\r
+ {\r
+ traceDFinder = "dFinder: "+dFinder+" ";\r
+ }\r
+\r
+ if (providerName == null)\r
+ {\r
+ traceProviderName = "providerName: null ";\r
+ }\r
+ else\r
+ {\r
+ traceProviderName = "providerName: "+providerName+" ";\r
+ }\r
+\r
+ return "ProviderInfo: ("+traceUUID+traceDFinder+traceProviderName+")";\r
+ }\r
+ else\r
+ {\r
+ return "";\r
+ }\r
+ }\r
+}\r