1 18 package org.objectweb.jorm.naming.lib; 19 20 import org.objectweb.jorm.naming.api.PNameGetterConverter; 21 import org.objectweb.jorm.naming.api.PNameGetter; 22 import org.objectweb.jorm.naming.api.PExceptionNaming; 23 import org.objectweb.jorm.api.PException; 24 25 import java.util.Date ; 26 import java.math.BigInteger ; 27 import java.math.BigDecimal ; 28 29 34 public class SimplePNGConverter implements PNameGetterConverter { 35 36 private class MyPNG implements PNameGetter { 37 Object value; 38 39 public MyPNG(Object o) { 40 this.value = o; 41 } 42 43 public byte pngetByteField(String fn, Object ctxt) throws PException { 44 return ((Byte ) value).byteValue(); 45 } 46 47 public Byte pngetObyteField(String fn, Object ctxt) throws PException { 48 return (Byte ) value; 49 } 50 51 public char pngetCharField(String fn, Object ctxt) throws PException { 52 return ((Character ) value).charValue(); 53 } 54 55 public Character pngetOcharField(String fn, Object ctxt) throws PException { 56 return (Character ) value; 57 } 58 59 public short pngetShortField(String fn, Object ctxt) throws PException { 60 return ((Short ) value).shortValue(); 61 } 62 63 public Short pngetOshortField(String fn, Object ctxt) throws PException { 64 return (Short ) value; 65 } 66 67 public int pngetIntField(String fn, Object ctxt) throws PException { 68 return ((Integer ) value).intValue(); 69 } 70 71 public Integer pngetOintField(String fn, Object ctxt) throws PException { 72 return (Integer ) value; 73 } 74 75 public long pngetLongField(String fn, Object ctxt) throws PException { 76 return ((Long ) value).longValue(); 77 } 78 79 public Long pngetOlongField(String fn, Object ctxt) throws PException { 80 return (Long ) value; 81 } 82 83 public String pngetStringField(String fn, Object ctxt) throws PException { 84 return (String ) value; 85 } 86 87 public byte[] pngetByteArrayField(String fn, Object ctxt) throws PException { 88 return (byte[]) value; 89 } 90 91 public char[] pngetCharArrayField(String fn, Object ctxt) throws PException { 92 return (char[]) value; 93 } 94 95 public Date pngetDateField(String fn, Object ctxt) throws PException { 96 return (Date ) value; 97 } 98 99 public BigInteger pngetBigIntegerField(String fn, Object ctxt) throws PException { 100 return (BigInteger ) value; 101 } 102 103 public BigDecimal pngetBigDecimalField(String fn, Object ctxt) throws PException { 104 return (BigDecimal ) value; 105 } 106 } 107 108 public PNameGetter convert(PNameGetter png) throws PExceptionNaming { 109 return png; 110 } 111 112 public PNameGetter convert(Object o) throws PExceptionNaming { 113 return new MyPNG(o); 114 } 115 116 public PNameGetter convert(byte o) throws PExceptionNaming { 117 return new MyPNG(new Byte (o)); 118 } 119 120 public PNameGetter convert(char o) throws PExceptionNaming { 121 return new MyPNG(new Character (o)); 122 } 123 124 public PNameGetter convert(short o) throws PExceptionNaming { 125 return new MyPNG(new Short (o)); 126 } 127 128 public PNameGetter convert(int o) throws PExceptionNaming { 129 return new MyPNG(new Integer (o)); 130 } 131 132 public PNameGetter convert(long o) throws PExceptionNaming { 133 return new MyPNG(new Long (o)); 134 } 135 } 136 | Popular Tags |