Java String Quote quoteAtom(String term)

Here you can find the source of quoteAtom(String term)

Description

Wraps an atom with single quotes and escapes all single quotes contained in the atom.

License

Open Source License

Parameter

Parameter Description
term unquoted atom

Return

quoted atom

Declaration

public static String quoteAtom(String term) 

Method Source Code

//package com.java2s;
/*****************************************************************************
 * This file is part of the Prolog Development Tool (PDT)
 * // www. ja v a 2 s .c o m
 * Author: null (among others)
 * WWW: http://sewiki.iai.uni-bonn.de/research/pdt/start
 * Mail: pdt@lists.iai.uni-bonn.de
 * Copyright (C): 2004-2012, CS Dept. III, University of Bonn
 * 
 * All rights reserved. This program is  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
 * 
 ****************************************************************************/

public class Main {
    /**
     * Wraps an atom with single quotes and escapes all single quotes contained
     * in the atom.
     * 
     * @param term
     *            unquoted atom
     * @return quoted atom
     */
    public static String quoteAtom(String term) {

        return "'" + term.replace("'", "\\'") + "'";
    }
}

Related

  1. quoteArg(String arg)
  2. quoteArgForCommand(String input)
  3. quoteArgument(final String argument)
  4. quoteArgument(String arg)
  5. quoteAtom(String term)
  6. quoteAttrValue(String s)
  7. quoteCanonical(String s)
  8. quoteCeylonKeywords(String qualifiedName)
  9. quoteCharacterData(char[] ch, int start, int length)