1 17 package org.apache.ws.jaxme; 18 19 import java.io.Serializable ; 20 import java.sql.Types ; 21 import java.util.ArrayList ; 22 import java.util.Calendar ; 23 import java.util.Iterator ; 24 import java.util.List ; 25 26 27 32 public class PMParams implements Serializable { 33 35 public static class Param { 36 private int type; 37 private Object value; 38 40 public Param(int pType, Object pValue) { 41 type = pType; 42 value = pValue; 43 } 44 public int getType() { return type; } 45 public Object getValue() { return value; } 46 } 47 48 private List params; 49 private int max, start; 50 private boolean distinct; 51 52 54 public void addParam(Param pParam) { 55 if (params == null) { params = new ArrayList (); } 56 params.add(pParam); 57 } 58 59 61 public void addParam(String pParam) { 62 addParam(new Param(Types.VARCHAR, pParam)); 63 } 64 65 67 public void addParam(Long pParam) { 68 addParam(new Param(Types.BIGINT, pParam)); 69 } 70 71 73 public void addParam(long pParam) { 74 addParam(new Param(Types.BIGINT, new Long (pParam))); 75 } 76 77 79 public void addParam(Integer pParam) { 80 addParam(new Param(Types.INTEGER, pParam)); 81 } 82 83 85 public void addParam(int pParam) { 86 addParam(new Param(Types.INTEGER, new Integer (pParam))); 87 } 88 89 91 public void addParam(Short pParam) { 92 addParam(new Param(Types.SMALLINT, pParam)); 93 } 94 95 97 public void addParam(short pParam) { 98 addParam(new Param(Types.SMALLINT, new Short (pParam))); 99 } 100 101 103 public void addParam(Byte pParam) { 104 addParam(new Param(Types.TINYINT, pParam)); 105 } 106 107 109 public void addParam(byte pParam) { 110 addParam(new Param(Types.TINYINT, new Byte (pParam))); 111 } 112 113 115 public void addDateTimeParam(Calendar pParam) { 116 addParam(new Param(Types.TIMESTAMP, pParam)); 117 } 118 119 121 public void addParam(byte[] pParam) { 122 addParam(new Param(Types.VARBINARY, pParam)); 123 } 124 125 127 public void addDateParam(Calendar pParam) { 128 addParam(new Param(Types.DATE, pParam)); 129 } 130 131 133 public void addTimeParam(Calendar pParam) { 134 addParam(new Param(Types.TIME, pParam)); 135 } 136 137 139 public void setMaxResultDocuments(int pMax) { 140 max = pMax; 141 } 142 143 146 public int getMaxResultDocuments() { 147 return max; 148 } 149 150 153 public void setSkippedResultDocuments(int pStart) { 154 start = pStart; 155 } 156 157 160 public int getSkippedResultDocuments() { 161 return start; 162 } 163 164 167 public int getNumParams() { 168 return (params == null) ? 0 : params.size()/2; 169 } 170 171 174 public Iterator getParams() { 175 return params.iterator(); 176 } 177 178 181 public void setDistinct(boolean pDistinct) { 182 distinct = pDistinct; 183 } 184 185 188 public boolean isDistinct() { 189 return distinct; 190 } 191 } 192 | Popular Tags |