|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.wookie.w3c.util.WidgetPackageUtils
public class WidgetPackageUtils
Utilities for working with Widget packages, i.e. Zip Files with an XML manifest
| Constructor Summary | |
|---|---|
WidgetPackageUtils()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
convertIdToFolderName(java.lang.String id)
Converts a widget identifier (usually a URI) into a form suitable for use as a file system folder name |
static java.lang.String |
convertPathToPlatform(java.lang.String path)
|
static java.lang.String |
convertPathToRelativeUri(java.lang.String path)
|
static java.io.File |
createUnpackedWidgetFolder(java.io.File widgetFolder,
java.lang.String id)
Returns a File representing the unpacked folder for a widget with the given identifier. |
static java.lang.String |
extractManifest(org.apache.commons.compress.archivers.zip.ZipFile zipFile)
Retrieves the Manifest entry as a String |
static java.lang.String[] |
getDefaults(org.apache.commons.compress.archivers.zip.ZipFile zip,
java.lang.String[] locales,
java.lang.String[] defaults)
Return the set of valid default files for each locale in the zip |
static java.io.InputStream |
getEntryStream(java.lang.String entry,
org.apache.commons.compress.archivers.zip.ZipFile zipFile)
Gets the input stream for an entry in the zip |
static java.lang.String |
getURLForWidget(java.lang.String widgetFolder,
java.lang.String id,
java.lang.String file)
Returns the local URL for a widget |
static boolean |
hasManifest(org.apache.commons.compress.archivers.zip.ZipFile zipfile)
Checks for the existence of the Manifest. |
static java.lang.String |
languageTagForPath(java.lang.String path)
Return the language tag for a given path |
static java.lang.String |
locateFilePath(java.lang.String path,
java.lang.String[] locales,
org.apache.commons.compress.archivers.zip.ZipFile zip)
Implements the rule for finding a file within a widget; it returns the first localized version first before returning a root version. |
static java.lang.String[] |
locateFilePaths(java.lang.String path,
java.lang.String[] locales,
org.apache.commons.compress.archivers.zip.ZipFile zip)
Returns the set of valid file paths for a given resource. |
static void |
repackZip(java.io.File source,
java.io.File target)
Packages the source file/folder up as a new Zip file |
static void |
unpackZip(org.apache.commons.compress.archivers.zip.ZipFile zipfile,
java.io.File targetFolder)
uses apache commons compress to unpack all the zip entries into a target folder partly adapted from the examples on the apache commons compress site, and an example of generic Zip unpacking. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WidgetPackageUtils()
| Method Detail |
|---|
public static java.lang.String locateFilePath(java.lang.String path,
java.lang.String[] locales,
org.apache.commons.compress.archivers.zip.ZipFile zip)
throws java.lang.Exception
path - locales - the supported locales, in list of preferencezip -
java.lang.Exception
public static java.lang.String[] locateFilePaths(java.lang.String path,
java.lang.String[] locales,
org.apache.commons.compress.archivers.zip.ZipFile zip)
throws java.lang.Exception
path - locales - zip -
java.lang.Exceptionpublic static java.lang.String languageTagForPath(java.lang.String path)
path -
public static java.lang.String[] getDefaults(org.apache.commons.compress.archivers.zip.ZipFile zip,
java.lang.String[] locales,
java.lang.String[] defaults)
zip - locales - defaults -
public static java.io.File createUnpackedWidgetFolder(java.io.File widgetFolder,
java.lang.String id)
throws java.io.IOException
widgetFolder - the folder that contains unpacked widgetsid - the widget identifier URI
java.io.IOException
public static java.lang.String getURLForWidget(java.lang.String widgetFolder,
java.lang.String id,
java.lang.String file)
widgetFolder - the folder that contains unpacked widgetsid - the widget identifier URIfile - a file in the widget package; use "" to obtain the root of the widget folder
public static java.lang.String convertIdToFolderName(java.lang.String id)
id - the widget identifier URI
public static java.lang.String convertPathToRelativeUri(java.lang.String path)
public static java.lang.String convertPathToPlatform(java.lang.String path)
public static boolean hasManifest(org.apache.commons.compress.archivers.zip.ZipFile zipfile)
zipfile -
public static java.lang.String extractManifest(org.apache.commons.compress.archivers.zip.ZipFile zipFile)
throws java.io.IOException
zipFile - the zip file from which to extract the manifest
java.io.IOException
public static java.io.InputStream getEntryStream(java.lang.String entry,
org.apache.commons.compress.archivers.zip.ZipFile zipFile)
throws java.util.zip.ZipException,
java.io.IOException
entry - the name of the entryzipFile -
java.util.zip.ZipException
java.io.IOException
public static void unpackZip(org.apache.commons.compress.archivers.zip.ZipFile zipfile,
java.io.File targetFolder)
throws java.io.IOException
zipfile - the Zip File to unpacktargetFolder - the folder into which to unpack the Zip file
java.io.IOException
public static void repackZip(java.io.File source,
java.io.File target)
throws java.io.IOException
source - the source file or folder to be zippedtarget - the zip file to create
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||