Java String Unquote unquoteImpl(String s, char delim)

Here you can find the source of unquoteImpl(String s, char delim)

Description

unquote Impl

License

Open Source License

Declaration

private static String unquoteImpl(String s, char delim) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2012 Firestar Software, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://from  www  . ja v  a  2 s  .  c  o  m
 *     Firestar Software, Inc. - initial API and implementation
 *
 * Author:
 *     Gabriel Oancea
 *
 *******************************************************************************/

public class Main {
    private static String unquoteImpl(String s, char delim) {
        if (s == null || s.length() < 2)
            return s;
        if (!(s.charAt(0) == delim && s.charAt(s.length() - 1) == delim))
            return s;
        if (s.length() == 2)
            return "";
        s = s.substring(1, s.length() - 1);
        StringBuffer sb = new StringBuffer(s.length());
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c == delim) {
                if (i + 1 < s.length()) {
                    char d = s.charAt(i + 1);
                    if (d == delim)
                        i++;
                }
            }
            sb.append(c);
        }
        return sb.toString();
    }
}

Related

  1. unquotedString(String str)
  2. unquoteHtmlContent(String x)
  3. unQuoteIdentifier(String identifier, boolean useAnsiQuotedIdentifiers)
  4. unQuoteIdentifier(String identifier, String quoteChar)
  5. unQuoteIdentifier(String identifier, String quoteChar)
  6. unquotePath(String path)
  7. unquoteS(String s)
  8. unquoteString(final String input)
  9. unquoteString(String s)