Java Doc for ResourceUtils.java in  » UML » AndroMDA-3.2 » org » andromda » core » common » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » UML » AndroMDA 3.2 » org.andromda.core.common 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.andromda.core.common.ResourceUtils

ResourceUtils
public class ResourceUtils (Code)
Provides utilities for loading resources.
author:
   Chad Brandon




Method Summary
public static  voiddeleteDirectory(File directory)
     Recursively deletes a directory and its contents.
public static  ZipFilegetArchive(URL resource)
     If this resource is an archive file, it will return the resource as an archive.
public static  ListgetClassPathArchiveContents(URL resource)
     If the resource represents a classpath archive (i.e.
public static  URLgetClassResource(String className)
     Takes a className as an argument and returns the URL for the class.
public static  StringgetContents(URL resource)
     Loads the resource and returns the contents as a String.
Parameters:
  resource - the name of the resource.
public static  StringgetContents(Reader resource)
     Loads the resource and returns the contents as a String.
Parameters:
  resource - the name of the resource.
public static  StringgetContents(String resourceName)
     Loads the file resource and returns the contents as a String.
Parameters:
  resourceName - the name of the resource.
public static  ListgetDirectoryContents(URL resource, int levels)
     If this resource happens to be a directory, it will load the contents of that directory into a List and return the list of names relative to the given resource (otherwise it will return an empty List).
Parameters:
  resource - the resource from which to retrieve the contents
Parameters:
  levels - the number of levels to step down if the resource ends up being a directory (if its an artifact,levels will be ignored).
public static  ListgetDirectoryContents(URL resource, int levels, boolean includeSubdirectories)
     If this resource happens to be a directory, it will load the contents of that directory into a List and return the list of names relative to the given resource (otherwise it will return an empty List).
Parameters:
  resource - the resource from which to retrieve the contents
Parameters:
  levels - the number of levels to step down if the resource ends up being a directory (if its an artifact,levels will be ignored).
Parameters:
  includeSubdirectories - whether or not to include subdirectories in the contents.
public static  ListgetDirectoryContents(URL url, boolean absolute, String[] patterns)
     Gets the contents of this directory and any of its sub directories based on the given patterns. And returns absolute or relative paths depending on the value of absolute.
Parameters:
  url - the URL of the directory.
Parameters:
  absolute - whether or not the returned content paths should be absoluate (iffalse paths will be relative to URL).
public static  longgetLastModifiedTime(URL resource)
     Gets the time as a long when this resource was last modified. If it can not be determined 0 is returned.
Parameters:
  resource - the resource from which to retrievethe last modified time.
public static  URLgetResource(String resourceName)
     Retrieves a resource from the current classpath.
public static  URLgetResource(String resourceName, String directory)
    

Retrieves a resource from an optionally given directory or from the package on the classpath.

public static  URLgetResource(String resourceName, URL directory)
    

Retrieves a resource from an optionally given directory or from the package on the classpath.

If the directory is specified and is a valid directory then an attempt at finding the resource by appending the resourceName to the given directory will be made, otherwise an attempt to find the resourceName directly on the classpath will be initiated.
public static  booleanisArchive(URL resource)
     Returns true/false on whether or not this resource represents an archive or not (i.e.
public static  booleanisFile(URL url)
     Indicates whether or not the given url is a file.
Parameters:
  url - the URL to check.
public static  voidmakeDirectories(String location)
     Makes the directory for the given location if it doesn't exist.
public static  booleanmatchesAtLeastOnePattern(String path, String[] patterns)
     Indicates whether or not the given path matches on one or more of the patterns defined within this class returns true if no patterns are defined.
Parameters:
  path - the path to match on.
public static  booleanmodifiedAfter(long time, File directory)
     Indicates whether or not the contents of the given directory and any of its sub directories have been modified after the given time.
public static  StringnormalizePath(String path)
     Removes any extra path separators and converts all from back slashes to forward slashes.
Parameters:
  path - the path to normalize.
public static  StringrenameExtension(String path, String oldExtension, String newExtension)
     Takes a path and replaces the oldException with the newExtension.
Parameters:
  path - the path to rename.
Parameters:
  oldExtension - the extension to rename from.
Parameters:
  newExtension - the extension to rename to.
public static  URLresolveClasspathResource(String path)
     Resolves a URL to a classpath resource, this method will treat occurrences of the exclamation mark similar to what URL does with the jar:file protocol.
public static  URLtoURL(String path)
     Attempts to construct the given path to a URL instance.
public static  StringunescapeFilePath(String filePath)
     Replaces any escape characters in the given file path with their counterparts.
Parameters:
  filePath - the path of the file to unescape.
public static  voidwriteUrlToFile(URL url, String fileLocation, String encoding)
     Writes the URL contents to a file specified by the fileLocation argument.



Method Detail
deleteDirectory
public static void deleteDirectory(File directory)(Code)
Recursively deletes a directory and its contents.
Parameters:
  directory - the directory to delete.



getArchive
public static ZipFile getArchive(URL resource)(Code)
If this resource is an archive file, it will return the resource as an archive. the archive as a ZipFile



getClassPathArchiveContents
public static List getClassPathArchiveContents(URL resource)(Code)
If the resource represents a classpath archive (i.e. jar, zip, etc), this method will retrieve all contents from that resource as a List of relative paths (relative to the archive base). Otherwise an empty List will be returned.
Parameters:
  resource - the resource from which to retrieve the contents a list of Strings containing the names of every nested resource found in this resource.



getClassResource
public static URL getClassResource(String className)(Code)
Takes a className as an argument and returns the URL for the class.
Parameters:
  className - java.net.URL



getContents
public static String getContents(URL resource)(Code)
Loads the resource and returns the contents as a String.
Parameters:
  resource - the name of the resource. String



getContents
public static String getContents(Reader resource)(Code)
Loads the resource and returns the contents as a String.
Parameters:
  resource - the name of the resource. the contents of the resource as a string.



getContents
public static String getContents(String resourceName)(Code)
Loads the file resource and returns the contents as a String.
Parameters:
  resourceName - the name of the resource. String



getDirectoryContents
public static List getDirectoryContents(URL resource, int levels)(Code)
If this resource happens to be a directory, it will load the contents of that directory into a List and return the list of names relative to the given resource (otherwise it will return an empty List).
Parameters:
  resource - the resource from which to retrieve the contents
Parameters:
  levels - the number of levels to step down if the resource ends up being a directory (if its an artifact,levels will be ignored). a list of Strings containing the names of every nested resource found in this resource.



getDirectoryContents
public static List getDirectoryContents(URL resource, int levels, boolean includeSubdirectories)(Code)
If this resource happens to be a directory, it will load the contents of that directory into a List and return the list of names relative to the given resource (otherwise it will return an empty List).
Parameters:
  resource - the resource from which to retrieve the contents
Parameters:
  levels - the number of levels to step down if the resource ends up being a directory (if its an artifact,levels will be ignored).
Parameters:
  includeSubdirectories - whether or not to include subdirectories in the contents. a list of Strings containing the names of every nested resource found in this resource.



getDirectoryContents
public static List getDirectoryContents(URL url, boolean absolute, String[] patterns)(Code)
Gets the contents of this directory and any of its sub directories based on the given patterns. And returns absolute or relative paths depending on the value of absolute.
Parameters:
  url - the URL of the directory.
Parameters:
  absolute - whether or not the returned content paths should be absoluate (iffalse paths will be relative to URL). a collection of paths.



getLastModifiedTime
public static long getLastModifiedTime(URL resource)(Code)
Gets the time as a long when this resource was last modified. If it can not be determined 0 is returned.
Parameters:
  resource - the resource from which to retrievethe last modified time. the last modified time or 0 if it couldn't be retrieved.



getResource
public static URL getResource(String resourceName)(Code)
Retrieves a resource from the current classpath.
Parameters:
  resourceName - the name of the resource the resource url



getResource
public static URL getResource(String resourceName, String directory)(Code)

Retrieves a resource from an optionally given directory or from the package on the classpath.

If the directory is specified and is a valid directory then an attempt at finding the resource by appending the resourceName to the given directory will be made, otherwise an attempt to find the resourceName directly on the classpath will be initiated.


Parameters:
  resourceName - the name of a resource
Parameters:
  directory - the directory location the resource url



getResource
public static URL getResource(String resourceName, URL directory)(Code)

Retrieves a resource from an optionally given directory or from the package on the classpath.

If the directory is specified and is a valid directory then an attempt at finding the resource by appending the resourceName to the given directory will be made, otherwise an attempt to find the resourceName directly on the classpath will be initiated.


Parameters:
  resourceName - the name of a resource
Parameters:
  directory - the directory location the resource url



isArchive
public static boolean isArchive(URL resource)(Code)
Returns true/false on whether or not this resource represents an archive or not (i.e. jar, or zip, etc). true if its an archive, false otherwise.



isFile
public static boolean isFile(URL url)(Code)
Indicates whether or not the given url is a file.
Parameters:
  url - the URL to check. true/false



makeDirectories
public static void makeDirectories(String location)(Code)
Makes the directory for the given location if it doesn't exist.
Parameters:
  location - the location to make the directory.



matchesAtLeastOnePattern
public static boolean matchesAtLeastOnePattern(String path, String[] patterns)(Code)
Indicates whether or not the given path matches on one or more of the patterns defined within this class returns true if no patterns are defined.
Parameters:
  path - the path to match on. true/false



modifiedAfter
public static boolean modifiedAfter(long time, File directory)(Code)
Indicates whether or not the contents of the given directory and any of its sub directories have been modified after the given time.
Parameters:
  directory - the directory to check
Parameters:
  time - the time to check against true/false



normalizePath
public static String normalizePath(String path)(Code)
Removes any extra path separators and converts all from back slashes to forward slashes.
Parameters:
  path - the path to normalize. the normalizd path



renameExtension
public static String renameExtension(String path, String oldExtension, String newExtension)(Code)
Takes a path and replaces the oldException with the newExtension.
Parameters:
  path - the path to rename.
Parameters:
  oldExtension - the extension to rename from.
Parameters:
  newExtension - the extension to rename to. the path with the new extension.



resolveClasspathResource
public static URL resolveClasspathResource(String path)(Code)
Resolves a URL to a classpath resource, this method will treat occurrences of the exclamation mark similar to what URL does with the jar:file protocol.

Example: my/path/to/some.zip!/file.xml represents a resource file.xml that is located in a ZIP file on the classpath called my/path/to/some.zip

It is possible to have nested ZIP files, example: my/path/to/first.zip!/subdir/second.zip!/file.xml.

Please note that the extension of the ZIP file can be anything, but in the case the extension is .jar the JVM will automatically unpack resources one level deep and put them all on the classpath
Parameters:
  path - the name of the resource to resolve to a URL, potentially nested in ZIP archives a URL pointing the resource resolved from the argument pathor null if the argument is null or impossible to resolve




toURL
public static URL toURL(String path)(Code)
Attempts to construct the given path to a URL instance. If the argument cannot be resolved as a resource on the file system this method will attempt to locate it on the classpath.
Parameters:
  path - the path from which to construct the URL. the constructed URL or null if one couldn't be constructed.



unescapeFilePath
public static String unescapeFilePath(String filePath)(Code)
Replaces any escape characters in the given file path with their counterparts.
Parameters:
  filePath - the path of the file to unescape. the unescaped path.



writeUrlToFile
public static void writeUrlToFile(URL url, String fileLocation, String encoding) throws IOException(Code)
Writes the URL contents to a file specified by the fileLocation argument.
Parameters:
  url - the URL to read
Parameters:
  fileLocation - the location which to write.
Parameters:
  encoding - the optional encoding



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.