⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msvss.java

📁 Use the links below to download a source distribution of Ant from one of our mirrors. It is good pra
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }    /**     * Gets the recursive string. "-R"     * @return An empty string if recursive is not set or is false.     */    protected String getRecursive() {        return recursive ? FLAG_RECURSION : "";    }    /**     * Gets the writable string. "-W"     * @return An empty string if writable is not set or is false.     */    protected String getWritable() {        return writable ? FLAG_WRITABLE : "";    }    /**     * Gets the label string. "-Lbuild1"     * Max label length is 32 chars     * @return An empty string if label is not set.     */    protected String getLabel() {        String shortLabel = "";        if (label != null && label.length() > 0) {                shortLabel = FLAG_LABEL + getShortLabel();        }        return shortLabel;    }    /**     * Return at most the 30 first chars of the label,     * logging a warning message about the truncation     * @return at most the 30 first chars of the label     */    private String getShortLabel() {        String shortLabel;        // CheckStyle:MagicNumber OFF        if (label !=  null && label.length() > 31) {            shortLabel = this.label.substring(0, 30);            log("Label is longer than 31 characters, truncated to: " + shortLabel,                Project.MSG_WARN);        } else {            shortLabel = label;        }        // CheckStyle:MagicNumber ON        return shortLabel;    }    /**     * Gets the style string. "-Lbuild1"     * @return An empty string if label is not set.     */    protected String getStyle() {        return style != null ? style : "";    }    /**     * Gets the version string. Returns the first specified of version "-V1.0",     * date "-Vd01.01.01", label "-Vlbuild1".     * @return An empty string if a version, date and label are not set.     */    protected String getVersionDateLabel() {        String versionDateLabel = "";        if (version != null) {            versionDateLabel = FLAG_VERSION + version;        } else if (date != null) {            versionDateLabel = FLAG_VERSION_DATE + date;        } else {            // Use getShortLabel() so labels longer then 30 char are truncated            // and the user is warned            String shortLabel = getShortLabel();            if (shortLabel != null && !shortLabel.equals("")) {                versionDateLabel = FLAG_VERSION_LABEL + shortLabel;            }        }        return versionDateLabel;    }    /**     * Gets the version string.     * @return An empty string if a version is not set.     */    protected String getVersion() {        return version != null ? FLAG_VERSION + version : "";    }    /**     * Gets the localpath string. "-GLc:\source" <p>     * The localpath is created if it didn't exist.     * @return An empty string if localpath is not set.     */    protected String getLocalpath() {        String lclPath = ""; //set to empty str if no local path return        if (localPath != null) {            //make sure m_LocalDir exists, create it if it doesn't            File dir = getProject().resolveFile(localPath);            if (!dir.exists()) {                boolean done = dir.mkdirs();                if (!done) {                    String msg = "Directory " + localPath + " creation was not "                            + "successful for an unknown reason";                    throw new BuildException(msg, getLocation());                }                getProject().log("Created dir: " + dir.getAbsolutePath());            }            lclPath = FLAG_OVERRIDE_WORKING_DIR + localPath;        }        return lclPath;    }    /**     * Gets the comment string. "-Ccomment text"     * @return A comment of "-" if comment is not set.     */    protected String getComment() {        return comment != null ? FLAG_COMMENT + comment : FLAG_COMMENT + "-";    }    /**     * Gets the auto response string. This can be Y "-I-Y" or N "-I-N".     * @return The default value "-I-" if autoresponse is not set.     */    protected String getAutoresponse() {        if (autoResponse == null) {            return FLAG_AUTORESPONSE_DEF;        } else if (autoResponse.equalsIgnoreCase("Y")) {            return FLAG_AUTORESPONSE_YES;        } else if (autoResponse.equalsIgnoreCase("N")) {            return FLAG_AUTORESPONSE_NO;        } else {            return FLAG_AUTORESPONSE_DEF;        }    }    /**     * Gets the login string. This can be user and password, "-Yuser,password"     * or just user "-Yuser".     * @return An empty string if login is not set.     */    protected String getLogin() {        return vssLogin != null ? FLAG_LOGIN + vssLogin : "";    }    /**     * Gets the output file string. "-Ooutput.file"     * @return An empty string if user is not set.     */    protected String getOutput() {        return outputFileName != null ? FLAG_OUTPUT + outputFileName : "";    }    /**     * Gets the user string. "-Uusername"     * @return An empty string if user is not set.     */    protected String getUser() {        return user != null ? FLAG_USER + user : "";    }    /**     * Gets the version string. This can be to-from "-VLbuild2~Lbuild1", from     * "~Lbuild1" or to "-VLbuild2".     * @return An empty string if neither tolabel or fromlabel are set.     */    protected String getVersionLabel() {        if (fromLabel == null && toLabel == null) {            return "";        }        // CheckStyle:MagicNumber OFF        if (fromLabel != null && toLabel != null) {            if (fromLabel.length() > 31) {                fromLabel = fromLabel.substring(0, 30);                log("FromLabel is longer than 31 characters, truncated to: "                    + fromLabel, Project.MSG_WARN);            }            if (toLabel.length() > 31) {                toLabel = toLabel.substring(0, 30);                log("ToLabel is longer than 31 characters, truncated to: "                    + toLabel, Project.MSG_WARN);            }            return FLAG_VERSION_LABEL + toLabel + VALUE_FROMLABEL + fromLabel;        } else if (fromLabel != null) {            if (fromLabel.length() > 31) {                fromLabel = fromLabel.substring(0, 30);                log("FromLabel is longer than 31 characters, truncated to: "                    + fromLabel, Project.MSG_WARN);            }            return FLAG_VERSION + VALUE_FROMLABEL + fromLabel;        } else {            if (toLabel.length() > 31) {                toLabel = toLabel.substring(0, 30);                log("ToLabel is longer than 31 characters, truncated to: "                    + toLabel, Project.MSG_WARN);            }            return FLAG_VERSION_LABEL + toLabel;        }        // CheckStyle:MagicNumber ON    }    /**     * Gets the Version date string.     * @return An empty string if neither Todate or from date are set.     * @throws BuildException if there is an error.     */    protected String getVersionDate() throws BuildException {        if (fromDate == null && toDate == null            && numDays == Integer.MIN_VALUE) {            return "";        }        if (fromDate != null && toDate != null) {            return FLAG_VERSION_DATE + toDate + VALUE_FROMDATE + fromDate;        } else if (toDate != null && numDays != Integer.MIN_VALUE) {            try {                return FLAG_VERSION_DATE + toDate + VALUE_FROMDATE                        + calcDate(toDate, numDays);            } catch (ParseException ex) {                String msg = "Error parsing date: " + toDate;                throw new BuildException(msg, getLocation());            }        } else if (fromDate != null && numDays != Integer.MIN_VALUE) {            try {                return FLAG_VERSION_DATE + calcDate(fromDate, numDays)                        + VALUE_FROMDATE + fromDate;            } catch (ParseException ex) {                String msg = "Error parsing date: " + fromDate;                throw new BuildException(msg, getLocation());            }        } else {            return fromDate != null ? FLAG_VERSION + VALUE_FROMDATE                    + fromDate : FLAG_VERSION_DATE + toDate;        }    }    /**     * Builds and returns the -G- flag if required.     * @return An empty string if get local copy is true.     */    protected String getGetLocalCopy() {        return (!getLocalCopy) ? FLAG_NO_GET : "";    }    /**     * Gets the value of the fail on error flag.     * @return    True if the FailOnError flag has been set or if 'writablefiles=skip'.     */    private boolean getFailOnError() {        return getWritableFiles().equals(WRITABLE_SKIP) ? false : failOnError;    }    /**     * Gets the value set for the FileTimeStamp.     * if it equals "current" then we return -GTC     * if it equals "modified" then we return -GTM     * if it equals "updated" then we return -GTU     * otherwise we return -GTC     *     * @return The default file time flag, if not set.     */    public String getFileTimeStamp() {        if (timestamp == null) {            return "";        } else if (timestamp.getValue().equals(TIME_MODIFIED)) {            return FLAG_FILETIME_MODIFIED;        } else if (timestamp.getValue().equals(TIME_UPDATED)) {            return FLAG_FILETIME_UPDATED;        } else {            return FLAG_FILETIME_DEF;        }    }    /**     * Gets the value to determine the behaviour when encountering writable files.     * @return An empty String, if not set.     */    public String getWritableFiles() {        if (writableFiles == null) {            return "";        } else if (writableFiles.getValue().equals(WRITABLE_REPLACE)) {            return FLAG_REPLACE_WRITABLE;        } else if (writableFiles.getValue().equals(WRITABLE_SKIP)) {            // ss.exe exits with '100', when files have been skipped            // so we have to ignore the failure            failOnError = false;            return FLAG_SKIP_WRITABLE;        } else {            return "";        }    }    /**     *  Sets up the required environment and executes the command line.     *     * @param  cmd  The command line to execute.     * @return      The return code from the exec'd process.     */    private int run(Commandline cmd) {        try {            Execute exe = new Execute(new LogStreamHandler(this,                    Project.MSG_INFO,                    Project.MSG_WARN));            // If location of ss.ini is specified we need to set the            // environment-variable SSDIR to this value            if (serverPath != null) {                String[] env = exe.getEnvironment();                if (env == null) {                    env = new String[0];                }                String[] newEnv = new String[env.length + 1];                System.arraycopy(env, 0, newEnv, 0, env.length);                newEnv[env.length] = "SSDIR=" + serverPath;                exe.setEnvironment(newEnv);            }            exe.setAntRun(getProject());            exe.setWorkingDirectory(getProject().getBaseDir());            exe.setCommandline(cmd.getCommandline());            // Use the OS launcher so we get environment variables            exe.setVMLauncher(false);            return exe.execute();        } catch (IOException e) {            throw new BuildException(e, getLocation());        }    }     /**     * Calculates the start date for version comparison.     * <p>     * Calculates the date numDay days earlier than startdate.     * @param   startDate    The start date.     * @param   daysToAdd     The number of days to add.     * @return The calculated date.     * @throws ParseException     */    private String calcDate(String startDate, int daysToAdd) throws ParseException {        Calendar calendar = new GregorianCalendar();        Date currentDate = dateFormat.parse(startDate);        calendar.setTime(currentDate);        calendar.add(Calendar.DATE, daysToAdd);        return dateFormat.format(calendar.getTime());    }    /**     * Changes the password to '***' so it isn't displayed on screen if the build fails     *     * @param cmd   The command line to clean     * @return The command line as a string with out the password     */    private String formatCommandLine(Commandline cmd) {        StringBuffer sBuff = new StringBuffer(cmd.toString());        int indexUser = sBuff.substring(0).indexOf(FLAG_LOGIN);        if (indexUser > 0) {            int indexPass = sBuff.substring(0).indexOf(",", indexUser);            int indexAfterPass = sBuff.substring(0).indexOf(" ", indexPass);            for (int i = indexPass + 1; i < indexAfterPass; i++) {                sBuff.setCharAt(i, '*');            }        }        return sBuff.toString();    }    /**     * Extention of EnumeratedAttribute to hold the values for file time stamp.     */    public static class CurrentModUpdated extends EnumeratedAttribute {        /**         * Gets the list of allowable values.         * @return The values.         */        public String[] getValues() {            return new String[] {TIME_CURRENT, TIME_MODIFIED, TIME_UPDATED};        }    }    /**     * Extention of EnumeratedAttribute to hold the values for writable filess.     */    public static class WritableFiles extends EnumeratedAttribute {        /**         * Gets the list of allowable values.         * @return The values.         */        public String[] getValues() {            return new String[] {WRITABLE_REPLACE, WRITABLE_SKIP, WRITABLE_FAIL};        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -