protected static Map<String,String> parseSetAttributesAsTextArg(String text){
  String value="";
  String key="";
  StringBuilder buffer=new StringBuilder();
  Map<String,String> keyValuePairs=new HashMap<>();
  boolean isInsideQuotes=false;
  for (int i=0, N=text.length(); i < N; ++i) {
    final char c=text.charAt(i);
    if (c == '=') {
      key=buffer.toString();
      buffer.setLength(0);
    }
 else     if (c == '\"') {
      if (isInsideQuotes) {
        value=buffer.toString();
        buffer.setLength(0);
      }
      isInsideQuotes=!isInsideQuotes;
    }
 else     if (c == ' ' && !isInsideQuotes) {
      keyValuePairs.put(key,value);
    }
 else {
      buffer.append(c);
    }
  }
  if (!key.isEmpty() && !value.isEmpty()) {
    keyValuePairs.put(key,value);
  }
  return keyValuePairs;
}

protected static Map < String , String > parseSetAttributesAsTextArg ( String text ) { String value = "" ; String key = "" ; StringBuilder buffer = new StringBuilder ( ) ; Map < String , String > keyValuePairs = new HashMap < > ( ) ; boolean isInsideQuotes = false ; for ( int i = 0 , N = text . length ( ) ; i < N ; ++ i ) { final char c = text . charAt ( i ) ; if ( c == '=' ) { key = buffer . toString ( ) ; buffer . setLength ( 0 ) ; } else if ( c == '\"' ) { if ( isInsideQuotes ) { value = buffer . toString ( ) ; buffer . setLength ( 0 ) ; } isInsideQuotes = ! isInsideQuotes ; } else if ( c == ' ' && ! isInsideQuotes ) { keyValuePairs . put ( key , value ) ; } else { buffer . append ( c ) ; } } if ( ! key . isEmpty ( ) && ! value . isEmpty ( ) ) { keyValuePairs . put ( key , value ) ; } return keyValuePairs ; }
parses the text argument text from dom . setattributeastext ( ) text will be in the format " attribute1 = \ " value 1 \ " attribute2 = \ " value2 \ " "
