| 
      
      
      From: <ha...@us...> - 2006-11-22 20:34:24
       | 
| Revision: 1409
          http://svn.sourceforge.net/cogkit/?rev=1409&view=rev
Author:   hategan
Date:     2006-11-22 12:34:23 -0800 (Wed, 22 Nov 2006)
Log Message:
-----------
a better uid()
Modified Paths:
--------------
    trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2006-11-22 20:33:58 UTC (rev 1408)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2006-11-22 20:34:23 UTC (rev 1409)
@@ -167,9 +167,23 @@
 			prefix = TypeUtil.toString(OA_CONTEXT.getValue(stack));
 		}
 		synchronized (Misc.class) {
-			return prefix + (UIDIndex++) + suffix;
+			return prefix + alphanum(UIDIndex++) + suffix;
 		}
 	}
+	
+	public static final String codes = "0123456789abcdefghijklmnopqrstuvxyz";
+	
+	protected String alphanum(long val) {
+		StringBuffer sb = new StringBuffer();
+		int base = codes.length();
+		while (val > 0) {
+			int c = (int) (val % base);
+			sb.append(codes.charAt(c));
+			val = val / base;
+		}
+		return sb.toString();
+	}
+	
 
 	public static final Arg PA_NAME = new Arg.Positional("name");
 	public static final Arg.Channel CA_PROPERTIES = new Arg.Channel("properties");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <ha...@us...> - 2006-11-24 22:57:07
       | 
| Revision: 1423
          http://svn.sourceforge.net/cogkit/?rev=1423&view=rev
Author:   hategan
Date:     2006-11-24 14:57:03 -0800 (Fri, 24 Nov 2006)
Log Message:
-----------
fixed sort()
Modified Paths:
--------------
    trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2006-11-24 17:28:48 UTC (rev 1422)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2006-11-24 22:57:03 UTC (rev 1423)
@@ -23,6 +23,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -170,9 +171,9 @@
 			return prefix + alphanum(UIDIndex++) + suffix;
 		}
 	}
-	
+
 	public static final String codes = "0123456789abcdefghijklmnopqrstuvxyz";
-	
+
 	protected String alphanum(long val) {
 		StringBuffer sb = new StringBuffer();
 		int base = codes.length();
@@ -183,7 +184,6 @@
 		}
 		return sb.toString();
 	}
-	
 
 	public static final Arg PA_NAME = new Arg.Positional("name");
 	public static final Arg.Channel CA_PROPERTIES = new Arg.Channel("properties");
@@ -430,27 +430,54 @@
 		setArguments("sys_sort", new Arg[] { OA_DESCENDING, Arg.VARGS });
 	}
 
+	public static final Comparator INVERSE_COMPARATOR = new Comparator() {
+		public int compare(Object o1, Object o2) {
+			Comparable c2 = (Comparable) o2;
+			// c1.compareTo(o2) == -c2.compareTo(o1)
+			return c2.compareTo(o1);
+		}
+	};
+
 	public Object sys_sort(VariableStack stack) throws ExecutionException {
 		boolean descending = TypeUtil.toBoolean(OA_DESCENDING.getValue(stack));
 		Object[] args = Arg.VARGS.asArray(stack);
 		ArrayList ret = new ArrayList();
 		if (args.length > 1) {
 			for (int i = 0; i < args.length; i++) {
-				String value = TypeUtil.toString(args[i]);
-				ret.add(value);
+				ret.add(args[i]);
 			}
 			Object[] array = ret.toArray();
-			Arrays.sort(array);
+			try {
+				if (descending) {
+					Arrays.sort(array, INVERSE_COMPARATOR);
+				}
+				else {
+					Arrays.sort(array);
+				}
+			}
+			catch (ClassCastException e) {
+				throw new ExecutionException("Cannot sort items of different types");
+			}
 			return array;
 		}
 		else if (args.length == 1) {
 			Iterator i = TypeUtil.toIterator(args[0]);
 			while (i.hasNext()) {
-				String value = TypeUtil.toString(i.next());
-				ret.add(value);
+				ret.add(i.next());
 			}
 			Object[] array = ret.toArray();
 			Arrays.sort(array);
+			try {
+				if (descending) {
+					Arrays.sort(array, INVERSE_COMPARATOR);
+				}
+				else {
+					Arrays.sort(array);
+				}
+			}
+			catch (ClassCastException e) {
+				throw new ExecutionException("Cannot sort items of different types");
+			}
 			return Arrays.asList(array);
 		}
 		else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <ha...@us...> - 2006-12-05 19:14:49
       | 
| Revision: 1444
          http://svn.sourceforge.net/cogkit/?rev=1444&view=rev
Author:   hategan
Date:     2006-12-05 11:14:45 -0800 (Tue, 05 Dec 2006)
Log Message:
-----------
DOTALL support for str:matches()
Modified Paths:
--------------
    trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2006-12-05 19:13:27 UTC (rev 1443)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2006-12-05 19:14:45 UTC (rev 1444)
@@ -329,7 +329,8 @@
 	public boolean str_matches(VariableStack stack) throws ExecutionException {
 		String string = TypeUtil.toString(PA_STRING.getValue(stack));
 		String regexp = TypeUtil.toString(PA_REGEXP.getValue(stack));
-		return string.matches(regexp);
+		Pattern p = Pattern.compile(regexp, Pattern.DOTALL);
+		return p.matcher(string).matches();
 	}
 
 	public static final Arg PA_SEPARATOR = new Arg.Positional("separator");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <ha...@us...> - 2007-08-16 22:48:58
       | 
| Revision: 1679
          http://cogkit.svn.sourceforge.net/cogkit/?rev=1679&view=rev
Author:   hategan
Date:     2007-08-16 15:48:57 -0700 (Thu, 16 Aug 2007)
Log Message:
-----------
fixed extra newlines
Modified Paths:
--------------
    trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2007-08-16 22:47:46 UTC (rev 1678)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2007-08-16 22:48:57 UTC (rev 1679)
@@ -115,12 +115,12 @@
 			BufferedReader br = new BufferedReader(new FileReader(new File(
 					TypeUtil.toString(PA_FILE.getValue(stack)))));
 			StringBuffer text = new StringBuffer();
-			String line = "";
-			do {
+			String line = br.readLine();
+			while (line != null) {
 				text.append(line);
 				text.append('\n');
 				line = br.readLine();
-			} while (line != null);
+			};
 			return text.toString();
 		}
 		catch (Exception e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <ha...@us...> - 2007-09-07 00:52:28
       | 
| Revision: 1734
          http://cogkit.svn.sourceforge.net/cogkit/?rev=1734&view=rev
Author:   hategan
Date:     2007-09-06 17:52:18 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
same for file:read
Modified Paths:
--------------
    trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2007-09-06 22:16:54 UTC (rev 1733)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2007-09-07 00:52:18 UTC (rev 1734)
@@ -112,15 +112,19 @@
 
 	public Object sys_readfile(VariableStack stack) throws ExecutionException {
 		try {
-			BufferedReader br = new BufferedReader(new FileReader(new File(
-					TypeUtil.toString(PA_FILE.getValue(stack)))));
+			File f = new File(TypeUtil.toString(PA_FILE.getValue(stack)));
+			if (!f.isAbsolute()) {
+				f = new File(stack.getExecutionContext().getCwd() + File.separator + f.getPath());
+			}
+			BufferedReader br = new BufferedReader(new FileReader(f));
 			StringBuffer text = new StringBuffer();
 			String line = br.readLine();
 			while (line != null) {
 				text.append(line);
 				text.append('\n');
 				line = br.readLine();
-			};
+			}
+			;
 			return text.toString();
 		}
 		catch (Exception e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <ha...@us...> - 2007-09-07 01:05:43
       | 
| Revision: 1735
          http://cogkit.svn.sourceforge.net/cogkit/?rev=1735&view=rev
Author:   hategan
Date:     2007-09-06 18:05:39 -0700 (Thu, 06 Sep 2007)
Log Message:
-----------
hmm...
Modified Paths:
--------------
    trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2007-09-07 00:52:18 UTC (rev 1734)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2007-09-07 01:05:39 UTC (rev 1735)
@@ -124,7 +124,6 @@
 				text.append('\n');
 				line = br.readLine();
 			}
-			;
 			return text.toString();
 		}
 		catch (Exception e) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <ha...@us...> - 2008-02-22 16:31:40
       | 
| Revision: 1907
          http://cogkit.svn.sourceforge.net/cogkit/?rev=1907&view=rev
Author:   hategan
Date:     2008-02-22 08:31:35 -0800 (Fri, 22 Feb 2008)
Log Message:
-----------
added date format
Modified Paths:
--------------
    trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2008-02-22 16:25:16 UTC (rev 1906)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Misc.java	2008-02-22 16:31:35 UTC (rev 1907)
@@ -18,8 +18,10 @@
 import java.io.OutputStream;
 import java.io.PrintStream;
 import java.io.RandomAccessFile;
+import java.text.DateFormat;
 import java.text.DecimalFormat;
 import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -104,7 +106,16 @@
 		DecimalFormat df = new DecimalFormat(TypeUtil.toString(PA_PATTERN.getValue(stack)));
 		return df.format(TypeUtil.toDouble(PA_VALUE.getValue(stack)));
 	}
+	
+	static {
+        setArguments("sys_dateformat", new Arg[] { PA_PATTERN, PA_VALUE });
+    }
 
+    public Object sys_dateformat(VariableStack stack) throws ExecutionException {
+        DateFormat df = new SimpleDateFormat(TypeUtil.toString(PA_PATTERN.getValue(stack)));
+        return df.format(PA_VALUE.getValue(stack));
+    }
+
 	static {
 		setArguments("sys_readfile", new Arg[] { PA_FILE });
 		addAlias("sys_file_read", "sys_readfile");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |