1 23 24 package org.objectweb.jorm.facility.naming.rdbsequence; 25 26 import org.objectweb.jorm.naming.lib.BasicPName; 27 import org.objectweb.jorm.naming.lib.BasicPolymorphicPName; 28 import org.objectweb.jorm.naming.api.PNameManager; 29 import org.objectweb.jorm.naming.api.PExceptionNaming; 30 import org.objectweb.jorm.naming.api.PNameGetter; 31 import org.objectweb.jorm.api.PException; 32 33 import java.util.Date ; 34 import java.math.BigDecimal ; 35 import java.math.BigInteger ; 36 37 41 public class RdbSequencePName extends BasicPolymorphicPName implements PNameGetter { 42 public final static Long NULL_VALUE = null; 43 Long value = NULL_VALUE; 44 45 public RdbSequencePName(PNameManager pnm, long value) { 46 this.pnc = pnm; 47 this.value = new Long (value); 48 } 49 public RdbSequencePName(PNameManager pnm, Long value) { 50 this.pnc = pnm; 51 this.value = value; 52 } 53 public RdbSequencePName(PNameManager pnm, Object hints) throws PExceptionNaming { 54 this.pnc = pnm; 55 if (!(hints instanceof RdbSequencePName)) { 56 throw new PExceptionNaming("Unsupported operation: bad pname type," 57 + " expected RdbSequencePName: " + hints); 58 } 59 value = ((RdbSequencePName) hints).value; 60 } 61 62 public String toString() { 63 return super.toString() + " / pncRef:" + pnc + " / value:" + value; 64 } 65 66 public boolean equals(Object obj) { 67 if (!(obj instanceof RdbSequencePName)) { 68 return false; 69 } 70 RdbSequencePName rpn = (RdbSequencePName) obj; 71 boolean testPnc = true; 72 if (this.isPolymorphic() || rpn.isPolymorphic()) { 74 testPnc = (this.getPType().isa(rpn.getPType()) || rpn.getPType().isa(this.getPType())); 75 } else { 77 testPnc = (pnc == rpn.pnc); 78 } 79 return testPnc 80 && (value == null ? rpn.value == null : value.equals(rpn.value)); 81 } 82 83 public int hashCode() { 84 return (value == null ? -1 : value.intValue()); 85 } 86 87 public boolean isNull() { 88 return value == NULL_VALUE || (value != null && value.longValue() < 0); 89 } 90 91 public byte pngetByteField(String fn, Object ctxt) throws PException { 92 throw new PExceptionNaming("Bad type: expected long"); 93 } 94 95 public Byte pngetObyteField(String fn, Object ctxt) throws PException { 96 throw new PExceptionNaming("Bad type: expected long"); 97 } 98 99 public char pngetCharField(String fn, Object ctxt) throws PException { 100 throw new PExceptionNaming("Bad type: expected long"); 101 } 102 103 public Character pngetOcharField(String fn, Object ctxt) throws PException { 104 throw new PExceptionNaming("Bad type: expected long"); 105 } 106 107 public short pngetShortField(String fn, Object ctxt) throws PException { 108 throw new PExceptionNaming("Bad type: expected long"); 109 } 110 111 public Short pngetOshortField(String fn, Object ctxt) throws PException { 112 throw new PExceptionNaming("Bad type: expected long"); 113 } 114 115 public int pngetIntField(String fn, Object ctxt) throws PException { 116 throw new PExceptionNaming("Bad type: expected long"); 117 } 118 119 public Integer pngetOintField(String fn, Object ctxt) throws PException { 120 throw new PExceptionNaming("Bad type: expected long"); 121 } 122 123 public long pngetLongField(String fn, Object ctxt) throws PException { 124 return value == null ? -1 : value.longValue(); 125 } 126 127 public Long pngetOlongField(String fn, Object ctxt) throws PException { 128 return value; 129 } 130 131 public String pngetStringField(String fn, Object ctxt) throws PException { 132 throw new PExceptionNaming("Bad type: expected long"); 133 } 134 135 public byte[] pngetByteArrayField(String fn, Object ctxt) throws PException { 136 throw new PExceptionNaming("Bad type: expected long"); 137 } 138 139 public char[] pngetCharArrayField(String fn, Object ctxt) throws PException { 140 throw new PExceptionNaming("Bad type: expected long"); 141 } 142 143 public Date pngetDateField(String fn, Object ctxt) throws PException { 144 throw new PExceptionNaming("Bad type: expected long"); 145 } 146 147 public BigDecimal pngetBigDecimalField(String fn, Object ctxt) throws PException { 148 throw new PExceptionNaming("Bad type: expected long"); 149 } 150 151 public BigInteger pngetBigIntegerField(String fn, Object ctxt) throws PException { 152 throw new PExceptionNaming("Bad type: expected long"); 153 } 154 } 155 | Popular Tags |