Examples of CRC32


Examples of java.util.zip.CRC32

  public byte[] getGDSBytes() {
    return input;
  }

  public long calcCRC() {
    CRC32 crc32 = new CRC32();
    crc32.update(input);
    return crc32.getValue();
  }
View Full Code Here

Examples of java.util.zip.CRC32

      // check all the products for duplicates by comparing PDSs
      if( checkPDS ) {
        HashMap<Long, Integer> pdsMap = new HashMap<Long, Integer>();
        ArrayList<Integer> duplicate = new ArrayList<Integer>();
        CRC32 crc32 = new CRC32();
        for (int i = 0; i < products.size(); i++) {
          Grib2Product product = products.get( i );
          crc32.reset();
          crc32.update(product.getPDS().getPdsVars().getPDSBytes());

          // heres a way to get a byte array for CRC from other values we need for duplicate checking
          ByteBuffer bb = ByteBuffer.allocate(12);
          bb.putInt( product.getDiscipline());
          bb.putLong( product.getRefTime());
          crc32.update(bb.array());

          long crcv = crc32.getValue();
          Integer recnum = pdsMap.get(crcv);
          // duplicate found
          if ( recnum != null) {
            StringBuilder str = new StringBuilder( "Duplicate record with Discipline " );
            str.append( product.getDiscipline() );
View Full Code Here

Examples of java.util.zip.CRC32

      // check all the products for duplicates by comparing PDSs
      if( checkPDS ) {
        HashMap<Long, Integer> pdsMap = new HashMap<Long, Integer>();
        ArrayList<Integer> duplicate1 = new ArrayList<Integer>();
        ArrayList<Integer> duplicate2 = new ArrayList<Integer>();
        CRC32 crc32 = new CRC32();
        // initialize pdsMap with already indexed records
        int originalSize = recordList.size();
        for (int i = 0; i < recordList.size(); i++) {
          Grib2WriteIndex.RawRecord rr = recordList.get( i );
          crc32.reset();
          crc32.update( rr.pdsData );
          ByteBuffer bb = ByteBuffer.allocate(12);
          bb.putInt( rr.discipline );
          bb.putLong( rr.refTime );
          crc32.update(bb.array());
          pdsMap.put( crc32.getValue(), i );
        }
        Calendar cal = Calendar.getInstance();
        // now check new records for duplicates, assumes original index has no duplicates
        for (int i = 0; i < products.size(); i++) {
          Grib2Product product = products.get( i );
          crc32.reset();
          crc32.update(product.getPDS().getPdsVars().getPDSBytes());
          ByteBuffer bb = ByteBuffer.allocate(12);
          bb.putInt( product.getDiscipline());
          bb.putLong( product.getRefTime());
          crc32.update(bb.array());

          long crcv = crc32.getValue();
          Integer recnum = pdsMap.get(crcv);
          // duplicate found
          if ( recnum != null) {
            StringBuilder str = new StringBuilder( "Duplicate record with Discipline " );
            str.append( product.getDiscipline() );
View Full Code Here

Examples of java.util.zip.CRC32

      // check all the products for duplicates by comparing PDSs
      if( checkPDS ) {
        HashMap<Long, Integer> pdsMap = new HashMap<Long, Integer>();
        ArrayList<Integer> duplicate = new ArrayList<Integer>();
        CRC32 crc32 = new CRC32();
        for (int i = 0; i < products.size(); i++) {
          Grib1Product product = products.get( i );
          crc32.reset();
          crc32.update(product.getPDS().getPdsVars().getPDSBytes());
          ByteBuffer bb = ByteBuffer.allocate(8);
          bb.putLong( product.getPDS().getPdsVars().getReferenceTime());
          crc32.update(bb.array());

          long crcv = crc32.getValue();
          Integer recnum = pdsMap.get(crcv);
          // duplicate found
          if ( recnum != null ) {
            StringBuilder str = new StringBuilder( "Duplicate " );
            str.append( product.getHeader() );
View Full Code Here

Examples of java.util.zip.CRC32

      // check all the products for duplicates by comparing PDSs
      if( checkPDS ) {
        HashMap<Long, Integer> pdsMap = new HashMap<Long, Integer>();
        ArrayList<Integer> duplicate1 = new ArrayList<Integer>();
        ArrayList<Integer> duplicate2 = new ArrayList<Integer>();
        CRC32 crc32 = new CRC32();
        // initialize pdsMap with already indexed records
        int originalSize = recordList.size();
        for (int i = 0; i < recordList.size(); i++) {
          Grib2WriteIndex.RawRecord rr = recordList.get( i );
          crc32.reset();
          crc32.update( rr.pdsData );
          ByteBuffer bb = ByteBuffer.allocate(8);
          bb.putLong( rr.refTime );
          crc32.update(bb.array());
          pdsMap.put( crc32.getValue(), i );
        }
        // now check new records for duplicates, assumes original index has no duplicates
        for (int i = 0; i < products.size(); i++) {
          Grib1Product product = products.get( i );
          crc32.reset();
          crc32.update(product.getPDS().getPdsVars().getPDSBytes());
          ByteBuffer bb = ByteBuffer.allocate(8);
          bb.putLong( product.getPDS().getPdsVars().getReferenceTime() );
          crc32.update(bb.array());
          long crcv = crc32.getValue();
          Integer recnum = pdsMap.get(crcv);
          // duplicate found
          if ( recnum != null) {
            StringBuilder str = new StringBuilder( "Duplicate " );
            str.append( product.getHeader() );
View Full Code Here

Examples of java.util.zip.CRC32

      }

    } catch (Throwable thr) {
      throw new RegainException( thr.getMessage(), thr );
   
    CRC32 crc = new CRC32();
    crc.update(bytearrayMessage);
   
    mLog.debug("loadIMAPMessage crc: " + crc.getValue() + " for IMAP url: " + url);
    return bytearrayMessage;
  }
View Full Code Here

Examples of java.util.zip.CRC32

  /**
   * @see net.sourceforge.squirrel_sql.fw.util.IOUtilities#getCheckSum(java.io.File)
   */
  public long getCheckSum(File f) throws IOException
  {
    CRC32 result = new CRC32();
    FileInputStream fis = null;
    try
    {
      fis = new FileInputStream(f);
      int len = 0;
      byte[] buffer = new byte[DISK_DATA_BUFFER_SIZE];
      while ((len = fis.read(buffer)) != -1)
      {
        result.update(buffer, 0, len);
      }
    }
    finally
    {
      closeInputStream(fis);
    }
    return result.getValue();
  }
View Full Code Here

Examples of java.util.zip.CRC32

            //addResourceFile("mimetype", "/resource/ods/mimetype", out);
            ZipEntry ze = new ZipEntry("mimetype");
            String mime = "application/vnd.oasis.opendocument.spreadsheet";
            ze.setMethod(ZipEntry.STORED);
            ze.setSize(mime.length());
            CRC32 crc = new CRC32();
            crc.update(mime.getBytes());
            ze.setCrc(crc.getValue());
            out.putNextEntry(ze);
            for (int i=0; i<mime.length(); i++) {
                out.write(mime.charAt(i));
            }
            out.closeEntry();
View Full Code Here

Examples of java.util.zip.CRC32

   *@param  panel   the parent panel
   *@param  server  Description of the Parameter
   */
  public Ftp(wlPanel panel, FtpServer server) {
    super();
    crc = new CRC32();
    crcCache = new Hashtable();
    charset = Charset.forName(panel.getFrame().locale());
    decoder = charset.newDecoder();
    encoder = charset.newEncoder();

View Full Code Here

Examples of java.util.zip.CRC32

        File site = new File(filename);
        fileSize = site.length();

       // File Checksum
        try {
            cis = new CheckedInputStream( new FileInputStream(filename), new CRC32());
            byte[] buf = new byte[128];

            while(cis.read(buf) >= 0) {
            }
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.