Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.browseengine.bobo.geosearch.index.impl;
  
  import java.util.HashMap;
  import java.util.Map;
  
A directory implementation that wraps another directory and pairs two extensions together on delete. For each paiered extension (A, B), anytime fileName.B is deleted, PairedDeleteDirectory will first delete fileName.A, if it exists

Author(s):
Geoff Cooney
 
 public class DeletePairedExtensionDirectory extends Directory {
     private final Directory actualDirectory;
     private final Map<StringStringpairedDeleteExtensions;
     
     public DeletePairedExtensionDirectory(Directory directory) {
         this. = directory;
         this. =  new HashMap<StringString>();
     }
 
     public void addExtensionPairing(String extFromString extTo) {
         .put(extFromextTo);
     }
     
     @Override
     public String[] listAll() throws IOException {
         return .listAll();
     }
 
     @Override
     public boolean fileExists(String namethrows IOException {
         return .fileExists(name);
     }
 
     @Override
     public long fileModified(String namethrows IOException {
         return .fileModified(name);
     }
 
     @Override
     public void touchFile(String namethrows IOException {
         .touchFile(name);
     }
 
     @Override
     public void deleteFile(String namethrows IOException {
         String ext = FilenameUtils.getExtension(name);
         
         String pairedExt = .get(ext);
         if (StringUtils.isNotBlank(pairedExt)) {
             String pairedFileName = FilenameUtils.removeExtension(name) +
                 . +
                 pairedExt;
             
             if (fileExists(pairedFileName)) {
                 deleteFile(pairedFileName);
             }
         }
         
         .deleteFile(name);
     }
 
     @Override
     public long fileLength(String namethrows IOException {
         return .fileLength(name);
     }
 
     @Override
     public IndexOutput createOutput(String namethrows IOException {
         return .createOutput(name);
     }
 
     @Override
     public void sync(String namethrows IOException {
         .sync(name);
     }
 
     @Override
     public void sync(Collection<Stringnamesthrows IOException {
         .sync(names);
     }
 
     @Override
     public IndexInput openInput(String namethrows IOException {
         return .openInput(name);
     }
    @Override
    public IndexInput openInput(String nameint bufferSizethrows IOException {
        return .openInput(namebufferSize);
    }
    @Override
    public Lock makeLock(String name) {
        return .makeLock(name);
    }
    @Override
    public void clearLock(String namethrows IOException {
        .clearLock(name);
    }
    @Override
    public void close() throws IOException {
        .close();
    }
    @Override
    public void setLockFactory(LockFactory lockFactorythrows IOException {
        .setLockFactory(lockFactory);
    }
    @Override
    public LockFactory getLockFactory() {
        return .getLockFactory();
    }
    @Override
    public String getLockID() {
        return .getLockID();
    }
    @Override
    public String toString() {
        return .toString();
    }
    @Override
    public void copy(Directory toString srcString destthrows IOException {
        .copy(tosrcdest);
    }
New to GrepCode? Check out our FAQ X