Browse Source

checkstyle

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@474075 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
032ca220dd
3 changed files with 68 additions and 25 deletions
  1. +24
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java
  2. +10
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
  3. +34
    -23
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java

+ 24
- 0
src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java View File

@@ -547,14 +547,23 @@ public class PropertyFile extends Task {
public static class Operation extends EnumeratedAttribute {

// Property type operations
/** + */
public static final int INCREMENT_OPER = 0;
/** - */
public static final int DECREMENT_OPER = 1;
/** = */
public static final int EQUALS_OPER = 2;

/** {@inheritDoc}. */
public String[] getValues() {
return new String[] {"+", "-", "="};
}

/**
* Convert string to index.
* @param oper the string to convert.
* @return the index.
*/
public static int toOperation(String oper) {
if ("+".equals(oper)) {
return INCREMENT_OPER;
@@ -571,14 +580,23 @@ public class PropertyFile extends Task {
public static class Type extends EnumeratedAttribute {

// Property types
/** int */
public static final int INTEGER_TYPE = 0;
/** date */
public static final int DATE_TYPE = 1;
/** string */
public static final int STRING_TYPE = 2;

/** {@inheritDoc} */
public String[] getValues() {
return new String[] {"int", "date", "string"};
}

/**
* Convert string to index.
* @param type the string to convert.
* @return the index.
*/
public static int toType(String type) {
if ("int".equals(type)) {
return INTEGER_TYPE;
@@ -612,6 +630,7 @@ public class PropertyFile extends Task {

private Map calendarFields = new HashMap();

/** no arg constructor */
public Unit() {
calendarFields.put(MILLISECOND,
new Integer(Calendar.MILLISECOND));
@@ -624,12 +643,17 @@ public class PropertyFile extends Task {
calendarFields.put(YEAR, new Integer(Calendar.YEAR));
}

/**
* Convert the value to a Calendar field index.
* @return the calander value.
*/
public int getCalendarField() {
String key = getValue().toLowerCase();
Integer i = (Integer) calendarFields.get(key);
return i.intValue();
}

/** {@inheritDoc}. */
public String[] getValues() {
return UNITS;
}


+ 10
- 2
src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java View File

@@ -66,6 +66,7 @@ public class XMLValidateTask extends Task {

// ant task properties
// defaults
// CheckStyle:VisibilityModifier OFF - bc
protected boolean failOnError = true;
protected boolean warn = true;
protected boolean lenient = false;
@@ -87,6 +88,7 @@ public class XMLValidateTask extends Task {
// XMLReader used to validation process
protected ValidatorErrorHandler errorHandler = new ValidatorErrorHandler();
// to report sax parsing errors
// CheckStyle:VisibilityModifier ON

/** The vector to store all attributes (features) to be set on the parser. **/
private Vector attributeList = new Vector();
@@ -97,7 +99,9 @@ public class XMLValidateTask extends Task {
private final Vector propertyList = new Vector();

private XMLCatalog xmlCatalog = new XMLCatalog();
public static final String MESSAGE_FILES_VALIDATED = " file(s) have been successfully validated.";
/** Message for sucessfull validation */
public static final String MESSAGE_FILES_VALIDATED
= " file(s) have been successfully validated.";

/**
* Specify how parser error are to be handled.
@@ -517,6 +521,8 @@ public class XMLValidateTask extends Task {

/**
* parse the file
* @param afile the file to validate.
* @return true if the file validates.
*/
protected boolean doValidate(File afile) {
//for every file, we have a new instance of the validator
@@ -562,9 +568,11 @@ public class XMLValidateTask extends Task {
*/
protected class ValidatorErrorHandler implements ErrorHandler {

// CheckStyle:VisibilityModifier OFF - bc
protected File currentFile = null;
protected String lastErrorMessage = null;
protected boolean failed = false;
// CheckStyle:VisibilityModifier ON
/**
* initialises the class
* @param file file used
@@ -730,4 +738,4 @@ public class XMLValidateTask extends Task {



}
}

+ 34
- 23
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -180,8 +180,12 @@ public class FTP
* followSymlinks defaults to false
*/
protected class FTPDirectoryScanner extends DirectoryScanner {
// CheckStyle:VisibilityModifier OFF - bc
protected FTPClient ftp = null;
// CheckStyle:VisibilityModifier ON

private String rootPath = null;

/**
* since ant 1.6
* this flag should be set to true on UNIX and can save scanning time
@@ -542,8 +546,7 @@ public class FTP
return result;
}

private void forceRemoteSensitivityCheck()
{
private void forceRemoteSensitivityCheck() {
if (!remoteSensitivityChecked) {
try {
checkRemoteSensitivity(ftp.listFiles(), ftp.printWorkingDirectory());
@@ -813,7 +816,9 @@ public class FTP
// hit a hidden file assume not a symlink
relPath = relPath + currentElement;
currentPath = currentPath + remoteFileSep + currentElement;
log("Hidden file " + relPath + " assumed to not be a symlink.", Project.MSG_VERBOSE);
log("Hidden file " + relPath
+ " assumed to not be a symlink.",
Project.MSG_VERBOSE);
} else {
traversesSymlinks = traversesSymlinks || theFile.isSymbolicLink();
relPath = relPath + theFile.getName();
@@ -900,6 +905,10 @@ public class FTP
return traversesSymlinks;
}

/**
* Get a string rep of this object.
* @return a string containing the pwd and the file.
*/
public String toString() {
return "AntFtpFile: " + curpwd + "%" + ftpFile;
}
@@ -1297,8 +1306,7 @@ public class FTP
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setSystemTypeKey(FTPSystemType systemKey) {
if (systemKey != null && !systemKey.getValue().equals(""))
{
if (systemKey != null && !systemKey.getValue().equals("")) {
this.systemTypeKey = systemKey;
configurationHasBeenSet();
}
@@ -1311,8 +1319,7 @@ public class FTP
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setDefaultDateFormatConfig(String defaultDateFormat) {
if (defaultDateFormat != null && !defaultDateFormat.equals(""))
{
if (defaultDateFormat != null && !defaultDateFormat.equals("")) {
this.defaultDateFormatConfig = defaultDateFormat;
configurationHasBeenSet();
}
@@ -1325,8 +1332,7 @@ public class FTP
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setRecentDateFormatConfig(String recentDateFormat) {
if (recentDateFormat != null && !recentDateFormat.equals(""))
{
if (recentDateFormat != null && !recentDateFormat.equals("")) {
this.recentDateFormatConfig = recentDateFormat;
configurationHasBeenSet();
}
@@ -1339,8 +1345,7 @@ public class FTP
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setServerLanguageCodeConfig(LanguageCode serverLanguageCode) {
if (serverLanguageCode != null && !serverLanguageCode.equals(""))
{
if (serverLanguageCode != null && !serverLanguageCode.equals("")) {
this.serverLanguageCodeConfig = serverLanguageCode;
configurationHasBeenSet();
}
@@ -1353,8 +1358,7 @@ public class FTP
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setServerTimeZoneConfig(String serverTimeZoneId) {
if (serverTimeZoneId != null && !serverTimeZoneId.equals(""))
{
if (serverTimeZoneId != null && !serverTimeZoneId.equals("")) {
this.serverTimeZoneConfig = serverTimeZoneId;
configurationHasBeenSet();
}
@@ -1368,8 +1372,7 @@ public class FTP
* @see org.apache.commons.net.ftp.FTPClientConfig
*/
public void setShortMonthNamesConfig(String shortMonthNames) {
if (shortMonthNames != null && !shortMonthNames.equals(""))
{
if (shortMonthNames != null && !shortMonthNames.equals("")) {
this.shortMonthNamesConfig = shortMonthNames;
configurationHasBeenSet();
}
@@ -1518,14 +1521,14 @@ public class FTP
Class.forName("org.apache.commons.net.ftp.FTPClientConfig");
} catch (ClassNotFoundException e) {
throw new BuildException(
"commons-net.jar >= 1.4.0 is required for at least one of the attributes specified.");
"commons-net.jar >= 1.4.0 is required for at least one"
+ " of the attributes specified.");
}
}
}

protected void executeRetryable(RetryHandler h, Retryable r, String descr)
throws IOException
{
throws IOException {
h.execute(r, descr);
}

@@ -1626,7 +1629,8 @@ public class FTP
listFile(ftp, fbw, dsfile);
break;
case CHMOD:
doSiteCommand(ftp, "chmod " + chmod + " " + resolveFile(dsfile));
doSiteCommand(ftp, "chmod " + chmod
+ " " + resolveFile(dsfile));
transferred++;
break;
default:
@@ -2448,7 +2452,9 @@ public class FTP
private static final String[] VALID_GRANULARITIES = {
"", "MINUTE", "NONE"
};
/*

/**
* Get the valid values.
* @return the list of valid Granularity values
*/
public String[] getValues() {
@@ -2494,7 +2500,8 @@ public class FTP
};


/*
/**
* Get the valid values.
* @return the list of valid system types.
*/
public String[] getValues() {
@@ -2507,6 +2514,9 @@ public class FTP
return ftpst;
}
}
/**
* Enumerated class for languages.
*/
public static class LanguageCode extends EnumeratedAttribute {


@@ -2525,8 +2535,9 @@ public class FTP
}


/*
* @return the list of valid system types.
/**
* Return the value values.
* @return the list of valid language types.
*/
public String[] getValues() {
return VALID_LANGUAGE_CODES;


Loading…
Cancel
Save