Package org.eclipse.core.internal.runtime

Examples of org.eclipse.core.internal.runtime.HashMapOfString


  /**
   * Crawler configuration bean class
   */
  public CrawlConfig(boolean init)
   {
    paramHash = new HashMapOfString();
    String defaultIndexDir = Constants.MUSTRU_HOME + Constants.fs + "data" + Constants.fs + "index";
    String defaultDbDir = Constants.MUSTRU_HOME + Constants.fs + "data" + Constants.fs + "bdb";
   
    //*-- initialize the crawler configuration with default values
    if (init)
View Full Code Here


   String filtersFile = Constants.FILTER_FILE;    //*-- file containing the list of handlers
   String errMsg = null;        //*-- Error message
   RandomAccessFile tfile = null;       //*-- a random access file containing a list of files to scan
   BufferedReader filein = null;      //*-- reader to remove dups from the task file       
   PrintWriter outp = null;        //*-- writer to create the unique list of files
   HashMapOfString h = null;        //*-- hash set to save the list of files
  
   logger.info("Start creating task file for crawl");
  
   //*-- before creating a task file, check for a restart
   if (crawlConfig.getStartPosition() != -1)
   { ctRef.fileReadTime -= new Date().getTime();
     int numFiles = 0; LineNumberReader fileno = null;
     try
     { fileno = new LineNumberReader(new FileReader(taskFile));
       while ((fileno.readLine()) != null) numFiles++;
     }
     catch (IOException ie) { logger.error("IO Error in task file " + taskFile + " " + ie.getMessage()); }
     finally { try { if (fileno != null) fileno.close(); }
               catch (IOException ie) { logger.error("Ignore error"); } }
     setNumFiles(numFiles);
     ctRef.fileReadTime += new Date().getTime();
     return;
   }
  
   ctRef.fileReadTime -= new Date().getTime();
   String iDirs = crawlConfig.getIncDirs();
   String eDirs = crawlConfig.getExcDirs();
   boolean skipHidden = crawlConfig.isSkipHidden();
   boolean followLinks = crawlConfig.isFollowLinks();
 
   if ( !(iDirs.equals("")) && !(iDirs.endsWith(";")) ) iDirs += ";";
   if ( !(eDirs.equals("")) && !(eDirs.endsWith(";")) ) eDirs += ";";
   String[] incDirs = (iDirs.equals("") ) ? new String[0]: iDirs.split(";");
   String[] excDirs = (eDirs.equals("") ) ? new String[0]: eDirs.split(";");
   Pattern[] excPatts = new Pattern[excDirs.length];
   for (int i = 0; i < excDirs.length; i++) excPatts[i] = Pattern.compile("^" + excDirs[i] + ".*$");
    
   try
    {
     tfile = new RandomAccessFile(taskFile, "rw");
     tfile.setLength(0); tfile.close();

     // *-- Run the directory scan for each directory in the list
     DirTools dirTools = new DirTools();
     for (int i = 0; i < incDirs.length; i++)
      { logger.info("Start scanning " + incDirs[i]);
        dirTools.dirScan(incDirs[i], filtersFile, taskFile, skipHidden, followLinks);
        logger.info("Finished scanning " + incDirs[i]);
      }

     // *-- Read the task file into a hashset and remove dups.
     logger.info("Removing duplicate file names from task file");
     filein = new BufferedReader(new FileReader(taskFile));
     String s; h = new HashMapOfString();
     while ((s = filein.readLine()) != null) h.put(s, "");
    }
   catch (IOException ie)
     { errMsg = "IO Error in task file " + ie.getMessage(); }
   finally
    { if (filein != null) try { filein.close(); } catch (IOException ie) { logger.error("Ignore error");
      if (errMsg != null) ctRef.cleanUp(errMsg);
    }
     
   //*-- Dump the file back into tfile with a list of unique file names
   //*-- Check if any of the files belong to the list of exclusion directories
   try
   {
    tfile = new RandomAccessFile(taskFile, "rw");
    tfile.setLength(0); tfile.seek(0);
    outp = new PrintWriter(new FileWriter(taskFile));
   
    if (h != null)
     { String[] keys = h.keys();
       FLOOP: for (int i = 0; i < keys.length; i++)
        { for (int j = 0; j < excPatts.length; j++)     
           { Matcher matcher = excPatts[j].matcher(keys[i]);
             if (matcher.matches()) continue FLOOP;
          }
View Full Code Here

  Properties props = new Properties();
  try { props.load(new FileInputStream( Constants.DOCTYPES_FILE)); }
  catch ( IOException e) { logger.error("Could not open " + Constants.DOCTYPES_FILE + " " + e.getMessage()); }

  //*-- load the types of media from the docTypes properties file
  HashMapOfString stats = new HashMapOfString();
  String[] docTypes = new String[props.size()]; int j = 0;
  for (Enumeration keys = props.propertyNames(); keys.hasMoreElements(); )
  { String key = (String) keys.nextElement(); stats.put(key, "0" );
  docTypes[j++] = key; }

  //*-- scan the database by file name and keep track of the types of files in the index
  DbTools dbt = Constants.getDbt();  
  dbt.openDB(Constants.EXT_FILES_DB, true, false);
  Cursor cursor = null; IndexableDoc idoc = new IndexableDoc();
  try
  {
   cursor = dbt.getCurrentDB().openCursor(null, null);
   DatabaseEntry key = new DatabaseEntry();
   DatabaseEntry data = new DatabaseEntry(); int i = 0;
   LOOP: while (cursor.getNext(key, data, LockMode.DEFAULT) == OperationStatus.SUCCESS)
   {
    if (!running) break LOOP;
    idoc = (IndexableDoc) idoc.getBdbBinding().entryToObject(data);
    String docType = idoc.getFileType();
    if (docType == null) docType = "unknown";
    String num =  stats.get(docType);
    if ( num == null) { docType = "unknown"; num =  stats.get(docType); }
    int val =  Integer.parseInt(num) + 1;
   
    i++; if ( (i % 1000) == 0) System.out.println("finished " + i + " documents");
   
    stats.put(docType, String.valueOf(val) );
   } //*-- end of while

  } //*-- end of try
  catch (DatabaseException dbe)
  { logger.error("Could not open cursor to browse File index" + dbe.getMessage() ); }
  finally
  { try { if (cursor != null) cursor.close();  dbt.closeDB(); }
  catch (DatabaseException de) { logger.error("Ignore error"); }
  }

  StringBuffer out = new StringBuffer(); int numFiles = 0;
  int io;
  for (int i = 0; i < docTypes.length; i++)
  { io =   Integer.parseInt( stats.get( docTypes[i] ) );
  out.append("No. of " + docTypes[i] + " files: " + io + Constants.NEWLINE);
  numFiles += io;
  }
  out.append("Total no. of files: " + numFiles + Constants.NEWLINE)

View Full Code Here

TOP

Related Classes of org.eclipse.core.internal.runtime.HashMapOfString

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.