Java String Unquote unquoteText(String s)

Here you can find the source of unquoteText(String s)

Description

unquote Text

License

Open Source License

Declaration

public static String unquoteText(String s) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 BSI Business Systems Integration AG.
 * 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 w w  w  .  j  a v  a 2s  .co m
 *     BSI Business Systems Integration AG - initial API and implementation
 ******************************************************************************/

public class Main {
    public static String unquoteText(String s) {
        if (s == null || s.length() == 0) {
            return null;
        }
        if (s.charAt(0) == '\'' && s.charAt(s.length() - 1) == '\'') {
            s = s.substring(1, s.length() - 1);
        } else if (s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"') {
            s = s.substring(1, s.length() - 1);
        }
        return s;
    }

    public static int length(String s) {
        if (s == null) {
            return 0;
        } else {
            return s.length();
        }
    }

    public static String substring(String s, int start) {
        if (s == null || start >= s.length()) {
            return "";
        }
        return s.substring(start);
    }

    public static String substring(String s, int start, int len) {
        if (s == null || start >= s.length()) {
            return "";
        }
        len = Math.min(s.length() - start, len);
        return s.substring(start, start + len);
    }
}

Related

  1. unquoteString(final String input)
  2. unquoteString(String s)
  3. unquoteString(String s)
  4. unquoteString(String s)
  5. unquoteString(String value)
  6. unquoteXML(String xmlFragment)