svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.expressionevaluator / org.gvsig.expressionevaluator.lib / org.gvsig.expressionevaluator.lib.impl / src / main / java / org / gvsig / expressionevaluator / impl / function / foldersmanager / TemporaryFileFunction.java @ 45043
History | View | Annotate | Download (1.45 KB)
1 | 44389 | jjdelcerro | package org.gvsig.expressionevaluator.impl.function.foldersmanager; |
---|---|---|---|
2 | 43512 | jjdelcerro | |
3 | 44389 | jjdelcerro | import java.io.File; |
4 | 43512 | jjdelcerro | import org.apache.commons.lang3.Range; |
5 | 43521 | jjdelcerro | import org.gvsig.expressionevaluator.Interpreter; |
6 | 43512 | jjdelcerro | import org.gvsig.expressionevaluator.spi.AbstractFunction; |
7 | 44389 | jjdelcerro | import org.gvsig.tools.ToolsLocator; |
8 | import org.gvsig.tools.folders.FoldersManager; |
||
9 | 43512 | jjdelcerro | |
10 | 44389 | jjdelcerro | public class TemporaryFileFunction extends AbstractFunction { |
11 | 43512 | jjdelcerro | |
12 | 44389 | jjdelcerro | public static final String NAME = "TEMPORARYFILE"; |
13 | |||
14 | public TemporaryFileFunction() {
|
||
15 | super(
|
||
16 | "Folders",
|
||
17 | NAME, |
||
18 | Range.between(1, 1000), |
||
19 | "Return a file with the specified relative path to the temporary folder.\n" +
|
||
20 | "The file will be deleted when the application exits.\n" +
|
||
21 | " "+NAME+"('folder','name.txt')", |
||
22 | NAME+"({{pathComponents...}})",
|
||
23 | new String[] { |
||
24 | "pathComponents - relative pathname"
|
||
25 | }, |
||
26 | "File",
|
||
27 | false
|
||
28 | ); |
||
29 | 43512 | jjdelcerro | } |
30 | |||
31 | @Override
|
||
32 | 44009 | jjdelcerro | public boolean allowConstantFolding() { |
33 | 44389 | jjdelcerro | return false; |
34 | 44009 | jjdelcerro | } |
35 | |||
36 | @Override
|
||
37 | 43521 | jjdelcerro | public Object call(Interpreter interpreter, Object[] args) { |
38 | 44389 | jjdelcerro | FoldersManager folderManager = ToolsLocator.getFoldersManager(); |
39 | String[] pathComponents = new String[args.length]; |
||
40 | for (int i = 0; i < args.length; i++) { |
||
41 | pathComponents[i] = getStr(args,i); |
||
42 | } |
||
43 | File f = folderManager.getTemporaryFile(pathComponents);
|
||
44 | return f;
|
||
45 | 43512 | jjdelcerro | } |
46 | } |