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 bind row in the statement sent to ADB. Each instance of 25 * this class is immutable - instances can be freely shared among threads. 26 * @see AdbRequest 27 * @author Jawaid Hakim. 28 */ 29 public class AdbRequestBind implements DbRequestBind 30 { 31 /*** 32 * Constructor. 33 * @param position Placeholder position. 34 * @param column Column name. 35 * @param data Column data. A reference to the parameter is stored so be 36 * careful about modifying the data. 37 */ 38 public AdbRequestBind(int position, String column, Object data) 39 { 40 init(position, column, data); 41 } 42 43 /*** 44 * Constructor. A reference to the parameter is stored so be careful about 45 * modifying the data. 46 * @param column Column name. 47 * @param data Column data. A reference to the parameter is stored so be 48 * careful about modifying the data. 49 */ 50 public AdbRequestBind(String column, Object data) 51 { 52 init(NOPOSITION, column, data); 53 } 54 55 /*** 56 * Constructor. 57 * @param position Placeholder position. 58 * @param data Column data. A reference to the parameter is stored so be 59 * careful about modifying the data. 60 */ 61 public AdbRequestBind(int position, Object data) 62 { 63 init(position, null, data); 64 } 65 66 /*** 67 * Initialize. 68 * @param position Column position. 69 * @param column Column name. 70 * @param data Column data. 71 */ 72 private void init(int position, String column, Object data) 73 { 74 position_ = position; 75 columnName_ = column; 76 data_ = data; 77 } 78 79 /*** 80 * Get column position. 81 * @return Sql statement. 82 */ 83 public final int getPosition() 84 { 85 return position_; 86 } 87 88 /*** 89 * Get column position. 90 * @return Column name. 91 */ 92 public final String getColumnName() 93 { 94 return columnName_; 95 } 96 97 98 /*** 99 * Get column data. 100 * @return Column data. 101 */ 102 public final Object getData() 103 { 104 return data_; 105 } 106 107 /*** 108 * Build request message. 109 * @return Request message. 110 * @see com.tibco.tibrv.TibrvMsg 111 */ 112 public final TibrvMsg getBind() throws AdbSystemException 113 { 114 try 115 { 116 // Create request statement 117 TibrvMsg stmt = new TibrvMsg(); 118 if (getPosition() != NOPOSITION) 119 stmt.add(ADB_POSITION, getPosition()); 120 121 if (getColumnName() != null) 122 stmt.add(ADB_COLUMN, getColumnName()); 123 124 stmt.add(ADB_DATA, getData()); 125 126 return stmt; 127 } 128 catch (TibrvException ex) 129 { 130 throw new AdbSystemException(ex); 131 } 132 } 133 134 /*** 135 * Column position. 136 */ 137 protected static final String ADB_POSITION = "position"; 138 139 /*** 140 * Column name. 141 */ 142 protected static final String ADB_COLUMN = "column"; 143 144 /*** 145 * Column data. 146 */ 147 protected static final String ADB_DATA = "data"; 148 149 /*** 150 * No position specified in bind. 151 */ 152 protected static final int NOPOSITION = -1; 153 154 private int position_; 155 private String columnName_; 156 private Object data_; 157 }

This page was automatically generated by Maven