1 /* 2 * Copyright (C) 2016 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * 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, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * 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 * @author Alexey Reznichenko (alexey.reznichenko (at) gmail.com) 29 */ 30 public interface InterpreterDescriptor { 31 32 /** 33 * Returns unique name of the interpreter. 34 */ 35 public String getName(); 36 37 /** 38 * Returns display name of the interpreter. 39 */ 40 public String getNiceName(); 41 42 /** 43 * Returns supported script-file extension. 44 */ 45 public String getExtension(); 46 47 /** 48 * Returns interpreter version number. 49 */ 50 public int getVersion(); 51 52 /** 53 * Returns the binary as a File object. Context is the InterpreterProvider's {@link Context} and 54 * is provided to find the interpreter installation directory. 55 */ 56 public File getBinary(Context context); 57 58 /** 59 * Returns execution parameters in case when script name is not provided (when interpreter is 60 * started in a shell mode); 61 */ 62 public String getInteractiveCommand(Context context); 63 64 /** 65 * Returns command line arguments to execute a with a given script (format string with one 66 * argument). 67 */ 68 public String getScriptCommand(Context context); 69 70 /** 71 * Returns an array of command line arguments required to execute the interpreter (it's essential 72 * that the order in the array is consistent with order of arguments in the command line). 73 */ 74 public List<String> getArguments(Context context); 75 76 /** 77 * Should return a map of environment variables names and their values (or null if interpreter 78 * does not require any environment variables). 79 */ 80 public Map<String, String> getEnvironmentVariables(Context context); 81 82 /** 83 * Returns true if interpreter has an archive. 84 */ 85 public boolean hasInterpreterArchive(); 86 87 /** 88 * Returns true if interpreter has an extras archive. 89 */ 90 public boolean hasExtrasArchive(); 91 92 /** 93 * Returns true if interpreter comes with a scripts archive. 94 */ 95 public boolean hasScriptsArchive(); 96 97 /** 98 * Returns file name of the interpreter archive. 99 */ 100 public String getInterpreterArchiveName(); 101 102 /** 103 * Returns file name of the extras archive. 104 */ 105 public String getExtrasArchiveName(); 106 107 /** 108 * Returns file name of the scripts archive. 109 */ 110 public String getScriptsArchiveName(); 111 112 /** 113 * Returns URL location of the interpreter archive. 114 */ 115 public String getInterpreterArchiveUrl(); 116 117 /** 118 * Returns URL location of the scripts archive. 119 */ 120 public String getScriptsArchiveUrl(); 121 122 /** 123 * Returns URL location of the extras archive. 124 */ 125 public String getExtrasArchiveUrl(); 126 127 /** 128 * Returns true if interpreter can be executed in interactive mode. 129 */ 130 public boolean hasInteractiveMode(); 131 } 132