001package com.hfg.anttask;
002
003import org.apache.tools.ant.Project;
004
005//------------------------------------------------------------------------------
006/**
007 Common utility methods for ant tasks.
008 <div>
009 @author J. Alex Taylor, hairyfatguy.com
010 </div>
011 */
012//------------------------------------------------------------------------------
013// com.hfg XML/HTML Coding Library
014//
015// This library is free software; you can redistribute it and/or
016// modify it under the terms of the GNU Lesser General Public
017// License as published by the Free Software Foundation; either
018// version 2.1 of the License, or (at your option) any later version.
019//
020// This library is distributed in the hope that it will be useful,
021// but WITHOUT ANY WARRANTY; without even the implied warranty of
022// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
023// Lesser General Public License for more details.
024//
025// You should have received a copy of the GNU Lesser General Public
026// License along with this library; if not, write to the Free Software
027// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
028//
029// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
030// jataylor@hairyfatguy.com
031//------------------------------------------------------------------------------
032
033public class TaskUtil
034{
035   //---------------------------------------------------------------------------
036   /**
037    * test the if condition
038    * @param inValue the property to check for its existence
039    * @param inProject the project in which to check for the property
040    * @return true if there is no if condition, or the named property exists
041    */
042   public static boolean testIfCondition(String inValue, Project inProject)
043   {
044      if (inValue == null || "".equals(inValue))
045      {
046         return true;
047      }
048      return inProject.getProperty(inValue) != null;
049   }
050
051   //---------------------------------------------------------------------------
052   /**
053    * test the unless condition
054    * @param inValue the property to check for its existence
055    * @param inProject the project in which to check for the property
056    * @return true if there is no unless condition,
057    *  or there is a named property but it doesn't exist
058    */
059   public static boolean testUnlessCondition(String inValue, Project inProject)
060   {
061      if (inValue == null || "".equals(inValue))
062      {
063         return true;
064      }
065      return inProject.getProperty(inValue) == null;
066   }
067}