|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Target(value=FIELD) @Retention(value=RUNTIME) public @interface FileContent
Annotation for loading the contents of a file into a field.
The @FileContent will try to load a file (or other resource depending on the ReadingStrategy), convert it to the type of the annotated field and inject the result into the field. A file name can be specified as value explicitly. If no file name is specified, a default file name will be used: 'classname'.'extension'. The extension depends on the target type: 'txt' for String and 'properties' for Properties. By default, the file name is prefixed with the package name (. replaced by /).
public class MyTestClass extends UnitilsJUnit4 {
' @FileContent
private String field1;
' @FileContent("/someFile.properties")
private Properties field2;
...
}
In this example the content of 'org/mypackage/MyTestClass.txt" will be injected into field1 and the properties loaded from
'someFile.properties' will be injected into field2.
The encoding of the file can be passed as an argument. By default ISO-8859-1 is used. The default can be set by
overriding the IOModule.encoding.default property.
Optional Element Summary | |
---|---|
String |
encoding
Encoding to be used when reading the file. |
String |
value
|
public abstract String value
public abstract String encoding
Charset Description US-ASCII Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set ISO-8859-1 ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1 UTF-8 Eight-bit UCS Transformation Format UTF-16BE Sixteen-bit UCS Transformation Format, big-endian byte order UTF-16LE Sixteen-bit UCS Transformation Format, little-endian byte order UTF-16 Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |