示例#1
0
 /** {@inheritDoc} */
 public boolean addAll(Collection<? extends Byte> collection) {
   boolean changed = false;
   for (Byte element : collection) {
     byte e = element.byteValue();
     if (add(e)) {
       changed = true;
     }
   }
   return changed;
 }
示例#2
0
 Record rdataFromString(Name name, short dclass, int ttl, MyStringTokenizer st, Name origin)
     throws TextParseException {
   SIGRecord rec = new SIGRecord(name, dclass, ttl);
   rec.covered = Type.value(st.nextToken());
   rec.alg = Byte.parseByte(st.nextToken());
   rec.labels = Byte.parseByte(st.nextToken());
   rec.origttl = TTL.parseTTL(st.nextToken());
   rec.expire = parseDate(st.nextToken());
   rec.timeSigned = parseDate(st.nextToken());
   rec.footprint = (short) Integer.parseInt(st.nextToken());
   rec.signer = Name.fromString(st.nextToken(), origin);
   if (st.hasMoreTokens()) rec.signature = base64.fromString(st.remainingTokens());
   return rec;
 }
示例#3
0
  // Gets a property and converts it into byte.
  static byte getByteProperty(String propName, byte defaultValue) {

    String temp = getConfigValue(propName);
    byte result = defaultValue;
    if (temp != null) {
      result = Byte.parseByte(temp);
      Logger.info("{DB}-" + propName + ":" + result);
    } else {

      result = Byte.parseByte(properties.getProperty(propName, Byte.toString(defaultValue)).trim());
      Logger.info("{FILE}-" + propName + ":" + result);
    }

    return result;
  }
  /**
   * Convert a byte array to a hex string
   *
   * @param bytes byte array to convert to a hex string
   * @return return a String in hex representing the byte array
   */
  public String toHexString(byte[] bytes) {
    StringBuffer result = new StringBuffer("0x");

    for (int i = 0; i < bytes.length; i++) {
      Byte aByte = new Byte(bytes[i]);
      Integer anInt = new Integer(aByte.intValue());
      String hexVal = Integer.toHexString(anInt.intValue());

      if (hexVal.length() > SIZE) hexVal = hexVal.substring(hexVal.length() - SIZE);

      result.append(
          (SIZE > hexVal.length() ? ZEROS.substring(0, SIZE - hexVal.length()) : "") + hexVal);
    }
    return (result.toString());
  }
  /**
   * Parses the arguments table from the GATK Report and creates a RAC object with the proper
   * initialization values
   *
   * @param table the GATKReportTable containing the arguments and its corresponding values
   * @return a RAC object properly initialized with all the objects in the table
   */
  private RecalibrationArgumentCollection initializeArgumentCollectionTable(GATKReportTable table) {
    final RecalibrationArgumentCollection RAC = new RecalibrationArgumentCollection();

    for (int i = 0; i < table.getNumRows(); i++) {
      final String argument = table.get(i, "Argument").toString();
      Object value = table.get(i, RecalUtils.ARGUMENT_VALUE_COLUMN_NAME);
      if (value.equals("null"))
        value =
            null; // generic translation of null values that were printed out as strings | todo --
                  // add this capability to the GATKReport

      if (argument.equals("covariate") && value != null)
        RAC.COVARIATES = value.toString().split(",");
      else if (argument.equals("standard_covs"))
        RAC.DO_NOT_USE_STANDARD_COVARIATES = Boolean.parseBoolean((String) value);
      else if (argument.equals("solid_recal_mode"))
        RAC.SOLID_RECAL_MODE = RecalUtils.SOLID_RECAL_MODE.recalModeFromString((String) value);
      else if (argument.equals("solid_nocall_strategy"))
        RAC.SOLID_NOCALL_STRATEGY =
            RecalUtils.SOLID_NOCALL_STRATEGY.nocallStrategyFromString((String) value);
      else if (argument.equals("mismatches_context_size"))
        RAC.MISMATCHES_CONTEXT_SIZE = Integer.parseInt((String) value);
      else if (argument.equals("indels_context_size"))
        RAC.INDELS_CONTEXT_SIZE = Integer.parseInt((String) value);
      else if (argument.equals("mismatches_default_quality"))
        RAC.MISMATCHES_DEFAULT_QUALITY = Byte.parseByte((String) value);
      else if (argument.equals("insertions_default_quality"))
        RAC.INSERTIONS_DEFAULT_QUALITY = Byte.parseByte((String) value);
      else if (argument.equals("deletions_default_quality"))
        RAC.DELETIONS_DEFAULT_QUALITY = Byte.parseByte((String) value);
      else if (argument.equals("maximum_cycle_value"))
        RAC.MAXIMUM_CYCLE_VALUE = Integer.parseInt((String) value);
      else if (argument.equals("low_quality_tail"))
        RAC.LOW_QUAL_TAIL = Byte.parseByte((String) value);
      else if (argument.equals("default_platform")) RAC.DEFAULT_PLATFORM = (String) value;
      else if (argument.equals("force_platform")) RAC.FORCE_PLATFORM = (String) value;
      else if (argument.equals("quantizing_levels"))
        RAC.QUANTIZING_LEVELS = Integer.parseInt((String) value);
      else if (argument.equals("recalibration_report"))
        RAC.existingRecalibrationReport = (value == null) ? null : new File((String) value);
      else if (argument.equals("binary_tag_name"))
        RAC.BINARY_TAG_NAME = (value == null) ? null : (String) value;
      else if (argument.equals("sort_by_all_columns"))
        RAC.SORT_BY_ALL_COLUMNS = Boolean.parseBoolean((String) value);
    }

    return RAC;
  }
  private RecalDatum getRecalDatum(
      final GATKReportTable reportTable, final int row, final boolean hasEstimatedQReportedColumn) {
    final long nObservations =
        asLong(reportTable.get(row, RecalUtils.NUMBER_OBSERVATIONS_COLUMN_NAME));
    final double nErrors = asDouble(reportTable.get(row, RecalUtils.NUMBER_ERRORS_COLUMN_NAME));
    // final double empiricalQuality = asDouble(reportTable.get(row,
    // RecalUtils.EMPIRICAL_QUALITY_COLUMN_NAME));

    // the estimatedQreported column only exists in the ReadGroup table
    final double estimatedQReported =
        hasEstimatedQReportedColumn
            ? (Double) reportTable.get(row, RecalUtils.ESTIMATED_Q_REPORTED_COLUMN_NAME)
            : // we get it if we are in the read group table
            Byte.parseByte(
                (String)
                    reportTable.get(
                        row,
                        RecalUtils
                            .QUALITY_SCORE_COLUMN_NAME)); // or we use the reported quality if we
                                                          // are in any other table

    final RecalDatum datum = new RecalDatum(nObservations, nErrors, (byte) 1);
    datum.setEstimatedQReported(estimatedQReported);
    // datum.setEmpiricalQuality(empiricalQuality); // don't set the value here because we will want
    // to recompute with a different conditional Q score prior value
    return datum;
  }
示例#7
0
  /**
   * Applies a list of transformation on a block, if the block is not protected.
   *
   * @param toTransform the Bukkit block object to transform
   * @param transformations the list if transformations to apply
   */
  public static void transform(Block toTransform, List<List<String>> transformations) {
    if (isBlockProtected(toTransform)) {
      return;
    }

    for (List<String> toCheck : transformations) {
      ArrayList<String[]> stateIndex = new ArrayList<String[]>();

      for (int i = 0; i != 2; ++i) {
        String got = toCheck.get(i);

        if (got.contains(":")) { // Check for data _ appended.
          stateIndex.add(got.split(":"));
        } else {
          stateIndex.add(new String[] {got, "0"});
        }
      }

      String[] curState = stateIndex.get(0), toState = stateIndex.get(1);

      if (Integer.valueOf(curState[0]) == toTransform.getTypeId()
          && Integer.valueOf(curState[1]) == toTransform.getData()) {
        toTransform.setTypeIdAndData(Integer.valueOf(toState[0]), Byte.parseByte(toState[1]), true);
        return;
      }
    }
  }
示例#8
0
  private boolean compare_Byte(int operation, byte byteval, Object value2) {
    if (operation == SUBSTRING) {
      return false;
    }
    byte byteval2;
    try {
      byteval2 = Byte.parseByte(((String) value2).trim());
    } catch (IllegalArgumentException e) {
      return false;
    }

    switch (operation) {
      case APPROX:
      case EQUAL:
        {
          return byteval == byteval2;
        }
      case GREATER:
        {
          return byteval >= byteval2;
        }
      case LESS:
        {
          return byteval <= byteval2;
        }
    }
    return false;
  }
示例#9
0
  @Override
  public Response debug(Debug debug) throws TException {
    Set<Byte> partitions;
    if (debug.getType() == DebugCommands.POPULATE_FILE.getId()) {
      partitions = oracle.partitionsOf("/");
    } else {
      partitions = new HashSet<>();
      partitions.add(Byte.valueOf(Byte.parseByte(debug.getData().get("partition"))));
    }

    Command cmd = newCommand(CommandType.DEBUG, partitions, null);
    cmd.setDebug(debug);
    replica.submitCommand(cmd);
    Response r = new Response(replica.getInstanceMap());
    return r;
  }
示例#10
0
 /**
  * Helper method used to get default value for wrappers used for primitive types (0 for Integer
  * etc)
  *
  * @since 1.6.1
  */
 public static Object defaultValue(Class<?> cls) {
   if (cls == Integer.TYPE) {
     return Integer.valueOf(0);
   }
   if (cls == Long.TYPE) {
     return Long.valueOf(0L);
   }
   if (cls == Boolean.TYPE) {
     return Boolean.FALSE;
   }
   if (cls == Double.TYPE) {
     return Double.valueOf(0.0);
   }
   if (cls == Float.TYPE) {
     return Float.valueOf(0.0f);
   }
   if (cls == Byte.TYPE) {
     return Byte.valueOf((byte) 0);
   }
   if (cls == Short.TYPE) {
     return Short.valueOf((short) 0);
   }
   if (cls == Character.TYPE) {
     return '\0';
   }
   throw new IllegalArgumentException("Class " + cls.getName() + " is not a primitive type");
 }
示例#11
0
 /**
  * Check for byte
  *
  * @param input
  * @return
  */
 public static boolean isByte(String input) {
   try {
     Byte.parseByte(input);
     return true;
   } catch (Exception ex) {
     return false;
   }
 }
示例#12
0
  public static List readWatchableObjects(DataInputStream par0DataInputStream) throws IOException {
    ArrayList arraylist = null;

    for (byte byte0 = par0DataInputStream.readByte();
        byte0 != 127;
        byte0 = par0DataInputStream.readByte()) {
      if (arraylist == null) {
        arraylist = new ArrayList();
      }

      int i = (byte0 & 0xe0) >> 5;
      int j = byte0 & 0x1f;
      WatchableObject watchableobject = null;

      switch (i) {
        case 0:
          watchableobject = new WatchableObject(i, j, Byte.valueOf(par0DataInputStream.readByte()));
          break;

        case 1:
          watchableobject =
              new WatchableObject(i, j, Short.valueOf(par0DataInputStream.readShort()));
          break;

        case 2:
          watchableobject =
              new WatchableObject(i, j, Integer.valueOf(par0DataInputStream.readInt()));
          break;

        case 3:
          watchableobject =
              new WatchableObject(i, j, Float.valueOf(par0DataInputStream.readFloat()));
          break;

        case 4:
          watchableobject = new WatchableObject(i, j, Packet.readString(par0DataInputStream, 64));
          break;

        case 5:
          short word0 = par0DataInputStream.readShort();
          byte byte1 = par0DataInputStream.readByte();
          short word1 = par0DataInputStream.readShort();
          watchableobject = new WatchableObject(i, j, new ItemStack(word0, byte1, word1));
          break;

        case 6:
          int k = par0DataInputStream.readInt();
          int l = par0DataInputStream.readInt();
          int i1 = par0DataInputStream.readInt();
          watchableobject = new WatchableObject(i, j, new ChunkCoordinates(k, l, i1));
          break;
      }

      arraylist.add(watchableobject);
    }

    return arraylist;
  }
示例#13
0
  private static byte getByteData(String byte1Str) throws Exception {
    byte data_LC;
    byte byte1 = Byte.parseByte(byte1Str);
    // byte byte2 =  Byte.parseByte(byte2Str);
    data_LC = byte1;
    // data_LC[1] = byte2;

    return data_LC;
  }
示例#14
0
 public static Number toWrapper(int i) {
   if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) {
     return Byte.valueOf((byte) i);
   } else if (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE) {
     return Short.valueOf((short) i);
   } else {
     return Integer.valueOf(i);
   }
 }
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // For each test
    StringBuffer sb = new StringBuffer();
    for (byte T = Byte.parseByte(br.readLine()); T > 0; --T) {

      // INPUT
      byte N = Byte.parseByte(br.readLine());
      int[] A = new int[N];
      N = 0;
      for (String s : br.readLine().split(" ")) {
        A[N++] = Integer.parseInt(s);
      }

      sb.append(solve(A, N) ? YES : NO);
    }
    System.out.print(sb);
  }
 /** {@inheritDoc} */
 @SuppressWarnings({"SuspiciousMethodCalls"})
 public boolean retainAll(Collection<?> collection) {
   boolean modified = false;
   TByteIterator iter = iterator();
   while (iter.hasNext()) {
     if (!collection.contains(Byte.valueOf(iter.next()))) {
       iter.remove();
       modified = true;
     }
   }
   return modified;
 }
  /** Loads dependencies and initializes data structures. */
  @Override
  public void init(FloodlightModuleContext context) throws FloodlightModuleException {
    log.info(String.format("Initializing %s...", MODULE_NAME));
    Map<String, String> config = context.getConfigParams(this);
    table = Byte.parseByte(config.get("table"));

    this.floodlightProv = context.getServiceImpl(IFloodlightProviderService.class);
    this.linkDiscProv = context.getServiceImpl(ILinkDiscoveryService.class);
    this.deviceProv = context.getServiceImpl(IDeviceService.class);

    this.knownHosts = new ConcurrentHashMap<IDevice, Host>();
  }
示例#18
0
  public Object getFieldValue(_Fields field) {
    switch (field) {
      case ID:
        return Long.valueOf(getId());

      case FLAGS:
        return Integer.valueOf(getFlags());

      case PARTITION:
        return Byte.valueOf(getPartition());
    }
    throw new IllegalStateException();
  }
示例#19
0
  /*
   * Read a single pair of (X,Y) values from the ADXL202EVB board.
   * TODO: Better return value, or declare as throwing exception for errs
   */
  public static double[] chipRead() {
    double[] retval = {0.0, 0.0};
    byte[] rawBuf = {0, 0, 0, 0};
    int[] vals = {0, 0};

    try {
      // Read is triggered by sending 'G' to board
      outputStream.write('G');

      // Wait for all 4 result bytes to arrive
      // TODO: Finite wait w/error return if data never arrives
      while (inputStream.available() < 4) {
        Thread.sleep(1);
      }

      inputStream.read(rawBuf, 0, 4);

      // Convert from raw bytes to 16-bit signed integers, carefully
      Byte bTmp = new Byte(rawBuf[0]);
      vals[0] = bTmp.intValue() * 256;
      bTmp = new Byte(rawBuf[1]);
      vals[0] += bTmp.intValue();

      bTmp = new Byte(rawBuf[2]);
      vals[1] = bTmp.intValue() * 256;
      bTmp = new Byte(rawBuf[3]);
      vals[1] += bTmp.intValue();

      // See ADXL202EVB specs for details on conversion
      retval[0] = (((vals[0] / 100.0) - 50.0) / 12.5);
      retval[1] = (((vals[1] / 100.0) - 50.0) / 12.5);

      System.out.println("X: " + retval[0] + " Y: " + retval[1]);

    } catch (Exception ioe) {
      System.out.println("Error on data transmission");
    }
    return (retval);
  }
示例#20
0
文件: URL.java 项目: yungoo/apple-qos
 public byte getParameter(String key, byte defaultValue) {
   Number n = getNumbers().get(key);
   if (n != null) {
     return n.byteValue();
   }
   String value = getParameter(key);
   if (value == null || value.length() == 0) {
     return defaultValue;
   }
   byte b = Byte.parseByte(value);
   getNumbers().put(key, b);
   return b;
 }
示例#21
0
 @Override
 public Response readlink(String path, Map<Byte, Long> instanceMap) throws TException {
   path = makePathAbsolute(path);
   // can be sent to ANY partition that replicates the path - we send it to the first returned by
   // the oracle
   Set<Byte> parts = Sets.newHashSet(Byte.valueOf(partition));
   Command cmd = newCommand(CommandType.READLINK, parts, instanceMap);
   ReadlinkCmd readlink = new ReadlinkCmd(path, parts);
   cmd.setReadlink(readlink);
   String result = (String) replica.submitCommand(cmd);
   Response r = new Response(replica.getInstanceMap());
   r.setReadlink(result);
   return r;
 }
示例#22
0
 @Override
 public Response getattr(String path, Map<Byte, Long> instanceMap) throws TException {
   // can be sent to ANY partition that replicates the path - we send it to the first returned by
   // the oracle
   path = makePathAbsolute(path);
   Set<Byte> parts = Sets.newHashSet(Byte.valueOf(partition));
   Command cmd = newCommand(CommandType.ATTR, parts, instanceMap);
   AttrCmd attr = new AttrCmd(path, parts);
   cmd.setAttr(attr);
   Attr result = (Attr) replica.submitCommand(cmd);
   Response r = new Response(replica.getInstanceMap());
   r.setGetattr(result);
   return r;
 }
示例#23
0
文件: URL.java 项目: yungoo/apple-qos
 public byte getMethodParameter(String method, String key, byte defaultValue) {
   String methodKey = method + "." + key;
   Number n = getNumbers().get(methodKey);
   if (n != null) {
     return n.byteValue();
   }
   String value = getMethodParameter(method, key);
   if (value == null || value.length() == 0) {
     return defaultValue;
   }
   byte b = Byte.parseByte(value);
   getNumbers().put(methodKey, b);
   return b;
 }
 /**
  * Parses the quantization table from the GATK Report and turns it into a map of original =>
  * quantized quality scores
  *
  * @param table the GATKReportTable containing the quantization mappings
  * @return an ArrayList with the quantization mappings from 0 to MAX_SAM_QUAL_SCORE
  */
 private QuantizationInfo initializeQuantizationTable(GATKReportTable table) {
   final Byte[] quals = new Byte[QualityUtils.MAX_SAM_QUAL_SCORE + 1];
   final Long[] counts = new Long[QualityUtils.MAX_SAM_QUAL_SCORE + 1];
   for (int i = 0; i < table.getNumRows(); i++) {
     final byte originalQual = (byte) i;
     final Object quantizedObject = table.get(i, RecalUtils.QUANTIZED_VALUE_COLUMN_NAME);
     final Object countObject = table.get(i, RecalUtils.QUANTIZED_COUNT_COLUMN_NAME);
     final byte quantizedQual = Byte.parseByte(quantizedObject.toString());
     final long quantizedCount = Long.parseLong(countObject.toString());
     quals[originalQual] = quantizedQual;
     counts[originalQual] = quantizedCount;
   }
   return new QuantizationInfo(Arrays.asList(quals), Arrays.asList(counts));
 }
示例#25
0
 @Override
 public Response readBlocks(
     String path, FileHandle fh, long offset, long bytes, Map<Byte, Long> instanceMap)
     throws TException {
   path = makePathAbsolute(path);
   // assuming this replica replicates the file, send to own partition
   Set<Byte> parts = Sets.newHashSet(Byte.valueOf(partition));
   Command cmd = newCommand(CommandType.READ_BLOCKS, parts, instanceMap);
   ReadBlocksCmd read = new ReadBlocksCmd(path, fh, offset, bytes, parts);
   cmd.setRead(read);
   ReadResult readResult = (ReadResult) replica.submitCommand(cmd);
   Response r = new Response(replica.getInstanceMap());
   r.setReadBlocks(readResult);
   return r;
 }
示例#26
0
 @Override
 public Response getdir(String path, Map<Byte, Long> instanceMap) throws TException {
   // can be sent to ANY partition that replicates the path - we send it to the first returned by
   // the oracle
   path = makePathAbsolute(path);
   Set<Byte> parts = Sets.newHashSet(Byte.valueOf(partition));
   Command cmd = newCommand(CommandType.GETDIR, parts, instanceMap);
   GetdirCmd getdir = new GetdirCmd(path, parts);
   cmd.setGetdir(getdir);
   @SuppressWarnings("unchecked")
   List<DirEntry> entries = (List<DirEntry>) replica.submitCommand(cmd);
   Response r = new Response(replica.getInstanceMap());
   r.setGetdir(entries);
   return r;
 }
示例#27
0
 // Usage example
 public static void main(String[] args) throws Exception {
   FileInputStream fs = new FileInputStream("src/Lzw.java");
   byte[] data = new byte[1_000_000];
   int len = fs.read(data, 0, data.length);
   data = Arrays.copyOf(data, len);
   char[] buffer = new char[len];
   for (int i = 0; i < len; i++) buffer[i] = (char) (Byte.toUnsignedInt(data[i]));
   String s = new String(buffer, 0, len);
   int[] encoded = lzwEncoding(s);
   String s2 = lzwDecoding(encoded);
   byte[] data2 = new byte[len];
   for (int i = 0; i < len; i++) data2[i] = (byte) s2.charAt(i);
   System.out.println(Arrays.equals(data, data2));
   Locale.setDefault(Locale.US);
   System.out.printf("%d -> %.0f\n", s.length(), optimalCompressedLength(encoded));
 }
  // Deserialize object into a row for the table
  @Override
  public Object deserialize(Writable blob) throws SerDeException {
    Text rowText = (Text) blob;
    String[] values = rowText.toString().split("\t");
    String queryString = values[1];

    if (LOG.isDebugEnabled()) {
      LOG.debug("Deserialize row: " + queryString);
    }

    // create a map from log string
    Map<String, String> map = getQueryMap(queryString);
    map.put("key", values[0]);

    // Loop over columns in table and set values
    String colName;
    Object value;
    for (int c = 0; c < numColumns; c++) {
      colName = columnNames.get(c).toLowerCase();
      TypeInfo ti = columnTypes.get(c);

      if (!map.containsKey(colName)) {
        value = null;
      } else if (ti.getTypeName().equalsIgnoreCase(serdeConstants.DOUBLE_TYPE_NAME)) {
        value = Double.parseDouble(map.get(colName));
      } else if (ti.getTypeName().equalsIgnoreCase(serdeConstants.BIGINT_TYPE_NAME)) {
        value = Long.parseLong(map.get(colName));
      } else if (ti.getTypeName().equalsIgnoreCase(serdeConstants.INT_TYPE_NAME)) {
        value = Integer.parseInt(map.get(colName));
      } else if (ti.getTypeName().equalsIgnoreCase(serdeConstants.TINYINT_TYPE_NAME)) {
        value = Byte.parseByte(map.get(colName));
      } else if (ti.getTypeName().equalsIgnoreCase(serdeConstants.FLOAT_TYPE_NAME)) {
        value = Float.parseFloat(map.get(colName));
      } else if (ti.getTypeName().equalsIgnoreCase(serdeConstants.BOOLEAN_TYPE_NAME)) {
        value = Boolean.parseBoolean(map.get(colName));
      } else {
        value = decode(map.get(colName));
      }
      row.set(c, value);
    }

    return row;
  }
示例#29
0
 @SuppressWarnings("UnnecessaryBoxing")
 private static Object box(final Object value) {
   Object newBoxedValue;
   if (value instanceof Integer) {
     newBoxedValue = Integer.valueOf(((Integer) value).intValue());
   } else if (value instanceof Byte) {
     newBoxedValue = Byte.valueOf(((Byte) value).byteValue());
   } else if (value instanceof Short) {
     newBoxedValue = Short.valueOf(((Short) value).shortValue());
   } else if (value instanceof Long) {
     newBoxedValue = Long.valueOf(((Long) value).longValue());
   } else if (value instanceof Boolean) {
     newBoxedValue = Boolean.valueOf(((Boolean) value).booleanValue());
   } else if (value instanceof Character) {
     newBoxedValue = Character.valueOf(((Character) value).charValue());
   } else {
     return new Object();
   }
   return newBoxedValue;
 }
 @Override
 public <T> T next(InstanceType<T> instanceType, FixtureContract fixture) {
   try {
     if (instanceType.isCompatibleWith(Integer.class)) {
       return (T) Integer.valueOf(this.getNextRandom().intValue());
     } else if (instanceType.isCompatibleWith(Short.class)) {
       return (T) Short.valueOf(getNextRandom().shortValue());
     } else if (instanceType.isCompatibleWith(Long.class)) {
       return (T) getNextRandom();
     } else if (instanceType.isCompatibleWith(Byte.class)) {
       return (T) Byte.valueOf(getNextRandom().byteValue());
     } else if (instanceType.isCompatibleWith(Character.class)) {
       return (T)
           Character.valueOf(new String(new byte[] {getNextRandom().byteValue()}).charAt(0));
     }
     return (T) this.getNextRandom();
   } catch (Exception e) {
     throw new ObjectCreationException(instanceType, e);
   }
 }