Class FileUtilities
java.lang.Object
org.netbeans.modules.maven.api.FileUtilities
Various File/FileObject related utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic File
convertArtifactToLocalRepositoryFile
(org.apache.maven.artifact.Artifact artifact) take any (even unresolved) Maven Arfifact instance and construct a local repository based File instance for it.static File
converts a string representing a path to a normalized File instancestatic org.openide.filesystems.FileObject
static URI
convertStringToUri
(String str) static org.openide.filesystems.FileObject
getBasePackageNames
(org.netbeans.api.project.Project prj) static URI
static URI
getPackageNames
(org.netbeans.api.project.Project prj) Inspired by org.netbeans.modules.apisupport.project.Util.scanProjectForPackageNames Returns sorted set of given project's package names in x.y.z form.static String
getRelativePath
(File dir, File file) get relative path between file and it's child.static File
getUserSettingsFile
(boolean forceCreate) Get the user settings.xml file.static String
relativizeFile
(File basedir, File file) Produce a machine-independent relativized version of a filename from a basedir.static File
resolveFilePath
(File basedir, String filename) copied from netbeans.org's ant/project sources.
-
Method Details
-
convertURItoFileObject
@CheckForNull public static org.openide.filesystems.FileObject convertURItoFileObject(@NullAllowed URI uri) -
convertStringToFileObject
@CheckForNull public static org.openide.filesystems.FileObject convertStringToFileObject(@NullAllowed String str) -
convertStringToFile
-
convertStringToUri
-
convertArtifactToLocalRepositoryFile
public static File convertArtifactToLocalRepositoryFile(org.apache.maven.artifact.Artifact artifact) take any (even unresolved) Maven Arfifact instance and construct a local repository based File instance for it. The file does not have to exist though.- Parameters:
artifact
-- Returns:
-
resolveFilePath
-
getDirURI
-
getDirURI
-
getRelativePath
-
relativizeFile
Produce a machine-independent relativized version of a filename from a basedir. UnlikeURI.relativize(java.net.URI)
this will produce "../" sequences as needed.- Parameters:
basedir
- a directory to resolve relative to (need not exist on disk)file
- a file or directory to find a relative path for- Returns:
- a relativized path (slash-separated), or null if it is not possible (e.g. different DOS drives);
just
.
in case the paths are the same - Throws:
IllegalArgumentException
- if the basedir is known to be a file and not a directory copied from project.ant's PropertyUtils
-
getPackageNames
Inspired by org.netbeans.modules.apisupport.project.Util.scanProjectForPackageNames Returns sorted set of given project's package names in x.y.z form. Result contains only packages which are valid as candidates for public packages - contains some *.class or *.java- Parameters:
prj
- project to retrieve package names from- Returns:
- Sorted set of package names
-
getBasePackageNames
-
getUserSettingsFile
Get the user settings.xml file.- Parameters:
forceCreate
- determines whether file should be created in case it does not exist- Returns:
- either the settings.xml file or
null
if not available
-