1 package net.sourceforge.phpeclipse.xdebug.core;
3 import java.util.regex.Matcher;
4 import java.util.regex.Pattern;
6 import org.w3c.dom.NamedNodeMap;
7 import org.w3c.dom.Node;
9 public class PHPDebugUtils {
10 public static String getAttributeValue (Node CurrentNode, String AttributeName) {
12 if (CurrentNode.hasAttributes()) {
13 NamedNodeMap listAttribute = CurrentNode.getAttributes();
14 Node attribute = listAttribute.getNamedItem(AttributeName);
16 strValue = attribute.getNodeValue();
21 public static String escapeString(String string) {
22 StringBuffer escString=new StringBuffer();
23 Pattern pattern = Pattern.compile("[a-zA-Z0-9\\._-]");
25 for (int i= 0; i<string.length(); i++) {
26 char c=string.charAt(i);
27 matcher = pattern.matcher(""+c);
32 escString.append("%"+Integer.toHexString(hexval).toUpperCase());
36 return escString.toString();
39 public static String unescapeString(String escString) {
40 StringBuffer string=new StringBuffer();
41 if (escString.indexOf('%')==-1)
43 String[] s= escString.split("%");
45 for(int i=1 ; i<s.length;i++) {
46 int c =Integer.parseInt(s[i].substring(0,2),16);
47 string.append((char)c);
49 string.append(s[i].substring(2));
52 return string.toString();