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 the child table data of a MInstance message published by an ADB 25 * agent. It provides methods to extract the data from the MInstance message. 26 * @author Jawaid Hakim. 27 */ 28 public class AdbMInstChildPubMsgData implements DbChildPubMsgData 29 { 30 /*** 31 * Constructor. 32 * @param fldName Name of the child data field. 33 * @param childMsgData Child data published by ADB. 34 */ 35 public AdbMInstChildPubMsgData(String fldName, TibrvMsg childMsgData) 36 { 37 fldName_ = fldName; 38 childMsgData_ = childMsgData; 39 40 // The data field name is ADB_SEQUENCE_<table-name> 41 if (fldName_.indexOf(AdbMInstPubMsgData.ADB_CHILD_DATA_ADB_SEQUENCE) == 0) 42 className_ = fldName_.substring(AdbMInstPubMsgData.ADB_CHILD_DATA_ADB_SEQUENCE.length()); 43 else 44 className_ = null; 45 46 valid_ = (childMsgData_ != null && className_ != null); 47 } 48 49 /*** 50 * Check if the object contains a valid result set. 51 * @return <code>true</code> if the object contains a valid 52 * result set. Returns <code>false</code> if the object does 53 * not contain a valid result set. 54 */ 55 public final boolean isValid() 56 { 57 return valid_; 58 } 59 60 /*** 61 * Get a specified child row data. 62 * @param The idx of the requested row. 63 * @return Specifiedlished child row data. Returns <code>null</code> 64 * if the specified child row data is not found. 65 */ 66 public final DbPubMsgData getData(int idx) 67 { 68 try 69 { 70 TibrvMsgField rvFld = childMsgData_.getField("^" + String.valueOf(idx) + "^"); 71 return (rvFld != null) ? new AdbMInstPubMsgData((TibrvMsg)rvFld.data) : null; 72 } 73 catch (TibrvException ex) 74 { 75 return null; 76 } 77 } 78 79 /*** 80 * Get the IDX of the child table data rows. 81 * @return IDX of the child table data rows. Returns <code>-1</code> if the 82 * IDX is not found. 83 */ 84 public final int getIdx() 85 { 86 try 87 { 88 return ((Integer)childMsgData_.get(ADB_DATA_CHILD_IDX)).intValue(); 89 } 90 catch (TibrvException ex) 91 { 92 return -1; 93 } 94 } 95 96 /*** 97 * Get the child class name from which the update is published. 98 * @return Child table name. <code>null</code> is returned if the 99 * child class name is not found. 100 */ 101 public final String getClassName() throws AdbSystemException 102 { 103 return className_; 104 } 105 106 /*** 107 * Override. 108 */ 109 public String toString() 110 { 111 return childMsgData_.toString(); 112 } 113 114 /*** 115 * Field names for ADB published messages. 116 */ 117 private static final String ADB_DATA_CHILD_IDX = "^idx^"; 118 119 /*** 120 * Data published by ADB. 121 */ 122 private final String fldName_; 123 private final TibrvMsg childMsgData_; 124 125 /*** 126 * Computed data. 127 */ 128 private final String className_; 129 130 /*** 131 * Validity flag. 132 */ 133 private final boolean valid_; 134 }

This page was automatically generated by Maven