Skip to content

Commit

Permalink
Fix constructors for Command and JavaCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Stericson committed Jan 4, 2015
1 parent 5f6953a commit 2614b95
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/com/stericson/RootShell/RootShell.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class RootShell {

public static boolean debugMode = false;

public static final String version = "RootShell v1.1";
public static final String version = "RootShell v1.2";

/**
* Setting this to false will disable the handler that is used
Expand Down
44 changes: 4 additions & 40 deletions src/com/stericson/RootShell/execution/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@

public class Command {

//directly modified by JavaCommand
protected boolean javaCommand = false;
protected Context context = null;

public int totalOutput = 0;

public int totalOutputProcessed = 0;
Expand All @@ -46,10 +50,6 @@ public class Command {

String[] command = {};

boolean javaCommand = false;

Context context = null;

boolean finished = false;

boolean terminated = false;
Expand Down Expand Up @@ -106,42 +106,6 @@ public Command(int id, int timeout, String... command) {
createHandler(RootShell.handlerEnabled);
}

/**
* Constructor for executing Java commands rather than binaries
*
* @param javaCommand when True, it is a java command.
* @param context needed to execute java command.
*/
public Command(int id, boolean javaCommand, Context context, String... command) {
this(id, command);
this.javaCommand = javaCommand;
this.context = context;
}

/**
* Constructor for executing Java commands rather than binaries
*
* @param javaCommand when True, it is a java command.
* @param context needed to execute java command.
*/
public Command(int id, boolean handlerEnabled, boolean javaCommand, Context context, String... command) {
this(id, handlerEnabled, command);
this.javaCommand = javaCommand;
this.context = context;
}

/**
* Constructor for executing Java commands rather than binaries
*
* @param javaCommand when True, it is a java command.
* @param context needed to execute java command.
*/
public Command(int id, int timeout, boolean javaCommand, Context context, String... command) {
this(id, timeout, command);
this.javaCommand = javaCommand;
this.context = context;
}

//If you override this you MUST make a final call
//to the super method. The super call should be the last line of this method.
public void commandOutput(int id, String line) {
Expand Down
37 changes: 28 additions & 9 deletions src/com/stericson/RootShell/execution/JavaCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,40 @@

public class JavaCommand extends Command
{
public JavaCommand(int id, Context context, String... command)
{
super(id, true, context, command);
/**
* Constructor for executing Java commands rather than binaries
*
* @param context needed to execute java command.
*/
public JavaCommand(int id, Context context, String... command) {
super(id, command);
this.context = context;
this.javaCommand = true;
}

public JavaCommand(int id, boolean handlerEnabled, Context context, String... command)
{
super(id, handlerEnabled, true, context, command);
/**
* Constructor for executing Java commands rather than binaries
*
* @param context needed to execute java command.
*/
public JavaCommand(int id, boolean handlerEnabled, Context context, String... command) {
super(id, handlerEnabled, command);
this.context = context;
this.javaCommand = true;
}

public JavaCommand(int id, int timeout, Context context, String... command)
{
super(id, timeout, true, context, command);
/**
* Constructor for executing Java commands rather than binaries
*
* @param context needed to execute java command.
*/
public JavaCommand(int id, int timeout, Context context, String... command) {
super(id, timeout, command);
this.context = context;
this.javaCommand = true;
}


@Override
public void commandOutput(int id, String line)
{
Expand Down

0 comments on commit 2614b95

Please sign in to comment.