1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.googlecode.android_scripting.interpreter;
18 
19 import android.content.Context;
20 
21 import java.io.File;
22 import java.util.List;
23 import java.util.Map;
24 
25 /**
26  * Provides interpreter-specific info for execution/installation/removal purposes.
27  *
28  */
29 public interface InterpreterDescriptor {
30 
31   /**
32    * Returns unique name of the interpreter.
33    */
getName()34   public String getName();
35 
36   /**
37    * Returns display name of the interpreter.
38    */
getNiceName()39   public String getNiceName();
40 
41   /**
42    * Returns supported script-file extension.
43    */
getExtension()44   public String getExtension();
45 
46   /**
47    * Returns interpreter version number.
48    */
getVersion()49   public int getVersion();
50 
51   /**
52    * Returns the binary as a File object. Context is the InterpreterProvider's {@link Context} and
53    * is provided to find the interpreter installation directory.
54    */
getBinary(Context context)55   public File getBinary(Context context);
56 
57   /**
58    * Returns execution parameters in case when script name is not provided (when interpreter is
59    * started in a shell mode);
60    */
getInteractiveCommand(Context context)61   public String getInteractiveCommand(Context context);
62 
63   /**
64    * Returns command line arguments to execute a with a given script (format string with one
65    * argument).
66    */
getScriptCommand(Context context)67   public String getScriptCommand(Context context);
68 
69   /**
70    * Returns an array of command line arguments required to execute the interpreter (it's essential
71    * that the order in the array is consistent with order of arguments in the command line).
72    */
getArguments(Context context)73   public List<String> getArguments(Context context);
74 
75   /**
76    * Should return a map of environment variables names and their values (or null if interpreter
77    * does not require any environment variables).
78    */
getEnvironmentVariables(Context context)79   public Map<String, String> getEnvironmentVariables(Context context);
80 
81   /**
82    * Returns true if interpreter has an archive.
83    */
hasInterpreterArchive()84   public boolean hasInterpreterArchive();
85 
86   /**
87    * Returns true if interpreter has an extras archive.
88    */
hasExtrasArchive()89   public boolean hasExtrasArchive();
90 
91   /**
92    * Returns true if interpreter comes with a scripts archive.
93    */
hasScriptsArchive()94   public boolean hasScriptsArchive();
95 
96   /**
97    * Returns file name of the interpreter archive.
98    */
getInterpreterArchiveName()99   public String getInterpreterArchiveName();
100 
101   /**
102    * Returns file name of the extras archive.
103    */
getExtrasArchiveName()104   public String getExtrasArchiveName();
105 
106   /**
107    * Returns file name of the scripts archive.
108    */
getScriptsArchiveName()109   public String getScriptsArchiveName();
110 
111   /**
112    * Returns URL location of the interpreter archive.
113    */
getInterpreterArchiveUrl()114   public String getInterpreterArchiveUrl();
115 
116   /**
117    * Returns URL location of the scripts archive.
118    */
getScriptsArchiveUrl()119   public String getScriptsArchiveUrl();
120 
121   /**
122    * Returns URL location of the extras archive.
123    */
getExtrasArchiveUrl()124   public String getExtrasArchiveUrl();
125 
126   /**
127    * Returns true if interpreter can be executed in interactive mode.
128    */
hasInteractiveMode()129   public boolean hasInteractiveMode();
130 }
131