public class Copyright
extends java.lang.Object
Basic code used to parse a directory and add a copyright notice to the top of each file that ends in java,properties,sql,wsdl,xml or xsd. The appropriate type of comment is used for each file type. For XML type files, the copyright notice is added after the standard XML declaration (<?xml...).
The program will update the license text if it already exists but preserve the original copyright date.
This code is run using the main method. The root directory to start from can be specified as the first argument. If no arguments are present, the current working directory is used.
Modifier and Type | Field and Description |
---|---|
static java.util.Map<java.lang.String,java.util.regex.Pattern> |
boundPatterns |
static java.lang.String[] |
COPYRIGHT
Copyright notice
|
static java.util.regex.Pattern |
COPYRIGHT_REGEX
Regular expression matching the copyright notice or any other notice at the
top of a file to be replaced by the copyright notice.
|
static java.util.Map<java.lang.String,uk.ac.ed.epcc.webapp.apps.Copyright.Bounds> |
copyrightBounds |
static java.util.Map<java.lang.String,java.lang.String> |
copyrightText |
static java.lang.String |
NEW_LINE |
static java.util.regex.Pattern |
VERSION_REGEX |
static java.lang.String |
XML_HEADER_START |
Constructor and Description |
---|
Copyright() |
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String... args)
Examines all files recursively from a specified root directory/file.
|
public static final java.lang.String[] COPYRIGHT
public static final java.util.regex.Pattern COPYRIGHT_REGEX
public static final java.util.regex.Pattern VERSION_REGEX
public static final java.util.Map<java.lang.String,uk.ac.ed.epcc.webapp.apps.Copyright.Bounds> copyrightBounds
public static final java.util.Map<java.lang.String,java.util.regex.Pattern> boundPatterns
public static final java.util.Map<java.lang.String,java.lang.String> copyrightText
public static final java.lang.String NEW_LINE
public static final java.lang.String XML_HEADER_START
public static void main(java.lang.String... args)
Examines all files recursively from a specified root directory/file. If a
file ends in .java
or the xml extensions .xml
,
.xsd
or .wsdl
, a copyright notice is added (if it
is not already present). If a copyright notice is present and matches the
regular expression used to find copyright notices, but does not match the
copyright notice being used, the old notice is replaced.
This method takes a string array. Element 0 (if present) should be the root directory to search. If absent, the current working directory is used.
args
-