Package org.apache.jackrabbit.server.io
Class IOUtil
- java.lang.Object
-
- org.apache.jackrabbit.server.io.IOUtil
-
public final class IOUtil extends Object
IOUtil
provides utility methods used for import and export operations.
-
-
Field Summary
Fields Modifier and Type Field Description static long
UNDEFINED_LENGTH
Constant for undefined content lengthstatic long
UNDEFINED_TIME
Constant for undefined modification/creation time
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
buildContentType(String mimeType, String encoding)
Build a valid content type string from the given mimeType and encoding:static String
getCreated(long createdTime)
Return the creation time as formatted string.static String
getEncoding(String contentType)
Retrieve the encoding from the specified contentType.static String
getLastModified(long modificationTime)
Return the last modification time as formatted string.static String
getMimeType(String contentType)
Retrieve the mimeType from the specified contentType.static File
getTempFile(InputStream inputStream)
Builds a new temp.static Node
mkDirs(Node root, String relPath, String dirNodeType)
Recursively creates nodes below the specified root node.static void
spool(InputStream in, OutputStream out)
-
-
-
Field Detail
-
UNDEFINED_TIME
public static final long UNDEFINED_TIME
Constant for undefined modification/creation time- See Also:
- Constant Field Values
-
UNDEFINED_LENGTH
public static final long UNDEFINED_LENGTH
Constant for undefined content length- See Also:
- Constant Field Values
-
-
Method Detail
-
getLastModified
public static String getLastModified(long modificationTime)
Return the last modification time as formatted string.- Returns:
- last modification time as string.
- See Also:
HttpDateFormat.modificationDateFormat()
-
getCreated
public static String getCreated(long createdTime)
Return the creation time as formatted string.- Returns:
- creation time as string.
- See Also:
HttpDateFormat.creationDateFormat()
-
spool
public static void spool(InputStream in, OutputStream out) throws IOException
- Throws:
IOException
-
buildContentType
public static String buildContentType(String mimeType, String encoding)
Build a valid content type string from the given mimeType and encoding:<mimeType>; charset="<encoding>"
If the specified mimeType isnull
,null
is returned.- Parameters:
mimeType
-encoding
-- Returns:
- contentType or
null
if the specified mimeType isnull
-
getMimeType
public static String getMimeType(String contentType)
Retrieve the mimeType from the specified contentType.- Parameters:
contentType
-- Returns:
- mimeType or
null
-
getEncoding
public static String getEncoding(String contentType)
Retrieve the encoding from the specified contentType.- Parameters:
contentType
-- Returns:
- encoding or
null
if the specified contentType isnull
or does not define a charset.
-
getTempFile
public static File getTempFile(InputStream inputStream) throws IOException
Builds a new temp. file from the given input stream.It is left to the user to remove the file as soon as it is not used any more.
- Parameters:
inputStream
- the input stream- Returns:
- temp. file or
null
if the specified input isnull
. - Throws:
IOException
-
mkDirs
public static Node mkDirs(Node root, String relPath, String dirNodeType) throws RepositoryException
Recursively creates nodes below the specified root node.- Parameters:
root
-relPath
-- Returns:
- the node corresponding to the last segment of the specified relative path.
- Throws:
RepositoryException
-
-