KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > core > target > ArgumentsInfo


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 JavaDoc;
16 import org.w3c.dom.NodeList JavaDoc;
17
18 public class ArgumentsInfo extends TargetObject implements IArgumentsInfo {
19
20     private static final long serialVersionUID = 1L;
21     private String JavaDoc fProgramArgs = ""; //$NON-NLS-1$
22
private String JavaDoc fVMArgs = ""; //$NON-NLS-1$
23

24     public ArgumentsInfo(ITargetModel model) {
25         super(model);
26     }
27     
28     public String JavaDoc getProgramArguments() {
29         return fProgramArgs;
30     }
31     
32     public String JavaDoc getVMArguments() {
33         return fVMArgs;
34     }
35     
36     public void setProgramArguments(String JavaDoc args) {
37         String JavaDoc oldValue = fProgramArgs;
38         fProgramArgs = args;
39         if (isEditable())
40             firePropertyChanged(P_PROG_ARGS, oldValue, fProgramArgs);
41     }
42     
43     public void setVMArguments(String JavaDoc args) {
44         String JavaDoc oldValue = fVMArgs;
45         fVMArgs = args;
46         if (isEditable())
47             firePropertyChanged(P_VM_ARGS, oldValue, fVMArgs);
48     }
49
50     public void parse(Node JavaDoc node) {
51         NodeList JavaDoc list = node.getChildNodes();
52         for (int i = 0; i < list.getLength(); i++) {
53             Node JavaDoc 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 JavaDoc getText(Node JavaDoc node) {
65         node.normalize();
66         Node JavaDoc text = node.getFirstChild();
67         if (text != null && text.getNodeType() == Node.TEXT_NODE) {
68             return text.getNodeValue();
69         }
70         return ""; //$NON-NLS-1$
71
}
72
73     public void write(String JavaDoc indent,java.io.PrintWriter JavaDoc writer) {
74         if (( fProgramArgs == null || fProgramArgs.length()== 0) && (fVMArgs == null || fVMArgs.length() == 0))
75             return;
76         writer.println();
77         writer.println(indent + "<launcherArgs>"); //$NON-NLS-1$
78
if (fProgramArgs.length() > 0) {
79             writer.println(indent + " " + "<" + P_PROG_ARGS + ">" + getWritableString(fProgramArgs) + "</" + P_PROG_ARGS + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
80
}
81         if (fVMArgs.length() > 0) {
82             writer.println(indent + " " + "<" + P_VM_ARGS + ">" + getWritableString(fVMArgs) + "</" + P_VM_ARGS + ">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
83
}
84         writer.println(indent + "</launcherArgs>"); //$NON-NLS-1$
85
}
86
87 }
88
Popular Tags