|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2005, 2006 Intel Corporation. |
| 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 |
* Guru Nagarajan, Intel - Initial API and Implementation |
| 10 |
* |
| 11 |
* $Id$ |
| 12 |
*******************************************************************************/ |
| 13 |
|
| 14 |
package org.eclipse.tptp.platform.execution.client.core.internal.commands; |
| 15 |
|
| 16 |
import java.util.Enumeration; |
| 17 |
|
| 18 |
import org.eclipse.tptp.platform.execution.util.*; |
| 19 |
|
| 20 |
import java.util.*; |
| 21 |
import org.eclipse.tptp.platform.execution.exceptions.ProcessActiveException; |
| 22 |
import org.eclipse.tptp.platform.execution.util.internal.CommandElement; |
| 23 |
import org.eclipse.tptp.platform.execution.util.internal.Constants; |
| 24 |
import org.eclipse.tptp.platform.execution.util.internal.TPTPMessageUtil; |
| 25 |
import org.eclipse.tptp.platform.execution.util.internal.TPTPString; |
| 26 |
import org.eclipse.tptp.platform.execution.util.internal.TPTPXMLParse; |
| 27 |
|
| 28 |
/** |
| 29 |
* |
| 30 |
* TODO To change the template for this generated type comment go to |
| 31 |
* Window - Preferences - Java - Code Style - Code Templates |
| 32 |
*/ |
| 33 |
public class GetProcessUUIDCommand extends CommandElement { |
| 34 |
|
| 35 |
protected String _processID = null; |
| 36 |
protected String _commandData= null; |
| 37 |
|
| 38 |
public GetProcessUUIDCommand(String processID) |
| 39 |
{ |
| 40 |
this._commandData = new String(); |
| 41 |
this._processID = processID; |
| 42 |
} |
| 43 |
|
| 44 |
/* (non-Javadoc) |
| 45 |
* @see org.eclipse.tptp.platform.execution.core.ICommandElement#getSize() |
| 46 |
*/ |
| 47 |
public int getSize() |
| 48 |
{ |
| 49 |
return 0; |
| 50 |
} |
| 51 |
public long getContext() |
| 52 |
{ |
| 53 |
return _context; |
| 54 |
} |
| 55 |
/* (non-Javadoc) |
| 56 |
* @see org.eclipse.tptp.platform.execution.core.ICommandElement#setContextID(java.lang.String) |
| 57 |
*/ |
| 58 |
public void setContext(long contextID) { |
| 59 |
_context = contextID; |
| 60 |
} |
| 61 |
/* (non-Javadoc) |
| 62 |
* @see org.eclipse.tptp.platform.execution.core.ICommandElement#getSrcID() |
| 63 |
*/ |
| 64 |
public long getSource() { |
| 65 |
return _src; |
| 66 |
} |
| 67 |
public void setCommandData(String command) { |
| 68 |
this._commandData = new String(command); |
| 69 |
} |
| 70 |
|
| 71 |
/* (non-Javadoc) |
| 72 |
* @see org.eclipse.tptp.platform.execution.core.impl.commands.QueryRunningAgentsCommand#getCommandData() |
| 73 |
*/ |
| 74 |
public String getCommandData() { |
| 75 |
return this._commandData; |
| 76 |
} |
| 77 |
/* (non-Javadoc) |
| 78 |
* @see org.eclipse.tptp.platform.execution.core.ICommandElement#setSrcID(java.lang.String) |
| 79 |
*/ |
| 80 |
public void setSource(long srcID) { |
| 81 |
_src = srcID; |
| 82 |
} |
| 83 |
//No TAG for TPTP 4.0 |
| 84 |
public long getTag() { |
| 85 |
return _tag; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
public long getDestination() { |
| 90 |
return _dest; |
| 91 |
} |
| 92 |
|
| 93 |
/* (non-Javadoc) |
| 94 |
* @see org.eclipse.tptp.platform.execution.core.ICommandElement#getInterfaceID() |
| 95 |
*/ |
| 96 |
public String getInterfaceID() { |
| 97 |
return _iid; |
| 98 |
} |
| 99 |
|
| 100 |
/* (non-Javadoc) |
| 101 |
* @see org.eclipse.tptp.platform.execution.core.ICommandElement#setInterfaceID(java.lang.String) |
| 102 |
*/ |
| 103 |
public void setInterfaceID(String interfaceID) { |
| 104 |
_iid = interfaceID; |
| 105 |
} |
| 106 |
|
| 107 |
public void setDestination(long dest) { |
| 108 |
_dest=dest; |
| 109 |
} |
| 110 |
/* (non-Javadoc) |
| 111 |
* @see org.eclipse.tptp.platform.execution.core.ICommandElement#buildCommand(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) |
| 112 |
*/ |
| 113 |
public String buildCommand() |
| 114 |
{ |
| 115 |
StringBuffer sbuf = new StringBuffer(); |
| 116 |
//<Cmd src= ctxt= dest= ><></Cmd> |
| 117 |
|
| 118 |
setDestination(101); |
| 119 |
|
| 120 |
sbuf.append("<getProcessUUID iid=\""+Constants.PROC_CTLR_IID+"\">"); |
| 121 |
sbuf.append("<processID>"); |
| 122 |
sbuf.append(this._processID); |
| 123 |
sbuf.append("</processID></getProcessUUID>"); |
| 124 |
|
| 125 |
this._commandData = sbuf.toString(); |
| 126 |
return sbuf.toString(); |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
/** |
| 131 |
* Read the command from the input buffer. |
| 132 |
* @return int |
| 133 |
* @param buffer byte[] |
| 134 |
* @param offset int |
| 135 |
*/ |
| 136 |
public int readFromBuffer(byte[] buffer, int offset) |
| 137 |
{ |
| 138 |
int current=offset; |
| 139 |
String retStr = null; |
| 140 |
current=TPTPMessageUtil.readTPTPStringFromBuffer(buffer, current, new TPTPString(retStr)); |
| 141 |
//With the retStr value received parse the output for the specific elements |
| 142 |
TPTPXMLParse ParseObj = new TPTPXMLParse(); |
| 143 |
ParseObj.setParser(retStr); |
| 144 |
Enumeration enumer = ParseObj.getHashTable().elements(); |
| 145 |
|
| 146 |
return current; |
| 147 |
} |
| 148 |
/** |
| 149 |
* Write the XML Command to the input buffer. |
| 150 |
* @return int |
| 151 |
* @param buffer byte[] |
| 152 |
* @param offset int |
| 153 |
*/ |
| 154 |
public int writeToBuffer(byte[] buffer, int offset) |
| 155 |
{ |
| 156 |
int current=offset; |
| 157 |
current=TPTPMessageUtil.writeTPTPStringToBuffer(buffer, current, new TPTPString(buildCommand())); |
| 158 |
return current; |
| 159 |
} |
| 160 |
|
| 161 |
} |