Java String Quote quoted(final String str)

Here you can find the source of quoted(final String str)

Description

quoted

License

Open Source License

Declaration

public static final String quoted(final String str) 

Method Source Code

//package com.java2s;
/*/*w  ww.  j  a  v a 2  s.co  m*/
Copyright (c) 2000-2013 "independIT Integrative Technologies GmbH",
Authors: Ronald Jeninga, Dieter Stubler
    
schedulix Enterprise Job Scheduling System
    
independIT Integrative Technologies GmbH [http://www.independit.de]
mailto:contact@independit.de
    
This file is part of schedulix
    
schedulix is free software: 
you can redistribute it and/or modify it under the terms of the 
GNU Affero General Public License as published by the 
Free Software Foundation, either version 3 of the License, 
or (at your option) any later version.
    
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.
    
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

public class Main {
    public static final String quoted(final String str) {
        final StringBuffer buf = new StringBuffer(str);

        for (int i = buf.length() - 1; i >= 0; --i)
            switch (buf.charAt(i)) {
            case '\'':
            case '\\':
                buf.insert(i, '\\');
            }

        return buf.toString();
    }
}

Related

  1. quoteContentsOfNextBracket(String piece)
  2. quoteCSV(Object val)
  3. quoteCSVValue(String value, String sep)
  4. quoted(CharSequence s)
  5. quoted(CharSequence s)
  6. quoted(String i, char q)
  7. quoted(String path)
  8. quoteD(String s)
  9. quoted(String s)