本文整理汇总了Java中org.apache.tools.ant.util.StringUtils类的典型用法代码示例。如果您正苦于以下问题:Java StringUtils类的具体用法?Java StringUtils怎么用?Java StringUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringUtils类属于org.apache.tools.ant.util包,在下文中一共展示了StringUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logAndAddFilesToCompile
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
/**
* Add the file names to the Commandline. Log them in verbose mode.
* @param cmd the Commandline to be executed
*/
private void logAndAddFilesToCompile(Commandline cmd) {
log("Compilation " + cmd.describeArguments(),
Project.MSG_VERBOSE);
StringBuffer niceSourceList = new StringBuffer("File");
if (compileList.length != 1) {
niceSourceList.append("s");
}
niceSourceList.append(" to be compiled:");
niceSourceList.append(StringUtils.LINE_SEP);
for (int i = 0; i < compileList.length; i++) {
String arg = compileList[i].getAbsolutePath();
cmd.createArgument().setValue(arg);
niceSourceList.append(" ");
niceSourceList.append(arg);
niceSourceList.append(StringUtils.LINE_SEP);
}
log(niceSourceList.toString(), Project.MSG_VERBOSE);
}
示例2: startTestSuite
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
/**
* The whole testsuite started.
* @param suite the test suite
*/
public void startTestSuite(JUnitTest suite) {
if (output == null) {
return; // Quick return - no output do nothing.
}
StringBuffer sb = new StringBuffer("Testsuite: ");
String n = suite.getName();
if (n != null && !tag.isEmpty())
n = n + "-" + tag;
sb.append(n);
sb.append(StringUtils.LINE_SEP);
try {
output.write(sb.toString());
output.flush();
} catch (IOException ex) {
throw new BuildException(ex);
}
}
示例3: subBuildStarted
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param event An event with any relevant extra information. Must not be <code>null</code>.
*/
public void subBuildStarted(BuildEvent event) {
String name = extractNameOrDefault(event);
Project project = event.getProject();
File base = project == null ? null : project.getBaseDir();
String path =
(base == null)
? "With no base directory"
: "In " + base.getAbsolutePath();
printMessage(StringUtils.LINE_SEP + getHeader()
+ StringUtils.LINE_SEP + "Entering project " + name
+ StringUtils.LINE_SEP + path
+ StringUtils.LINE_SEP + getFooter(),
out,
event.getPriority());
}
示例4: messageLogged
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
/**
* Logs a message for a target if it is of an appropriate
* priority, also logging the name of the target if this
* is the first message which needs to be logged for the
* target.
*
* @param event A BuildEvent containing message information.
* Must not be <code>null</code>.
*/
public void messageLogged(BuildEvent event) {
if (event.getPriority() > msgOutputLevel
|| null == event.getMessage()
|| "".equals(event.getMessage().trim())) {
return;
}
synchronized (this) {
if (null != targetName) {
out.println(StringUtils.LINE_SEP + targetName + ":");
targetName = null;
}
}
super.messageLogged(event);
}
示例5: describeArguments
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
/**
* Return a String that describes the arguments suitable for
* verbose output before a call to <code>Runtime.exec(String[])</code>.
*
* @param args the command line to describe as an array of strings.
* @param offset ignore entries before this index.
* @return a string that describes the arguments
*
* @since Ant 1.5
*/
protected static String describeArguments(String[] args, int offset) {
if (args == null || args.length <= offset) {
return "";
}
StringBuilder buf = new StringBuilder("argument");
if (args.length > offset) {
buf.append("s");
}
buf.append(":").append(StringUtils.LINE_SEP);
for (int i = offset; i < args.length; i++) {
buf.append("\'").append(args[i]).append("\'")
.append(StringUtils.LINE_SEP);
}
buf.append(DISCLAIMER);
return buf.toString();
}
示例6: throwableMessage
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
static void throwableMessage(StringBuffer m, Throwable error, boolean verbose) {
while (error instanceof BuildException) { // #43398
Throwable cause = error.getCause();
if (cause == null) {
break;
}
String msg1 = error.toString();
String msg2 = cause.toString();
if (msg1.endsWith(msg2)) {
m.append(msg1.substring(0, msg1.length() - msg2.length()));
error = cause;
} else {
break;
}
}
if (verbose || !(error instanceof BuildException)) {
m.append(StringUtils.getStackTrace(error));
} else {
m.append(error).append(lSep);
}
}
示例7: buildFinished
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
/**
* Prints whether the build succeeded or failed,
* any errors the occurred during the build, and
* how long the build took.
*
* @param event An event with any relevant extra information.
* Must not be <code>null</code>.
*/
public void buildFinished(BuildEvent event) {
Throwable error = event.getException();
StringBuffer message = new StringBuffer();
if (error == null) {
message.append(StringUtils.LINE_SEP);
message.append(getBuildSuccessfulMessage());
} else {
message.append(StringUtils.LINE_SEP);
message.append(getBuildFailedMessage());
message.append(StringUtils.LINE_SEP);
throwableMessage(message, error, Project.MSG_VERBOSE <= msgOutputLevel);
}
message.append(StringUtils.LINE_SEP);
message.append("Total time: ");
message.append(formatTime(System.currentTimeMillis() - startTime));
String msg = message.toString();
if (error == null) {
printMessage(msg, out, Project.MSG_VERBOSE);
} else {
printMessage(msg, err, Project.MSG_ERR);
}
log(msg);
}
示例8: buildFinished
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
/**
* @see org.apache.tools.ant.BuildListener#buildFinished(BuildEvent)
* {@inheritDoc}.
*/
public void buildFinished(BuildEvent event) {
log("< BUILD FINISHED", Project.MSG_DEBUG);
if (record && out != null) {
Throwable error = event.getException();
if (error == null) {
out.println(StringUtils.LINE_SEP + "BUILD SUCCESSFUL");
} else {
out.println(StringUtils.LINE_SEP + "BUILD FAILED"
+ StringUtils.LINE_SEP);
error.printStackTrace(out); //NOSONAR
}
}
cleanup();
}
示例9: setPropertyFromBAOS
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
/**
* Set a property from a ByteArrayOutputStream
*
* @param baos
* contains the property value.
* @param propertyName
* the property name.
*
* @exception IOException
* if the value cannot be read form the stream.
*/
private void setPropertyFromBAOS(final ByteArrayOutputStream baos,
final String propertyName) throws IOException {
final BufferedReader in = new BufferedReader(new StringReader(Execute
.toString(baos)));
String line = null;
final StringBuffer val = new StringBuffer();
while ((line = in.readLine()) != null) {
if (val.length() != 0) {
val.append(StringUtils.LINE_SEP);
}
val.append(line);
}
managingTask.getProject().setNewProperty(propertyName, val.toString());
}
示例10: writeJavaClass
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
private void writeJavaClass() {
try {
File sourceFile = new File(getLocationName() + ".java");
verbose("Write collector class to '" + sourceFile.getAbsolutePath() + "'");
if (sourceFile.exists() && !sourceFile.delete()) {
throw new IOException("could not delete " + sourceFile);
}
writer = new BufferedWriter(new FileWriter(sourceFile));
createClassHeader();
createSuiteMethod();
createClassFooter();
} catch (IOException e) {
log(StringUtils.getStackTrace(e));
} finally {
FileUtils.close(writer);
}
}
示例11: setProcessOutputStream
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
/**
* read the output stream to retrieve the new task number.
* @param is InputStream
* @throws IOException on error
*/
@Override
public void setProcessOutputStream(InputStream is) throws IOException {
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(is))) {
String buffer = reader.readLine();
if (buffer != null) {
log("buffer:" + buffer, Project.MSG_DEBUG);
String taskstring = buffer.substring(buffer.indexOf(' ')).trim();
taskstring = taskstring.substring(0, taskstring.lastIndexOf(' ')).trim();
setTask(taskstring);
log("task is " + getTask(), Project.MSG_DEBUG);
}
} catch (NullPointerException npe) {
log("error procession stream, null pointer exception", Project.MSG_ERR);
log(StringUtils.getStackTrace(npe), Project.MSG_ERR);
throw new BuildException(npe);
} catch (Exception e) {
log("error procession stream " + e.getMessage(), Project.MSG_ERR);
throw new BuildException(e.getMessage());
}
}
示例12: logAndAddFilesToCompile
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
/**
* Logs the compilation parameters, adds the files to compile and logs the
* "niceSourceList"
* @param cmd the command line to add parameters to.
*/
protected void logAndAddFilesToCompile(Commandline cmd) {
log("Compilation " + cmd.describeArguments(),
Project.MSG_VERBOSE);
String[] c = getClasses();
StringBuilder message = new StringBuilder("Class");
if (c.length > 1) {
message.append("es");
}
message.append(" to be compiled:");
message.append(StringUtils.LINE_SEP);
for (String element : c) {
cmd.createArgument().setValue(element);
message.append(" ").append(element).append(StringUtils.LINE_SEP);
}
log(message.toString(), Project.MSG_VERBOSE);
}
示例13: reset
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
/**
* Reset state to default.
*/
public void reset() {
append = false;
forceOverwrite = true;
dest = null;
encoding = null;
outputEncoding = null;
fixLastLine = false;
filterChains = null;
footer = null;
header = null;
binary = false;
outputWriter = null;
textBuffer = null;
eolString = StringUtils.LINE_SEP;
rc = null;
ignoreEmpty = true;
force = false;
}
示例14: executeToString
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
private String executeToString(Execute execute) {
String cmdLine = Commandline.describeCommand(execute
.getCommandline());
StringBuilder buf = removeCvsPassword(cmdLine);
String newLine = StringUtils.LINE_SEP;
String[] variableArray = execute.getEnvironment();
if (variableArray != null) {
buf.append(newLine);
buf.append(newLine);
buf.append("environment:");
buf.append(newLine);
for (int z = 0; z < variableArray.length; z++) {
buf.append(newLine);
buf.append("\t");
buf.append(variableArray[z]);
}
}
return buf.toString();
}
示例15: eval
import org.apache.tools.ant.util.StringUtils; //导入依赖的package包/类
/**
* Evaluate the condition.
* @return true if there enough free space.
* @throws BuildException if there is a problem.
*/
@Override
public boolean eval() throws BuildException {
validate();
try {
if (JavaEnvUtils.isAtLeastJavaVersion("1.6")) {
//reflection to avoid bootstrap/build problems
File fs = new File(partition);
ReflectWrapper w = new ReflectWrapper(fs);
long free = w.<Long> invoke("getFreeSpace").longValue();
return free >= StringUtils.parseHumanSizes(needed);
}
throw new BuildException(
"HasFreeSpace condition not supported on Java5 or less.");
} catch (Exception e) {
throw new BuildException(e);
}
}