View Javadoc
1 /*** 2 * Copyright (c) 2002, Reuters America Inc. All rights reserved.<p> 3 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following 4 * conditions are met:<p> 5 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 7 * in the documentation and/or other materials provided with the distribution. Neither the name of Reuters America Inc. nor the 8 * names of its contributors may be used to endorse or promote products derived from this software without specific prior written 9 * permission.<p> 10 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 11 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 12 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 13 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 14 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 15 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<p> 16 */ 17 18 package com.reuters.rc.db.adb; 19 20 import com.reuters.rc.db.*; 21 import com.tibco.tibrv.*; 22 23 /*** 24 * This class represents a MInstance message published by an ADB agent. It provides static methods to extract 25 * the data from the MInstance message.<p> 26 * @author Jawaid Hakim. 27 */ 28 public class AdbMInstPubMsg implements DbPubMsg 29 { 30 /*** 31 * Constructor. 32 * @param pubMsg Message published by ADB. 33 */ 34 public AdbMInstPubMsg(TibrvMsg pubMsg) 35 { 36 pubMsg_ = pubMsg; 37 valid_ = true; 38 } 39 40 /*** 41 * Check if the object contains a valid result set. 42 * @return <code>true</code> if the object contains a valid 43 * result set. Returns <code>false</code> if the object does 44 * not contain a valid result set. 45 * @see #getStatus() 46 */ 47 public final boolean isValid() 48 { 49 return valid_; 50 } 51 52 /*** 53 * Get the message type. 54 * @return Message type. 55 */ 56 public final Integer getMsgType() throws AdbSystemException 57 { 58 try 59 { 60 return (Integer)pubMsg_.get(ADB_MESSAGE_TYPE); 61 } 62 catch (TibrvException ex) 63 { 64 throw new AdbSystemException(ex); 65 } 66 } 67 68 /*** 69 * Get the message type. 70 * @param rvMsg TibrvMsg published by ADB. 71 * @return Message type. 72 */ 73 public static Integer getMsgType(TibrvMsg rvMsg) throws AdbSystemException 74 { 75 try 76 { 77 return (Integer)rvMsg.get(ADB_MESSAGE_TYPE); 78 } 79 catch (TibrvException ex) 80 { 81 throw new AdbSystemException(ex); 82 } 83 } 84 85 /*** 86 * Get the message pfmt. 87 * @return Message pfmt. 88 */ 89 public final Integer getMsgPfmt() throws AdbSystemException 90 { 91 try 92 { 93 return (Integer)pubMsg_.get(ADB_MESSAGE_PFMT); 94 } 95 catch (TibrvException ex) 96 { 97 throw new AdbSystemException(ex); 98 } 99 } 100 101 /*** 102 * Get the message pfmt. 103 * @param rvMsg TibrvMsg published by ADB. 104 * @return Message pfmt. 105 */ 106 public static Integer getMsgPfmt(TibrvMsg rvMsg) throws AdbSystemException 107 { 108 try 109 { 110 return (Integer)rvMsg.get(ADB_MESSAGE_PFMT); 111 } 112 catch (TibrvException ex) 113 { 114 throw new AdbSystemException(ex); 115 } 116 } 117 118 /*** 119 * Get the message version. 120 * @return Message version. 121 */ 122 public final Integer getMsgVersion() throws AdbSystemException 123 { 124 try 125 { 126 return (Integer)pubMsg_.get(ADB_MESSAGE_VER); 127 } 128 catch (TibrvException ex) 129 { 130 throw new AdbSystemException(ex); 131 } 132 } 133 134 /*** 135 * Get the message version. 136 * @param rvMsg TibrvMsg published by ADB. 137 * @return Message version. 138 */ 139 public final Integer getMsgVersion(TibrvMsg rvMsg) throws AdbSystemException 140 { 141 try 142 { 143 return (Integer)rvMsg.get(ADB_MESSAGE_VER); 144 } 145 catch (TibrvException ex) 146 { 147 throw new AdbSystemException(ex); 148 } 149 } 150 151 /*** 152 * Get the published data. 153 * @see AdbMInstPubMsgData 154 */ 155 public final DbPubMsgData getData() throws AdbSystemException 156 { 157 try 158 { 159 return new AdbMInstPubMsgData((TibrvMsg)pubMsg_.get(ADB_DATA)); 160 } 161 catch (TibrvException ex) 162 { 163 throw new AdbSystemException(ex); 164 } 165 } 166 167 /*** 168 * Get the published data. 169 * @param rvMsg TibrvMsg published by ADB. 170 * @see AdbMInstPubMsgData 171 */ 172 public static AdbMInstPubMsgData getData(TibrvMsg rvMsg) throws AdbSystemException 173 { 174 try 175 { 176 return new AdbMInstPubMsgData((TibrvMsg)rvMsg.get(ADB_DATA)); 177 } 178 catch (TibrvException ex) 179 { 180 throw new AdbSystemException(ex); 181 } 182 } 183 184 /*** 185 * Override. 186 */ 187 public String toString() 188 { 189 return pubMsg_.toString(); 190 } 191 192 /*** 193 * Static data 194 */ 195 private static final String ADB_SUBJECT = "subject"; 196 private static final String ADB_MESSAGE = "message"; 197 private static final String ADB_MESSAGE_TYPE = "^type^"; 198 private static final String ADB_MESSAGE_PFMT = "^pfmt^"; 199 private static final String ADB_MESSAGE_VER = "^ver^"; 200 private static final String ADB_MESSAGE_PREFIXLIST = "^prefixlist^"; 201 private static final String ADB_MESSAGE_PREFIXLIST_DEFAULT = "default"; 202 private static final String ADB_DATA = "^data^"; 203 204 /*** 205 * Message published byom ADB. 206 */ 207 private final TibrvMsg pubMsg_; 208 209 /*** 210 * Validity flag. 211 */ 212 private final boolean valid_; 213 } 214

This page was automatically generated by Maven