build.CopyrightInsertionTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jt400-jdk8 Show documentation
Show all versions of jt400-jdk8 Show documentation
The Open Source version of the IBM Toolbox for Java
The newest version!
import java.io.*;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.taskdefs.MatchingTask;
public class CopyrightInsertionTask extends MatchingTask
{
private static final String copyrightStringPart1_ = "Copyright (C) ";
private static final String copyrightStringPart2_ = "1997-2019";
private static final String copyrightStringPart3_ = " International Business Machines Corporation and others.";
private static final String copyrightString_ = copyrightStringPart1_ + copyrightStringPart2_ + copyrightStringPart3_;
private static final int copyrightStringLength_ = copyrightString_.length();
private boolean verbose_;
private File destDir_; // directory where the *.class files are located
private int numFilesProcessed_ = 0; // count of class files processed
private int numFilesStamped_ = 0; // count of class files stamped
private int numFilesAlreadyStamped_ = 0; // count of class files already stamped
public void setDestdir(File destDir)
{
destDir_ = destDir;
}
public void setVerbose(boolean verbose)
{
verbose_ = verbose;
}
// Executes the task.
public void execute() throws BuildException
{
DirectoryScanner scanner = getDirectoryScanner(destDir_);
String[] classFileNames = scanner.getIncludedFiles();
for (int i=0; i 0x7F) // not a single-byte char
{
i++;
byte b = (byte)bytes[i];
validate(b);
if (b > 0xBF) // not a double-byte char
{
i++;
byte c = (byte)bytes[i];
validate(c);
ch = ((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f);
}
else // is a double-byte
{
ch = ((a & 0x1f) << 6) + (b & 0x3f);
}
}
else // is a single-byte
{
ch = a;
}
name.append((char)ch);
i++;
}
name_ = name.toString();
}
private /*static*/ void validate(byte x)
{
if (x==0x0 || x>=0xf0)
throw new NullPointerException("Invalid byte: "+x);
}
}
}