org.glassfish.copyright
Class AbstractCopyright

java.lang.Object
  extended by org.glassfish.copyright.AbstractCopyright
Direct Known Subclasses:
BatCopyright, CommonCopyright, PropertiesCopyright, TextCopyright

public abstract class AbstractCopyright
extends Object


Field Summary
protected static String allrights
           
protected  Copyright c
           
protected static String licensor
           
protected static String thisYear
           
protected static Pattern ypat
           
 
Constructor Summary
AbstractCopyright(Copyright c)
           
 
Method Summary
protected  String addCopyrightDate(String date, String lastChanged)
          Update the given copyright date to include the lastChanged date (assumed to be a date greater than any date included in "date").
protected  void checkCopyright(File file)
          Check a file for the correct copyright notice.
protected  void copy(BufferedReader in, BufferedWriter out, boolean skipBlanks)
          Copy "in" to "out", skipping blank lines at the beginning of "in" if skipBlanks is true, and canonicalizing the line terminators to '\n'.
protected  void err(String s)
           
protected static String findPrefix(String line)
          Find the prefix (if any) for the current line.
protected  String fixCopyright(String cr, String date, String lic)
          Update the copyright line in cr to use "date" as the copyright date and "lic" as the licensor.
protected  boolean isModified(String file)
          Exec the "svn status" command to find out if the file has been modified locally.
protected  String lastChanged(String file)
          Exec the "svn info" command to get the date the file was last changed.
protected  boolean matches(Pattern pat, String s)
          Does the string match the pattern?
protected abstract  String readComment(BufferedReader r)
          Read the first comment block in the file.
protected  void repair(File file, String comment, org.glassfish.copyright.AbstractCopyright.RepairType type)
          Repair the c.errors in the file.
protected abstract  void replaceCopyright(BufferedReader in, BufferedWriter out, String comment, String lastChanged)
          Skip the first comment block, replacing it with the correct copyright.
protected static boolean startsWith(File file, String prefix)
          Does the file start with the specified prefix?
protected static boolean startsWith(String s, String prefix)
          Like String.startsWith, but ignores case and skips leading whitespace.
protected static String strip(String line)
          Strip any trailing whitespace.
protected abstract  boolean supports(File file)
          Does this class support this file? Subclasses will use the file name, and possibly examine the content of the file, to determine whether it's supported.
protected abstract  String toComment(String comment)
          Convert the comment text to the appropriate syntax.
protected abstract  void updateCopyright(BufferedReader in, BufferedWriter out, String lastChanged)
          Update the existing copyright statement, changing the copyright year to include lastChanged.
protected  void warnCopyright(File file, BufferedReader in)
          Warn if there's another copyright statement in the file.
protected  void writeCopyright(BufferedWriter out, String year, String comment)
          Write the correct copyright to "out", using "year" as the copyright date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

c

protected Copyright c

ypat

protected static Pattern ypat

licensor

protected static final String licensor
See Also:
Constant Field Values

allrights

protected static final String allrights
See Also:
Constant Field Values

thisYear

protected static final String thisYear
Constructor Detail

AbstractCopyright

public AbstractCopyright(Copyright c)
Method Detail

supports

protected abstract boolean supports(File file)
Does this class support this file? Subclasses will use the file name, and possibly examine the content of the file, to determine whether it's supported.


checkCopyright

protected void checkCopyright(File file)
                       throws IOException
Check a file for the correct copyright notice.

Throws:
IOException

matches

protected boolean matches(Pattern pat,
                          String s)
Does the string match the pattern?


repair

protected void repair(File file,
                      String comment,
                      org.glassfish.copyright.AbstractCopyright.RepairType type)
               throws IOException
Repair the c.errors in the file. Repair cases and strategy: Missing copyright Insert correct copyright Wrong copyright Try to extract copyright date. Insert correct copyright. Wrong date Update existing date in existing copyright.

Throws:
IOException

writeCopyright

protected void writeCopyright(BufferedWriter out,
                              String year,
                              String comment)
                       throws IOException
Write the correct copyright to "out", using "year" as the copyright date. The original license may be supplied as "comment", from which a secondary license may be extracted, and which determines whether the new license is a BSD license or not.

Throws:
IOException

replaceCopyright

protected abstract void replaceCopyright(BufferedReader in,
                                         BufferedWriter out,
                                         String comment,
                                         String lastChanged)
                                  throws IOException
Skip the first comment block, replacing it with the correct copyright. If the file starts with a "package" statement, save it and write it out after the new copyright.

Throws:
IOException

updateCopyright

protected abstract void updateCopyright(BufferedReader in,
                                        BufferedWriter out,
                                        String lastChanged)
                                 throws IOException
Update the existing copyright statement, changing the copyright year to include lastChanged.

Throws:
IOException

toComment

protected abstract String toComment(String comment)
Convert the comment text to the appropriate syntax.


readComment

protected abstract String readComment(BufferedReader r)
                               throws IOException
Read the first comment block in the file.

Throws:
IOException

warnCopyright

protected void warnCopyright(File file,
                             BufferedReader in)
                      throws IOException
Warn if there's another copyright statement in the file.

Throws:
IOException

copy

protected void copy(BufferedReader in,
                    BufferedWriter out,
                    boolean skipBlanks)
             throws IOException
Copy "in" to "out", skipping blank lines at the beginning of "in" if skipBlanks is true, and canonicalizing the line terminators to '\n'.

Throws:
IOException

addCopyrightDate

protected String addCopyrightDate(String date,
                                  String lastChanged)
Update the given copyright date to include the lastChanged date (assumed to be a date greater than any date included in "date"). Return the updated date string.


fixCopyright

protected String fixCopyright(String cr,
                              String date,
                              String lic)
Update the copyright line in cr to use "date" as the copyright date and "lic" as the licensor.


strip

protected static String strip(String line)
Strip any trailing whitespace.


findPrefix

protected static String findPrefix(String line)
Find the prefix (if any) for the current line.


startsWith

protected static boolean startsWith(String s,
                                    String prefix)
Like String.startsWith, but ignores case and skips leading whitespace.


startsWith

protected static boolean startsWith(File file,
                                    String prefix)
Does the file start with the specified prefix?


lastChanged

protected String lastChanged(String file)
                      throws IOException
Exec the "svn info" command to get the date the file was last changed.

Throws:
IOException

isModified

protected boolean isModified(String file)
                      throws IOException
Exec the "svn status" command to find out if the file has been modified locally.

Throws:
IOException

err

protected void err(String s)


Copyright © 2012 GlassFish Community. All Rights Reserved.