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

📄 dependendjava.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of// the Infozone Software License version 2 published by the Infozone Group// (http://www.infozone-group.org).//// Copyright (C) @year@ by The Infozone Group. All rights reserved.//// $Id: DependendJava.java,v 1.1 2002/05/10 08:59:12 per_nyfelt Exp $package org.infozone.tools.ant;import org.apache.tools.ant.BuildException;import org.apache.tools.ant.taskdefs.Java;import org.apache.tools.ant.Project;import java.io.File;import java.io.IOException;/** * ANT cannot handle the dependency of source files from a definition file. * This ability is needed if one will generate source files with castor. * This module solves this problem. * * @version $Revision: 1.1 $ * @author andreas.kasparz@interface-projects.de */public class DependendJava extends Java {    //    // Data    //    /** the filename of the target */    private	String	_target = null;    /** the filename or directory the target depends on */    private	String	_source = null;    /**     * Check if the target is older than the source file or not exists.     * @param target the target     * @param source the source file     */    private boolean isOlder( String source, String target ) throws BuildException {        File f_src = new File( source );        if( !(f_src.exists() && (f_src.isFile() || f_src.isDirectory())) )            throw new BuildException("Source [[" + source + "]] doesn't exists or isn't a regular entry");            File f_dst = new File( target );        if( !(f_dst.exists()))            return true; // non existing target is ok        if ( f_dst.isDirectory() ) {            target = target + File.separator + ".depend";            f_dst = new File (target);            if( !(f_dst.exists()))                return true; // again, non existing (modified) target is ok            }        if( !(f_dst.isFile()) )            throw new BuildException("Target [[" + target + "]] isn't a regular entry");        return f_src.lastModified() > f_dst.lastModified();    }    /**     * Touch the target file.     * @param target the target to touch.     */    private void touch( String target ) throws BuildException {        File f_dst = new File( target );        // if the target is a directory, modify the target to point to a hidden file        if( f_dst.exists() ) {            if ( f_dst.isDirectory() ) {                target = target + File.separator + ".depend";                f_dst = new File (target);            }        }        else            return; // do nothing if target does not exist                    if( f_dst.exists() ) {            f_dst.setLastModified( System.currentTimeMillis() );        }        else {            try {                // JDK 1.2 dependency :-(                f_dst.createNewFile();            } catch (IOException e) {                // simply ignore this exception            }                    }    }    /**     * Execute the task. this function will be called by the ANT build system.     * The work will be made by the ANT internal 'Java' task. We create one,     * give them the needed parameters and execute them.     */    public void execute() throws BuildException {        if( isOlder( _source, _target ) ) {            super.execute();            touch( _target );        }        else {            System.out.println("Nothing to be done for this dependency: " + _source + Project.MSG_INFO);            //log ("Nothing to be done for this dependency: " + _source, Project.MSG_INFO);        }    }    /**     * @param s The target name.     */    public void setTarget( String s ) {        _target = s;    }    /**     * @param s The file name of the source file     */    public void setDependsOn( String s ) {        _source = s;    }}

⌨️ 快捷键说明

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