Home » jdo2-tck-2.3-ea-src » org.apache.jdo.tck.pc.mylib » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    * 
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    * 
   11    * Unless required by applicable law or agreed to in writing, software 
   12    * distributed under the License is distributed on an "AS IS" BASIS, 
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
   14    * See the License for the specific language governing permissions and 
   15    * limitations under the License.
   16    */
   17    
   18   package org.apache.jdo.tck.pc.mylib;
   19   
   20   import java.io.Serializable;
   21   import java.math.BigDecimal;
   22   import java.math.BigInteger;
   23   import java.util.Date;
   24   
   25   public class PrimitiveTypes implements Serializable {
   26   
   27       private static long counter = new Date().getTime();
   28       private static long newId() {
   29           synchronized (PrimitiveTypes.class) {
   30               return counter++;
   31           }
   32       }
   33       private long id = newId();
   34       private boolean booleanNotNull;
   35       private Boolean booleanNull;
   36       private byte byteNotNull;
   37       private Byte byteNull;
   38       private short shortNotNull;
   39       private Short shortNull;
   40       private int intNotNull;
   41       private Integer intNull;
   42       private long longNotNull;
   43       private Long longNull;
   44       private float floatNotNull;
   45       private Float floatNull;
   46       private double doubleNotNull;
   47       private Double doubleNull;
   48       private char charNotNull;
   49       private Character charNull;
   50       private Date dateNull;
   51       private String stringNull;
   52       private BigDecimal bigDecimal;
   53       private BigInteger bigInteger;
   54       private Long PrimitiveTypes;
   55   
   56       public Object getOid() {
   57           Oid oid = new Oid();
   58           oid.id = this.id;
   59           return oid;
   60       }
   61   
   62       public String toString() { 
   63           return "PrimitiveTypes(" + id + ")";
   64       }
   65       
   66       public int hashCode() {
   67           int hashCode = 0;
   68           hashCode += id;
   69           hashCode += booleanNotNull ? 
   70                   Boolean.TRUE.hashCode() : Boolean.FALSE.hashCode();
   71           hashCode += booleanNull != null ? booleanNull.hashCode() : 0;
   72           hashCode += byteNotNull;
   73           hashCode += byteNull != null ? byteNull.hashCode() : 0;
   74           hashCode += shortNotNull;
   75           hashCode += shortNull != null ? shortNull.hashCode() : 0;
   76           hashCode += intNotNull;
   77           hashCode += intNull != null ? intNull.hashCode() : 0;
   78           hashCode += longNotNull;
   79           hashCode += longNull != null ? longNull.hashCode() : 0;
   80           hashCode += floatNotNull;
   81           hashCode += floatNull != null ? floatNull.hashCode() : 0;
   82           hashCode += doubleNotNull;
   83           hashCode += doubleNull != null ? doubleNull.hashCode() : 0;
   84           hashCode += charNotNull;
   85           hashCode += charNull != null ? charNull.hashCode() : 0;
   86           hashCode += dateNull != null ? dateNull.hashCode() : 0;
   87           hashCode += stringNull != null ? stringNull.hashCode() : 0;
   88           hashCode += bigDecimal != null ? bigDecimal.hashCode() : 0;
   89           hashCode += bigInteger != null ? bigDecimal.hashCode() : 0;
   90           hashCode += PrimitiveTypes != null ? PrimitiveTypes.hashCode() : 0;
   91           return hashCode;
   92       }
   93   
   94       public boolean equals(Object o) {
   95           PrimitiveTypes p = (PrimitiveTypes) o;
   96           if (id != p.id) return false;
   97           if (booleanNotNull != p.booleanNotNull) return false;
   98           if (booleanNull != null) return booleanNull.equals(p.booleanNull);
   99           else if (p.booleanNull != null) return false;
  100           if (byteNotNull != p.byteNotNull) return false;
  101           if (byteNull != null) return byteNull.equals(p.byteNull);
  102           else if (p.byteNull != null) return false;
  103           if (shortNotNull != p.shortNotNull) return false;
  104           if (shortNull != null) return shortNull.equals(p.shortNull);
  105           else if (p.shortNull != null) return false;
  106           if (intNotNull != p.intNotNull) return false;
  107           if (intNull != null) return intNull.equals(p.intNull);
  108           else if (p.intNull != null) return false;
  109           if (longNotNull != p.longNotNull) return false;
  110           if (longNull != null) return longNull.equals(p.longNull);
  111           else if (p.longNull != null) return false;
  112           if (floatNotNull != p.floatNotNull) return false;
  113           if (floatNull != null) return floatNull.equals(p.floatNull);
  114           else if (p.floatNull != null) return false;
  115           if (doubleNotNull != p.doubleNotNull) return false;
  116           if (doubleNull != null) return doubleNull.equals(p.doubleNull);
  117           else if (p.doubleNull != null) return false;
  118           if (charNotNull != p.charNotNull) return false;
  119           if (charNull != null) return charNull.equals(p.charNull);
  120           else if (p.charNull != null) return false;
  121           if (dateNull != null) return dateNull.equals(p.dateNull);
  122           else if (p.dateNull != null) return false;
  123           if (stringNull != null) return stringNull.equals(p.stringNull);
  124           else if (p.stringNull != null) return false;
  125           if (bigDecimal != null) return bigDecimal.equals(p.bigDecimal);
  126           else if (p.bigDecimal != null) return false;
  127           if (bigInteger != null) return bigInteger.equals(p.bigInteger);
  128           else if (p.bigInteger != null) return false;
  129           if (PrimitiveTypes != null) return PrimitiveTypes.equals(p.PrimitiveTypes);
  130           else if (p.PrimitiveTypes != null) return false;
  131           return true;
  132       }
  133   
  134       public PrimitiveTypes() {
  135       }
  136   
  137       public PrimitiveTypes(long id,
  138                             boolean booleanNotNull,
  139                             Boolean booleanNull,
  140                             byte byteNotNull,
  141                             Byte byteNull,
  142                             short shortNotNull,
  143                             Short shortNull,
  144                             int intNotNull,
  145                             Integer intNull,
  146                             long longNotNull,
  147                             Long longNull,
  148                             float floatNotNull,
  149                             Float floatNull,
  150                             double doubleNotNull,
  151                             Double doubleNull,
  152                             char charNotNull,
  153                             Character charNull,
  154                             Date dateNull,
  155                             String stringNull,
  156                             BigDecimal bigDecimal,
  157                             BigInteger bigInteger,
  158                             Long PrimitiveTypes) {
  159           this.id = id;
  160           this.booleanNotNull = booleanNotNull;
  161           this.booleanNull = booleanNull;
  162           this.byteNotNull = byteNotNull;
  163           this.byteNull = byteNull;
  164           this.shortNotNull = shortNotNull;
  165           this.shortNull = shortNull;
  166           this.intNotNull = intNotNull;
  167           this.intNull = intNull;
  168           this.longNotNull = longNotNull;
  169           this.longNull =longNull;
  170           this.floatNotNull = floatNotNull;
  171           this.floatNull =floatNull;
  172           this.doubleNotNull = doubleNotNull;
  173           this.doubleNull = doubleNull;
  174           this.charNotNull = charNotNull;
  175           this.charNull = charNull;
  176           this.dateNull = dateNull;
  177           this.stringNull = stringNull;
  178           this.bigDecimal = bigDecimal; 
  179           this.bigInteger = bigInteger;
  180           this.PrimitiveTypes = PrimitiveTypes;
  181       }
  182   
  183       public long getId() {
  184           return id;
  185       }
  186   
  187       public void setId(long id) {
  188           this.id = id;
  189       }
  190   
  191       public boolean getBooleanNotNull() {
  192           return booleanNotNull;
  193       }
  194   
  195       public void setBooleanNotNull(boolean booleanNotNull) {
  196           this.booleanNotNull = booleanNotNull;
  197       }
  198   
  199       public Boolean getBooleanNull() {
  200           return booleanNull;
  201       }
  202   
  203       public void setBooleanNull(Boolean booleanNull) {
  204           this.booleanNull = booleanNull;
  205       }
  206   
  207       public byte getByteNotNull() {
  208           return byteNotNull;
  209       }
  210   
  211       public void setByteNotNull(byte byteNotNull) {
  212           this.byteNotNull = byteNotNull;
  213       }
  214   
  215       public Byte getByteNull() {
  216           return byteNull;
  217       }
  218   
  219       public void setByteNull(Byte byteNull) {
  220           this.byteNull = byteNull;
  221       }
  222   
  223       public short getShortNotNull() {
  224           return shortNotNull;
  225       }
  226   
  227       public void setShortNotNull(short shortNotNull) {
  228           this.shortNotNull = shortNotNull;
  229       }
  230   
  231       public Short getShortNull() {
  232           return shortNull;
  233       }
  234   
  235       public void setShortNull(Short shortNull) {
  236           this.shortNull = shortNull;
  237       }
  238   
  239       public int getIntNotNull() {
  240           return intNotNull;
  241       }
  242   
  243       public void setIntNotNull(int intNotNull) {
  244           this.intNotNull = intNotNull;
  245       }
  246   
  247       public Integer getIntNull() {
  248           return intNull;
  249       }
  250   
  251       public void setIntNull(Integer intNull) {
  252           this.intNull = intNull;
  253       }
  254   
  255       public long getLongNotNull() {
  256           return longNotNull;
  257       }
  258   
  259       public void setLongNotNull(long longNotNull) {
  260           this.longNotNull = longNotNull;
  261       }
  262   
  263       public Long getLongNull() {
  264           return longNull;
  265       }
  266   
  267       public void setLongNull(Long longNull) {
  268           this.longNull = longNull;
  269       }
  270   
  271       public float getFloatNotNull() {
  272           return floatNotNull;
  273       }
  274   
  275       public void setFloatNotNull(float floatNotNull) {
  276           this.floatNotNull = floatNotNull;
  277       }
  278   
  279       public Float getFloatNull() {
  280           return floatNull;
  281       }
  282   
  283       public void setFloatNull(Float floatNull) {
  284           this.floatNull = floatNull;
  285       }
  286   
  287       public double getDoubleNotNull() {
  288           return doubleNotNull;
  289       }
  290   
  291       public void setDoubleNotNull(double doubleNotNull) {
  292           this.doubleNotNull = doubleNotNull;
  293       }
  294   
  295       public Double getDoubleNull() {
  296           return doubleNull;
  297       }
  298   
  299       public void setDoubleNull(Double doubleNull) {
  300           this.doubleNull = doubleNull;
  301       }
  302   
  303       public char getCharNotNull() {
  304           return charNotNull;
  305       }
  306   
  307       public void setCharNotNull(char charNotNull) {
  308           this.charNotNull = charNotNull;
  309       }
  310   
  311       public Character getCharNull() {
  312           return charNull;
  313       }
  314   
  315       public void setCharNull(Character charNull) {
  316           this.charNull = charNull;
  317       }
  318   
  319       public Date getDateNull() {
  320           return dateNull;
  321       }
  322   
  323       public void setDateNull(Date dateNull) {
  324           this.dateNull = dateNull;
  325       }
  326   
  327       public String getStringNull() {
  328           return stringNull;
  329       }
  330   
  331       public void setStringNull(String stringNull) {
  332           this.stringNull = stringNull;
  333       }
  334   
  335       public BigDecimal getBigDecimal() {
  336           return bigDecimal;
  337       }
  338   
  339       public void setBigDecimal(BigDecimal bigDecimal) {
  340           this.bigDecimal = bigDecimal;
  341       }
  342   
  343       public BigInteger getBigInteger() {
  344           return bigInteger;
  345       }
  346   
  347       public void setBigInteger(BigInteger bigInteger) {
  348           this.bigInteger = bigInteger;
  349       }
  350   
  351       public Long getPrimitiveTypes() {
  352           return PrimitiveTypes;
  353       }
  354   
  355       public void setPrimitiveTypes(Long primitiveTypes) {
  356           this.PrimitiveTypes = primitiveTypes;
  357       }
  358       
  359       public static class Oid implements Serializable, Comparable {
  360   
  361           public long id;
  362   
  363           public Oid() {
  364           }
  365   
  366           public Oid(String s) { id = Long.parseLong(justTheId(s)); }
  367   
  368           public String toString() { return this.getClass().getName() + ": "  + id;}
  369   
  370           public int hashCode() { return (int)id ; }
  371   
  372           public boolean equals(Object other) {
  373               if (other != null && (other instanceof Oid)) {
  374                   Oid k = (Oid)other;
  375                   return k.id == this.id;
  376               }
  377               return false;
  378           }
  379           
  380           protected static String justTheId(String str) {
  381               return str.substring(str.indexOf(':') + 1);
  382           }
  383   
  384           public int compareTo(Object o) {
  385               if (o == null)
  386                   throw new ClassCastException();
  387               if (o == this)
  388                   return 0;
  389               long otherId = ((Oid)o).id;
  390               if (id == otherId)
  391                   return 0;
  392               else if (id < otherId)
  393                   return -1;
  394               return 1;
  395           }
  396       }
  397   
  398   }
  399   

Home » jdo2-tck-2.3-ea-src » org.apache.jdo.tck.pc.mylib » [javadoc | source]