001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 019 package org.activemq.message; 020 021 /** 022 * Provides a infomation about a Transaction 023 * 024 * @version $Revision: 1.1.1.1 $ 025 */ 026 public class TransactionInfo extends AbstractPacket implements TransactionType { 027 028 private int type; 029 private String transactionId; 030 031 /** 032 * @return Returns the transactionId. 033 */ 034 public String getTransactionId() { 035 return transactionId; 036 } 037 038 /** 039 * @param transactionId The transactionId to set. 040 */ 041 public void setTransactionId(String transactionId) { 042 this.transactionId = transactionId; 043 } 044 045 /** 046 * Return the type of Packet 047 * 048 * @return integer representation of the type of Packet 049 */ 050 051 public int getPacketType() { 052 return TRANSACTION_INFO; 053 } 054 055 056 /** 057 * Test for equality 058 * 059 * @param obj object to test 060 * @return true if equivalent 061 */ 062 public boolean equals(Object obj) { 063 boolean result = false; 064 if (obj != null && obj instanceof TransactionInfo) { 065 TransactionInfo info = (TransactionInfo) obj; 066 result = this.transactionId == info.transactionId; 067 } 068 return result; 069 } 070 071 /** 072 * @return hash code for instance 073 */ 074 public int hashCode() { 075 return this.transactionId != null ? this.transactionId.hashCode() : super.hashCode(); 076 } 077 078 /** 079 * @return Returns the type of transacton command. 080 */ 081 public int getType() { 082 return this.type; 083 } 084 085 /** 086 * @param newType the type of transaction command The type to set. 087 */ 088 public void setType(int newType) { 089 this.type = newType; 090 } 091 092 public String toString() { 093 return super.toString() + " TransactionInfo{ " + 094 "transactionId = '" + transactionId + "' " + 095 ", type = " + type + 096 " }"; 097 } 098 }