org.jboss.virtual.plugins.copy
Class AbstractCopyMechanism

java.lang.Object
  extended by org.jboss.virtual.plugins.copy.AbstractCopyMechanism
All Implemented Interfaces:
CopyMechanism
Direct Known Subclasses:
ExactCopyMechanism, ExplodedCopyMechanism, UnjarCopyMechanism

public abstract class AbstractCopyMechanism
extends Object
implements CopyMechanism

Copy mechanism to be used in VFSUtils.

Author:
Ales Justin

Constructor Summary
AbstractCopyMechanism()
           
 
Method Summary
protected  File copy(File guidDir, VirtualFileHandler handler)
          Copy handler.
 VirtualFile copy(VirtualFile file, VirtualFileHandler handler)
          Copy handler.
protected  File createCopy(File guidDir, VirtualFileHandler handler)
          Create copy destination.
protected static File createTempDirectory(File parent, String name)
          Create the temp directory.
protected abstract  void doCopy(File copy, VirtualFileHandler handler)
          Do copy.
protected static void exactCopy(File copy, VirtualFileHandler root)
          Exact copy.
protected static void explode(File copy, VirtualFileHandler root)
          Explode the root into file.
static File getTempDirectory()
          Get temp directory.
protected abstract  String getType()
          Get mechanism type.
protected abstract  boolean isAlreadyModified(VirtualFileHandler handler)
          Is handler already modified.
protected abstract  boolean replaceOldHandler(VirtualFileHandler parent, VirtualFileHandler oldHandler, VirtualFileHandler newHandler)
          Should we replace old handler with new.
protected static void rewrite(VirtualFileHandler handler, File file)
          Rewrite contents of handler into file.
protected static void unjar(File copy, VirtualFileHandler handler)
          Unjar to copy parameter.
protected static void unpack(File copy, VirtualFileHandler root, org.jboss.virtual.plugins.copy.AbstractCopyMechanism.WriteRootChecker checker)
          Unpack the root into file.
protected static VirtualFileHandler unwrap(VirtualFileHandler handler)
          Unwrap the handler from possible delegate handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCopyMechanism

public AbstractCopyMechanism()
Method Detail

getTempDirectory

public static File getTempDirectory()
Get temp directory.

Returns:
the temp directory

getType

protected abstract String getType()
Get mechanism type.

Returns:
the type

isAlreadyModified

protected abstract boolean isAlreadyModified(VirtualFileHandler handler)
                                      throws IOException
Is handler already modified.

Parameters:
handler - the handler
Returns:
true if already modified
Throws:
IOException - for any error

replaceOldHandler

protected abstract boolean replaceOldHandler(VirtualFileHandler parent,
                                             VirtualFileHandler oldHandler,
                                             VirtualFileHandler newHandler)
                                      throws IOException
Should we replace old handler with new.

Parameters:
parent - the parent handler
oldHandler - the old handler
newHandler - the new handler
Returns:
true if needs replacement
Throws:
IOException - for any error

unwrap

protected static VirtualFileHandler unwrap(VirtualFileHandler handler)
Unwrap the handler from possible delegate handler.

Parameters:
handler - the handler to unwrap
Returns:
unwrapped handler

copy

public VirtualFile copy(VirtualFile file,
                        VirtualFileHandler handler)
                 throws IOException,
                        URISyntaxException
Description copied from interface: CopyMechanism
Copy handler. If already modified, return handler's file.

Specified by:
copy in interface CopyMechanism
Parameters:
file - the original file
handler - the handler to copy
Returns:
handler's copy
Throws:
IOException - for any error
URISyntaxException - for any URI syntax error

copy

protected File copy(File guidDir,
                    VirtualFileHandler handler)
             throws IOException
Copy handler.

Parameters:
guidDir - the guid directory
handler - the handler to copy
Returns:
handler's copy as file
Throws:
IOException - for any error

createCopy

protected File createCopy(File guidDir,
                          VirtualFileHandler handler)
                   throws IOException
Create copy destination.

Parameters:
guidDir - the guid dir
handler - the handler to copy
Returns:
copy's destination
Throws:
IOException - for any error

doCopy

protected abstract void doCopy(File copy,
                               VirtualFileHandler handler)
                        throws IOException
Do copy.

Parameters:
copy - the copy destination
handler - the handler
Throws:
IOException - for any error

createTempDirectory

protected static File createTempDirectory(File parent,
                                          String name)
Create the temp directory.

Parameters:
parent - the parent
name - the dir name
Returns:
new directory

exactCopy

protected static void exactCopy(File copy,
                                VirtualFileHandler root)
                         throws IOException
Exact copy.

Parameters:
copy - the copy dest
root - the handler to copy
Throws:
IOException - for any error

explode

protected static void explode(File copy,
                              VirtualFileHandler root)
                       throws IOException
Explode the root into file.

Parameters:
copy - the copy dest
root - the root
Throws:
IOException - for any error

unpack

protected static void unpack(File copy,
                             VirtualFileHandler root,
                             org.jboss.virtual.plugins.copy.AbstractCopyMechanism.WriteRootChecker checker)
                      throws IOException
Unpack the root into file. Repeat this on the root's children.

Parameters:
copy - the copy dest
root - the root
checker - do we write the root checker
Throws:
IOException - for any error

unjar

protected static void unjar(File copy,
                            VirtualFileHandler handler)
                     throws IOException
Unjar to copy parameter.

Parameters:
copy - the dest to unjar
handler - the handler to unjar
Throws:
IOException - for any error

rewrite

protected static void rewrite(VirtualFileHandler handler,
                              File file)
                       throws IOException
Rewrite contents of handler into file.

Parameters:
handler - the handler
file - the file
Throws:
IOException - for any error


Copyright © 2009 JBoss, A division of Red Hat, Inc. All Rights Reserved.