KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > vss > MSVSS


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18
19 package org.apache.tools.ant.taskdefs.optional.vss;
20
21 import org.apache.tools.ant.types.EnumeratedAttribute;
22 import java.io.File JavaDoc;
23 import java.io.IOException JavaDoc;
24 import java.text.DateFormat JavaDoc;
25 import java.text.ParseException JavaDoc;
26 import java.util.Calendar JavaDoc;
27 import java.util.Date JavaDoc;
28 import java.util.GregorianCalendar JavaDoc;
29
30 import org.apache.tools.ant.BuildException;
31 import org.apache.tools.ant.Project;
32 import org.apache.tools.ant.Task;
33 import org.apache.tools.ant.taskdefs.Execute;
34 import org.apache.tools.ant.taskdefs.LogStreamHandler;
35 import org.apache.tools.ant.types.Commandline;
36 import org.apache.tools.ant.util.FileUtils;
37
38 /**
39  * A base class for creating tasks for executing commands on Visual SourceSafe.
40  * <p>
41  * The class extends the 'exec' task as it operates by executing the ss.exe program
42  * supplied with SourceSafe. By default the task expects ss.exe to be in the path,
43  * you can override this be specifying the ssdir attribute.
44  * </p>
45  * <p>
46  * This class provides set and get methods for 'login' and 'vsspath' attributes. It
47  * also contains constants for the flags that can be passed to SS.
48  * </p>
49  *
50  */

51 public abstract class MSVSS extends Task implements MSVSSConstants {
52
53     private String JavaDoc ssDir = null;
54     private String JavaDoc vssLogin = null;
55     private String JavaDoc vssPath = null;
56     private String JavaDoc serverPath = null;
57
58     /** Version */
59     private String JavaDoc version = null;
60     /** Date */
61     private String JavaDoc date = null;
62     /** Label */
63     private String JavaDoc label = null;
64     /** Auto response */
65     private String JavaDoc autoResponse = null;
66     /** Local path */
67     private String JavaDoc localPath = null;
68     /** Comment */
69     private String JavaDoc comment = null;
70     /** From label */
71     private String JavaDoc fromLabel = null;
72     /** To label */
73     private String JavaDoc toLabel = null;
74     /** Output file name */
75     private String JavaDoc outputFileName = null;
76     /** User */
77     private String JavaDoc user = null;
78     /** From date */
79     private String JavaDoc fromDate = null;
80     /** To date */
81     private String JavaDoc toDate = null;
82     /** History style */
83     private String JavaDoc style = null;
84     /** Quiet defaults to false */
85     private boolean quiet = false;
86     /** Recursive defaults to false */
87     private boolean recursive = false;
88     /** Writable defaults to false */
89     private boolean writable = false;
90     /** Fail on error defaults to true */
91     private boolean failOnError = true;
92     /** Get local copy for checkout defaults to true */
93     private boolean getLocalCopy = true;
94     /** Number of days offset for History */
95     private int numDays = Integer.MIN_VALUE;
96     /** Date format for History */
97     private DateFormat JavaDoc dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);
98     /** Timestamp for retreived files */
99     private CurrentModUpdated timestamp = null;
100     /** Behaviour for writable files */
101     private WritableFiles writableFiles = null;
102
103     /**
104      * Each sub-class must implemnt this method and return the constructed
105      * command line to be executed. It is up to the sub-task to determine the
106      * required attrubutes and their order.
107      * @return The Constructed command line.
108      */

109     abstract Commandline buildCmdLine();
110
111     /**
112      * Directory where <code>ss.exe</code> resides.
113      * By default the task expects it to be in the PATH.
114      * @param dir The directory containing ss.exe.
115      */

116     public final void setSsdir(String JavaDoc dir) {
117         this.ssDir = FileUtils.translatePath(dir);
118     }
119
120     /**
121      * Login to use when accessing VSS, formatted as "username,password".
122      * <p>
123      * You can omit the password if your database is not password protected.
124      * If you have a password and omit it, Ant will hang.
125      * @param vssLogin The login string to use.
126      */

127     public final void setLogin(final String JavaDoc vssLogin) {
128         this.vssLogin = vssLogin;
129     }
130
131     /**
132      * SourceSafe path which specifies the project/file(s) you wish to perform
133      * the action on.
134      * <p>
135      * A prefix of 'vss://' will be removed if specified.
136      * @param vssPath The VSS project path.
137      * @ant.attribute group="required"
138      */

139     public final void setVsspath(final String JavaDoc vssPath) {
140         String JavaDoc projectPath;
141         if (vssPath.startsWith("vss://")) { //$NON-NLS-1$
142
projectPath = vssPath.substring(5);
143         } else {
144             projectPath = vssPath;
145         }
146
147         if (projectPath.startsWith(PROJECT_PREFIX)) {
148             this.vssPath = projectPath;
149         } else {
150             this.vssPath = PROJECT_PREFIX + projectPath;
151         }
152     }
153
154     /**
155      * Directory where <code>srssafe.ini</code> resides.
156      * @param serverPath The path to the VSS server.
157      */

158     public final void setServerpath(final String JavaDoc serverPath) {
159         this.serverPath = serverPath;
160     }
161
162     /**
163      * Indicates if the build should fail if the Sourcesafe command does. Defaults to true.
164      * @param failOnError True if task should fail on any error.
165      */

166     public final void setFailOnError(final boolean failOnError) {
167         this.failOnError = failOnError;
168     }
169
170     /**
171      * Executes the task. <br>
172      * Builds a command line to execute ss.exe and then calls Exec's run method
173      * to execute the command line.
174      * @throws BuildException if the command cannot execute.
175      */

176     public void execute() throws BuildException {
177         int result = 0;
178         Commandline commandLine = buildCmdLine();
179         result = run(commandLine);
180         if (Execute.isFailure(result) && getFailOnError()) {
181             String JavaDoc msg = "Failed executing: " + formatCommandLine(commandLine)
182                      + " With a return code of " + result;
183             throw new BuildException(msg, getLocation());
184         }
185     }
186
187     // Special setters for the sub-classes
188

189     /**
190      * Set the internal comment attribute.
191      * @param comment the value to use.
192      */

193     protected void setInternalComment(final String JavaDoc comment) {
194         this.comment = comment;
195     }
196
197     /**
198      * Set the auto response attribute.
199      * @param autoResponse the value to use.
200      */

201     protected void setInternalAutoResponse(final String JavaDoc autoResponse) {
202         this.autoResponse = autoResponse;
203     }
204
205     /**
206      * Set the date attribute.
207      * @param date the value to use.
208      */

209     protected void setInternalDate(final String JavaDoc date) {
210         this.date = date;
211     }
212
213     /**
214      * Set the date format attribute.
215      * @param dateFormat the value to use.
216      */

217     protected void setInternalDateFormat(final DateFormat JavaDoc dateFormat) {
218         this.dateFormat = dateFormat;
219     }
220
221     /**
222      * Set the failOnError attribute.
223      * @param failOnError the value to use.
224      */

225     protected void setInternalFailOnError(final boolean failOnError) {
226         this.failOnError = failOnError;
227     }
228
229     /**
230      * Set the from date attribute.
231      * @param fromDate the value to use.
232      */

233     protected void setInternalFromDate(final String JavaDoc fromDate) {
234         this.fromDate = fromDate;
235     }
236
237     /**
238      * Set the from label attribute.
239      * @param fromLabel the value to use.
240      */

241     protected void setInternalFromLabel(final String JavaDoc fromLabel) {
242         this.fromLabel = fromLabel;
243     }
244
245     /**
246      * Set the label attribute.
247      * @param label the value to use.
248      */

249     protected void setInternalLabel(final String JavaDoc label) {
250         this.label = label;
251     }
252
253     /**
254      * Set the local path comment attribute.
255      * @param localPath the value to use.
256      */

257     protected void setInternalLocalPath(final String JavaDoc localPath) {
258         this.localPath = localPath;
259     }
260
261     /**
262      * Set the num days attribute.
263      * @param numDays the value to use.
264      */

265     protected void setInternalNumDays(final int numDays) {
266         this.numDays = numDays;
267     }
268
269     /**
270      * Set the outputFileName comment attribute.
271      * @param outputFileName the value to use.
272      */

273     protected void setInternalOutputFilename(final String JavaDoc outputFileName) {
274         this.outputFileName = outputFileName;
275     }
276
277     /**
278      * Set the quiet attribute.
279      * @param quiet the value to use.
280      */

281     protected void setInternalQuiet(final boolean quiet) {
282         this.quiet = quiet;
283     }
284
285     /**
286      * Set the recursive attribute.
287      * @param recursive the value to use.
288      */

289     protected void setInternalRecursive(final boolean recursive) {
290         this.recursive = recursive;
291     }
292
293     /**
294      * Set the style attribute.
295      * @param style the value to use.
296      */

297     protected void setInternalStyle(final String JavaDoc style) {
298         this.style = style;
299     }
300
301     /**
302      * Set the to date attribute.
303      * @param toDate the value to use.
304      */

305     protected void setInternalToDate(final String JavaDoc toDate) {
306         this.toDate = toDate;
307     }
308
309     /**
310      * Set the to label attribute.
311      * @param toLabel the value to use.
312      */

313     protected void setInternalToLabel(final String JavaDoc toLabel) {
314         this.toLabel = toLabel;
315     }
316
317     /**
318      * Set the user attribute.
319      * @param user the value to use.
320      */

321     protected void setInternalUser(final String JavaDoc user) {
322         this.user = user;
323     }
324
325     /**
326      * Set the version attribute.
327      * @param version the value to use.
328      */

329     protected void setInternalVersion(final String JavaDoc version) {
330         this.version = version;
331     }
332
333     /**
334      * Set the writable attribute.
335      * @param writable the value to use.
336      */

337     protected void setInternalWritable(final boolean writable) {
338         this.writable = writable;
339     }
340
341     /**
342      * Set the timestamp attribute.
343      * @param timestamp the value to use.
344      */

345     protected void setInternalFileTimeStamp(final CurrentModUpdated timestamp) {
346         this.timestamp = timestamp;
347     }
348
349     /**
350      * Set the writableFiles attribute.
351      * @param writableFiles the value to use.
352      */

353     protected void setInternalWritableFiles(final WritableFiles writableFiles) {
354         this.writableFiles = writableFiles;
355     }
356
357     /**
358      * Set the getLocalCopy attribute.
359      * @param getLocalCopy the value to use.
360      */

361     protected void setInternalGetLocalCopy(final boolean getLocalCopy) {
362         this.getLocalCopy = getLocalCopy;
363     }
364
365     /**
366      * Gets the sscommand string. "ss" or "c:\path\to\ss"
367      * @return The path to ss.exe or just ss if sscommand is not set.
368      */

369     protected String JavaDoc getSSCommand() {
370         if (ssDir == null) {
371             return SS_EXE;
372         }
373         return ssDir.endsWith(File.separator) ? ssDir + SS_EXE : ssDir
374                  + File.separator + SS_EXE;
375     }
376
377     /**
378      * Gets the vssserverpath string.
379      * @return null if vssserverpath is not set.
380      */

381     protected String JavaDoc getVsspath() {
382         return vssPath;
383     }
384
385     /**
386      * Gets the quiet string. -O-
387      * @return An empty string if quiet is not set or is false.
388      */

389     protected String JavaDoc getQuiet() {
390         return quiet ? FLAG_QUIET : "";
391     }
392
393     /**
394      * Gets the recursive string. "-R"
395      * @return An empty string if recursive is not set or is false.
396      */

397     protected String JavaDoc getRecursive() {
398         return recursive ? FLAG_RECURSION : "";
399     }
400
401     /**
402      * Gets the writable string. "-W"
403      * @return An empty string if writable is not set or is false.
404      */

405     protected String JavaDoc getWritable() {
406         return writable ? FLAG_WRITABLE : "";
407     }
408
409     /**
410      * Gets the label string. "-Lbuild1"
411      * Max label length is 32 chars
412      * @return An empty string if label is not set.
413      */

414     protected String JavaDoc getLabel() {
415         String JavaDoc shortLabel = "";
416         if (label != null && label.length() > 0) {
417                 shortLabel = FLAG_LABEL + getShortLabel();
418         }
419         return shortLabel;
420     }
421     /**
422      * Return at most the 30 first chars of the label,
423      * logging a warning message about the truncation
424      * @return at most the 30 first chars of the label
425      */

426     private String JavaDoc getShortLabel() {
427         String JavaDoc shortLabel;
428         if (label != null && label.length() > 31) {
429             shortLabel = this.label.substring(0, 30);
430             log("Label is longer than 31 characters, truncated to: " + shortLabel,
431                 Project.MSG_WARN);
432         } else {
433             shortLabel = label;
434         }
435         return shortLabel;
436     }
437     /**
438      * Gets the style string. "-Lbuild1"
439      * @return An empty string if label is not set.
440      */

441     protected String JavaDoc getStyle() {
442         return style != null ? style : "";
443     }
444
445     /**
446      * Gets the version string. Returns the first specified of version "-V1.0",
447      * date "-Vd01.01.01", label "-Vlbuild1".
448      * @return An empty string if a version, date and label are not set.
449      */

450     protected String JavaDoc getVersionDateLabel() {
451         String JavaDoc versionDateLabel = "";
452         if (version != null) {
453             versionDateLabel = FLAG_VERSION + version;
454         } else if (date != null) {
455             versionDateLabel = FLAG_VERSION_DATE + date;
456         } else {
457             // Use getShortLabel() so labels longer then 30 char are truncated
458
// and the user is warned
459
String JavaDoc shortLabel = getShortLabel();
460             if (shortLabel != null && !shortLabel.equals("")) {
461                 versionDateLabel = FLAG_VERSION_LABEL + shortLabel;
462             }
463         }
464         return versionDateLabel;
465     }
466
467     /**
468      * Gets the version string.
469      * @return An empty string if a version is not set.
470      */

471     protected String JavaDoc getVersion() {
472         return version != null ? FLAG_VERSION + version : "";
473     }
474
475     /**
476      * Gets the localpath string. "-GLc:\source" <p>
477      * The localpath is created if it didn't exist.
478      * @return An empty string if localpath is not set.
479      */

480     protected String JavaDoc getLocalpath() {
481         String JavaDoc lclPath = ""; //set to empty str if no local path return
482
if (localPath != null) {
483             //make sure m_LocalDir exists, create it if it doesn't
484
File JavaDoc dir = getProject().resolveFile(localPath);
485             if (!dir.exists()) {
486                 boolean done = dir.mkdirs();
487                 if (!done) {
488                     String JavaDoc msg = "Directory " + localPath + " creation was not "
489                             + "successful for an unknown reason";
490                     throw new BuildException(msg, getLocation());
491                 }
492                 getProject().log("Created dir: " + dir.getAbsolutePath());
493             }
494             lclPath = FLAG_OVERRIDE_WORKING_DIR + localPath;
495         }
496         return lclPath;
497     }
498
499     /**
500      * Gets the comment string. "-Ccomment text"
501      * @return A comment of "-" if comment is not set.
502      */

503     protected String JavaDoc getComment() {
504         return comment != null ? FLAG_COMMENT + comment : FLAG_COMMENT + "-";
505     }
506
507     /**
508      * Gets the auto response string. This can be Y "-I-Y" or N "-I-N".
509      * @return The default value "-I-" if autoresponse is not set.
510      */

511     protected String JavaDoc getAutoresponse() {
512         if (autoResponse == null) {
513             return FLAG_AUTORESPONSE_DEF;
514         } else if (autoResponse.equalsIgnoreCase("Y")) {
515             return FLAG_AUTORESPONSE_YES;
516         } else if (autoResponse.equalsIgnoreCase("N")) {
517             return FLAG_AUTORESPONSE_NO;
518         } else {
519             return FLAG_AUTORESPONSE_DEF;
520         }
521     }
522
523     /**
524      * Gets the login string. This can be user and password, "-Yuser,password"
525      * or just user "-Yuser".
526      * @return An empty string if login is not set.
527      */

528     protected String JavaDoc getLogin() {
529         return vssLogin != null ? FLAG_LOGIN + vssLogin : "";
530     }
531
532     /**
533      * Gets the output file string. "-Ooutput.file"
534      * @return An empty string if user is not set.
535      */

536     protected String JavaDoc getOutput() {
537         return outputFileName != null ? FLAG_OUTPUT + outputFileName : "";
538     }
539
540     /**
541      * Gets the user string. "-Uusername"
542      * @return An empty string if user is not set.
543      */

544     protected String JavaDoc getUser() {
545         return user != null ? FLAG_USER + user : "";
546     }
547
548     /**
549      * Gets the version string. This can be to-from "-VLbuild2~Lbuild1", from
550      * "~Lbuild1" or to "-VLbuild2".
551      * @return An empty string if neither tolabel or fromlabel are set.
552      */

553     protected String JavaDoc getVersionLabel() {
554         if (fromLabel == null && toLabel == null) {
555             return "";
556         }
557         if (fromLabel != null && toLabel != null) {
558             if (fromLabel.length() > 31) {
559                 fromLabel = fromLabel.substring(0, 30);
560                 log("FromLabel is longer than 31 characters, truncated to: "
561                     + fromLabel, Project.MSG_WARN);
562             }
563             if (toLabel.length() > 31) {
564                 toLabel = toLabel.substring(0, 30);
565                 log("ToLabel is longer than 31 characters, truncated to: "
566                     + toLabel, Project.MSG_WARN);
567             }
568             return FLAG_VERSION_LABEL + toLabel + VALUE_FROMLABEL + fromLabel;
569         } else if (fromLabel != null) {
570             if (fromLabel.length() > 31) {
571                 fromLabel = fromLabel.substring(0, 30);
572                 log("FromLabel is longer than 31 characters, truncated to: "
573                     + fromLabel, Project.MSG_WARN);
574             }
575             return FLAG_VERSION + VALUE_FROMLABEL + fromLabel;
576         } else {
577             if (toLabel.length() > 31) {
578                 toLabel = toLabel.substring(0, 30);
579                 log("ToLabel is longer than 31 characters, truncated to: "
580                     + toLabel, Project.MSG_WARN);
581             }
582             return FLAG_VERSION_LABEL + toLabel;
583         }
584     }
585
586     /**
587      * Gets the Version date string.
588      * @return An empty string if neither Todate or from date are set.
589      * @throws BuildException if there is an error.
590      */

591     protected String JavaDoc getVersionDate() throws BuildException {
592         if (fromDate == null && toDate == null
593             && numDays == Integer.MIN_VALUE) {
594             return "";
595         }
596         if (fromDate != null && toDate != null) {
597             return FLAG_VERSION_DATE + toDate + VALUE_FROMDATE + fromDate;
598         } else if (toDate != null && numDays != Integer.MIN_VALUE) {
599             try {
600                 return FLAG_VERSION_DATE + toDate + VALUE_FROMDATE
601                         + calcDate(toDate, numDays);
602             } catch (ParseException JavaDoc ex) {
603                 String JavaDoc msg = "Error parsing date: " + toDate;
604                 throw new BuildException(msg, getLocation());
605             }
606         } else if (fromDate != null && numDays != Integer.MIN_VALUE) {
607             try {
608                 return FLAG_VERSION_DATE + calcDate(fromDate, numDays)
609                         + VALUE_FROMDATE + fromDate;
610             } catch (ParseException JavaDoc ex) {
611                 String JavaDoc msg = "Error parsing date: " + fromDate;
612                 throw new BuildException(msg, getLocation());
613             }
614         } else {
615             return fromDate != null ? FLAG_VERSION + VALUE_FROMDATE
616                     + fromDate : FLAG_VERSION_DATE + toDate;
617         }
618     }
619
620     /**
621      * Builds and returns the -G- flag if required.
622      * @return An empty string if get local copy is true.
623      */

624     protected String JavaDoc getGetLocalCopy() {
625         return (!getLocalCopy) ? FLAG_NO_GET : "";
626     }
627
628     /**
629      * Gets the value of the fail on error flag.
630      * @return True if the FailOnError flag has been set or if 'writablefiles=skip'.
631      */

632     private boolean getFailOnError() {
633         return getWritableFiles().equals(WRITABLE_SKIP) ? false : failOnError;
634     }
635
636
637     /**
638      * Gets the value set for the FileTimeStamp.
639      * if it equals "current" then we return -GTC
640      * if it equals "modified" then we return -GTM
641      * if it equals "updated" then we return -GTU
642      * otherwise we return -GTC
643      *
644      * @return The default file time flag, if not set.
645      */

646     public String JavaDoc getFileTimeStamp() {
647         if (timestamp == null) {
648             return "";
649         } else if (timestamp.getValue().equals(TIME_MODIFIED)) {
650             return FLAG_FILETIME_MODIFIED;
651         } else if (timestamp.getValue().equals(TIME_UPDATED)) {
652             return FLAG_FILETIME_UPDATED;
653         } else {
654             return FLAG_FILETIME_DEF;
655         }
656     }
657
658
659     /**
660      * Gets the value to determine the behaviour when encountering writable files.
661      * @return An empty String, if not set.
662      */

663     public String JavaDoc getWritableFiles() {
664         if (writableFiles == null) {
665             return "";
666         } else if (writableFiles.getValue().equals(WRITABLE_REPLACE)) {
667             return FLAG_REPLACE_WRITABLE;
668         } else if (writableFiles.getValue().equals(WRITABLE_SKIP)) {
669             // ss.exe exits with '100', when files have been skipped
670
// so we have to ignore the failure
671
failOnError = false;
672             return FLAG_SKIP_WRITABLE;
673         } else {
674             return "";
675         }
676     }
677
678     /**
679      * Sets up the required environment and executes the command line.
680      *
681      * @param cmd The command line to execute.
682      * @return The return code from the exec'd process.
683      */

684     private int run(Commandline cmd) {
685         try {
686             Execute exe = new Execute(new LogStreamHandler(this,
687                     Project.MSG_INFO,
688                     Project.MSG_WARN));
689
690             // If location of ss.ini is specified we need to set the
691
// environment-variable SSDIR to this value
692
if (serverPath != null) {
693                 String JavaDoc[] env = exe.getEnvironment();
694                 if (env == null) {
695                     env = new String JavaDoc[0];
696                 }
697                 String JavaDoc[] newEnv = new String JavaDoc[env.length + 1];
698                 System.arraycopy(env, 0, newEnv, 0, env.length);
699                 newEnv[env.length] = "SSDIR=" + serverPath;
700
701                 exe.setEnvironment(newEnv);
702             }
703
704             exe.setAntRun(getProject());
705             exe.setWorkingDirectory(getProject().getBaseDir());
706             exe.setCommandline(cmd.getCommandline());
707             // Use the OS launcher so we get environment variables
708
exe.setVMLauncher(false);
709             return exe.execute();
710         } catch (IOException JavaDoc e) {
711             throw new BuildException(e, getLocation());
712         }
713     }
714
715      /**
716      * Calculates the start date for version comparison.
717      * <p>
718      * Calculates the date numDay days earlier than startdate.
719      * @param startDate The start date.
720      * @param daysToAdd The number of days to add.
721      * @return The calculated date.
722      * @throws ParseException
723      */

724     private String JavaDoc calcDate(String JavaDoc startDate, int daysToAdd) throws ParseException JavaDoc {
725         Calendar JavaDoc calendar = new GregorianCalendar JavaDoc();
726         Date JavaDoc currentDate = dateFormat.parse(startDate);
727         calendar.setTime(currentDate);
728         calendar.add(Calendar.DATE, daysToAdd);
729         return dateFormat.format(calendar.getTime());
730     }
731
732     /**
733      * Changes the password to '***' so it isn't displayed on screen if the build fails
734      *
735      * @param cmd The command line to clean
736      * @return The command line as a string with out the password
737      */

738     private String JavaDoc formatCommandLine(Commandline cmd) {
739         StringBuffer JavaDoc sBuff = new StringBuffer JavaDoc(cmd.toString());
740         int indexUser = sBuff.substring(0).indexOf(FLAG_LOGIN);
741         if (indexUser > 0) {
742             int indexPass = sBuff.substring(0).indexOf(",", indexUser);
743             int indexAfterPass = sBuff.substring(0).indexOf(" ", indexPass);
744
745             for (int i = indexPass + 1; i < indexAfterPass; i++) {
746                 sBuff.setCharAt(i, '*');
747             }
748         }
749         return sBuff.toString();
750     }
751
752     /**
753      * Extention of EnumeratedAttribute to hold the values for file time stamp.
754      */

755     public static class CurrentModUpdated extends EnumeratedAttribute {
756         /**
757          * Gets the list of allowable values.
758          * @return The values.
759          */

760         public String JavaDoc[] getValues() {
761             return new String JavaDoc[] {TIME_CURRENT, TIME_MODIFIED, TIME_UPDATED};
762         }
763     }
764
765     /**
766      * Extention of EnumeratedAttribute to hold the values for writable filess.
767      */

768     public static class WritableFiles extends EnumeratedAttribute {
769         /**
770          * Gets the list of allowable values.
771          * @return The values.
772          */

773         public String JavaDoc[] getValues() {
774             return new String JavaDoc[] {WRITABLE_REPLACE, WRITABLE_SKIP, WRITABLE_FAIL};
775         }
776     }
777 }
778
Popular Tags