summaryrefslogtreecommitdiffstats
path: root/tools/runner/java/vogar/Action.java
blob: 5a562c737010c2fa8c55caa3ac905763a5d470f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package vogar;

import java.io.File;

/**
 * A named job such as a test or benchmark run. This class tracks the resource
 * files and classes for compiling and running a Java source file.
 */
public final class Action {

    private final String name;
    private final String actionClass;
    private final File resourcesDirectory;
    private final File javaFile;
    private final RunnerSpec runnerSpec;
    private File userDir = new File(System.getProperty("user.dir"));

    public Action(String name, String actionClass, File resourcesDirectory,
            File javaFile, RunnerSpec runnerSpec) {
        this.name = name;
        this.actionClass = actionClass;
        this.resourcesDirectory = resourcesDirectory;
        this.javaFile = javaFile;
        this.runnerSpec = runnerSpec;
    }

    /**
     * Returns the local directory containing this action's required resource
     * files, or {@code null} if this action is standalone.
     */
    public File getResourcesDirectory() {
        return resourcesDirectory;
    }

    /**
     * Returns this action's java file, or {@code null} if this file wasn't
     * built from source.
     */
    public File getJavaFile() {
        return javaFile;
    }

    /**
     * Returns the executable classname, such as java.lang.IntegerTest
     * or BitTwiddle.
     */
    public String getTargetClass() {
        return actionClass;
    }

    /**
     * Returns a unique identifier for this action.
     */
    public String getName() {
        return name;
    }

    public RunnerSpec getRunnerSpec() {
        return runnerSpec;
    }

    /**
     * Initializes the directory from which local files can be read by the
     * action.
     */
    public void setUserDir(File base) {
        this.userDir = base;
    }

    public File getUserDir() {
        return userDir;
    }

    @Override public String toString() {
        return name;
    }
}