1 11 package org.eclipse.pde.internal.core.target; 12 13 import org.eclipse.pde.internal.core.itarget.IArgumentsInfo; 14 import org.eclipse.pde.internal.core.itarget.ITargetModel; 15 import org.w3c.dom.Node ; 16 import org.w3c.dom.NodeList ; 17 18 public class ArgumentsInfo extends TargetObject implements IArgumentsInfo { 19 20 private static final long serialVersionUID = 1L; 21 private String fProgramArgs = ""; private String fVMArgs = ""; 24 public ArgumentsInfo(ITargetModel model) { 25 super(model); 26 } 27 28 public String getProgramArguments() { 29 return fProgramArgs; 30 } 31 32 public String getVMArguments() { 33 return fVMArgs; 34 } 35 36 public void setProgramArguments(String args) { 37 String oldValue = fProgramArgs; 38 fProgramArgs = args; 39 if (isEditable()) 40 firePropertyChanged(P_PROG_ARGS, oldValue, fProgramArgs); 41 } 42 43 public void setVMArguments(String args) { 44 String oldValue = fVMArgs; 45 fVMArgs = args; 46 if (isEditable()) 47 firePropertyChanged(P_VM_ARGS, oldValue, fVMArgs); 48 } 49 50 public void parse(Node node) { 51 NodeList list = node.getChildNodes(); 52 for (int i = 0; i < list.getLength(); i++) { 53 Node child = list.item(i); 54 if (child.getNodeType() == Node.ELEMENT_NODE) { 55 if (child.getNodeName().equals(P_PROG_ARGS)) { 56 fProgramArgs = getText(child); 57 } else if (child.getNodeName().equals(P_VM_ARGS)) { 58 fVMArgs = getText(child); 59 } 60 } 61 } 62 } 63 64 private String getText(Node node) { 65 node.normalize(); 66 Node text = node.getFirstChild(); 67 if (text != null && text.getNodeType() == Node.TEXT_NODE) { 68 return text.getNodeValue(); 69 } 70 return ""; } 72 73 public void write(String indent,java.io.PrintWriter writer) { 74 if (( fProgramArgs == null || fProgramArgs.length()== 0) && (fVMArgs == null || fVMArgs.length() == 0)) 75 return; 76 writer.println(); 77 writer.println(indent + "<launcherArgs>"); if (fProgramArgs.length() > 0) { 79 writer.println(indent + " " + "<" + P_PROG_ARGS + ">" + getWritableString(fProgramArgs) + "</" + P_PROG_ARGS + ">"); } 81 if (fVMArgs.length() > 0) { 82 writer.println(indent + " " + "<" + P_VM_ARGS + ">" + getWritableString(fVMArgs) + "</" + P_VM_ARGS + ">"); } 84 writer.println(indent + "</launcherArgs>"); } 86 87 } 88 | Popular Tags |