Examples of dbc


Examples of com.sleepycat.db.internal.Dbc

    }

    public String[] list()
        throws IOException
    {
        Dbc cursor = null;
        List list = new ArrayList();

        try {
            try {
                DatabaseEntry key = new DatabaseEntry(new byte[0]);
                DatabaseEntry data = new DatabaseEntry((byte[]) null);

                data.setPartial(true);

                cursor = files.cursor(txn, flags);

                if (cursor.get(key, data,
                               DbConstants.DB_SET_RANGE | flags) != DbConstants.DB_NOTFOUND)
                {
                    ByteArrayInputStream buffer =
                        new ByteArrayInputStream(key.getData());
                    DataInputStream in = new DataInputStream(buffer);
                    String name = in.readUTF();
               
                    in.close();
                    list.add(name);

                    while (cursor.get(key, data,
                                      DbConstants.DB_NEXT | flags) != DbConstants.DB_NOTFOUND) {
                        buffer = new ByteArrayInputStream(key.getData());
                        in = new DataInputStream(buffer);
                        name = in.readUTF();
                        in.close();

                        list.add(name);
                    }
                }
            } finally {
                if (cursor != null)
                    cursor.close();
            }
        } catch (DatabaseException e) {
            throw new IOException(e.getMessage());
        }
View Full Code Here

Examples of com.sleepycat.db.internal.Dbc

        throws IOException
    {
        if (!exists(directory))
            throw new IOException("File does not exist: " + getName());

        Dbc cursor = null;

        try {
            try {
                byte[] bytes = getKey();
                int ulen = bytes.length + 8;
                byte[] cursorBytes = new byte[ulen];
                DatabaseEntry cursorKey = new DatabaseEntry(cursorBytes);
                DatabaseEntry cursorData = new DatabaseEntry((byte[]) null);
                Db files = directory.files;
                Db blocks = directory.blocks;
                DbTxn txn = directory.txn;
                int flags = directory.flags;

                System.arraycopy(bytes, 0, cursorBytes, 0, bytes.length);
                cursorKey.setUserBuffer(ulen, true);
                cursorData.setPartial(true);

                cursor = blocks.cursor(txn, flags);

                if (cursor.get(cursorKey, cursorData,
                               DbConstants.DB_SET_RANGE | flags) != DbConstants.DB_NOTFOUND)
                {
                    cursor.del(0);

                  outer:
                    while (cursor.get(cursorKey, cursorData,
                                      DbConstants.DB_NEXT | flags) != DbConstants.DB_NOTFOUND)
                    {
                        for (int i = 0; i < bytes.length; i++)
                            if (bytes[i] != cursorBytes[i])
                                break outer;

                        cursor.del(0);
                    }
                }

                files.del(txn, key, 0);
            } finally {
                if (cursor != null)
                    cursor.close();
            }
        } catch (DatabaseException e) {
            throw new IOException(e.getMessage());
        }
    }
View Full Code Here

Examples of com.sleepycat.db.internal.Dbc

    @Override
    public String[] listAll()
        throws IOException
    {
        Dbc cursor = null;
        List<String> list = new ArrayList<String>();

        try {
            try {
                DatabaseEntry key = new DatabaseEntry(new byte[0]);
                DatabaseEntry data = new DatabaseEntry((byte[]) null);

                data.setPartial(true);

                cursor = files.cursor(txn, flags);

                if (cursor.get(key, data,
                               DbConstants.DB_SET_RANGE | flags) != DbConstants.DB_NOTFOUND)
                {
                    ByteArrayInputStream buffer =
                        new ByteArrayInputStream(key.getData());
                    DataInputStream in = new DataInputStream(buffer);
                    String name = in.readUTF();
               
                    in.close();
                    list.add(name);

                    while (cursor.get(key, data,
                                      DbConstants.DB_NEXT | flags) != DbConstants.DB_NOTFOUND) {
                        buffer = new ByteArrayInputStream(key.getData());
                        in = new DataInputStream(buffer);
                        name = in.readUTF();
                        in.close();

                        list.add(name);
                    }
                }
            } finally {
                if (cursor != null)
                    cursor.close();
            }
        } catch (DatabaseException e) {
            throw new IOException(e.getMessage());
        }
View Full Code Here

Examples of starlight.taliis.core.files.dbc

   * @param row the row/value which shall be translated
   * @return
   */
  public String getDBCValue_s(String dbcname,int vCol,int dCol,int row){
    String rets="";
    dbc src;
    //request (load) DBC file
    openedFile of = null;
   
    // ask the file loader
    for(openedFile af : fm.getFileList()) {
      if(af.f.getName().endsWith(dbcname)) {
        of = af;
        break;
      }
    }
    // ask the mpq loader
    if(of==null) {
      if(mpqLoader==null) return null;
      if(!(mpqLoader instanceof PluginRequest)) return null;
      PluginRequest mpql = (PluginRequest)mpqLoader;

      try {
        of = mpql.requestRessource("DBFilesClient\\" + dbcname);
      } catch (InvalidClassException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (ChunkNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
   
    if(of==null) return null;
    src = (dbc)of.obj;
    // copy data
    try{
      Object t;
      int rrow = 0;
      for(int i=0;i<src.getNRecords();i++)
      if(((Number)src.getData(vCol, i)).intValue()==row){
        rrow=i;
        break;
      }
        //int vIndex = ((Number)t).intValue();
       
        // index in the string table
        t = src.getData(dCol, rrow);
        int strIndex = ((Number)t).intValue();
       
        rets=src.getStringByOffset(strIndex).toString();
    }catch (Exception e){
      return null;
    }
        return rets;
  }
View Full Code Here

Examples of starlight.taliis.core.files.dbc

      }
     
     
    // catch the dbc file we need
    //-----------------------------------------------------
      dbc src;
      if(mix.endsWith("same")) {
        src = data.dbcFile;
      }
      else {
        //request (load) DBC file
        openedFile of = null;
       
        // ask the file loader
        for(openedFile af : fm.getFileList()) {
          if(af.f.getName().endsWith(mix)) {
            of = af;
            break;
          }
        }
        // ask the mpq loader
        if(of==null) {
          if(mpqLoader==null) continue;
          if(!(mpqLoader instanceof PluginRequest)) continue;
          PluginRequest mpql = (PluginRequest)mpqLoader;
         
          of = mpql.requestRessource("DBFilesClient\\" + mix);
        }
       
        if(of==null) continue;
        src = (dbc)of.obj;
      }
     
    // prepare create crosslist vector
    //-----------------------------------------------------
      int l = data.mixArrIndexies[i];
      data.CrossLists[l] = new HashMap<Integer, String>();
     
      // lazy shortcut ..
      HashMap<Integer, String> tmpVec = data.CrossLists[l];
     
      // copy data
      for(int j=0; j<src.getNRecords(); j++) {
        // index in our tmpVector
        Object t = src.getData(vCol, j);
          int vIndex = ((Number)t).intValue();
         
          // index in the string table
          t = src.getData(dCol, j);
          int strIndex = ((Number)t).intValue();
         
          // string we want to store
          tmpVec.put(vIndex, src.getStringByOffset(strIndex).toString());
      }
    }
  }
View Full Code Here

Examples of starlight.taliis.core.files.dbc

      System.out.println("Open adt File: " + FileName);
      obj = new adt( fileLoader.openBuffer(path) );
    }
    else if(FileName.endsWith("dbc")) {
      System.out.println("Open dbc File: " + FileName);
      obj = new dbc( fileLoader.openBuffer(path) );
    }
    else {
      System.err.println("File Extension is not supported.");
      return;
    }
View Full Code Here

Examples of starlight.taliis.core.files.dbc

  public void setFileManangerRef(fileMananger ref) {
    fm = ref;
  }
 
  public wowfile load(File f) throws InvalidClassException {
    return new dbc( fileLoader.openBuffer(f.getAbsolutePath()) );
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.