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

📄 wsdltodotnet.java

📁 java ant的源码!非常值得看的源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        command.addArgument("/out:" + destFile);        command.addArgument("/language:", language);        if (server) {            command.addArgument("/server");        }        command.addArgument("/namespace:", namespace);        if (protocol != null) {            command.addArgument("/protocol:" + protocol);        }        if (ideErrors) {            command.addArgument("/parsableErrors");        }        command.addArgument(extraOptions);        //set source and rebuild options        boolean rebuild = true;        long destLastModified = -1;        //rebuild unless the dest file is newer than the source file        if (destFile.exists()) {            destLastModified = destFile.lastModified();            rebuild = isRebuildNeeded(wsdl, destLastModified);        }        String path;        //mark for a rebuild if the dest file is newer        path = wsdl.evaluate();        if (!compiler.supportsAbsoluteFiles() && wsdl.getFile() != null) {            // Mono 1.0's wsdl doesn't deal with absolute paths            File f = wsdl.getFile();            command.setDirectory(f.getParentFile());            path = f.getName();        }        command.addArgument(path);        //add in any extra files.        //this is an error in mono, but we do not warn on it as they may fix that outside        //the ant build cycle.        Iterator it = schemas.iterator();        while (it.hasNext()) {            Schema schema = (Schema) it.next();            //mark for a rebuild if we are newer            rebuild |= isRebuildNeeded(schema, destLastModified);            command.addArgument(schema.evaluate());        }        //conditionally compile        if (rebuild) {            command.runCommand();        }    }    /**     * checks for a schema being out of data     * @param schema url/file     * @param destLastModified timestamp, -1 for no dest     * @return true if a rebuild is needed.     */    private boolean isRebuildNeeded(Schema schema, long destLastModified) {        if (destLastModified == -1) {            return true;        }        return !FILE_UTILS.isUpToDate(schema.getTimestamp(), destLastModified);    }    /**     * nested schema class     * Only supported on NET until mono add multi-URL handling on the command line     */    public static class Schema {        private File file;        private String url;        private boolean makeURL = false;        // Errors        /** One of file or url must be set */        public static final String ERROR_NONE_DECLARED = "One of file and url must be set";        /** Only one of file or url */        public static final String ERROR_BOTH_DECLARED = "Only one of file or url can be set";        /** Not found */        public static final String ERROR_FILE_NOT_FOUND = "Not found: ";        /** File is a directory */        public static final String ERROR_FILE_IS_DIR = "File is a directory: ";        /** Could not URL convert */        public static final String ERROR_NO_URL_CONVERT = "Could not URL convert ";        /**         * validate the schema         */        public  void validate() {            if (file != null) {                if (!file.exists()) {                    throw new BuildException(ERROR_FILE_NOT_FOUND + file.toString());                }                if (file.isDirectory()) {                    throw new BuildException(ERROR_FILE_IS_DIR + file.toString());                }            }            if (file != null && url != null) {                throw new BuildException(ERROR_BOTH_DECLARED);            }            if (file == null && url == null) {                throw new BuildException(ERROR_NONE_DECLARED);            }        }        /**         * Validate our settings.         * @return either the URL or the full file path         */        public String evaluate() {            validate();            if (url != null) {                return getUrl();            }            if (makeURL) {                try {                    return file.toURL().toExternalForm();                } catch (MalformedURLException e) {                    throw new BuildException(ERROR_NO_URL_CONVERT + file);                }            }            return file.toString();        }        /**         * Get the file.         * @return the file used.         */        public File getFile() {            return file;        }        /**         * name of a file to use as a source of WSDL or XSD data         * @param file the file to use.         */        public void setFile(File file) {            this.file = file;        }        /**         * Get the url.         * @return the URL of the resource.         */        public String getUrl() {            return url;        }        /**         * url of a resource.         * URLs have no timestamp checking, and are not validated         * @param url the URL string to use.         */        public void setUrl(String url) {            this.url = url;        }        /**         * Get the makeURL attribute.         * @return the attribute.         */        public boolean isMakeURL() {            return makeURL;        }        /**         * flag to request that a file is turned into an absolute file: URL         * before being passed to the WSDL compiler         * @param makeURL a <code>boolean</code> value.         */        public void setMakeURL(boolean makeURL) {            this.makeURL = makeURL;        }        /**         * Gets the file timestamp.         * @return the timestamp of a file, or -1 for a URL (meaning we do not know its age)         */        public long getTimestamp() {            if (file != null) {                return file.lastModified();            } else {                return -1;            }        }    }    /**     * The enumerated values for our compiler     */    public static class Compiler extends EnumeratedAttribute {        /** microsoft */        public static final String COMPILER_MS = "microsoft";        /** mono */        public static final String COMPILER_MONO = "mono";        /** microsoft-on-mono */        public static final String COMPILER_MS_ON_MONO = "microsoft-on-mono";        // CheckStyle:VisibilityModifier OFF - bc        /** the index to string mappings */        String[] compilers = {            COMPILER_MS,            COMPILER_MONO,            COMPILER_MS_ON_MONO        };        /** WSDL */        public static final String EXE_WSDL = "wsdl";        /** MONO */        public static final String EXE_MONO = "mono";        /**         * programs to run         */        String[] compilerExecutables = {            EXE_WSDL,            EXE_WSDL,            EXE_MONO        };        /**         * extra things         */        String[][] extraCompilerArgs = {            {},            {},            {EXE_WSDL + ".exe"}        };        boolean[] absoluteFiles = {            true,            false,            true        };        // CheckStyle:VisibilityModifier ON        /**         * This is the only method a subclass needs to implement.         *         * @return an array holding all possible values of the enumeration.         *         The order of elements must be fixed so that <tt>indexOfValue(String)</tt>         *         always return the same index for the same value.         */        public String[] getValues() {            return compilers;        }        /**         * Create the default compiler for this platform.         * @return the default compiler         */        public static Compiler createDefaultCompiler() {            Compiler c = new Compiler();            String compilerName;            compilerName = Os.isFamily("windows") ? COMPILER_MS : COMPILER_MONO;            c.setValue(compilerName);            return c;        }        /**         * return the command to run         * @return the command         */        public String getCommand() {            return compilerExecutables[getIndex()];        }        /**         * return any extra arguments for the compiler         * @return extra compiler arguments         */        public String[] getExtraArgs() {            return extraCompilerArgs[getIndex()];        }        /**         * Get where the current value supports absolute files.         * @return true if the compiler does supports absolute files.         */        public boolean supportsAbsoluteFiles() {            return absoluteFiles[getIndex()];        }        /**         * apply any extra arguments of this class         * @param command the command to apply the arguments to.         */        public void applyExtraArgs(NetCommand command) {            String[] args = getExtraArgs();            for (int i = 0; i < args.length; i++) {               command.addArgument(args[i]);            }        }    }}

⌨️ 快捷键说明

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