code: @SuppressWarnings("checkstyle:magicnumber")
  	public String escape(CharSequence text) {
  		final StringBuilder result = new StringBuilder();
  
  		for (int i = 0; i < text.length(); ++i) {
  			final char c = text.charAt(i);
  			final String cs = Character.toString(c);
  			if (this.escapeCharacters.contains(cs)) {
  				// Escape protected elements
  				result.append(this.toEscapeCharacter);
  				result.append(cs);
  			} else {
  				// Escape special characters
  				final String special = this.specialChars.get(cs);
  				if (special != null) {
  					result.append(special);
  				} else if (c < this.minValidChar || c > this.maxValidChar) {
  					if (this.maxValidChar > 0) {
  						// Escape invalid characters.
  						result.append("\\u"); //$NON-NLS-1$
  						result.append(formatHex(c, 4));
  					}
  				} else {
  					result.append(cs);
  				}
  			}
  		}
  		return result.toString();
  	}
docs: Escape the given text.
  
  @param text is the text to convert.
  @return the Java string for the text.