public class FileExt
extends java.io.File
See java.io.File The practice of code generation requires some more details on file names. Here's an extended class, which adds these to the Java File class in order to make this information easily accessible from a StringTemplate V4 template.
Note, to fetch the information from the Java base class java.io.File you need to be aware of the way, the StringTemplate V4 engine accesses public methods of a class: The access is restricted to public methods with names starting with "get", followed by a capitalized character. The function must not have any function argument. From a template, such a function is accessed without the "get" and with lower case first character, see these examples:
- <info.output.canonicalFile> to access File.getCanonicalFile()
for the currently generated file
- <info.templateFile.absoluteFile> to access File.getAbsoluteFile()
for the currently applied template group file
| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
ext
The file name extension without the dot.
|
java.lang.String |
mnm
The file name prefix or menmonic.
|
java.lang.String |
nameStem
The file name stem, the name without path, menmonic and extension.
|
java.lang.String |
rawName
The file name without extension (and without the separating dot).
|
| Constructor and Description |
|---|
FileExt(java.lang.String fName)
Split a file name into parts and store all details about the file name and path
in public fields.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
toString()
The default representation of the file name in user feedback.
|
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toURI, toURLpublic java.lang.String rawName
public java.lang.String nameStem
public java.lang.String ext
public java.lang.String mnm
"(?i)^([a-z][a-z_0-9]*)_.+$"
on the file name stem. If the regular expression doesn't match then this field is null.
The use case of this file name part is to shape a kind of name space for global objects in plain C code. Normally, a three character menemonic ("mnm") of the file or module name is used and this will then prepend the names of all global objects in the generated C code.