vm/src/test/java/org/apidesign/vm4brwsr/Instance.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 24 Sep 2012 11:07:38 +0200
changeset 22 b9318fe303cd
parent 16 src/test/java/org/apidesign/java4browser/Instance.java@6e8e00258234
child 24 a82e89aae050
permissions -rw-r--r--
Getting ready for multiple projects inside one Hg repository
     1 /*
     2  * To change this template, choose Tools | Templates
     3  * and open the template in the editor.
     4  */
     5 package org.apidesign.vm4brwsr;
     6 
     7 /**
     8  *
     9  * @author Jaroslav Tulach <jtulach@netbeans.org>
    10  */
    11 public class Instance {
    12     private int i;
    13     protected short s;
    14     public double d;
    15     private float f;
    16     protected byte b = (byte)31;
    17     
    18     private Instance() {
    19     }
    20 
    21     public Instance(int i, double d) {
    22         this.i = i;
    23         this.d = d;
    24     }
    25     public byte getByte() {
    26         return b;
    27     }
    28     
    29     public void setByte(byte b) {
    30         this.b = b;
    31     }
    32     public static double defaultDblValue() {
    33         Instance create = new Instance();
    34         return create.d;
    35     }
    36     
    37     public static byte assignedByteValue() {
    38         return new Instance().b;
    39     }
    40     public static double magicOne() {
    41         Instance i = new Instance(10, 3.3d);
    42         i.b = (byte)0x09;
    43         return (i.i - i.b) * i.d;
    44     }
    45     public static int virtualBytes() {
    46         Instance i = new InstanceSub(7, 2.2d);
    47         i.setByte((byte)0x0a);
    48         Instance i2 = new Instance(3, 333.0d);
    49         i2.setByte((byte)44);
    50         return i.getByte() + i2.getByte();
    51     }
    52     public static float interfaceBytes() {
    53         GetByte i = new InstanceSub(7, 2.2d);
    54         return i.getByte();
    55     }
    56     public static boolean instanceOf(boolean sub) {
    57         Instance i = createInstance(sub);
    58         return isInstanceSubOf(i);
    59     }
    60     private static boolean isInstanceSubOf(Instance instance) {
    61         return instance instanceof InstanceSub;
    62     }
    63     private static Instance createInstance(boolean sub) {
    64         return sub ? new InstanceSub(3, 0) : new Instance();
    65     }
    66     private static boolean isNull() {
    67         return createInstance(true) == null;
    68     }
    69 }