Package javax.microedition.rms

Examples of javax.microedition.rms.RecordEnumeration


   * @see net.sf.microlog.core.appender.AbstractAppender#clear()
   */
  public synchronized void clear() {

    try {
      RecordEnumeration enumeration = logRecordStore.enumerateRecords(
          null, null, false);
      while (enumeration.hasNextElement()) {
        int recordId = enumeration.nextRecordId();
        logRecordStore.deleteRecord(recordId);
      }
    } catch (RecordStoreNotOpenException e) {
      System.err.println("RecordStore not open " + e);
    } catch (InvalidRecordIDException e) {
View Full Code Here


      // runtime
      if (!logOpen) {
        logRecordStore = RecordStore.openRecordStore(recordStoreName,
            true);
      }
      RecordEnumeration recordEnum = logRecordStore.enumerateRecords(
          null, new DescendingComparator(), false);

      while (recordEnum.hasNextElement()) {
        int recId = recordEnum.nextRecordId();
        if (arrayPointer >= 0) {
          // save recId
          limitedRecordIDs[arrayPointer] = recId;
          arrayPointer--;
        } else {
          // too old, just delete
          logRecordStore.deleteRecord(recId);
        }
      }
      recordEnum.destroy();
    } catch (RecordStoreNotFoundException e) {
      System.err.println("Failed to find recordstore. " + e);
    } catch (RecordStoreException e) {
      System.err.println("Something is wrong with the RecordStore. " + e);
    }
View Full Code Here

   */
  public void clearLog() {

    try {
      logRecordStore = RecordStore.openRecordStore(recordStoreName, true);
      RecordEnumeration enumeration = logRecordStore.enumerateRecords(
          null, null, false);
      while (enumeration.hasNextElement()) {
        int recordId = enumeration.nextRecordId();
        logRecordStore.deleteRecord(recordId);
      }

      logRecordStore = RecordStore.openRecordStore(recordStoreName, true);

View Full Code Here

    }

    static synchronized void load()
    {
        RecordStore rs = null;
        RecordEnumeration re = null;
        //noinspection CheckForOutOfMemoryOnLargeArrayAllocation
        byte[] buffer = new byte[ 256 ];
        try
        {
            rs = RecordStore.openRecordStore( RS_NAME, true );
            cache = new Hashtable( rs.getNumRecords() );
            re = rs.enumerateRecords( null, null, false );
            int recordId;
            int recordSize;
            //noinspection MethodCallInLoopCondition
            while( re.hasNextElement() )
            {
                recordId = re.nextRecordId();
                recordSize = rs.getRecordSize( recordId );
                if( buffer.length < recordSize )
                {
                    buffer = new byte[ recordSize + 64 ];
                }
                rs.getRecord( recordId, buffer, 0 );
                final StoreInfo info = new StoreInfo();
                info.deserialize( new SerializerInputStream(
                        new ByteArrayInputStream( buffer )
                ) );
                info.recordId = new Integer( recordId );
                cache.put( info.name, info );
            }
        }
        catch( RecordStoreException e )
        {
            log.error( e );
            ErrorHandler.handleError( null, e );
        }
        catch( SerializationException e )
        {
            log.error( e );
            ErrorHandler.handleError( null, e );
        }
        finally
        {
            if( re != null ) try{ re.destroy(); }catch( Exception e ){}
            if( rs != null ) try{ rs.closeRecordStore(); }catch( Exception e ){}
        }
    }
View Full Code Here

        try
        {
            rs=RecordStore.openRecordStore(RMS_ID,true);
            //buscar y borrar elemto con mismo nombre
            RecordFilter filtro=new RmsFiltro(nombre);
            RecordEnumeration re=rs.enumerateRecords(filtro,null,false);
            while(re.hasNextElement())
            {
                int el=re.nextRecordId();
                result=rs.getRecord(el);
            }
            rs.closeRecordStore();
        }
        catch (Exception e)
View Full Code Here

        try
        {
            rs=RecordStore.openRecordStore(RMS_ID,true);
            //buscar y borrar elemto con mismo nombre
            RecordFilter filtro=new RmsFiltro(nombre);
            RecordEnumeration re=rs.enumerateRecords(filtro,null,false);
            while(re.hasNextElement())
            {
                int el=re.nextRecordId();
                rs.deleteRecord(el);
            }
            rs.closeRecordStore();
        }
        catch (Exception e)
View Full Code Here

        RecordStore rs=null;
        try
        {
            rs=RecordStore.openRecordStore(RMS_ID,true);
            //buscar y borrar elemto con mismo nombre
            RecordEnumeration re=rs.enumerateRecords(null,null,false);
            result=new String[re.numRecords()];
            for(int i=0;i<result.length;i++)
            {
                String el=new String(re.nextRecord());
                result[i]=getId(el);
            }
            rs.closeRecordStore();
        }
        catch (Exception e)
View Full Code Here

        try
        {
            rs=RecordStore.openRecordStore(AlmacenMicropocha.RMS_ID,true);
            //buscar y borrar elemto con mismo nombre
            RecordFilter filtro=new AlmacenMicropocha.RmsFiltro(nombre);
            RecordEnumeration re=rs.enumerateRecords(filtro,null,false);
            while(re.hasNextElement())
            {
                int el=re.nextRecordId();
                rs.deleteRecord(el);
            }
            rs.closeRecordStore();
        }
        catch (Exception e)
View Full Code Here

        try
        {
            rs=RecordStore.openRecordStore(AlmacenMicropocha.RMS_ID,true);
            //buscar y borrar elemto con mismo nombre
            RecordFilter filtro=new AlmacenMicropocha.RmsFiltro(nombre);
            RecordEnumeration re=rs.enumerateRecords(filtro,null,false);
            while(re.hasNextElement())
            {
                int el=re.nextRecordId();
                rs.deleteRecord(el);
            }
            rs.closeRecordStore();
        }
        catch (Exception e)
View Full Code Here

    return registry;
  }

  public static Vector loadFromRMS(RecordStore rms) throws RecordStoreNotOpenException, InvalidRecordIDException, RecordStoreException, IOException {
    Vector registry = new Vector(rms.getNumRecords());
    RecordEnumeration enumeration = rms.enumerateRecords(null,null,false);
    while(enumeration.hasNextElement()) {
      int id = enumeration.nextRecordId();
      Mucus mucus = new Mucus();
      ByteArrayInputStream bin = new ByteArrayInputStream(rms.getRecord(id));
      DataInputStream in = new DataInputStream(bin);
      mucus.readFrom(in);
      mucus.setId(id);
View Full Code Here

TOP

Related Classes of javax.microedition.rms.RecordEnumeration

Copyright © 2018 www.massapicom. 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.