1 23 24 package org.objectweb.jorm.naming.lib; 25 26 import org.objectweb.jorm.naming.api.PNamingContext; 27 import org.objectweb.jorm.naming.api.PName; 28 import org.objectweb.jorm.naming.api.PExceptionNaming; 29 import org.objectweb.jorm.naming.api.PNameGetter; 30 import org.objectweb.jorm.type.api.PType; 31 import org.objectweb.jorm.api.PException; 32 33 import java.util.Date ; 34 import java.math.BigInteger ; 35 import java.math.BigDecimal ; 36 37 41 public abstract class BasicPNamingContext implements PNamingContext { 42 protected PType ptype = null; 43 44 public PType getPType() { 45 return ptype; 46 } 47 48 public void setPType(PType pt) { 49 ptype = pt; 50 } 51 52 public boolean codingSupported(int codingtype) { 53 return false; 54 } 55 56 public PName decode(byte[] en) throws PExceptionNaming { 57 return null; 58 } 59 60 public PName decodeCharArray(char[] en) throws PExceptionNaming { 61 throw new UnsupportedOperationException ("char[] coding not supported"); 62 } 63 64 public PName decodeAbstract(Object en, Object context) throws PExceptionNaming, UnsupportedOperationException { 65 throw new UnsupportedOperationException ("abstract coding not supported"); 66 } 67 68 public PName decodeByte(byte en) throws PExceptionNaming, UnsupportedOperationException { 69 throw new UnsupportedOperationException ("byte coding not supported"); 70 } 71 72 public PName decodeObyte(Byte en) throws PExceptionNaming, UnsupportedOperationException { 73 throw new UnsupportedOperationException ("Byte coding not supported"); 74 } 75 76 public PName decodeChar(char en) throws PExceptionNaming, UnsupportedOperationException { 77 throw new UnsupportedOperationException ("char coding not supported"); 78 } 79 80 public PName decodeOchar(Character en) throws PExceptionNaming, UnsupportedOperationException { 81 throw new UnsupportedOperationException ("Character coding not supported"); 82 } 83 84 public PName decodeInt(int en) throws PExceptionNaming, UnsupportedOperationException { 85 throw new UnsupportedOperationException ("int coding not supported"); 86 } 87 88 public PName decodeOint(Integer en) throws PExceptionNaming, UnsupportedOperationException { 89 throw new UnsupportedOperationException ("Integer coding not supported"); 90 } 91 92 public PName decodeLong(long en) throws PExceptionNaming, UnsupportedOperationException { 93 throw new UnsupportedOperationException ("long coding not supported"); 94 } 95 96 public PName decodeOlong(Long en) throws PExceptionNaming, UnsupportedOperationException { 97 throw new UnsupportedOperationException ("Long coding not supported"); 98 } 99 100 public PName decodeShort(short en) throws PExceptionNaming, UnsupportedOperationException { 101 throw new UnsupportedOperationException ("short coding not supported"); 102 } 103 104 public PName decodeOshort(Short en) throws PExceptionNaming, UnsupportedOperationException { 105 throw new UnsupportedOperationException ("Short coding not supported"); 106 } 107 108 public PName decodeDate(Date en) throws PExceptionNaming { 109 throw new UnsupportedOperationException ("date coding not supported"); 110 } 111 112 public PName decodeBigInteger(BigInteger en) throws PExceptionNaming { 113 throw new UnsupportedOperationException ("BigInteger coding not supported"); 114 } 115 116 public PName decodeBigDecimal(BigDecimal en) throws PExceptionNaming { 117 throw new UnsupportedOperationException ("BigDecimal coding not supported"); 118 } 119 120 public byte[] encode(PName pn) throws PExceptionNaming { 121 if (codingSupported(CTBYTEARRAY)) { 122 try { 123 return ((PNameGetter) pn.encodeAbstract()).pngetByteArrayField(null, null); 124 } catch (PExceptionNaming e) { 125 throw e; 126 } catch (PException e) { 127 throw new PExceptionNaming(e); 128 } 129 } 130 return null; 131 } 132 133 public char[] encodeCharArray(PName pn) throws PExceptionNaming { 134 if (codingSupported(CTCHARARRAY)) { 135 try { 136 return ((PNameGetter) pn.encodeAbstract()).pngetCharArrayField(null, null); 137 } catch (PExceptionNaming e) { 138 throw e; 139 } catch (PException e) { 140 throw new PExceptionNaming(e); 141 } 142 } 143 throw new UnsupportedOperationException ("char[] coding not supported"); 144 } 145 146 public Object encodeAbstract(PName pn) throws PExceptionNaming, UnsupportedOperationException { 147 if (codingSupported(CTCOMPOSITE)) { 148 return pn; 149 } 150 throw new UnsupportedOperationException ("abstract coding not supported"); 151 } 152 153 public byte encodeByte(PName pn) throws PExceptionNaming, UnsupportedOperationException { 154 if (codingSupported(CTBYTE)) { 155 try { 156 return ((PNameGetter) pn.encodeAbstract()).pngetByteField(null, null); 157 } catch (PExceptionNaming e) { 158 throw e; 159 } catch (PException e) { 160 throw new PExceptionNaming(e); 161 } 162 } 163 throw new UnsupportedOperationException ("byte coding not supported"); 164 } 165 166 public Byte encodeObyte(PName pn) throws PExceptionNaming, UnsupportedOperationException { 167 if (codingSupported(CTOBYTE)) { 168 try { 169 return ((PNameGetter) pn.encodeAbstract()).pngetObyteField(null, null); 170 } catch (PExceptionNaming e) { 171 throw e; 172 } catch (PException e) { 173 throw new PExceptionNaming(e); 174 } 175 } 176 throw new UnsupportedOperationException ("Byte coding not supported"); 177 } 178 179 public char encodeChar(PName pn) throws PExceptionNaming, UnsupportedOperationException { 180 if (codingSupported(CTCHAR)) { 181 try { 182 return ((PNameGetter) pn.encodeAbstract()).pngetCharField(null, null); 183 } catch (PExceptionNaming e) { 184 throw e; 185 } catch (PException e) { 186 throw new PExceptionNaming(e); 187 } 188 } 189 throw new UnsupportedOperationException ("char coding not supported"); 190 } 191 192 public Character encodeOchar(PName pn) throws PExceptionNaming, UnsupportedOperationException { 193 if (codingSupported(CTOCHAR)) { 194 try { 195 return ((PNameGetter) pn.encodeAbstract()).pngetOcharField(null, null); 196 } catch (PExceptionNaming e) { 197 throw e; 198 } catch (PException e) { 199 throw new PExceptionNaming(e); 200 } 201 } 202 throw new UnsupportedOperationException ("Character coding not supported"); 203 } 204 205 public int encodeInt(PName pn) throws PExceptionNaming, UnsupportedOperationException { 206 if (codingSupported(CTINT)) { 207 try { 208 return ((PNameGetter) pn.encodeAbstract()).pngetIntField(null, null); 209 } catch (PExceptionNaming e) { 210 throw e; 211 } catch (PException e) { 212 throw new PExceptionNaming(e); 213 } 214 } 215 throw new UnsupportedOperationException ("int coding not supported"); 216 } 217 218 public Integer encodeOint(PName pn) throws PExceptionNaming, UnsupportedOperationException { 219 if (codingSupported(CTOINT)) { 220 try { 221 return ((PNameGetter) pn.encodeAbstract()).pngetOintField(null, null); 222 } catch (PExceptionNaming e) { 223 throw e; 224 } catch (PException e) { 225 throw new PExceptionNaming(e); 226 } 227 } 228 throw new UnsupportedOperationException ("Integer coding not supported"); 229 } 230 231 public long encodeLong(PName pn) throws PExceptionNaming, UnsupportedOperationException { 232 if (codingSupported(CTLONG)) { 233 try { 234 return ((PNameGetter) pn.encodeAbstract()).pngetLongField(null, null); 235 } catch (PExceptionNaming e) { 236 throw e; 237 } catch (PException e) { 238 throw new PExceptionNaming(e); 239 } 240 } 241 throw new UnsupportedOperationException ("long coding not supported"); 242 } 243 244 public Long encodeOlong(PName pn) throws PExceptionNaming, UnsupportedOperationException { 245 if (codingSupported(CTOLONG)) { 246 try { 247 return ((PNameGetter) pn.encodeAbstract()).pngetOlongField(null, null); 248 } catch (PExceptionNaming e) { 249 throw e; 250 } catch (PException e) { 251 throw new PExceptionNaming(e); 252 } 253 } 254 throw new UnsupportedOperationException ("Long coding not supported"); 255 } 256 257 public short encodeShort(PName pn) throws PExceptionNaming, UnsupportedOperationException { 258 if (codingSupported(CTSHORT)) { 259 try { 260 return ((PNameGetter) pn.encodeAbstract()).pngetShortField(null, null); 261 } catch (PExceptionNaming e) { 262 throw e; 263 } catch (PException e) { 264 throw new PExceptionNaming(e); 265 } 266 } 267 throw new UnsupportedOperationException ("short coding not supported"); 268 } 269 270 public Short encodeOshort(PName pn) throws PExceptionNaming, UnsupportedOperationException { 271 if (codingSupported(CTOSHORT)) { 272 try { 273 return ((PNameGetter) pn.encodeAbstract()).pngetOshortField(null, null); 274 } catch (PExceptionNaming e) { 275 throw e; 276 } catch (PException e) { 277 throw new PExceptionNaming(e); 278 } 279 } 280 throw new UnsupportedOperationException ("Short coding not supported"); 281 } 282 283 public Date encodeDate(PName pn) throws PExceptionNaming { 284 if (codingSupported(CTDATE)) { 285 try { 286 return ((PNameGetter) pn.encodeAbstract()).pngetDateField(null, null); 287 } catch (PExceptionNaming e) { 288 throw e; 289 } catch (PException e) { 290 throw new PExceptionNaming(e); 291 } 292 } 293 throw new UnsupportedOperationException ("date coding not supported"); 294 } 295 296 public BigInteger encodeBigInteger(PName pn) throws PExceptionNaming { 297 if (codingSupported(CTBIGINTEGER)) { 298 try { 299 return ((PNameGetter) pn.encodeAbstract()).pngetBigIntegerField(null, null); 300 } catch (PExceptionNaming e) { 301 throw e; 302 } catch (PException e) { 303 throw new PExceptionNaming(e); 304 } 305 } 306 throw new UnsupportedOperationException ("BigInteger coding not supported"); 307 } 308 309 public BigDecimal encodeBigDecimal(PName pn) throws PExceptionNaming { 310 if (codingSupported(CTBIGDECIMAL)) { 311 try { 312 return ((PNameGetter) pn.encodeAbstract()).pngetBigDecimalField(null, null); 313 } catch (PExceptionNaming e) { 314 throw e; 315 } catch (PException e) { 316 throw new PExceptionNaming(e); 317 } 318 } 319 throw new UnsupportedOperationException ("BigDecimal coding not supported"); 320 } 321 322 public boolean supportDynamicComposite() { 323 return false; 324 } 325 326 public boolean supportCompositeField(String fn, PType ft) { 327 return false; 328 } 329 330 public boolean supportStaticComposite() { 331 return false; 332 } 333 } 334 | Popular Tags |