Separate XDebugResponse from ResponseListner.
authorincastrix <incastrix>
Thu, 25 Dec 2008 03:17:10 +0000 (03:17 +0000)
committerincastrix <incastrix>
Thu, 25 Dec 2008 03:17:10 +0000 (03:17 +0000)
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/xdebug/ResponseList.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/xdebug/ResponseListener.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/xdebug/XDebugResponse.java [new file with mode: 0644]
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugThread.java

index bf0f967..5b6d0ee 100644 (file)
@@ -1,8 +1,7 @@
 package net.sourceforge.phpeclipse.xdebug.core.xdebug;
 
 import java.util.HashMap;
-//import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugResponse;
 
 public class ResponseList {
        private int fLastId;
@@ -13,7 +12,7 @@ public class ResponseList {
                fList = new HashMap();
        }
 
-       public synchronized void add(XDebugResponse response/*, int id*/) {
+       public synchronized void add(XDebugResponse response) {
                int id = response.getTransactionID();
                fList.put(new Integer(id), response);
                fLastId = id;
index d1ea8f8..f79af8f 100644 (file)
@@ -11,6 +11,7 @@ import javax.xml.parsers.ParserConfigurationException;
 import net.sourceforge.phpeclipse.xdebug.core.IPHPDebugEvent;
 import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
 import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin;
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugResponse;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
@@ -29,191 +30,6 @@ import org.w3c.dom.CDATASection;
  */
 
 public class ResponseListener extends Job {
-       public class XDebugResponse {
-               final public static String TYPE_INIT = "init";
-               
-               final public static String TYPE_RESPONSE = "response";
-               
-               final public static String TYPE_STREAM = "stream";
-
-               private Node parentNode;
-               private int fTransactionID = -1;
-               private String fCommand = "";
-               private String fStatus;
-               private String fReason;
-               private String fName;
-               private boolean  fError;
-       
-               private String fValue;
-               private String fType;
-               private String fAddress;
-               private String fIdeKey;
-                       
-               public XDebugResponse(String XMLInput) {
-                       fTransactionID = -1;
-                       fCommand = "";
-                       fStatus = "";
-                       fReason = "";                   
-                       fName= "";
-                       setParentNode(XMLInput);
-               }
-       
-               /*public*/private synchronized void setParentNode(String xmlInput) {
-                       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-                       DocumentBuilder builder = null;
-                       Document doc = null;
-                       
-                       try {
-                               builder = factory.newDocumentBuilder();
-                       } catch (ParserConfigurationException e) {
-                               e.printStackTrace();
-                       }
-                       ByteArrayInputStream InputXMLStream = new ByteArrayInputStream(xmlInput.getBytes());
-                       try {
-                               doc = builder.parse(InputXMLStream);
-                       } catch (SAXException e) {
-                               e.printStackTrace();
-                       } catch (IOException e) {
-                               e.printStackTrace();
-                       }
-       
-                       parentNode = doc.getFirstChild();
-                       
-                       String responseType = parentNode.getNodeName();
-                       if (responseType == TYPE_INIT) {
-                               fName = TYPE_INIT;
-                               parseInit(parentNode);
-                       } else if (responseType == TYPE_RESPONSE) {
-                               fName = TYPE_RESPONSE;
-                               parseResponse(parentNode);
-                       } else if (responseType == TYPE_STREAM) {
-                               fName = TYPE_STREAM;
-                               parseStream();
-                       } else {
-                               fName = null;
-                       }
-               }
-               
-               private void parseInit(Node parentNode) {
-                       fIdeKey = getAttributeValue("idekey");
-                       
-                       /*int startIdx = initString.indexOf("idekey=\"");
-                       if (startIdx == -1)
-                               return;
-                       startIdx += 8;
-                       int endIdx=initString.indexOf('"',startIdx);
-                       if (endIdx==-1)
-                               return;
-                       fSessionID = initString.substring(startIdx,endIdx);*/
-               }
-               
-               private void parseResponse(Node parentNode) {
-                       String idStr = getAttributeValue("transaction_id");
-                       if (!"".equals(idStr))
-                               fTransactionID = Integer.parseInt(idStr);
-                       fCommand = getAttributeValue("command");
-                       if (parentNode.hasChildNodes()) {
-                               Node child = parentNode.getFirstChild();
-                               if (child.getNodeName().equals("error")) {
-                                       int code = Integer.parseInt(PHPDebugUtils.getAttributeValue(child, "code"));
-                                       String text = (child.getFirstChild()).getNodeValue();
-                                       XDebugCorePlugin.log(IStatus.ERROR," ERROR "+code+": "+text);
-                                       fError = true;
-                                       return;
-                               }
-                       }
-                       fError = false;
-                       
-                       fStatus = getAttributeValue("status");
-                       fReason = getAttributeValue("reason");
-       
-                       if( fCommand.compareTo("eval") == 0 ) {
-                               try {
-                                       Node property = parentNode.getFirstChild();
-       
-                                       NamedNodeMap listAttribute = property.getAttributes();
-                                       Node attribute = listAttribute.getNamedItem("type");
-                                       if (attribute !=null) {
-                                               fType = attribute.getNodeValue();
-                                       }
-       
-                                       Node attribute1 = listAttribute.getNamedItem("address");
-                                       if (attribute1 !=null) {
-                                               fAddress = attribute1.getNodeValue();
-                                       }
-                                       
-                                       Node firstChild1 = (Node) property.getFirstChild();
-                                       
-                                       if( firstChild1 != null ) {
-                                               fValue = firstChild1.getNodeValue();
-                                       } else {
-                                               fValue = "";
-                                       }
-                               } catch (Exception e) {
-                                       // TODO: handle exception
-                               }
-                       } else {
-                               try {
-                                       CDATASection firstChild = (CDATASection) parentNode.getFirstChild();
-       
-                                       if( firstChild != null ) {
-                                               fValue = parentNode.getFirstChild().getNodeValue();
-                                       }
-                               } catch (Exception e) {
-                               }
-                       }
-                       
-               }
-               
-               private void parseStream() {
-                       
-               }
-               
-               
-               public String getAttributeValue (String AttributeName) {
-                       String strValue = "";
-                       if (parentNode.hasAttributes()) {
-                               NamedNodeMap listAttribute = parentNode.getAttributes();
-                               Node attribute = listAttribute.getNamedItem(AttributeName);
-                               if (attribute !=null)
-                                       strValue = attribute.getNodeValue();
-                       }
-                       return strValue;
-               }
-               
-               public synchronized Node getParentNode(){
-                       return parentNode;
-               }
-               
-               /*public*/private  synchronized String getCommand() {
-                       return fCommand;
-               }
-               /*public*/private synchronized String getName() {
-                       return fName;
-               }
-               
-               public synchronized String getValue() {
-                       return fValue;
-               }
-       
-               public synchronized String getReason() {
-                       return fReason;
-               }
-       
-               public synchronized String getStatus() {
-                       return fStatus;
-               }
-       
-               public synchronized int getTransactionID() {
-                       return fTransactionID;
-               }
-               
-               public boolean isError() {
-                       return fError;
-               }
-       }
-       
-       
        private XDebugConnection fConnection;
        private ResponseList fResponseList;
        
diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/xdebug/XDebugResponse.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/xdebug/XDebugResponse.java
new file mode 100644 (file)
index 0000000..58ae013
--- /dev/null
@@ -0,0 +1,203 @@
+package net.sourceforge.phpeclipse.xdebug.core.xdebug;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
+import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin;
+
+import org.eclipse.core.runtime.IStatus;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+public class XDebugResponse {
+       final public static String TYPE_INIT = "init";
+       
+       final public static String TYPE_RESPONSE = "response";
+       
+       final public static String TYPE_STREAM = "stream";
+
+       private Node parentNode;
+       private int fTransactionID = -1;
+       private String fCommand = "";
+       private String fStatus;
+       private String fReason;
+       private String fName;
+       private boolean  fError;
+
+       private String fValue;
+       private String fType;
+       private String fAddress;
+       private String fIdeKey;
+               
+       public XDebugResponse(String XMLInput) {
+               fTransactionID = -1;
+               fCommand = "";
+               fStatus = "";
+               fReason = "";                   
+               fName= "";
+               setParentNode(XMLInput);
+       }
+
+       private synchronized void setParentNode(String xmlInput) {
+               DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+               DocumentBuilder builder = null;
+               Document doc = null;
+               
+               try {
+                       builder = factory.newDocumentBuilder();
+               } catch (ParserConfigurationException e) {
+                       e.printStackTrace();
+               }
+               ByteArrayInputStream InputXMLStream = new ByteArrayInputStream(xmlInput.getBytes());
+               try {
+                       doc = builder.parse(InputXMLStream);
+               } catch (SAXException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+
+               parentNode = doc.getFirstChild();
+               
+               String responseType = parentNode.getNodeName();
+               if (responseType == TYPE_INIT) {
+                       fName = TYPE_INIT;
+                       parseInit(parentNode);
+               } else if (responseType == TYPE_RESPONSE) {
+                       fName = TYPE_RESPONSE;
+                       parseResponse(parentNode);
+               } else if (responseType == TYPE_STREAM) {
+                       fName = TYPE_STREAM;
+                       parseStream();
+               } else {
+                       fName = null;
+               }
+       }
+       
+       private void parseInit(Node parentNode) {
+               fIdeKey = getAttributeValue("idekey");
+               
+               /*int startIdx = initString.indexOf("idekey=\"");
+               if (startIdx == -1)
+                       return;
+               startIdx += 8;
+               int endIdx=initString.indexOf('"',startIdx);
+               if (endIdx==-1)
+                       return;
+               fSessionID = initString.substring(startIdx,endIdx);*/
+       }
+       
+       private void parseResponse(Node parentNode) {
+               String idStr = getAttributeValue("transaction_id");
+               if (!"".equals(idStr))
+                       fTransactionID = Integer.parseInt(idStr);
+               fCommand = getAttributeValue("command");
+               if (parentNode.hasChildNodes()) {
+                       Node child = parentNode.getFirstChild();
+                       if (child.getNodeName().equals("error")) {
+                               int code = Integer.parseInt(PHPDebugUtils.getAttributeValue(child, "code"));
+                               String text = (child.getFirstChild()).getNodeValue();
+                               XDebugCorePlugin.log(IStatus.ERROR," ERROR "+code+": "+text);
+                               fError = true;
+                               return;
+                       }
+               }
+               fError = false;
+               
+               fStatus = getAttributeValue("status");
+               fReason = getAttributeValue("reason");
+
+               if( fCommand.compareTo("eval") == 0 ) {
+                       try {
+                               Node property = parentNode.getFirstChild();
+
+                               NamedNodeMap listAttribute = property.getAttributes();
+                               Node attribute = listAttribute.getNamedItem("type");
+                               if (attribute !=null) {
+                                       fType = attribute.getNodeValue();
+                               }
+
+                               Node attribute1 = listAttribute.getNamedItem("address");
+                               if (attribute1 !=null) {
+                                       fAddress = attribute1.getNodeValue();
+                               }
+                               
+                               Node firstChild1 = (Node) property.getFirstChild();
+                               
+                               if( firstChild1 != null ) {
+                                       fValue = firstChild1.getNodeValue();
+                               } else {
+                                       fValue = "";
+                               }
+                       } catch (Exception e) {
+                               // TODO: handle exception
+                       }
+               } else {
+                       try {
+                               CDATASection firstChild = (CDATASection) parentNode.getFirstChild();
+
+                               if( firstChild != null ) {
+                                       fValue = parentNode.getFirstChild().getNodeValue();
+                               }
+                       } catch (Exception e) {
+                       }
+               }
+               
+       }
+       
+       private void parseStream() {
+               
+       }
+       
+       
+       public String getAttributeValue (String AttributeName) {
+               String strValue = "";
+               if (parentNode.hasAttributes()) {
+                       NamedNodeMap listAttribute = parentNode.getAttributes();
+                       Node attribute = listAttribute.getNamedItem(AttributeName);
+                       if (attribute !=null)
+                               strValue = attribute.getNodeValue();
+               }
+               return strValue;
+       }
+       
+       public synchronized Node getParentNode(){
+               return parentNode;
+       }
+       
+       public /*synchronized*/ String getCommand() {
+               return fCommand;
+       }
+       
+       /*private*/public /*synchronized*/ String getName() {
+               return fName;
+       }
+       
+       public synchronized String getValue() {
+               return fValue;
+       }
+
+       public synchronized String getReason() {
+               return fReason;
+       }
+
+       public synchronized String getStatus() {
+               return fStatus;
+       }
+
+       public synchronized int getTransactionID() {
+               return fTransactionID;
+       }
+       
+       public boolean isError() {
+               return fError;
+       }
+}
\ No newline at end of file
index def9a6f..36b4569 100644 (file)
@@ -43,7 +43,7 @@ import org.w3c.dom.Node;
 
 import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener;
 import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugConnection;
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugResponse;
 
 /**
  * @author Christian
index 463ae99..2e00970 100644 (file)
@@ -7,7 +7,7 @@
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
 import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugResponse;
 
 import org.eclipse.debug.core.DebugEvent;
 import org.eclipse.debug.core.DebugException;