From f25d3801bb03267e98e239d6fae047b8d3778eed Mon Sep 17 00:00:00 2001 From: Conor MacNeill Date: Mon, 10 Feb 2003 10:32:34 +0000 Subject: [PATCH] Make variables private with protected accessors PR: 16910 Submitted by: Jesse Stockall git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274030 13f79535-47bb-0310-9956-ffa450edef68 --- .../ant/taskdefs/optional/vss/MSVSS.java | 118 +++++++++++++++--- .../ant/taskdefs/optional/vss/MSVSSADD.java | 14 ++- .../taskdefs/optional/vss/MSVSSCHECKIN.java | 14 +-- .../taskdefs/optional/vss/MSVSSCHECKOUT.java | 12 +- .../ant/taskdefs/optional/vss/MSVSSCP.java | 2 +- .../taskdefs/optional/vss/MSVSSCREATE.java | 10 +- .../ant/taskdefs/optional/vss/MSVSSGET.java | 23 ++-- .../taskdefs/optional/vss/MSVSSHISTORY.java | 39 +++--- .../ant/taskdefs/optional/vss/MSVSSLABEL.java | 8 +- 9 files changed, 157 insertions(+), 83 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java index eb5e54669..e3d2c5b66 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSS.java @@ -93,43 +93,43 @@ public abstract class MSVSS extends Task implements MSVSSConstants { private String m_serverPath = null; /** Version */ - protected String m_Version = null; + private String m_Version = null; /** Date */ - protected String m_Date = null; + private String m_Date = null; /** Label */ - protected String m_Label = null; + private String m_Label = null; /** Auto response */ - protected String m_AutoResponse = null; + private String m_AutoResponse = null; /** Local path */ - protected String m_LocalPath = null; + private String m_LocalPath = null; /** Comment */ - protected String m_Comment = null; + private String m_Comment = null; /** From label */ - protected String m_FromLabel = null; + private String m_FromLabel = null; /** To label */ - protected String m_ToLabel = null; + private String m_ToLabel = null; /** Output file name */ - protected String m_OutputFileName = null; + private String m_OutputFileName = null; /** User */ - protected String m_User = null; + private String m_User = null; /** From date */ - protected String m_FromDate = null; + private String m_FromDate = null; /** To date */ - protected String m_ToDate = null; + private String m_ToDate = null; /** History style */ - protected String m_Style = null; + private String m_Style = null; /** Quiet defaults to false */ - protected boolean m_Quiet = false; + private boolean m_Quiet = false; /** Recursive defaults to false */ - protected boolean m_Recursive = false; + private boolean m_Recursive = false; /** Writable defaults to false */ - protected boolean m_Writable = false; + private boolean m_Writable = false; /** Fail on error defaults to true */ - protected boolean m_FailOnError = true; + private boolean m_FailOnError = true; /** Number of days offset for History */ - protected int m_NumDays = Integer.MIN_VALUE; + private int m_NumDays = Integer.MIN_VALUE; /** Date format for History */ - protected DateFormat m_DateFormat = DateFormat.getDateInstance(DateFormat.SHORT); + private DateFormat m_DateFormat = DateFormat.getDateInstance(DateFormat.SHORT); /** * Each sub-class must implemnt this method and return the constructed @@ -214,12 +214,90 @@ public abstract class MSVSS extends Task implements MSVSSConstants { } } + // Special setters for the sub-classes + + protected void setInternalComment(String text) { + m_Comment = text; + } + + protected void setInternalAutoResponse(String text) { + m_AutoResponse = text; + } + + protected void setInternalDate(String text) { + m_Date = text; + } + + protected void setInternalDateFormat(DateFormat date) { + m_DateFormat = date; + } + + protected void setInternalFailOnError(boolean fail) { + m_FailOnError = fail; + } + + protected void setInternalFromDate(String text) { + m_FromDate = text; + } + + protected void setInternalFromLabel(String text) { + m_FromLabel = text; + } + + protected void setInternalLabel(String text) { + m_Label = text; + } + + protected void setInternalLocalPath(String text) { + m_LocalPath = text; + } + + protected void setInternalNumDays(int days) { + m_NumDays = days; + } + + protected void setInternalOutputFilename(String text) { + m_OutputFileName = text; + } + + protected void setInternalQuiet(boolean quiet) { + m_Quiet = quiet; + } + + protected void setInternalRecursive(boolean recursive) { + m_Recursive = recursive; + } + + protected void setInternalStyle(String style) { + m_Style = style; + } + + protected void setInternalToDate(String text) { + m_ToDate = text; + } + + protected void setInternalToLabel(String text) { + m_ToLabel = text; + } + + protected void setInternalUser(String user) { + m_User = user; + } + + protected void setInternalVersion(String text) { + m_Version = text; + } + + protected void setInternalWritable(boolean writable) { + m_Writable = writable; + } + /** * Gets the sscommand string. "ss" or "c:\path\to\ss" * * @return The path to ss.exe or just ss if sscommand is not set. */ - public String getSSCommand() { + protected String getSSCommand() { if (m_SSDir == null) { return SS_EXE; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSADD.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSADD.java index 9836df003..7bf52e78a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSADD.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSADD.java @@ -69,6 +69,8 @@ import org.apache.tools.ant.types.Path; */ public class MSVSSADD extends MSVSS { + private String m_LocalPath = null; + /** * Builds a command line to execute ss. * @return The constructed commandline. @@ -119,15 +121,15 @@ public class MSVSSADD extends MSVSS { * @param recursive The boolean value for recursive. */ public void setRecursive(boolean recursive) { - m_Recursive = recursive; + super.setInternalRecursive(recursive); } /** * Leave checked in files writable? Default: false. - * @param argWritable The boolean value for writable. + * @param writable The boolean value for writable. */ - public final void setWritable(boolean argWritable) { - m_Writable = argWritable; + public final void setWritable(boolean writable) { + super.setInternalWritable(writable); } /** @@ -137,7 +139,7 @@ public class MSVSSADD extends MSVSS { * @param response The auto response value. */ public void setAutoresponse(String response){ - m_AutoResponse = response; + super.setInternalAutoResponse(response); } /** @@ -148,7 +150,7 @@ public class MSVSSADD extends MSVSS { * @param comment The comment to apply in SourceSafe */ public void setComment(String comment) { - m_Comment = comment; + super.setInternalComment(comment); } /** diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java index 7d0bb2d13..c8ac35218 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKIN.java @@ -113,7 +113,7 @@ public class MSVSSCHECKIN extends MSVSS { * @param localPath The path on disk. */ public void setLocalpath(Path localPath) { - m_LocalPath = localPath.toString(); + super.setInternalLocalPath(localPath.toString()); } /** @@ -122,15 +122,15 @@ public class MSVSSCHECKIN extends MSVSS { * @param recursive The boolean value for recursive. */ public void setRecursive(boolean recursive) { - m_Recursive = recursive; + super.setInternalRecursive(recursive); } /** * Sets behaviour, unset the READ-ONLY flag on files checkedin to VSS.; optional - * @param argWritable The boolean value for writable. + * @param writable The boolean value for writable. */ - public final void setWritable(boolean argWritable) { - m_Writable = argWritable; + public final void setWritable(boolean writable) { + super.setInternalWritable(writable); } /** @@ -140,7 +140,7 @@ public class MSVSSCHECKIN extends MSVSS { * @param response The auto response value. */ public void setAutoresponse(String response){ - m_AutoResponse = response; + super.setInternalAutoResponse(response); } /** @@ -151,6 +151,6 @@ public class MSVSSCHECKIN extends MSVSS { * @param comment The comment to apply in SourceSafe */ public void setComment(String comment) { - m_Comment = comment; + super.setInternalComment(comment); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java index ab9573aec..a2b0536b7 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCHECKOUT.java @@ -113,7 +113,7 @@ public class MSVSSCHECKOUT extends MSVSS { * @param localPath The path on disk. */ public void setLocalpath(Path localPath) { - m_LocalPath = localPath.toString(); + super.setInternalLocalPath(localPath.toString()); } /** @@ -122,7 +122,7 @@ public class MSVSSCHECKOUT extends MSVSS { * @param recursive The boolean value for recursive. */ public void setRecursive(boolean recursive) { - m_Recursive = recursive; + super.setInternalRecursive(recursive); } /** @@ -130,7 +130,7 @@ public class MSVSSCHECKOUT extends MSVSS { * @param version The version to checkout. */ public void setVersion(String version) { - m_Version = version; + super.setInternalVersion(version); } /** @@ -138,7 +138,7 @@ public class MSVSSCHECKOUT extends MSVSS { * @param date The date to checkout. */ public void setDate(String date) { - m_Date = date; + super.setInternalDate(date); } /** @@ -146,7 +146,7 @@ public class MSVSSCHECKOUT extends MSVSS { * @param label The label to apply. */ public void setLabel(String label) { - m_Label = label; + super.setInternalLabel(label); } /** @@ -156,6 +156,6 @@ public class MSVSSCHECKOUT extends MSVSS { * @param response The auto response value. */ public void setAutoresponse(String response){ - m_AutoResponse = response; + super.setInternalAutoResponse(response); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCP.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCP.java index 3b9c5fb94..1f9295b0a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCP.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCP.java @@ -105,6 +105,6 @@ public class MSVSSCP extends MSVSS { * @param response The auto response value. */ public void setAutoresponse(String response) { - m_AutoResponse = response; + super.setInternalAutoResponse(response); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCREATE.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCREATE.java index 636a5ca8e..237a967c8 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCREATE.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCREATE.java @@ -156,7 +156,7 @@ public class MSVSSCREATE extends MSVSS { * @param comment The comment to apply in SourceSafe */ public void setComment(String comment) { - m_Comment = comment; + super.setInternalComment(comment); } /** @@ -164,16 +164,16 @@ public class MSVSSCREATE extends MSVSS { * @param quiet The boolean value for quiet. */ public final void setQuiet (boolean quiet) { - m_Quiet = quiet; + super.setInternalQuiet(quiet); } /** * Sets behaviour, whether task should fail if there is an error creating - * the project.; optional. + * the project.; optional, default true * @param failOnError True if task should fail on any error. */ public final void setFailOnError (boolean failOnError) { - m_FailOnError = failOnError; + super.setInternalFailOnError(failOnError); } /** @@ -183,6 +183,6 @@ public class MSVSSCREATE extends MSVSS { * @param response The auto response value. */ public void setAutoresponse(String response) { - m_AutoResponse = response; + super.setInternalAutoResponse(response); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java index 65266290b..f65458fb6 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java @@ -54,7 +54,6 @@ package org.apache.tools.ant.taskdefs.optional.vss; -import java.io.File; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; @@ -175,7 +174,7 @@ public class MSVSSGET extends MSVSS { * @param localPath The path on disk. */ public void setLocalpath(Path localPath) { - m_LocalPath = localPath.toString(); + super.setInternalLocalPath(localPath.toString()); } /** @@ -184,7 +183,7 @@ public class MSVSSGET extends MSVSS { * @param recursive The boolean value for recursive. */ public final void setRecursive(boolean recursive) { - m_Recursive = recursive; + super.setInternalRecursive(recursive); } /** @@ -192,15 +191,15 @@ public class MSVSSGET extends MSVSS { * @param quiet The boolean value for quiet. */ public final void setQuiet (boolean quiet) { - m_Quiet = quiet; + super.setInternalQuiet(quiet); } /** - * Sets behaviour, unset the READ-ONLY flag on files retrieved from VSS.; optional - * @param argWritable The boolean value for writable. + * Sets behaviour, unset the READ-ONLY flag on files retrieved from VSS.; optional, default false + * @param writable The boolean value for writable. */ - public final void setWritable(boolean argWritable) { - m_Writable = argWritable; + public final void setWritable(boolean writable) { + super.setInternalWritable(writable); } /** @@ -208,7 +207,7 @@ public class MSVSSGET extends MSVSS { * @param version The version to get. */ public void setVersion(String version) { - m_Version = version; + super.setInternalVersion(version); } /** @@ -216,7 +215,7 @@ public class MSVSSGET extends MSVSS { * @param date The date to checkout. */ public void setDate(String date) { - m_Date = date; + super.setInternalDate(date); } /** @@ -224,7 +223,7 @@ public class MSVSSGET extends MSVSS { * @param label The label to apply. */ public void setLabel(String label) { - m_Label = label; + super.setInternalLabel(label); } /** @@ -234,6 +233,6 @@ public class MSVSSGET extends MSVSS { * @param response The auto response value. */ public void setAutoresponse(String response){ - m_AutoResponse = response; + super.setInternalAutoResponse(response); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java index 41089899d..a5bd32306 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSHISTORY.java @@ -55,15 +55,12 @@ package org.apache.tools.ant.taskdefs.optional.vss; import java.io.File; -import java.text.DateFormat; -import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.EnumeratedAttribute; + /** * Performs History commands to Microsoft Visual SourceSafe. * @@ -120,7 +117,7 @@ public class MSVSSHISTORY extends MSVSS { * @param recursive The boolean value for recursive. */ public void setRecursive(boolean recursive) { - m_Recursive = recursive; + super.setInternalRecursive(recursive); } /** @@ -128,7 +125,7 @@ public class MSVSSHISTORY extends MSVSS { * @param user The username. */ public void setUser(String user) { - m_User = user; + super.setInternalUser(user); } /** @@ -137,7 +134,7 @@ public class MSVSSHISTORY extends MSVSS { * @param fromDate The start date. */ public void setFromDate(String fromDate) { - m_FromDate = fromDate; + super.setInternalFromDate(fromDate); } /** @@ -145,7 +142,7 @@ public class MSVSSHISTORY extends MSVSS { * @param toDate The end date. */ public void setToDate(String toDate) { - m_ToDate = toDate; + super.setInternalToDate(toDate); } /** @@ -153,7 +150,7 @@ public class MSVSSHISTORY extends MSVSS { * @param fromLabel The start label. */ public void setFromLabel(String fromLabel) { - m_FromLabel = fromLabel; + super.setInternalFromLabel(fromLabel); } /** @@ -161,7 +158,7 @@ public class MSVSSHISTORY extends MSVSS { * @param toLabel The end label. */ public void setToLabel(String toLabel) { - m_ToLabel = toLabel; + super.setInternalToLabel(toLabel); } /** @@ -172,7 +169,7 @@ public class MSVSSHISTORY extends MSVSS { * @param numd The number of days. */ public void setNumdays(int numd) { - m_NumDays = numd; + super.setInternalNumDays(numd); } /** @@ -180,10 +177,8 @@ public class MSVSSHISTORY extends MSVSS { * @param outfile The output file name. */ public void setOutput(File outfile) { - if (outfile == null) { - m_OutputFileName = null; - } else { - m_OutputFileName = outfile.getAbsolutePath(); + if (outfile != null) { + super.setInternalOutputFilename(outfile.getAbsolutePath()); } } @@ -196,7 +191,7 @@ public class MSVSSHISTORY extends MSVSS { * @param dateFormat The date format. */ public void setDateFormat(String dateFormat) { - m_DateFormat = new SimpleDateFormat(dateFormat); + super.setInternalDateFormat(new SimpleDateFormat(dateFormat)); } /** @@ -213,15 +208,15 @@ public class MSVSSHISTORY extends MSVSS { public void setStyle(BriefCodediffNofile attr) { String option = attr.getValue(); if (option.equals(STYLE_BRIEF)) { - m_Style = FLAG_BRIEF; + super.setInternalStyle(FLAG_BRIEF); } else if (option.equals(STYLE_CODEDIFF)) { - m_Style = FLAG_CODEDIFF; + super.setInternalStyle(FLAG_CODEDIFF); } else if (option.equals(STYLE_DEFAULT)) { - m_Style = ""; + super.setInternalStyle(""); } else if (option.equals(STYLE_NOFILE)) { - m_Style = FLAG_NO_FILE; + super.setInternalStyle(FLAG_NO_FILE); } else { - throw new BuildException("Style " + attr + " unknown."); + throw new BuildException("Style " + attr + " unknown.", getLocation()); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java index ea2c744d8..204b4351a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSLABEL.java @@ -158,7 +158,7 @@ public class MSVSSLABEL extends MSVSS { * @param label The label to apply. */ public void setLabel(String label) { - m_Label = label; + super.setInternalLabel(label); } /** @@ -166,7 +166,7 @@ public class MSVSSLABEL extends MSVSS { * @param version The version to label. */ public void setVersion(String version) { - m_Version = version; + super.setInternalVersion(version); } /** @@ -175,7 +175,7 @@ public class MSVSSLABEL extends MSVSS { * @param comment The comment to apply in SourceSafe */ public void setComment(String comment) { - m_Comment = comment; + super.setInternalComment(comment); } /** @@ -185,6 +185,6 @@ public class MSVSSLABEL extends MSVSS { * @param response The auto response value. */ public void setAutoresponse(String response){ - m_AutoResponse = response; + super.setInternalAutoResponse(response); } }