Java String Unquote unquote(String name)

Here you can find the source of unquote(String name)

Description

Return the unquoted version of name (stripping the start and end '`' characters if present).

License

Apache License

Parameter

Parameter Description
name The name to be unquoted.

Return

The unquoted version.

Declaration

public static String unquote(String name) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**// w w  w . j  a v  a 2 s.  c  o  m
     * Return the unquoted version of name (stripping the start and end '`' characters if present).
     *
     * @param name The name to be unquoted.
     * @return The unquoted version.
     */
    public static String unquote(String name) {
        return isQuoted(name) ? name.substring(1, name.length() - 1) : name;
    }

    /**
     * Determine if the given string is quoted (wrapped by '`' characters at beginning and end).
     *
     * @param name The name to check.
     * @return True if the given string starts and ends with '`'; false otherwise.
     */
    public static boolean isQuoted(String name) {
        return name != null && name.length() != 0
                && ((name.charAt(0) == '`' && name.charAt(name.length() - 1) == '`')
                        || (name.charAt(0) == '"' && name.charAt(name.length() - 1) == '"'));
    }
}

Related

  1. unquote(String input, char quoteChar)
  2. unquote(String literal)
  3. unquote(String maybeQuoted)
  4. unquote(String message)
  5. unquote(String name)
  6. unquote(String quoted)
  7. unquote(String quoted)
  8. unquote(String quoted)
  9. unquote(String quotedString)