Java String Substritute substitutePropertyWithIn(String propertyName, String replacementString, String evaluatedString)

Here you can find the source of substitutePropertyWithIn(String propertyName, String replacementString, String evaluatedString)

Description

Substitute property with in.

License

Open Source License

Parameter

Parameter Description
propertyName the property name
replacementString the replacement string
evaluatedString the evaluated string

Return

the string

Declaration

public static String substitutePropertyWithIn(String propertyName, String replacementString,
        String evaluatedString) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2008 Pierre-Antoine Gr?goire.
 * 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 va 2 s. co  m
 *    Pierre-Antoine Gr?goire - initial API and implementation
 *******************************************************************************/

public class Main {
    /**
     * Substitute property with in.
     * 
     * @param propertyName
     *            the property name
     * @param replacementString
     *            the replacement string
     * @param evaluatedString
     *            the evaluated string
     * 
     * @return the string
     */
    public static String substitutePropertyWithIn(String propertyName, String replacementString,
            String evaluatedString) {
        replacementString = replacementString.replace("\\", "\\\\");
        return evaluatedString.replaceAll("\\$\\{" + propertyName + "\\}", replacementString);
    }
}

Related

  1. substituteHex(String aString)
  2. substituteInvalidChars(String str)
  3. substituteJobID(String path)
  4. substituteMarkers(String sql, String marker, Object substitution)
  5. substituteNull(String value, String substitution)
  6. substituteSelectedCharacters(String text, boolean skip)
  7. substituteSpaces(String originalPath)
  8. substituteSubString(String input, String find, String replace)
  9. substituteSymbol(String text, String symbol, String value)