Class FilteringUtils
- java.lang.Object
-
- org.apache.maven.shared.filtering.FilteringUtils
-
public final class FilteringUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static intCOPY_BUFFER_LENGTHprivate static intFILE_COPY_BUFFER_SIZEThe file copy buffer size (30 MB)private static intONE_KBThe number of bytes in a kilobyte.private static intONE_MBThe number of bytes in a megabyte.private static java.util.regex.PatternPATTERNprivate static java.lang.StringWINDOWS_PATH_PATTERN
-
Constructor Summary
Constructors Modifier Constructor Description privateFilteringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private static java.lang.StringbuildRelativePath(java.lang.String toPath, java.lang.String fromPath, char separatorChar)private static java.nio.charset.Charsetcharset(java.lang.String encoding)static voidcopyFile(java.io.File from, java.io.File to, java.lang.String encoding, FilterWrapper[] wrappers)If wrappers is null or empty, the file will be copy only if to.lastModified() < from.lastModified() or if overwrite is true.static voidcopyFile(java.io.File from, java.io.File to, java.lang.String encoding, FilterWrapper[] wrappers, boolean overwrite)Deprecated.usecopyFile(File, File, String, FilterWrapper[])insteadprivate static voidcopyFilePermissions(java.io.File source, java.io.File destination)Attempts to copy file permissions from the source to the destination file.static java.lang.StringescapeWindowsPath(java.lang.String val)static java.lang.StringgetRelativeFilePath(java.lang.String oldPath, java.lang.String newPath)This method can calculate the relative path between two paths on a file system.(package private) static booleanisEmpty(java.lang.String string)static java.io.FileresolveFile(java.io.File baseFile, java.lang.String filename)Resolve a filefilenameto its canonical form.private static voidsetReadWritePermissions(java.io.File file)
-
-
-
Field Detail
-
ONE_KB
private static final int ONE_KB
The number of bytes in a kilobyte.- See Also:
- Constant Field Values
-
ONE_MB
private static final int ONE_MB
The number of bytes in a megabyte.- See Also:
- Constant Field Values
-
FILE_COPY_BUFFER_SIZE
private static final int FILE_COPY_BUFFER_SIZE
The file copy buffer size (30 MB)- See Also:
- Constant Field Values
-
WINDOWS_PATH_PATTERN
private static final java.lang.String WINDOWS_PATH_PATTERN
- See Also:
- Constant Field Values
-
PATTERN
private static final java.util.regex.Pattern PATTERN
-
COPY_BUFFER_LENGTH
public static final int COPY_BUFFER_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
escapeWindowsPath
public static java.lang.String escapeWindowsPath(java.lang.String val)
- Parameters:
val- The value to be escaped.- Returns:
- Escaped value
-
resolveFile
public static java.io.File resolveFile(java.io.File baseFile, java.lang.String filename)Resolve a filefilenameto its canonical form. Iffilenameis relative (doesn't start with/), it is resolved relative tobaseFile. Otherwise it is treated as a normal root-relative path.- Parameters:
baseFile- where to resolvefilenamefrom, iffilenameis relativefilename- absolute or relative file path to resolve- Returns:
- the canonical
Fileoffilename
-
getRelativeFilePath
public static java.lang.String getRelativeFilePath(java.lang.String oldPath, java.lang.String newPath)This method can calculate the relative path between two paths on a file system.
PathTool.getRelativeFilePath( null, null ) = "" PathTool.getRelativeFilePath( null, "/usr/local/java/bin" ) = "" PathTool.getRelativeFilePath( "/usr/local", null ) = "" PathTool.getRelativeFilePath( "/usr/local", "/usr/local/java/bin" ) = "java/bin" PathTool.getRelativeFilePath( "/usr/local", "/usr/local/java/bin/" ) = "java/bin" PathTool.getRelativeFilePath( "/usr/local/java/bin", "/usr/local/" ) = "../.." PathTool.getRelativeFilePath( "/usr/local/", "/usr/local/java/bin/java.sh" ) = "java/bin/java.sh" PathTool.getRelativeFilePath( "/usr/local/java/bin/java.sh", "/usr/local/" ) = "../../.." PathTool.getRelativeFilePath( "/usr/local/", "/bin" ) = "../../bin" PathTool.getRelativeFilePath( "/bin", "/usr/local/" ) = "../usr/local"
Note: On Windows based system, the/character should be replaced by\character.- Parameters:
oldPath- old pathnewPath- new path- Returns:
- a relative file path from
oldPath.
-
buildRelativePath
private static java.lang.String buildRelativePath(java.lang.String toPath, java.lang.String fromPath, char separatorChar)
-
isEmpty
static boolean isEmpty(java.lang.String string)
-
copyFile
public static void copyFile(java.io.File from, java.io.File to, java.lang.String encoding, FilterWrapper[] wrappers) throws java.io.IOExceptionIf wrappers is null or empty, the file will be copy only if to.lastModified() < from.lastModified() or if overwrite is true.- Parameters:
from- the file to copyto- the destination fileencoding- the file output encoding (only if wrappers is not empty)wrappers- array ofFilterWrapper- Throws:
java.io.IOException- if an IO error occurs during copying or filtering
-
copyFile
@Deprecated public static void copyFile(java.io.File from, java.io.File to, java.lang.String encoding, FilterWrapper[] wrappers, boolean overwrite) throws java.io.IOExceptionDeprecated.usecopyFile(File, File, String, FilterWrapper[])insteadIf wrappers is null or empty, the file will be copy only if to.lastModified() < from.lastModified() or if overwrite is true.- Parameters:
from- the file to copyto- the destination fileencoding- the file output encoding (only if wrappers is not empty)wrappers- array ofFilterWrapperoverwrite- unused- Throws:
java.io.IOException- if an IO error occurs during copying or filtering
-
copyFilePermissions
private static void copyFilePermissions(java.io.File source, java.io.File destination) throws java.io.IOExceptionAttempts to copy file permissions from the source to the destination file. Initially attempts to copy posix file permissions, assuming that the files are both on posix filesystems. If the initial attempts fail then a second attempt using less precise permissions model. Note that permissions are copied on a best-efforts basis, failure to copy permissions will not result in an exception.- Parameters:
source- the file to copy permissions from.destination- the file to copy permissions to.- Throws:
java.io.IOException
-
setReadWritePermissions
private static void setReadWritePermissions(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
charset
private static java.nio.charset.Charset charset(java.lang.String encoding)
-
-