com.bbn.openmap.util.wanderer
Class OneWaySync

java.lang.Object
  |
  +--com.bbn.openmap.util.wanderer.Wanderer
        |
        +--com.bbn.openmap.util.wanderer.OneWaySync
All Implemented Interfaces:
WandererCallback
Direct Known Subclasses:
OneWaySync.BackCheck

public class OneWaySync
extends Wanderer
implements WandererCallback

The OneWaySync is a class that copies files from one directory to another, skipping specified extensions or only copying files and directories with specified extensions. It's used by the OpenMap team to keep the internal CVS tree in sync with the external one. The main() function has the avoid/limit suffixes hard-coded, you can extend or change the settings in a different class.


Nested Class Summary
static class OneWaySync.BackCheck
           
 
Field Summary
 java.lang.String[] dirSuffixAvoids
          The suffixes to skip over for directories.
 java.lang.String[] dirSuffixLimits
          The suffixes to limit copying to for directories.
protected  boolean fakeit
          Flag for not doing the changes, just saying what would happen.
 java.lang.String[] fileSuffixAvoids
          The suffixes to skip over for files.
 java.lang.String[] fileSuffixLimits
          The suffixes to limit copying to for files.
protected  java.util.LinkedList notCopiedList
          The list of stuff skipped over.
protected  boolean overwrite
          Flag to not have files that exist overwritten.
protected  java.io.File src
          The source directory.
protected  java.io.File tgt
          The target directory.
protected  boolean verbose
          Flag for printing out activities.
 
Constructor Summary
OneWaySync(java.lang.String srcDirName, java.lang.String targetDirName)
           
 
Method Summary
 void checkTargetSolos()
          Create a BackCheck object that looks to see what files are in the target but not in the source.
protected  boolean checkToSkipDirectory(java.lang.String name)
          Check to see if a source directory name should be skipped, based on the avoid and limit list.
protected  boolean checkToSkipFile(java.lang.String name)
          Check to see if a source file name should be skipped, based on the avoid and limit list.
 void copy(java.io.File fromFile, java.io.File toFile)
          Copy files.
 boolean getFakeit()
           
 java.lang.String getRelativePathFromSource(java.io.File file)
          Strip the source directory part of the path from the file, return what remains.
 java.lang.String getRelativePathFromTarget(java.io.File file)
          Strip the target directory part of the path from the file, return what remains.
 java.io.File getSourceFile(java.lang.String relativePath)
          Tack the file path onto the source directory.
 java.io.File getTargetFile(java.lang.String relativePath)
          Tack the file path onto the target directory.
 boolean getVerbose()
           
 void handleDirectory(java.io.File file)
          WandererCallback method handing directories, not used.
 void handleDirectory(java.io.File directory, java.lang.String[] contentNames)
          Wanderer method handing directories.
 void handleFile(java.io.File file)
          WandererCallback method handing files, check and copy those that fit the avoid and limit parameters.
static void main(java.lang.String[] argv)
          Given a set of files or directories, parade through them to change their case.
 void setDirSuffixAvoids(java.lang.String[] avoids)
           
 void setDirSuffixLimits(java.lang.String[] limits)
           
 void setFakeit(boolean val)
           
 void setFileSuffixAvoids(java.lang.String[] avoids)
           
 void setFileSuffixLimits(java.lang.String[] limits)
           
 void setVerbose(boolean val)
           
 void start()
          Start copying files from the source directory to the target directory.
protected  java.lang.String subtractPathFromDirectory(java.io.File dir, java.io.File file)
          Take the source directory out of the path to the directory.
 void writeUnsynched()
          Print out the files/directories not copied.
 
Methods inherited from class com.bbn.openmap.util.wanderer.Wanderer
getCallback, handleEntry, setCallback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

src

protected java.io.File src
The source directory.


tgt

protected java.io.File tgt
The target directory.


dirSuffixAvoids

public java.lang.String[] dirSuffixAvoids
The suffixes to skip over for directories.


fileSuffixAvoids

public java.lang.String[] fileSuffixAvoids
The suffixes to skip over for files.


dirSuffixLimits

public java.lang.String[] dirSuffixLimits
The suffixes to limit copying to for directories.


fileSuffixLimits

public java.lang.String[] fileSuffixLimits
The suffixes to limit copying to for files.


notCopiedList

protected java.util.LinkedList notCopiedList
The list of stuff skipped over.


verbose

protected boolean verbose
Flag for printing out activities.


fakeit

protected boolean fakeit
Flag for not doing the changes, just saying what would happen.


overwrite

protected boolean overwrite
Flag to not have files that exist overwritten.

Constructor Detail

OneWaySync

public OneWaySync(java.lang.String srcDirName,
                  java.lang.String targetDirName)
Method Detail

checkToSkipDirectory

protected boolean checkToSkipDirectory(java.lang.String name)
Check to see if a source directory name should be skipped, based on the avoid and limit list.


checkToSkipFile

protected boolean checkToSkipFile(java.lang.String name)
Check to see if a source file name should be skipped, based on the avoid and limit list.


handleDirectory

public void handleDirectory(java.io.File directory,
                            java.lang.String[] contentNames)
Wanderer method handing directories.

Overrides:
handleDirectory in class Wanderer

handleDirectory

public void handleDirectory(java.io.File file)
WandererCallback method handing directories, not used.

Specified by:
handleDirectory in interface WandererCallback

handleFile

public void handleFile(java.io.File file)
WandererCallback method handing files, check and copy those that fit the avoid and limit parameters.

Specified by:
handleFile in interface WandererCallback

copy

public void copy(java.io.File fromFile,
                 java.io.File toFile)
Copy files.


getRelativePathFromSource

public java.lang.String getRelativePathFromSource(java.io.File file)
Strip the source directory part of the path from the file, return what remains.


getRelativePathFromTarget

public java.lang.String getRelativePathFromTarget(java.io.File file)
Strip the target directory part of the path from the file, return what remains.


getSourceFile

public java.io.File getSourceFile(java.lang.String relativePath)
Tack the file path onto the source directory.


getTargetFile

public java.io.File getTargetFile(java.lang.String relativePath)
Tack the file path onto the target directory.


writeUnsynched

public void writeUnsynched()
Print out the files/directories not copied.


checkTargetSolos

public void checkTargetSolos()
Create a BackCheck object that looks to see what files are in the target but not in the source.


subtractPathFromDirectory

protected java.lang.String subtractPathFromDirectory(java.io.File dir,
                                                     java.io.File file)
Take the source directory out of the path to the directory.


start

public void start()
Start copying files from the source directory to the target directory.


setVerbose

public void setVerbose(boolean val)

getVerbose

public boolean getVerbose()

setFakeit

public void setFakeit(boolean val)

getFakeit

public boolean getFakeit()

setDirSuffixAvoids

public void setDirSuffixAvoids(java.lang.String[] avoids)

setFileSuffixAvoids

public void setFileSuffixAvoids(java.lang.String[] avoids)

setDirSuffixLimits

public void setDirSuffixLimits(java.lang.String[] limits)

setFileSuffixLimits

public void setFileSuffixLimits(java.lang.String[] limits)

main

public static void main(java.lang.String[] argv)
Description copied from class: Wanderer
Given a set of files or directories, parade through them to change their case.

Parameters:
argv - paths to files or directories, use -h to get a usage statement.


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details