--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.impl.store.raw.xact.GlobalXactId\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.store.raw.xact;\r
+\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+\r
+import org.apache.derby.iapi.services.io.FormatIdUtil;\r
+import org.apache.derby.iapi.services.io.StoredFormatIds;\r
+import org.apache.derby.catalog.UUID;\r
+\r
+import org.apache.derby.iapi.store.raw.GlobalTransactionId;\r
+import org.apache.derby.iapi.store.access.GlobalXact;\r
+\r
+import org.apache.derby.iapi.util.ByteArray;\r
+\r
+import java.io.ObjectOutput;\r
+import java.io.ObjectInput;\r
+import java.io.IOException;\r
+\r
+public class GlobalXactId extends GlobalXact implements GlobalTransactionId\r
+{\r
+ /**************************************************************************\r
+ * Private Fields of the class\r
+ **************************************************************************\r
+ */\r
+\r
+ /**************************************************************************\r
+ * Constructors for This class:\r
+ **************************************************************************\r
+ */\r
+ public GlobalXactId(\r
+ int format_id,\r
+ byte[] global_id,\r
+ byte[] branch_id)\r
+ {\r
+ this.format_id = format_id;\r
+ this.global_id = new byte[global_id.length];\r
+ System.arraycopy(global_id, 0, this.global_id, 0, global_id.length);\r
+ this.branch_id = new byte[branch_id.length];\r
+ System.arraycopy(branch_id, 0, this.branch_id, 0, branch_id.length);\r
+ }\r
+\r
+ /**************************************************************************\r
+ * Public Methods of Formatable interface:\r
+ **************************************************************************\r
+ */\r
+\r
+ // no-arg constructor, required by Formatable \r
+ public GlobalXactId()\r
+ { \r
+ }\r
+\r
+ /**\r
+ Write this out.\r
+ @exception IOException error writing to log stream\r
+ */\r
+ public void writeExternal(ObjectOutput out) throws IOException \r
+ {\r
+ out.writeInt(format_id);\r
+\r
+ if (SanityManager.DEBUG)\r
+ {\r
+ SanityManager.ASSERT(global_id.length <= 64);\r
+ SanityManager.ASSERT(global_id != null);\r
+ SanityManager.ASSERT(branch_id != null);\r
+ }\r
+\r
+ // write length of array followed by the array\r
+ out.write(global_id.length);\r
+ if (global_id.length > 0)\r
+ out.write(global_id);\r
+\r
+ // write length of array followed by the array\r
+ out.write(branch_id.length);\r
+ if (branch_id.length > 0)\r
+ out.write(branch_id);\r
+ }\r
+\r
+ /**\r
+ Read this in\r
+ @exception IOException error reading from log stream\r
+ @exception ClassNotFoundException log stream corrupted\r
+ */\r
+ public void readExternal(ObjectInput in) \r
+ throws IOException, ClassNotFoundException\r
+ {\r
+ format_id = in.readInt();\r
+\r
+ // read global_id in from disk\r
+ int array_len = in.read();\r
+\r
+ if (SanityManager.DEBUG) \r
+ {\r
+ SanityManager.ASSERT(array_len >= 0);\r
+ }\r
+\r
+ global_id = new byte[array_len];\r
+ if (array_len > 0)\r
+ in.read(global_id);\r
+\r
+ // read branch_id in from disk\r
+ array_len = in.read();\r
+\r
+ if (SanityManager.DEBUG)\r
+ {\r
+ SanityManager.ASSERT(array_len >= 0);\r
+ }\r
+\r
+ branch_id = new byte[array_len];\r
+ if (array_len > 0)\r
+ in.read(branch_id);\r
+ }\r
+\r
+ /**\r
+ Return my format identifier.\r
+ */\r
+ public int getTypeFormatId() {\r
+ return StoredFormatIds.RAW_STORE_GLOBAL_XACT_ID_NEW;\r
+ }\r
+\r
+ /**************************************************************************\r
+ * Private/Protected methods of This class:\r
+ **************************************************************************\r
+ */\r
+\r
+ /**************************************************************************\r
+ * Public Methods of This class:\r
+ **************************************************************************\r
+ */\r
+ public int getFormat_Id()\r
+ {\r
+ return(format_id);\r
+ }\r
+\r
+ public byte[] getGlobalTransactionId()\r
+ {\r
+ return(global_id);\r
+ }\r
+\r
+ public byte[] getBranchQualifier()\r
+ {\r
+ return(branch_id);\r
+ }\r
+}\r