1 23 24 38 39 package com.sun.enterprise.admin.jmx.remote.internal; 40 41 42 48 public final class Shifter { 49 50 private Object [] args; 51 public Shifter(Object [] in) { 52 if (in == null) 53 throw new IllegalArgumentException ("null array"); 54 this.args = new Object [in.length]; 55 System.arraycopy(in, 0, args, 0, in.length); 56 } 57 58 public void shiftRight(Object addition) { 59 if (addition == null) 60 throw new IllegalArgumentException ("Null argument"); 61 final Object [] tmp = new Object [args.length + 1]; 62 tmp[0] = addition; 63 for (int i = 0 ; i < args.length ; i++) { 64 tmp[i + 1] = args[i]; 65 } 66 args = tmp; 67 } 68 69 public Object shiftLeft() { 70 if (args.length == 0) 71 throw new IllegalStateException ("Can't Shift left, no elements"); 72 final Object ret = args[0]; 73 final Object [] tmp = new Object [args.length - 1]; 74 for (int i = 0 ; i < tmp.length ; i++) { 75 tmp[i] = args[i + 1]; 76 } 77 args = tmp; 78 return ( ret ); 79 } 80 81 public Object [] state() { 82 return ( args ); 83 } 84 } 85 | Popular Tags |