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,
11 String AttributeName) {
13 if (CurrentNode.hasAttributes()) {
14 NamedNodeMap listAttribute = CurrentNode.getAttributes();
15 Node attribute = listAttribute.getNamedItem(AttributeName);
16 if (attribute != null)
17 strValue = attribute.getNodeValue();
22 public static String escapeString(String string) {
23 StringBuffer escString = new StringBuffer();
24 Pattern pattern = Pattern.compile("[a-zA-Z0-9\\._-]");
26 for (int i = 0; i < string.length(); i++) {
27 char c = string.charAt(i);
28 matcher = pattern.matcher("" + c);
32 int hexval = (byte) c;
34 + Integer.toHexString(hexval).toUpperCase());
38 return escString.toString();
41 public static String unescapeString(String escString) {
42 StringBuffer string = new StringBuffer();
43 if (escString.indexOf('%') == -1)
45 String[] s = escString.split("%");
47 for (int i = 1; i < s.length; i++) {
48 int c = Integer.parseInt(s[i].substring(0, 2), 16);
49 string.append((char) c);
50 if (s[i].length() > 2)
51 string.append(s[i].substring(2));
54 return string.toString();