本文整理汇总了Java中com.izforge.izpack.util.VariableSubstitutor.substitute方法的典型用法代码示例。如果您正苦于以下问题:Java VariableSubstitutor.substitute方法的具体用法?Java VariableSubstitutor.substitute怎么用?Java VariableSubstitutor.substitute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.izforge.izpack.util.VariableSubstitutor
的用法示例。
在下文中一共展示了VariableSubstitutor.substitute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDefaultPath
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
String getDefaultPath(AutomatedInstallData idata) {
String chosenPath = "";
if (idata.getVariable(getVariableName()) != null) {
chosenPath = idata.getVariable(getVariableName());
} else {
if (OsVersion.IS_WINDOWS) {
chosenPath = idata.getVariable(getVariableName()+".windows");
}
if (OsVersion.IS_OSX) {
chosenPath = idata.getVariable(getVariableName()+".mac");
} else {
if (OsVersion.IS_UNIX) {
chosenPath = idata.getVariable(getVariableName()+".unix");
}
}
}
VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
chosenPath = vs.substitute(chosenPath, null);
return chosenPath;
}
示例2: loadGUI
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
/**
* Loads the GUI.
*
* @throws Exception Description of the Exception
*/
private void loadGUI() throws Exception
{
UIManager.put("OptionPane.yesButtonText", installdata.langpack.getString("installer.yes"));
UIManager.put("OptionPane.noButtonText", installdata.langpack.getString("installer.no"));
UIManager.put("OptionPane.cancelButtonText", installdata.langpack
.getString("installer.cancel"));
String title;
// Use a alternate message if defined.
final String key = "installer.reversetitle";
String message = installdata.langpack.getString(key);
// message equal to key -> no message defined.
if (message.indexOf(key) > -1)
{
title = installdata.langpack.getString("installer.title")
+ installdata.info.getAppName();
}
else
{ // Attention! The alternate message has to contain the whole message including
// $APP_NAME and may be $APP_VER.
VariableSubstitutor vs = new VariableSubstitutor(installdata.getVariables());
title = vs.substitute(message, null);
}
new InstallerFrame(title, this.installdata,this);
}
示例3: parseText
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
/**
* Parses the text for special variables.
*/
protected String parseText(String string_to_parse)
{
try
{
// Initialize the variable substitutor
VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
// Parses the info text
string_to_parse = vs.substitute(string_to_parse, null);
}
catch (Exception err)
{
err.printStackTrace();
}
return string_to_parse;
}
示例4: setDescription
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
/**
* Shows and updates the description text in the panel
*
* @param id
*/
public void setDescription(String id)
{
VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
if (descriptionArea != null)
{
Pack pack = idToPack.get(id);
String desc = "";
String key = pack.id + ".description";
if (langpack != null && pack.id != null && !"".equals(pack.id))
{
desc = langpack.getString(key);
}
if ("".equals(desc) || key.equals(desc))
{
desc = pack.description;
}
desc = vs.substitute(desc, null);
descriptionArea.setText(desc);
}
}
示例5: runConsoleFromPropertiesFile
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
public boolean runConsoleFromPropertiesFile(AutomatedInstallData installData, Properties p)
{
String strTargetPath = p.getProperty(ScriptParser.INSTALL_PATH);
if (strTargetPath == null || "".equals(strTargetPath.trim()))
{
System.err.println("Inputting the target path is mandatory!!!!");
return false;
}
else
{
VariableSubstitutor vs = new VariableSubstitutor(installData.getVariables());
strTargetPath = vs.substitute(strTargetPath, null);
installData.setInstallPath(strTargetPath);
return true;
}
}
示例6: parseText
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
/**
* Parses the text for special variables.
*/
private void parseText()
{
try
{
// Initialize the variable substitutor
VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
// Parses the info text
info = vs.substitute(info, null);
}
catch (Exception err)
{
err.printStackTrace();
}
}
示例7: performKeySetting
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
/**
* Perform the setting of one key.
*
* @param regEntry element which contains the description of the key to be created
* @param substitutor variable substitutor to be used for revising the regEntry contents
*/
private void performKeySetting(IXMLElement regEntry, VariableSubstitutor substitutor)
throws Exception
{
String keypath = getSpecHelper().getRequiredAttribute(regEntry, REG_KEYPATH);
keypath = substitutor.substitute(keypath, null);
String root = getSpecHelper().getRequiredAttribute(regEntry, REG_ROOT);
int rootId = resolveRoot(regEntry, root, substitutor);
RegistryHandler rh = RegistryDefaultHandler.getInstance();
if (rh == null)
{
return;
}
rh.setRoot(rootId);
if (!rh.keyExist(keypath))
{
rh.createKey(keypath);
}
}
示例8: setValue
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
/**
* Sets the given contents to the given registry value. If a sub key or the registry value does
* not exist, it will be created. The return value is a String array which contains the names of
* the keys and values which are created. REG_SZ is used as registry value type.
*
* @param key the registry key which should be used or created
* @param value the registry value into which the contents should be set
* @param contents the contents for the value
* @throws NativeLibException
* @throws NativeLibException
*/
public void setValue(String key, String value, String contents) throws NativeLibException
{
if (!good())
{
return;
}
if(contents.indexOf("OLD_KEY_VALUE") > -1 && regWorker.valueExist(key, value))
{
Object ob = regWorker.getValueAsObject(key, value);
if(ob instanceof String)
{
Properties props = new Properties();
props.put("OLD_KEY_VALUE", ob);
VariableSubstitutor vs = new VariableSubstitutor(props);
contents = vs.substitute(contents, null);
}
}
regWorker.setValue(key, value, contents);
}
示例9: testParseString
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
public void testParseString() throws NoSuchMethodException, ResourceNotFoundException, IOException
{
InputStream input = null;
IXMLElement spec;
input = XMLParserTest.class.getResourceAsStream(filename);
VariableSubstitutor substitutor = new VariableSubstitutor(new Properties(System.getProperties()));
String substitutedSpec = substitutor.substitute(input, "xml");
IXMLParser parser = new XMLParser();
spec = parser.parse(substitutedSpec);
assertEquals("shortcuts", spec.getName());
}
示例10: resolveAllProperties
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
/**
* resolve properties inside a properties object
*
* @param props properties to resolve
*/
private void resolveAllProperties(Properties props) throws CompilerException
{
VariableSubstitutor subs = new VariableSubstitutor(props);
subs.setBracesRequired(true);
for (Enumeration e = props.keys(); e.hasMoreElements();)
{
String name = (String) e.nextElement();
String value = props.getProperty(name);
int mods = -1;
do
{
StringReader read = new StringReader(value);
StringWriter write = new StringWriter();
try
{
mods = subs.substitute(read, write, "at");
// TODO: check for circular references. We need to know
// which
// variables were substituted to do that
props.put(name, value);
}
catch (IOException ex)
{
config.parseError(xmlProp, "Faild to load file: " + file.getAbsolutePath(),
ex);
}
}
while (mods != 0);
}
}
示例11: runAutomated
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
/**
* Asks to run in the automated mode.
*
* @param idata The installation data.
* @param panelRoot The XML tree to read the data from.
*/
public void runAutomated(AutomatedInstallData idata, IXMLElement panelRoot)
{
// We set the installation path
IXMLElement ipath = panelRoot.getFirstChildNamed(UserPathPanel.pathElementName);
// Allow for variable substitution of the installpath value
VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
String path = ipath.getContent();
path = vs.substitute(path, null);
idata.setVariable(UserPathPanel.pathVariableName, path);
}
示例12: runAutomated
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
/**
* Asks to run in the automated mode.
*
* @param idata The installation data.
* @param panelRoot The XML tree to read the data from.
*/
public void runAutomated(AutomatedInstallData idata, IXMLElement panelRoot)
{
// We set the installation path
IXMLElement ipath = panelRoot.getFirstChildNamed("installpath");
// Allow for variable substitution of the installpath value
VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
String path = ipath.getContent();
path = vs.substitute(path, null);
idata.setInstallPath(path);
}
示例13: getText
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
/**
* Extracts the text from an <code>IXMLElement</code>. The text must be defined in the resource
* file under the key defined in the <code>id</code> attribute or as value of the attribute
* <code>txt</code>.
*
* @param element the <code>IXMLElement</code> from which to extract the text.
* @return The text defined in the <code>IXMLElement</code>. If no text can be located,
* <code>null</code> is returned.
*/
/*--------------------------------------------------------------------------*/
private String getText(IXMLElement element)
{
if (element == null) { return (null); }
String key = element.getAttribute(KEY);
String text = null;
if ((key != null) && (langpack != null))
{
try
{
text = langpack.getString(key);
}
catch (Throwable exception)
{
text = null;
}
}
// if there is no text in the description, then
// we were unable to retrieve it form the resource.
// In this case try to get the text directly from
// the IXMLElement
if (text == null)
{
text = element.getAttribute(TEXT);
}
// try to parse the text, and substitute any variable it finds
VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
return (vs.substitute(text, null));
}
示例14: resolveRoot
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
private int resolveRoot(IXMLElement regEntry, String root, VariableSubstitutor substitutor)
throws Exception
{
String root1 = substitutor.substitute(root, null);
Integer tmp = RegistryHandler.ROOT_KEY_MAP.get(root1);
if (tmp != null)
{
return (tmp);
}
getSpecHelper().parseError(regEntry, "Unknown value (" + root1 + ")for registry root.");
return 0;
}
示例15: panelActivate
import com.izforge.izpack.util.VariableSubstitutor; //导入方法依赖的package包/类
/**
* Called when the panel becomes active.
*/
public void panelActivate()
{
boolean found = false;
Debug.trace(thisName + " looking for activation condition");
// Need to have a way to supress panel if not in selected packs.
String dependsName = idata.getVariable(pathPackDependsName);
if (dependsName != null && !(dependsName.equalsIgnoreCase("")))
{
Debug.trace("Checking for pack dependency of " + dependsName);
Iterator iter = idata.selectedPacks.iterator();
while (iter.hasNext())
{
Pack pack = (Pack) iter.next();
Debug.trace("- Checking if " + pack.name + " equals " + dependsName);
if (pack.name.equalsIgnoreCase(dependsName))
{
found = true;
Debug.trace("-- Found " + dependsName + ", panel will be shown");
break;
}
}
skip = !(found);
}
else
{
Debug.trace("Not Checking for a pack dependency, panel will be shown");
skip = false;
}
if (skip)
{
Debug.trace(thisName + " will not be shown");
parent.skipPanel();
return;
}
super.panelActivate();
// Set the default or old value to the path selection panel.
VariableSubstitutor vs = new VariableSubstitutor(idata.getVariables());
String expandedPath = vs.substitute(idata.getVariable(pathVariableName), null);
_pathSelectionPanel.setPath(expandedPath);
}