net.sf.sail.core.util
Class BinaryUtils

java.lang.Object
  extended by net.sf.sail.core.util.BinaryUtils

public class BinaryUtils
extends java.lang.Object

Author:
turadg AUDIT07-

Constructor Summary
BinaryUtils()
           
 
Method Summary
static java.net.URL addToArchive(Pod pod, java.util.zip.ZipOutputStream podArchiveOutputStream, java.lang.String filename, java.io.InputStream source)
           
static void cleanClosePodArchive(Pod pod, java.util.jar.JarOutputStream podArchive)
          TODO think of way to avoid this hack
static java.io.File createTempDir(java.lang.String tempDirName)
           
static CurnitFile curnitFileForArgs(java.lang.String[] args)
           
static CurnitUuid curnitIdFromInt(int someInt)
          Transform integer id into a valid curnit uuid
static java.io.File fileForCommandArgument(java.lang.String path)
           
static Curnit loadCurnit(java.io.File file)
          loads a curnit from a file, returns the curnit object
static java.net.URL makeJarUrl(java.net.URL jarUrl, java.lang.String pathInJar)
           
static java.util.jar.JarOutputStream newPodArchiveFor(Pod pod)
          Note: ignores the previous archive associated with the pod
static java.io.File tempCurnitArchive(PodUuid rootPodId)
           
static java.io.File tempFileForUrl(java.lang.String externalForm)
           
static java.io.File tempFileForUrl(java.net.URL url)
           
static java.io.File tempFileForUrl(java.net.URL url, boolean deleteOnExit)
           
static java.net.URL toFileUrl(java.net.URL location)
          Takes a URL that points to a resource within a JAR, unzips it onto the filesystem, and returns a file: url to it
static java.net.URL urlForCommandArgument(java.lang.String path)
           
static void writeCurnit(CurnitUuid curnitId, java.lang.String curnitTitle, Pod rootPod, java.io.OutputStream out)
          Write to the output stream a curnit archive of a curnit with the specified curnit id, title and root pod
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryUtils

public BinaryUtils()
Method Detail

toFileUrl

public static java.net.URL toFileUrl(java.net.URL location)
                              throws java.io.IOException
Takes a URL that points to a resource within a JAR, unzips it onto the filesystem, and returns a file: url to it

Parameters:
location - points to a resource within a JAR
Returns:
file: URL to the specified jar: URL resource
Throws:
java.io.IOException

createTempDir

public static java.io.File createTempDir(java.lang.String tempDirName)
                                  throws java.io.IOException
Parameters:
tempDirName - TODO
Throws:
java.io.IOException

makeJarUrl

public static java.net.URL makeJarUrl(java.net.URL jarUrl,
                                      java.lang.String pathInJar)

tempFileForUrl

public static java.io.File tempFileForUrl(java.lang.String externalForm)
                                   throws java.io.IOException
Parameters:
externalForm -
Returns:
Throws:
java.io.IOException

tempFileForUrl

public static java.io.File tempFileForUrl(java.net.URL url,
                                          boolean deleteOnExit)
                                   throws java.io.IOException
Parameters:
curnitArchiveUrl -
deleteOnExit -
Returns:
Throws:
java.io.IOException

tempFileForUrl

public static java.io.File tempFileForUrl(java.net.URL url)
                                   throws java.io.IOException
Parameters:
curnitArchiveUrl -
Returns:
Throws:
java.io.IOException

fileForCommandArgument

public static java.io.File fileForCommandArgument(java.lang.String path)
                                           throws java.io.IOException
Parameters:
path -
Returns:
Throws:
java.io.IOException

urlForCommandArgument

public static java.net.URL urlForCommandArgument(java.lang.String path)
                                          throws java.io.IOException
Parameters:
path -
Returns:
Throws:
java.io.IOException

addToArchive

public static java.net.URL addToArchive(Pod pod,
                                        java.util.zip.ZipOutputStream podArchiveOutputStream,
                                        java.lang.String filename,
                                        java.io.InputStream source)
                                 throws java.io.IOException
Throws:
java.io.IOException

newPodArchiveFor

public static java.util.jar.JarOutputStream newPodArchiveFor(Pod pod)
                                                      throws java.io.IOException
Note: ignores the previous archive associated with the pod

Parameters:
pod -
Returns:
a new JarOutputStream to which to write to the new archive
Throws:
java.io.IOException

cleanClosePodArchive

public static void cleanClosePodArchive(Pod pod,
                                        java.util.jar.JarOutputStream podArchive)
                                 throws java.io.IOException
TODO think of way to avoid this hack

Parameters:
pod -
podToArchive -
Throws:
java.io.IOException

curnitFileForArgs

public static CurnitFile curnitFileForArgs(java.lang.String[] args)
                                    throws java.io.IOException
Parameters:
args -
Returns:
Throws:
java.io.IOException

writeCurnit

public static void writeCurnit(CurnitUuid curnitId,
                               java.lang.String curnitTitle,
                               Pod rootPod,
                               java.io.OutputStream out)
                        throws java.lang.Exception
Write to the output stream a curnit archive of a curnit with the specified curnit id, title and root pod

Throws:
java.lang.Exception

curnitIdFromInt

public static CurnitUuid curnitIdFromInt(int someInt)
Transform integer id into a valid curnit uuid

Parameters:
someInt -
Returns:
uuid of curnit for given serial id

loadCurnit

public static Curnit loadCurnit(java.io.File file)
                         throws java.io.IOException,
                                UnknownPodException
loads a curnit from a file, returns the curnit object

Parameters:
file - - curnit archive file
Returns:
Throws:
java.io.IOException
UnknownPodException

tempCurnitArchive

public static java.io.File tempCurnitArchive(PodUuid rootPodId)
                                      throws java.io.IOException,
                                             java.io.FileNotFoundException,
                                             java.net.MalformedURLException
Parameters:
rootPodId -
Returns:
Throws:
java.io.IOException
java.io.FileNotFoundException
java.net.MalformedURLException


Copyright © 2004-2008 TELS Center. All Rights Reserved.