本文整理了Java中org.apache.tools.ant.Project.replaceProperties()
方法的一些代码示例,展示了Project.replaceProperties()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.replaceProperties()
方法的具体详情如下:
包路径:org.apache.tools.ant.Project
类名称:Project
方法名:replaceProperties
[英]Replace ${} style constructions in the given value with the string value of the corresponding data types.
[中]用相应数据类型的字符串值替换给定值中的${}式构造。
代码示例来源:origin: org.apache.ant/ant
/**
* Replaces <code>${xxx}</code> style constructions in the given value with
* the string value of the corresponding properties.
*
* @param project The project containing the properties to replace.
* Must not be <code>null</code>.
*
* @param value The string to be scanned for property references.
* May be <code>null</code>.
*
* @exception BuildException if the string contains an opening
* <code>${</code> without a closing
* <code>}</code>
* @return the original string with the properties replaced, or
* <code>null</code> if the original string is <code>null</code>.
*
* @deprecated since 1.6.x.
* Use project.replaceProperties().
* @since 1.5
*/
@Deprecated
public static String replaceProperties(Project project, String value) throws BuildException {
// needed since project properties are not accessible
return project.replaceProperties(value);
}
代码示例来源:origin: apache/groovy
/**
* Read in lines and execute them.
*
* @param reader the reader from which to get the groovy source to exec
* @param out the outputstream to use
* @throws java.io.IOException if something goes wrong
*/
protected void runStatements(Reader reader, PrintStream out)
throws IOException {
log.debug("runStatements()");
StringBuilder txt = new StringBuilder();
String line = "";
BufferedReader in = new BufferedReader(reader);
while ((line = in.readLine()) != null) {
line = getProject().replaceProperties(line);
if (line.contains("--")) {
txt.append("\n");
}
}
// Catch any statements not followed by ;
if (!txt.toString().equals("")) {
execGroovy(txt.toString(), out);
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Set a multiline message.
* @param msg The message to be displayed.
*/
public void addText(final String msg) {
if (messageAttribute && msg.trim().isEmpty()) {
return;
}
message += getProject().replaceProperties(msg);
}
代码示例来源:origin: org.apache.ant/ant
/**
* Set the error text; all properties are expanded in the message.
*
* @param message the text to use in a failure message
*/
public void addText(String message) {
text = getProject().replaceProperties(message);
}
代码示例来源:origin: org.apache.ant/ant
/**
* @return the text
*/
public String getText() {
String s = buf.toString();
return expandProperties ? getProject().replaceProperties(s) : s;
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Convenience method to expand properties.
* @param content the string to expand
* @return the converted string
*/
protected String expand(final String content) {
return getProject().replaceProperties(content);
}
代码示例来源:origin: org.apache.ant/ant
/**
* set the text using inline
* @param value the text to place inline
*/
public void addText(String value) {
this.value += getProject().replaceProperties(value);
}
代码示例来源:origin: org.apache.ant/ant
/**
* Set a multiline message.
* @param msg the message to display
*/
public void addText(String msg) {
if (message == null) {
message = "";
}
message += getProject().replaceProperties(msg);
}
代码示例来源:origin: org.apache.ant/ant
/**
* Set a multiline message.
* @param msg the CDATA text to append to the output text
*/
public void addText(String msg) {
message += getProject().replaceProperties(msg);
}
代码示例来源:origin: org.apache.ant/ant
/**
* Set the script text.
*
* @param text a component of the script text to be added.
* @since ant1.7
*/
public void addText(String text) {
this.text = getProject().replaceProperties(text);
}
代码示例来源:origin: org.apache.ant/ant
/**
* Add text to a node.
* @param n node
* @param s value
*/
private void addText(Node n, String s) {
s = getProject().replaceProperties(s);
//only text nodes that are non null after property expansion are added
if (s != null && !s.trim().isEmpty()) {
Text t = doc.createTextNode(s.trim());
n.appendChild(t);
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Get all the attributes in the ant-attribute:param
* namespace and place them in a map.
* @param el the element this attribute is in.
* @return a map of attributes.
*/
protected Map<String, String> getParams(UnknownElement el) {
// this makes a copy!
return el.getWrapper().getAttributeMap().entrySet().stream()
.filter(e -> e.getKey().startsWith("ant-attribute:param"))
.collect(Collectors.toMap(e -> e.getKey().substring(e.getKey().lastIndexOf(':') + 1),
e -> el.getProject().replaceProperties((String) e.getValue()), (a, b) -> b));
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Construct a StringResource with the supplied project and value,
* doing property replacement against the project if non-null.
* @param project the owning Project.
* @param value the value of this StringResource.
*/
public StringResource(Project project, String value) {
setProject(project);
setValue(project == null ? value : project.replaceProperties(value));
}
代码示例来源:origin: org.apache.ant/ant
private static void concatDescriptions(Project project, Target t,
StringBuilder description) {
if (t == null) {
return;
}
for (Task task : findElementInTarget(t, "description")) {
if (task instanceof UnknownElement) {
UnknownElement ue = (UnknownElement) task;
String descComp = ue.getWrapper().getText().toString();
if (descComp != null) {
description.append(project.replaceProperties(descComp));
}
}
}
}
代码示例来源:origin: org.apache.ant/ant
String line;
while ((line = in.readLine()) != null) {
out.write(getProject().replaceProperties(line));
out.newLine();
out.write(getProject().replaceProperties(buffer.substring(0)));
out.newLine();
代码示例来源:origin: org.apache.ant/ant
/**
* Set a (multiline) property as nested text.
* @param msg the text to append to the output text
* @since Ant 1.8.0
*/
public void addText(String msg) {
if (!valueAttributeUsed) {
msg = getProject().replaceProperties(msg);
String currentValue = getValue();
if (currentValue != null) {
msg = currentValue + msg;
}
internalSetValue(msg);
} else if (!msg.trim().isEmpty()) {
throw new BuildException("can't combine nested text with value attribute");
}
}
代码示例来源:origin: org.apache.ant/ant
/**
* Return the value for the given attribute.
* If we are not using semantic attributes, its just the
* literal string value of the attribute.
*
* <p>If we <em>are</em> using semantic attributes, then first
* dependent properties are resolved (i.e., ${foo} is resolved
* based on the foo property value), and then an appropriate data
* type is used. In particular, location-based properties are
* resolved to absolute file names. Also for refid values, look
* up the referenced object from the project.</p>
*/
private String getAttributeValue(Node attributeNode) {
String nodeValue = attributeNode.getNodeValue().trim();
if (semanticAttributes) {
String attributeName = attributeNode.getNodeName();
nodeValue = getProject().replaceProperties(nodeValue);
if (LOCATION.equals(attributeName)) {
File f = resolveFile(nodeValue);
return f.getPath();
}
if (REF_ID.equals(attributeName)) {
Object ref = getProject().getReference(nodeValue);
if (ref != null) {
return ref.toString();
}
}
}
return nodeValue;
}
代码示例来源:origin: org.apache.ant/ant
private void setValueFromOutputStream(String output) {
String value;
if (getProject() != null) {
value = getProject().replaceProperties(output);
} else {
value = output;
}
setValue(value);
}
代码示例来源:origin: org.apache.ant/ant
/**
* Add nested text to this resource.
* Properties will be expanded during this process.
* @since Ant 1.7.1
* @param text text to use as the string resource
*/
public void addText(String text) {
checkChildrenAllowed();
setValue(getProject().replaceProperties(text));
}
代码示例来源:origin: org.apache.ant/ant
continue;
value = owner.getProject().replaceProperties(value); // FixMe: need to make config
if (!enable.isEnabled(owner, value)) {
return false;
内容来源于网络,如有侵权,请联系作者删除!