/*
 * Copyright (C) 2010 Google Inc.
 * 
 * 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 com.googlecode.android_scripting.interpreter;

import android.content.Context;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * A description of the interpreters hosted by the SL4A project.
 * 
 * @author Damon Kohler (damonkohler@gmail.com)
 * @author Alexey Reznichenko (alexey.reznichenko@gmail.com)
 */
public abstract class Sl4aHostedInterpreter implements InterpreterDescriptor {

  public static final String BASE_INSTALL_URL = "http://android-scripting.googlecode.com/files/";
  public static final String DALVIKVM = "/system/bin/dalvikvm";

  public int getInterpreterVersion() {
    return getVersion();
  }

  public int getExtrasVersion() {
    return getVersion();
  }

  public int getScriptsVersion() {
    return getVersion();
  }

  public String getInterpreterArchiveName() {
    return String.format("%s_r%s.zip", getName(), getInterpreterVersion());
  }

  public String getExtrasArchiveName() {
    return String.format("%s_extras_r%s.zip", getName(), getExtrasVersion());
  }

  public String getScriptsArchiveName() {
    return String.format("%s_scripts_r%s.zip", getName(), getScriptsVersion());
  }

  public String getInterpreterArchiveUrl() {
    return BASE_INSTALL_URL + getInterpreterArchiveName();
  }

  public String getExtrasArchiveUrl() {
    return BASE_INSTALL_URL + getExtrasArchiveName();
  }

  public String getScriptsArchiveUrl() {
    return BASE_INSTALL_URL + getScriptsArchiveName();
  }

  // TODO(damonkohler): This shouldn't be public.
  public File getExtrasPath(Context context) {
    if (!hasInterpreterArchive() && hasExtrasArchive()) {
      return new File(InterpreterConstants.SDCARD_ROOT + this.getClass().getPackage().getName()
          + InterpreterConstants.INTERPRETER_EXTRAS_ROOT, getName());
    }
    return InterpreterUtils.getInterpreterRoot(context, getName());
  }

  public String getInteractiveCommand(Context context) {
    return "";
  }

  public boolean hasInteractiveMode() {
    return true;
  }

  public String getScriptCommand(Context context) {
    return "%s";
  }

  @Override
  public List<String> getArguments(Context context) {
    return new ArrayList<String>();
  }

  @Override
  public Map<String, String> getEnvironmentVariables(Context context) {
    return new HashMap<String, String>();
  }
}

@@ -1230,16 +1230,128 @@
 ikvm%22;%0A%0A
+  // TODO(damonkohler): Remove getVersion() and pull these three version methods up in to the base%0A  // class.%0A%0A
   public
@@ -1373,32 +1373,32 @@
 eterVersion() %7B%0A
-
     return getVe
@@ -1532,32 +1532,44 @@
 Version();%0A  %7D%0A%0A
+  @Override%0A
   public String 
@@ -1671,32 +1671,44 @@
 ersion());%0A  %7D%0A%0A
+  @Override%0A
   public String 
@@ -1807,32 +1807,44 @@
 ersion());%0A  %7D%0A%0A
+  @Override%0A
   public String 
@@ -1946,32 +1946,44 @@
 ersion());%0A  %7D%0A%0A
+  @Override%0A
   public String 
@@ -2067,32 +2067,44 @@
 iveName();%0A  %7D%0A%0A
+  @Override%0A
   public String 
@@ -2178,32 +2178,44 @@
 iveName();%0A  %7D%0A%0A
+  @Override%0A
   public String 
@@ -2305,405 +2305,17 @@
 %0A%0A  
-// TODO(damonkohler): This shouldn't be public.%0A  public File getExtrasPath(Context context) %7B%0A    if (!hasInterpreterArchive() && hasExtrasArchive()) %7B%0A      return new File(InterpreterConstants.SDCARD_ROOT + this.getClass().getPackage().getName()%0A          + InterpreterConstants.INTERPRETER_EXTRAS_ROOT, getName());%0A    %7D%0A    return InterpreterUtils.getInterpreterRoot(context, getName());%0A  %7D%0A
+@Override
 %0A  p
@@ -2384,24 +2384,36 @@
 rn %22%22;%0A  %7D%0A%0A
+  @Override%0A
   public boo
@@ -2458,24 +2458,36 @@
  true;%0A  %7D%0A%0A
+  @Override%0A
   public Str
@@ -2731,32 +2731,32 @@
 text context) %7B%0A
-
     return new H
@@ -2784,11 +2784,411 @@
 %3E();%0A  %7D
+%0A%0A  // TODO(damonkohler): This shouldn't be public.%0A  public File getExtrasPath(Context context) %7B%0A    if (!hasInterpreterArchive() && hasExtrasArchive()) %7B%0A      return new File(InterpreterConstants.SDCARD_ROOT + this.getClass().getPackage().getName()%0A          + InterpreterConstants.INTERPRETER_EXTRAS_ROOT, getName());%0A    %7D%0A    return InterpreterUtils.getInterpreterRoot(context, getName());%0A  %7D
 %0A%7D%0A

Add todo and missing @Override notations.