/** * <p> * Quote and escape a String with the given character, handling <code>null</code>. * </p> * * @param source * @param quoteChar * @param quotingTriggers * @return the String quoted and escaped * @since 1.5.1 * @see #quoteAndEscape(String, char, char[], char[], char, boolean) */ public static String quoteAndEscape( String source, char quoteChar, char[] quotingTriggers ) { return quoteAndEscape( source, quoteChar, new char[] { quoteChar }, quotingTriggers, '\\', false ); }
/** * @param source * @param quoteChar * @param escapedChars * @param quotingTriggers * @param escapeChar * @param force * @return the String quoted and escaped * @since 1.5.1 */ public static String quoteAndEscape( String source, char quoteChar, final char[] escapedChars, final char[] quotingTriggers, char escapeChar, boolean force ) { return quoteAndEscape( source, quoteChar, escapedChars, quotingTriggers, escapeChar + "%s", force ); }
/** * @param source * @param quoteChar * @param escapedChars * @param escapeChar * @param force * @return the String quoted and escaped * @since 1.5.1 * @see #quoteAndEscape(String, char, char[], char[], char, boolean) */ public static String quoteAndEscape( String source, char quoteChar, final char[] escapedChars, char escapeChar, boolean force ) { return quoteAndEscape( source, quoteChar, escapedChars, new char[] { ' ' }, escapeChar, force ); }
/** * <p> * Quote and escape a String with the given character, handling <code>null</code>. * </p> * * <pre> * StringUtils.quoteAndEscape(null, *) = null * StringUtils.quoteAndEscape("", *) = "" * StringUtils.quoteAndEscape("abc", '"') = abc * StringUtils.quoteAndEscape("a\"bc", '"') = "a\"bc" * StringUtils.quoteAndEscape("a\"bc", '\'') = 'a\"bc' * </pre> * * @param source * @param quoteChar * @return the String quoted and escaped * @since 1.5.1 * @see #quoteAndEscape(String, char, char[], char[], char, boolean) */ public static String quoteAndEscape( String source, char quoteChar ) { return quoteAndEscape( source, quoteChar, new char[] { quoteChar }, new char[] { ' ' }, '\\', false ); }
public static String toString( String[] line ) { // empty path return empty string if ( ( line == null ) || ( line.length == 0 ) ) { return ""; } // path containing one or more elements final StringBuilder result = new StringBuilder(); for ( int i = 0; i < line.length; i++ ) { if ( i > 0 ) { result.append( ' ' ); } try { result.append( StringUtils.quoteAndEscape( line[i], '\"' ) ); } catch ( Exception e ) { System.err.println( "Error quoting argument: " + e.getMessage() ); } } return result.toString(); }
protected String quoteOneItem( String inputString, boolean isExecutable ) { char[] escapeChars = getEscapeChars( isSingleQuotedExecutableEscaped(), isDoubleQuotedExecutableEscaped() ); return StringUtils.quoteAndEscape( inputString, isExecutable ? getExecutableQuoteDelimiter() : getArgumentQuoteDelimiter(), escapeChars, getQuotingTriggerChars(), '\\', unconditionallyQuote ); }
public static String quoteAndEscape( String source, char quoteChar, char[] quotingTriggers ) { return quoteAndEscape( source, quoteChar, new char[]{ quoteChar }, quotingTriggers, '\\', false ); }
public static String quoteAndEscape( String source, char quoteChar, final char[] escapedChars, char escapeChar, boolean force ) { return quoteAndEscape( source, quoteChar, escapedChars, new char[]{ ' ' }, escapeChar, force ); }
private String quote(String arg) { return StringUtils.quoteAndEscape( arg, '"', new char[] { '"', ' ', '\t', '\r', '\n' } ); }
private String quote(String value) { return StringUtils.quoteAndEscape(value,'"'); }
private String quote(String arg) { return StringUtils.quoteAndEscape( arg, '"', new char[] { '"', ' ', '\t', '\r', '\n' } ); }
private String quote(File file) { return StringUtils.quoteAndEscape(file.getAbsolutePath(), '"'); }
public static String toPath(final Collection<File> files) { StringBuilder result = new StringBuilder(files.size() * 20); Iterator<File> iterator = files.iterator(); if (iterator.hasNext()) { result.append(iterator.next().getAbsolutePath()); } else { return ""; } while (iterator.hasNext()) { result.append(File.pathSeparatorChar); result.append(iterator.next().getAbsolutePath()); } return StringUtils.quoteAndEscape(result.toString(), '\''); }
@Override protected String getExtraJvmArgs() { String jvmArgs = super.getExtraJvmArgs(); // workaround to GWT issue 4031 with IBM JDK // @see https://code.google.com/p/google-web-toolkit/issues/detail?id=4031#c16 if ( System.getProperty( "java.vendor" ).startsWith( "IBM" ) && StringUtils.isEmpty(getJvm()) && !StringUtils.isEmpty( jvmArgs )) { return jvmArgs + " -Dgwt.jjs.javaArgs=" + StringUtils.quoteAndEscape( jvmArgs, '"', new char[] { '"', ' ', '\t', '\r', '\n' } ); } return jvmArgs; }
@Override protected String getExtraJvmArgs() { String jvmArgs = super.getExtraJvmArgs(); // workaround to GWT issue 4031 with IBM JDK // @see https://code.google.com/p/google-web-toolkit/issues/detail?id=4031#c16 if ( System.getProperty( "java.vendor" ).startsWith( "IBM" ) && StringUtils.isEmpty(getJvm()) && !StringUtils.isEmpty( jvmArgs )) { return jvmArgs + " -Dgwt.jjs.javaArgs=" + StringUtils.quoteAndEscape( jvmArgs, '"', new char[] { '"', ' ', '\t', '\r', '\n' } ); } return jvmArgs; }
private String interpolateBaseDirAndRepo( String content ) { StringReader sr = new StringReader( content ); StringWriter result = new StringWriter(); Map<Object, Object> context = new HashMap<Object, Object>(); context.put( "BASEDIR", StringUtils.quoteAndEscape( getBasedir(), '"' ) ); context.put( "REPO", StringUtils.quoteAndEscape( getRepo(), '"' ) ); InterpolationFilterReader interpolationFilterReader = new InterpolationFilterReader( sr, context, "@", "@" ); try { IOUtil.copy( interpolationFilterReader, result ); } catch ( IOException e ) { // shouldn't happen... } return result.toString(); }
private String interpolateBaseDirAndRepo( String content ) { StringReader sr = new StringReader( content ); StringWriter result = new StringWriter(); Map<Object, Object> context = new HashMap<Object, Object>(); context.put( "BASEDIR", StringUtils.quoteAndEscape( getBasedir(), '"' ) ); context.put( "REPO", StringUtils.quoteAndEscape( getRepo(), '"' ) ); InterpolationFilterReader interpolationFilterReader = new InterpolationFilterReader( sr, context, "@", "@" ); try { IOUtil.copy( interpolationFilterReader, result ); } catch ( IOException e ) { // shouldn't happen... } return result.toString(); }
final String javaExe = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; final Commandline commandline = new Commandline(StringUtils.quoteAndEscape(javaExe, '"')); final String classPath = System.getProperty("java.class.path") + File.pathSeparator + pluginPath;