コード例 #1
0
 @SuppressWarnings({"unchecked"})
 public <X> X unwrap(Character[] value, Class<X> type, WrapperOptions options) {
   if (value == null) {
     return null;
   }
   if (Character[].class.isAssignableFrom(type)) {
     return (X) value;
   }
   if (String.class.isAssignableFrom(type)) {
     return (X) new String(unwrapChars(value));
   }
   if (Clob.class.isAssignableFrom(type)) {
     return (X) options.getLobCreator().createClob(new String(unwrapChars(value)));
   }
   if (Reader.class.isAssignableFrom(type)) {
     return (X) new StringReader(new String(unwrapChars(value)));
   }
   if (CharacterStream.class.isAssignableFrom(type)) {
     return (X) new CharacterStreamImpl(new String(unwrapChars(value)));
   }
   throw unknownUnwrap(type);
 }
コード例 #2
0
  @SuppressWarnings({"unchecked"})
  public <X> X unwrap(Byte[] value, Class<X> type, WrapperOptions options) {
    if (value == null) {
      return null;
    }
    if (Byte[].class.isAssignableFrom(type)) {
      return (X) value;
    }
    if (byte[].class.isAssignableFrom(type)) {
      return (X) unwrapBytes(value);
    }
    if (InputStream.class.isAssignableFrom(type)) {
      return (X) new ByteArrayInputStream(unwrapBytes(value));
    }
    if (BinaryStream.class.isAssignableFrom(type)) {
      return (X) new BinaryStreamImpl(unwrapBytes(value));
    }
    if (Blob.class.isAssignableFrom(type)) {
      return (X) options.getLobCreator().createBlob(unwrapBytes(value));
    }

    throw unknownUnwrap(type);
  }