Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*-
   * See the file LICENSE for redistribution information.
   *
   * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
   *
   */
  
  package com.sleepycat.je.log;
  
 import java.io.File;
JEFileFilters are used for listing je files.
 
 class JEFileFilter implements FilenameFilter {
     String[] suffix;
     long minFileNumber = 0;
     long maxFileNumber = -1;
 
     JEFileFilter(String[] suffix) {
         this. = suffix;
     }

    

Parameters:
maxFileNumber this filter will only return files that are numbers <= maxFileNumber.
 
     JEFileFilter(String[] suffixlong maxFileNumber) {
         this. = suffix;
         this. = maxFileNumber;
     }

    

Parameters:
minFileNumber this filter will only return files that are >= minFileNumber.
maxFileNumber this filter will only return files that are numbers <= maxFileNumber.
 
     JEFileFilter(String[] suffixlong minFileNumberlong maxFileNumber) {
         this. = suffix;
         this. = minFileNumber;
         this. = maxFileNumber;
     }
 
     private boolean matches(String fileSuffix) {
         for (int i = 0; i < .i++) {
             if (fileSuffix.equalsIgnoreCase([i])) {
                 return true;
             }
         }
         return false;
     }

    
A JE file has to be of the format nnnnnnnn.suffix.
 
     public boolean accept(File dirString name) {
         boolean ok = false;
         StringTokenizer tokenizer = new StringTokenizer(name".");
         /* There should be two parts. */
         int nTokens = tokenizer.countTokens();
         if (nTokens == 2 || nTokens == 3) {
             boolean hasVersion = (nTokens == 3);
             String fileNumber = tokenizer.nextToken();
             String fileSuffix = "." + tokenizer.nextToken();
             String fileVersion = (hasVersion ? tokenizer.nextToken() : null);
 
             /* Check the length and the suffix. */
             if ((fileNumber.length() == 8) &&
                 matches(fileSuffix)) {
                 //(fileSuffix.equalsIgnoreCase(suffix))) {
 
                 /* The first part should be a number. */
                 try {
                     long fileNum = Long.parseLong(fileNumber, 16);
                     if (fileNum < ) {
                         ok = false;
                     } else if ((fileNum <= ) ||
                                ( == -1)) {
                         ok = true;
                     }
                 } catch (NumberFormatException e) {
                     ok = false;
                 }
                 if (hasVersion) {
                     try {
                         Integer.parseInt(fileVersion);
                         ok = true;
                     } catch (NumberFormatException e) {
                         ok = false;
                     }
                 }
             }
         }
 
         return ok;
     }
New to GrepCode? Check out our FAQ X