code: public static String translate(String str) {
  	if (str == null) return "";
  	// TODO do-while machen
  	int index, last = 0, endIndex;
  	StringBuilder sb = null;
  	String tagName;
  	while ((index = str.indexOf('<', last)) != -1) {
  	    // read tagname
  	    int len = str.length();
  	    char c;
  	    for (endIndex = index + 1; endIndex < len; endIndex++) {
  		c = str.charAt(endIndex);
  		if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z')) break;
  	    }
  	    tagName = str.substring(index + 1, endIndex);
  
  	    if (compareTagName(tagName)) {
  		if (sb == null) {
  		    sb = new StringBuilder();
  		    last = 0;
  		}
  		sb.append(str.substring(last, index + 1));
  		sb.append("invalidTag");
  		last = endIndex;
  	    }
  	    else if (sb != null) {
  		sb.append(str.substring(last, index + 1));
  		last = index + 1;
  	    }
  	    else last = index + 1;
  
  	}
  	if (sb != null) {
  	    if (last != str.length()) sb.append(str.substring(last));
  	    return sb.toString();
  	}
  	return str;
      }
docs: translate string to script-protected form
  
  @param str
  @return translated String