Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Apache Ant Source Code Files
Apache Ant Source Code Files are inside the Apache Ant source package file like apache-ant-1.10.10-src.zip. Unzip the source package file and go to the "src/main" sub-directory, you will see source code files.
Here is the list of Java source code files of the Apache Ant 1.10.10 in \Users\fyicenter\apache-ant-1.10.10\src\main:
✍: FYIcenter.com
⏎ org/apache/tools/ant/taskdefs/condition/IsLastModified.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.apache.tools.ant.taskdefs.condition; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.taskdefs.Touch; import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.Resource; /** * Condition that makes assertions about the last modified date of a * resource. * * @since Ant 1.8.0 */ public class IsLastModified extends ProjectComponent implements Condition { private long millis = -1; private String dateTime = null; private Touch.DateFormatFactory dfFactory = Touch.DEFAULT_DF_FACTORY; private Resource resource; private CompareMode mode = CompareMode.EQUALS; /** * Set the new modification time of file(s) touched * in milliseconds since midnight Jan 1 1970. * @param millis the <code>long</code> timestamp to use. */ public void setMillis(long millis) { this.millis = millis; } /** * Set the new modification time of file(s) touched * in the format "MM/DD/YYYY HH:MM AM <i>or</i> PM" * or "MM/DD/YYYY HH:MM:SS AM <i>or</i> PM". * @param dateTime the <code>String</code> date in the specified format. */ public void setDatetime(String dateTime) { this.dateTime = dateTime; } /** * Set the format of the datetime attribute. * @param pattern the <code>SimpleDateFormat</code>-compatible * format pattern. */ public void setPattern(final String pattern) { dfFactory = new Touch.DateFormatFactory() { @Override public DateFormat getPrimaryFormat() { return new SimpleDateFormat(pattern); } @Override public DateFormat getFallbackFormat() { return null; } }; } /** * The resource to test. * @param r the resource to test */ public void add(Resource r) { if (resource != null) { throw new BuildException("only one resource can be tested"); } resource = r; } /** * The type of comparison to test. * @param mode the mode of comparison. */ public void setMode(CompareMode mode) { this.mode = mode; } /** * Argument validation. * @throws BuildException if the required attributes are not supplied or * if there is an inconsistency in the attributes. */ protected void validate() throws BuildException { if (millis >= 0 && dateTime != null) { throw new BuildException( "Only one of dateTime and millis can be set"); } if (millis < 0 && dateTime == null) { throw new BuildException("millis or dateTime is required"); } if (resource == null) { throw new BuildException("resource is required"); } } /** * Calculate timestamp as millis either based on millis or * dateTime (and pattern) attribute. * @return time in milliseconds * @throws BuildException if the date cannot be parsed. */ protected long getMillis() throws BuildException { if (millis >= 0) { return millis; } if ("now".equalsIgnoreCase(dateTime)) { return System.currentTimeMillis(); } DateFormat df = dfFactory.getPrimaryFormat(); ParseException pe; try { return df.parse(dateTime).getTime(); } catch (ParseException peOne) { df = dfFactory.getFallbackFormat(); if (df == null) { pe = peOne; } else { try { return df.parse(dateTime).getTime(); } catch (ParseException peTwo) { pe = peTwo; } } } throw new BuildException(pe.getMessage(), pe, getLocation()); } /** * evaluate the condition * @return true or false depending on the comparison mode and the time of the resource * @throws BuildException if something goes wrong */ @Override public boolean eval() throws BuildException { validate(); long expected = getMillis(); long actual = resource.getLastModified(); log("expected timestamp: " + expected + " (" + new Date(expected) + ")" + ", actual timestamp: " + actual + " (" + new Date(actual) + ")", Project.MSG_VERBOSE); if (CompareMode.EQUALS_TEXT.equals(mode.getValue())) { return expected == actual; } if (CompareMode.BEFORE_TEXT.equals(mode.getValue())) { return expected > actual; } if (CompareMode.NOT_BEFORE_TEXT.equals(mode.getValue())) { return expected <= actual; } if (CompareMode.AFTER_TEXT.equals(mode.getValue())) { return expected < actual; } if (CompareMode.NOT_AFTER_TEXT.equals(mode.getValue())) { return expected >= actual; } throw new BuildException("Unknown mode " + mode.getValue()); } /** * describes comparison modes. */ public static class CompareMode extends EnumeratedAttribute { private static final String EQUALS_TEXT = "equals"; private static final String BEFORE_TEXT = "before"; private static final String AFTER_TEXT = "after"; private static final String NOT_BEFORE_TEXT = "not-before"; private static final String NOT_AFTER_TEXT = "not-after"; private static final CompareMode EQUALS = new CompareMode(EQUALS_TEXT); /** * creates a CompareMode instance of type equals */ public CompareMode() { this(EQUALS_TEXT); } /** * creates a comparemode instance * @param s one of the authorized values for comparemode */ public CompareMode(String s) { super(); setValue(s); } /** {@inheritDoc}. */ @Override public String[] getValues() { return new String[] { EQUALS_TEXT, BEFORE_TEXT, AFTER_TEXT, NOT_BEFORE_TEXT, NOT_AFTER_TEXT, }; } } }
⏎ org/apache/tools/ant/taskdefs/condition/IsLastModified.java
Or download all of them as a single archive file:
File name: apache-ant-1.10.10-fyi.zip File size: 2392938 bytes Release date: 2021-04-17 Download
⇐ Download Apache Ant Source Package
2021-07-10, 110169👍, 0💬
Popular Posts:
HttpComponents Core Source Code Files are provided in the source package file, httpcomponents-core-5...
What Is ojdbc5.jar for Oracle 11g R1? ojdbc5.jar for Oracle 11g R1 is the JAR files of ojdbc.jar, JD...
ASM is an all purpose Java bytecode manipulation and analysis framework. It can be used to modify ex...
ZooKeeper is a centralized service for maintaining configuration information, naming, providing dist...
Apache Log4j SLF4J Binding allows applications coded to the SLF4J API to use Log4j 2 as the implemen...