int transferType = getTransferType(); if (getTransferType() != data.getDataType()) { throw new IllegalArgumentException("transfer type ("+ getTransferType()+"), "+ "does not match data "+ "buffer type (" + data.getDataType() + ")."); }  try { switch (transferType) { case DataBuffer.TYPE_BYTE: { DataBufferByte out = (DataBufferByte) data; byte[] in = (byte[]) obj; out.getData()[offset] = in[0]; return; } case DataBuffer.TYPE_USHORT: { DataBufferUShort out = (DataBufferUShort) data; short[] in = (short[]) obj; out.getData()[offset] = in[0]; return; } case DataBuffer.TYPE_INT: { DataBufferInt out = (DataBufferInt) data; int[] in = (int[]) obj; out.getData()[offset] = in[0]; return; }  default: throw new InternalError(); } } catch (ArrayIndexOutOfBoundsException aioobe) { String msg = "While writing data elements" + ", x="+x+", y="+y+ ", width="+width+", height="+height+ ", scanlineStride="+scanlineStride+ ", offset="+offset+ ", data.getSize()="+data.getSize()+ ", data.getOffset()="+data.getOffset()+ ": " + aioobe; throw new ArrayIndexOutOfBoundsException(msg); }
Object pixelData; switch (getTransferType()) { case DataBuffer.TYPE_BYTE: pixelData = ((DataBufferByte) data).getData(); break; case DataBuffer.TYPE_USHORT: pixelData = ((DataBufferUShort) data).getData(); break; case DataBuffer.TYPE_INT: pixelData = ((DataBufferInt) data).getData(); break; default:  throw new ClassCastException();
  public void setDataElements(int x, int y, Object obj, DataBuffer data)  {    int offset = scanlineStride*y + x + data.getOffset();        int transferType = getTransferType();    if (getTransferType() != data.getDataType())      {	throw new IllegalArgumentException("transfer type ("+					   getTransferType()+"), "+					   "does not match data "+					   "buffer type (" +					   data.getDataType() +					   ").");      }    try      {	switch (transferType)	  {	  case DataBuffer.TYPE_BYTE:	    {	      DataBufferByte out = (DataBufferByte) data;	      byte[] in = (byte[]) obj;	      out.getData()[offset] = in[0];	      return;	    }	  case DataBuffer.TYPE_USHORT:	    {	      DataBufferUShort out = (DataBufferUShort) data;	      short[] in = (short[]) obj;	      out.getData()[offset] = in[0];	      return;	    }	  case DataBuffer.TYPE_INT:	    {	      DataBufferInt out = (DataBufferInt) data;	      int[] in = (int[]) obj;	      out.getData()[offset] = in[0];	      return;	    }	    // FIXME: Fill in the other possible types.	  default:	    throw new InternalError();	  }      }    catch (ArrayIndexOutOfBoundsException aioobe)      {	String msg = "While writing data elements" +	  ", x="+x+", y="+y+	  ", width="+width+", height="+height+	  ", scanlineStride="+scanlineStride+	  ", offset="+offset+	  ", data.getSize()="+data.getSize()+	  ", data.getOffset()="+data.getOffset()+	  ": " +	  aioobe;	throw new ArrayIndexOutOfBoundsException(msg);      }    }