intarsys runtime library

de.intarsys.tools.locator
Class LocatorTools

java.lang.Object
  extended by de.intarsys.tools.locator.LocatorTools

public class LocatorTools
extends Object

Tool methods for dealing with ILocator.


Field Summary
static String PATH_SEPARATOR
           
 
Method Summary
static void checkHash(ILocator locator, Object hash)
           
static void checkHash(ILocator locator, String algorithmName, Object hash)
          Deprecated.  
static void copy(ILocator source, ILocator target)
          Copy locator content.
static ILocator createLocator(Object value, ILocatorFactory factory, ILocator defaultValue)
           
static ILocator[] createLocators(String paths, ILocatorFactory factory)
           
static File createTempFile(ILocator locator)
          A temporary File with a copy of the data from "locator".
static ILocator createTempLocator(ILocator locator)
          A new temporary ILocator with a copy of the data from "locator".
static ILocator createTempLocator(ILocator locator, boolean keepName)
          A new temporary ILocator with a copy of the data from "locator".
static IDigest digest(ILocator locator, String algorithmName)
           
static byte[] getBytes(ILocator locator)
          The bytes referenced by "locator".
static File getFile(ILocator locator)
           
static String getString(ILocator locator)
          The String data referenced by "locator".
static String getString(ILocator locator, String defaultCharsetName, int size)
          The String data referenced by "locator".
static void putBytes(ILocator locator, byte[] bytes)
          Write bytes to locator.
static void save(ILocator locator, File file)
          Save "locator"s content to a file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_SEPARATOR

public static final String PATH_SEPARATOR
See Also:
Constant Field Values
Method Detail

checkHash

public static void checkHash(ILocator locator,
                             Object hash)
                      throws IOException
Throws:
IOException

checkHash

@Deprecated
public static void checkHash(ILocator locator,
                                        String algorithmName,
                                        Object hash)
                      throws IOException
Deprecated. 

Throws:
IOException

copy

public static void copy(ILocator source,
                        ILocator target)
                 throws IOException
Copy locator content.

Parameters:
source -
target -
Throws:
IOException

createLocator

public static ILocator createLocator(Object value,
                                     ILocatorFactory factory,
                                     ILocator defaultValue)

createLocators

public static ILocator[] createLocators(String paths,
                                        ILocatorFactory factory)
                                 throws IOException
Throws:
IOException

createTempFile

public static File createTempFile(ILocator locator)
                           throws IOException
A temporary File with a copy of the data from "locator".

Parameters:
locator -
Returns:
The temporary file.
Throws:
IOException

createTempLocator

public static ILocator createTempLocator(ILocator locator)
                                  throws IOException
A new temporary ILocator with a copy of the data from "locator". The ILocator and the data backing store created is guaranteed to live as long as it is used (not garbage collected). Best effort is made to delete all artifacts after it is no longer used.

Parameters:
locator -
Returns:
The temporary ILocator
Throws:
IOException

createTempLocator

public static ILocator createTempLocator(ILocator locator,
                                         boolean keepName)
                                  throws IOException
A new temporary ILocator with a copy of the data from "locator". The ILocator and the data backing store created is guaranteed to live as long as it is used (not garbage collected). Best effort is made to delete all artifacts after it is no longer used.

Parameters:
locator -
keepName - Flag if the resulting locator should have the same name as the original input.
Returns:
The temporary ILocator
Throws:
IOException

digest

public static IDigest digest(ILocator locator,
                             String algorithmName)
                      throws IOException
Throws:
IOException

getBytes

public static byte[] getBytes(ILocator locator)
                       throws IOException
The bytes referenced by "locator".

Parameters:
locator -
Returns:
The bytes referenced by "locator".
Throws:
IOException

getFile

public static File getFile(ILocator locator)
                    throws IOException
Throws:
IOException

getString

public static String getString(ILocator locator)
                        throws IOException
The String data referenced by "locator". If necessary, the encoding associated with the locator is used by using its "getReader" method.

Parameters:
locator -
Returns:
The String data referenced by "locator".
Throws:
IOException

getString

public static String getString(ILocator locator,
                               String defaultCharsetName,
                               int size)
                        throws IOException
The String data referenced by "locator". The encoding is derived from the InputStream or defaulted to the charset declared by the ILocator or the parameter defaultCharsetName.

Parameters:
locator -
defaultCharsetName -
Returns:
The String data referenced by "locator".
Throws:
IOException

putBytes

public static void putBytes(ILocator locator,
                            byte[] bytes)
                     throws IOException
Write bytes to locator.

Throws:
IOException

save

public static void save(ILocator locator,
                        File file)
                 throws IOException
Save "locator"s content to a file. The previous file content is deleted.

Parameters:
locator -
file -
Throws:
IOException

intarsys runtime library

Copyright © 2012 intarsys consulting GmbH. All Rights Reserved.