This commit was generated by cvs2svn to compensate for changes in r50,
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.ui / src / net / sourceforge / phpdt / internal / debug / ui / launcher / ExecutionArguments.java
1 package net.sourceforge.phpdt.internal.debug.ui.launcher;
2
3 import org.eclipse.core.resources.IFile;
4 import org.eclipse.core.runtime.CoreException;
5 import org.eclipse.core.runtime.QualifiedName;
6
7 public class ExecutionArguments {
8         protected static final QualifiedName EXECUTION_ARGUMENTS_PROPERTY = new QualifiedName("net.sourceforge.phpdt", "executionArguments");
9         protected static final String ARGUMENT_SEPARATOR = "**<ArgBreak>**";
10         
11         protected String interpreterArguments, phpFileArguments;
12
13         public static ExecutionArguments getExecutionArguments(IFile phpScriptFile) {
14                 try {
15                         String executionArgumentsPersistableFormat = phpScriptFile.getPersistentProperty(EXECUTION_ARGUMENTS_PROPERTY);
16                         ExecutionArguments executionArguments = new ExecutionArguments();
17                         
18                         if (executionArgumentsPersistableFormat != null) {                              
19                                 int argBreakIndex = executionArgumentsPersistableFormat.indexOf(ARGUMENT_SEPARATOR);
20                                 executionArguments.setInterpreterArguments(executionArgumentsPersistableFormat.substring(0, argBreakIndex));
21                                 executionArguments.setPHPFileArguments(executionArgumentsPersistableFormat.substring(argBreakIndex + ARGUMENT_SEPARATOR.length()));
22                         }
23                         
24                         return executionArguments;
25                 } catch (CoreException e) {}
26                 
27                 return null;
28         }
29
30         public static void setExecutionArguments(IFile phpScriptFile, ExecutionArguments arguments) {
31                 try {
32                         phpScriptFile.setPersistentProperty(EXECUTION_ARGUMENTS_PROPERTY, arguments.toPersistableFormat());
33                 } catch (CoreException e) {}
34         }
35
36         public void setInterpreterArguments(String theArguments) {
37                 interpreterArguments = theArguments;
38         }
39
40         public void setPHPFileArguments(String theArguments) {
41                 phpFileArguments = theArguments;
42         }
43
44         public String toPersistableFormat() {
45                 return interpreterArguments + ARGUMENT_SEPARATOR + phpFileArguments;
46         }
47 }