示例#1
0
 public void handleLobs(long fromTime, long toTime, CDOLobHandler handler) throws IOException {
   for (DB4OBlob db4oBlob : DB4OStore.getElementsOfType(getObjectContainer(), DB4OBlob.class)) {
     byte[] id = HexUtil.hexToBytes(db4oBlob.getId());
     byte[] blob = db4oBlob.getValue();
     ByteArrayInputStream in = new ByteArrayInputStream(blob);
     OutputStream out = handler.handleBlob(id, blob.length);
     if (out != null) {
       try {
         IOUtil.copyBinary(in, out, blob.length);
       } finally {
         IOUtil.close(out);
       }
     }
   }
   for (DB4OClob db4oClob : DB4OStore.getElementsOfType(getObjectContainer(), DB4OClob.class)) {
     byte[] id = HexUtil.hexToBytes(db4oClob.getId());
     char[] clob = db4oClob.getValue();
     CharArrayReader in = new CharArrayReader(clob);
     Writer out = handler.handleClob(id, clob.length);
     if (out != null) {
       try {
         IOUtil.copyCharacter(in, out, clob.length);
       } finally {
         IOUtil.close(out);
       }
     }
   }
 }
示例#2
0
  public void loadLob(byte[] id, OutputStream out) throws IOException {
    String key = HexUtil.bytesToHex(id);
    IDB4OIdentifiableObject identifiableObject =
        DB4OStore.getIdentifiableObject(getObjectContainer(), key);
    if (identifiableObject == null) {
      throw new IOException("Lob not found: " + key);
    }

    if (identifiableObject instanceof DB4OBlob) {
      DB4OBlob blob = (DB4OBlob) identifiableObject;
      byte[] byteArray = blob.getValue();
      ByteArrayInputStream in = new ByteArrayInputStream(byteArray);
      IOUtil.copyBinary(in, out, byteArray.length);
    } else {
      DB4OClob clob = (DB4OClob) identifiableObject;
      char[] charArray = clob.getValue();
      CharArrayReader in = new CharArrayReader(charArray);
      IOUtil.copyCharacter(in, new OutputStreamWriter(out), charArray.length);
    }
  }
示例#3
0
 @Override
 protected void writeClob(byte[] id, long size, Reader reader) throws IOException {
   CharArrayWriter out = new CharArrayWriter();
   IOUtil.copyCharacter(reader, out, size);
   writeObject(new DB4OClob(HexUtil.bytesToHex(id), out.toCharArray()), new Monitor());
 }