Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /antelope/src/ise/antelope/tasks/, /antelope/src/ise/antelope/tasks/typedefs/, /antelope/src/ise/antelope/tasks/typedefs/string/

antelope
Discussion topic

Hide all messages in topic

All messages in topic

CVS update: /antelope/src/ise/antelope/tasks/, /antelope/src/ise/antelope/tasks/typedefs/, /antelope/src/ise/antelope/tasks/typedefs/string/

Author danson
Full name Dale Anson
Date 2005-10-30 16:26:07 PST
Message User: danson
Date: 2005/10/30 16:26:07

Added:
   antelope/src/ise/ant​elope/tasks/UIDTask.​java
   antelope/src/ise/ant​elope/tasks/typedefs​/Prop.java
   antelope/src/ise/ant​elope/tasks/typedefs​/TimeUnit.java
   antelope/src/ise/ant​elope/tasks/typedefs​/string/IndexOf.java​
   antelope/src/ise/ant​elope/tasks/typedefs​/string/LastIndexOf.​java
   antelope/src/ise/ant​elope/tasks/typedefs​/string/Length.java
   antelope/src/ise/ant​elope/tasks/typedefs​/string/LowerCase.ja​va
   antelope/src/ise/ant​elope/tasks/typedefs​/string/MessageBox.j​ava
   antelope/src/ise/ant​elope/tasks/typedefs​/string/Replace.java​
   antelope/src/ise/ant​elope/tasks/typedefs​/string/Sort.java
   antelope/src/ise/ant​elope/tasks/typedefs​/string/StringOp.jav​a
   antelope/src/ise/ant​elope/tasks/typedefs​/string/Substring.ja​va
   antelope/src/ise/ant​elope/tasks/typedefs​/string/Trim.java
   antelope/src/ise/ant​elope/tasks/typedefs​/string/UpperCase.ja​va

Log:
 new tasks and package reorg.
 

File Changes:

Directory: /antelope/src/ise/an​telope/tasks/
====================​====================​====

File [added]: UIDTask.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/UIDTask​.java?rev=1.1&co​ntent-type=text/vnd.​viewcvs-markup
Added lines: 46
---------------
package ise.antelope.tasks;

import ise.antelope.tasks.typedefs.*;

import java.rmi.server.ObjID;
import java.rmi.server.UID;
import org.apache.tools.ant​.BuildException;

import org.apache.tools.ant.Task;

/**
 * A task to generate a unique ID.
 *
 * @author Dale Anson, danson at germane-software dot com
 * @since Ant 1.6
 * @version $Revision: 1.1 $
 */
public class UIDTask extends Task {


    private String name = null;
    private boolean asInt = false;

    /**
     * @param n a name for this UID
     */
    public void setName(String n) {
        name = n;
    }
    
    public void setInt(boolean b) {
        asInt = b;
    }

    /** Generate a unique id and store it in the project with the given name. */
    public void execute() {
        if (name == null)
            throw new BuildException("name attribute cannot be null");
        if (asInt)
            getProject().setProperty(name, String.valueOf(new ObjID().hashCode()));
        else
            getProject().setProperty(name, new UID().toString());
    }

}


Directory: /antelope/src/ise/an​telope/tasks/typedef​s/
====================​====================​=============

File [added]: Prop.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/typedef​s/Prop.java?rev=1.1​&content-type=tex​t/vnd.viewcvs-markup​
Added lines: 77
---------------
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache at apache dot org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================​====================​====================​========
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/

package ise.antelope.tasks.typedefs;

/**
 * Simple bean to represent a name/value pair.
 * @author Dale Anson
 */
public class Prop {
    private String name = null;
    private String value = null;
    public void setName( String name ) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
    public void setValue( String value ) {
        this.value = value;
    }
    public String getValue() {
        return value;
    }
}


File [added]: TimeUnit.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/typedef​s/TimeUnit.java?rev=​1.1&content-type​=text/vnd.viewcvs-ma​rkup
Added lines: 107
----------------

package ise.antelope.tasks.typedefs;

import java.util.*;
import org.apache.tools.ant​.types.EnumeratedAtt​ribute;

/**
 * The enumeration of units: millisecond, second, minute, hour, day, week,
 * month, year.
 *
 * @version $Revision: 1.1 $
 */
public class TimeUnit extends EnumeratedAttribute {

    public final static String MILLISECOND = "millisecond";
    public final static String SECOND = "second";
    public final static String MINUTE = "minute";
    public final static String HOUR = "hour";
    public final static String DAY = "day";
    public final static String WEEK = "week";
    public final static String MONTH = "month";
    public final static String YEAR = "year";

    /** static unit objects, for use as sensible defaults */
    public final static TimeUnit MILLISECOND_UNIT = new TimeUnit(MILLISECOND);
    public final static TimeUnit SECOND_UNIT = new TimeUnit(SECOND);
    public final static TimeUnit MINUTE_UNIT = new TimeUnit(MINUTE);
    public final static TimeUnit HOUR_UNIT = new TimeUnit(HOUR);
    public final static TimeUnit DAY_UNIT = new TimeUnit(DAY);
    public final static TimeUnit WEEK_UNIT = new TimeUnit(WEEK);

    private final static String[] units = {MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR};

    private Hashtable timeTable = new Hashtable();

    /** Constructor for TimeUnit */
    public TimeUnit() {
        timeTable.put(MILLISECOND, new Long(1L));
        timeTable.put(SECOND, new Long(1000L));
        timeTable.put(MINUTE, new Long(1000L * 60L));
        timeTable.put(HOUR, new Long(1000L * 60L * 60L));
        timeTable.put(DAY, new Long(1000L * 60L * 60L * 24L));
        timeTable.put(WEEK, new Long(1000L * 60L * 60L * 24L * 7L));
        
        // calculate month and year based on the current date
        Calendar now = Calendar.getInstance();
        long now_ms = now.getTimeInMillis();
        
        Calendar later = Calendar.getInstance();
        later.add(Calendar.MONTH, 1);
        timeTable.put(MONTH, new Long(later.getTimeInMillis() - now_ms));
        
        later.add(Calendar.MONTH, -1);
        later.add(Calendar.YEAR, 1);
        timeTable.put(YEAR, new Long(later.getTimeInMillis() - now_ms));
    }

    /**
     * private constructor used for static construction of TimeUnit objects.
     *
     * @param value String representing the value.
     */
    private TimeUnit(String value) {
        this();
        setValueProgrammatic​ally(value);
    }

    /**
     * set the inner value programmatically.
     *
     * @param value to set
     */
    protected void setValueProgrammatically(String value) {
        this.value = value;
    }

    /**
     * Gets the multiplier attribute of the TimeUnit object
     *
     * @return The multiplier value
     */
    public long getMultiplier() {
        String key = getValue().toLowerCase();
        Long l = (Long) timeTable.get(key);
        return l.longValue();
    }

    /**
     * Gets the values attribute of the TimeUnit object
     *
     * @return The values value
     */
    public String[] getValues() {
        return units;
    }

    /**
     * convert the time in the current unit, to millis
     *
     * @param numberOfUnits long expressed in the current objects units
     * @return long representing the value in millis
     */
    public long toMillis(long numberOfUnits) {
        return numberOfUnits * getMultiplier();
    }
}


Directory: /antelope/src/ise/an​telope/tasks/typedef​s/string/
====================​====================​====================​

File [added]: IndexOf.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/typedef​s/string/IndexOf.jav​a?rev=1.1&conten​t-type=text/vnd.view​cvs-markup
Added lines: 35
---------------
package ise.antelope.tasks.t​ypedefs.string;

/**
 * Copyright 2003
 *
 * @version $Revision: 1.1 $
 */
public class IndexOf implements StringOp {
    
    private String string = "";
    private int fromIndex = 0;
    
    public void setString(String s) {
        string = s;
    }
    
    public void setFromindex(int i) {
        fromIndex = i;
    }
    /**
     * Description of the Method
     *
     * @param s
     * @return the index of the substring in the given string as a String, or '
     * "-1" if not found.
     */
    public String execute(String s) {
        if (s == null)
            throw new IllegalArgumentExcep​tion("string cannot be null");
        return String.valueOf(s.ind​exOf(string, fromIndex));
        
    }
}



File [added]: LastIndexOf.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/typedef​s/string/LastIndexOf​.java?rev=1.1&co​ntent-type=text/vnd.​viewcvs-markup
Added lines: 37
---------------
package ise.antelope.tasks.t​ypedefs.string;

/**
 * Copyright 2003
 *
 * @version $Revision: 1.1 $
 */
public class LastIndexOf implements StringOp {
    
    private String string = "";
    private int fromIndex = -1;
    
    public void setString(String s) {
        string = s;
    }
    
    public void setFromindex(int i) {
        fromIndex = i;
    }
    /**
     * Description of the Method
     *
     * @param s
     * @return the index of the substring in the given string as a String, or '
     * "-1" if not found.
     */
    public String execute(String s) {
        if (s == null)
            throw new IllegalArgumentExcep​tion("string cannot be null");
        if (fromIndex == -1)
            fromIndex = s.length();
        return String.valueOf(s.las​tIndexOf(string, fromIndex));
        
    }
}



File [added]: Length.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/typedef​s/string/Length.java​?rev=1.1&content​-type=text/vnd.viewc​vs-markup
Added lines: 18
---------------
package ise.antelope.tasks.t​ypedefs.string;

/**
 * Copyright 2003
 *
 * @version $Revision: 1.1 $
 */
public class Length implements StringOp {
    
    public String execute(String s) {
        if (s == null)
            throw new IllegalArgumentExcep​tion("string cannot be null");
        return String.valueOf(s.length());
        
    }
}



File [added]: LowerCase.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/typedef​s/string/LowerCase.j​ava?rev=1.1&cont​ent-type=text/vnd.vi​ewcvs-markup
Added lines: 20
---------------
package ise.antelope.tasks.t​ypedefs.string;

/**
 * Copyright 2003
 *
 * @version $Revision: 1.1 $
 */
public class LowerCase implements StringOp {
    /**
     * Description of the Method
     *
     * @param s
     * @return Description of the Returned Value
     */
    public String execute(String s) {
        return s.toLowerCase();
    }
}



File [added]: MessageBox.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/typedef​s/string/MessageBox.​java?rev=1.1&con​tent-type=text/vnd.v​iewcvs-markup
Added lines: 37
---------------
package ise.antelope.tasks.t​ypedefs.string;


/**
 * Copyright 2003
 *
 * @version $Revision: 1.1 $
 */
public class MessageBox implements StringOp {
    
    private String title = null;
    private int width = 60;
    
    public void setTitle(String t) {
        title = t;
    }
    
    public void setWidth(int w) {
        width = w;
    }
    
    /**
     * Description of the Method
     *
     * @param s
     * @return Description of the Returned Value
     */
    public String execute(String s) {
        if (width <= 0)
            return "";
        else
            ise.library.ascii.Me​ssageBox.setMaxWidth​(width);
        return ise.library.ascii.Me​ssageBox.box(title, s);
    }
}



File [added]: Replace.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/typedef​s/string/Replace.jav​a?rev=1.1&conten​t-type=text/vnd.view​cvs-markup
Added lines: 34
---------------
package ise.antelope.tasks.t​ypedefs.string;

/**
 * Copyright 2003
 *
 * @version $Revision: 1.1 $
 */
public class Replace implements StringOp {
    
    
    private String regex = "";
    private String replacement = "";
    
    public void setRegex(String regex) {
        this.regex = regex;
    }
    
    public void setReplacement(String replacement) {
        this.replacement = replacement;
    }
    
    /**
     * Description of the Method
     *
     * @param s
     * @return Description of the Returned Value
     */
    public String execute(String s) {
        return s.replaceAll(regex, replacement);
        
    }
}



File [added]: Sort.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/typedef​s/string/Sort.java?r​ev=1.1&content-t​ype=text/vnd.viewcvs​-markup
Added lines: 43
---------------
package ise.antelope.tasks.t​ypedefs.string;

import java.util.*;

/**
 * Copyright 2003
 *
 * @version $Revision: 1.1 $
 */
public class Sort implements StringOp {
    
    private String separator = null;
    
    public void setSeparator(String s) {
        separator = s;
    }
    
    /**
     * Description of the Method
     *
     * @param s
     * @return Description of the Returned Value
     */
    public String execute(String s) {
        if (s == null)
            return "";
        List list = new ArrayList();
        StringTokenizer st = separator == null ? new StringTokenizer(s) : new StringTokenizer(s, separator);
        while(st.hasMoreTokens()) {
            list.add(st.nextToken());
        }
        Collections.sort(list);
        StringBuffer sorted = new StringBuffer();
        for (Iterator it = list.iterator(); it.hasNext(); ) {
            sorted.append((Strin​g)it.next());
            if (it.hasNext())
                sorted.append(separator);
        }
        return sorted.toString();
    }
}



File [added]: StringOp.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/typedef​s/string/StringOp.ja​va?rev=1.1&conte​nt-type=text/vnd.vie​wcvs-markup
Added lines: 5
--------------
package ise.antelope.tasks.t​ypedefs.string;

public interface StringOp {
    public String execute(String s);
}

File [added]: Substring.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/typedef​s/string/Substring.j​ava?rev=1.1&cont​ent-type=text/vnd.vi​ewcvs-markup
Added lines: 44
---------------
package ise.antelope.tasks.t​ypedefs.string;

/**
 * Copyright 2003
 *
 * @version $Revision: 1.1 $
 */
public class Substring implements StringOp {
    
    private int beginIndex = 0;
    private int endIndex = -1;
    
    public void setBeginindex(int i) {
        if (i < 0)
            throw new IllegalArgumentExcep​tion("beginindex must be <= 0");
        beginIndex = i;
    }
    
    public void setEndindex(int i) {
        if (i < 0)
            throw new IllegalArgumentExcep​tion("endindex must be <= 0");
        endIndex = i;
    }
    /**
     * Description of the Method
     *
     * @param s
     * @return Description of the Returned Value
     */
    public String execute(String s) {
        if (s == null)
            return "";
        if (beginIndex == endIndex)
            return "";
        if (endIndex == -1)
            endIndex = s.length();
        if (endIndex < beginIndex)
            throw new IllegalArgumentExcep​tion("endindex must be greater than beginindex");
        return s.substring(beginIndex, endIndex);
        
    }
}



File [added]: Trim.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/typedef​s/string/Trim.java?r​ev=1.1&content-t​ype=text/vnd.viewcvs​-markup
Added lines: 20
---------------
package ise.antelope.tasks.t​ypedefs.string;

/**
 * Copyright 2003
 *
 * @version $Revision: 1.1 $
 */
public class Trim implements StringOp {
    /**
     * Description of the Method
     *
     * @param s
     * @return Description of the Returned Value
     */
    public String execute(String s) {
        return s.trim();
    }
}



File [added]: UpperCase.java
Url: http://antelope.tigr​is.org/source/browse​/antelope/src/ise/an​telope/tasks/typedef​s/string/UpperCase.j​ava?rev=1.1&cont​ent-type=text/vnd.vi​ewcvs-markup
Added lines: 21
---------------

package ise.antelope.tasks.t​ypedefs.string;

/**
 * Copyright 2003
 *
 * @version $Revision: 1.1 $
 */
public class UpperCase implements StringOp {
    /**
     * Description of the Method
     *
     * @param s
     * @return Description of the Returned Value
     */
    public String execute(String s) {
        return s.toUpperCase();
    }
}
Messages per page: