code: public String unescape( String str )
      {
          StringBuffer buf = new StringBuffer( str.length() );
          int i;
          for ( i = 0; i < str.length(); ++i ) {
              char ch = str.charAt( i );
              if ( ch == '&' ) {
                  int semi = str.indexOf( ';', i + 1 );
                  if ( semi == -1 ) {
                      buf.append( ch );
                      continue;
                  }
                  String entityName = str.substring( i + 1, semi );
                  int entityValue;
                  if ( entityName.length() == 0 ) {
                      entityValue = -1;
                  } else if ( entityName.charAt( 0 ) == '#' ) {
                      if ( entityName.length() == 1 ) {
                          entityValue = -1;
                      } else {
                          char charAt1 = entityName.charAt( 1 );
                          try {
                              if ( charAt1 == 'x' || charAt1 == 'X' ) {
                                  entityValue = Integer.valueOf( entityName.substring( 2 ), 16 ).intValue();
                              } else {
                                  entityValue = Integer.parseInt( entityName.substring( 1 ) );
                              }
                          } catch ( NumberFormatException ex ) {
                              entityValue = -1;
                          }
                      }
                  } else {
                      entityValue = this.SPECIAL_CHARS_VALUES_ARRAY.get( entityName );
                  }
                  if ( entityValue == -1 ) {
                      buf.append( '&' );
                      buf.append( entityName );
                      buf.append( ';' );
                  } else {
                      buf.append( ( char ) ( entityValue ) );
                  }
                  i = semi;
              } else {
                  buf.append( ch );
              }
          }
          return buf.toString();
      }
docs: <p>
  Unescapes the entities in a <code>String</code>.</p>
  <p/>
  <p>
  For example, if you have called addEntity(&quot;foo&quot;, 0xA1), unescape(&quot;&amp;foo;&quot;) will return
  &quot;\u00A1&quot;</p>
  
  @param str The <code>String</code> to escape.
  @return A new escaped <code>String</code>.