[teiid-commits] teiid SVN: r4407 - in trunk: common-core/src/main/java/org/teiid/core/util and 3 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Thu Sep 6 15:15:49 EDT 2012


Author: shawkins
Date: 2012-09-06 15:15:48 -0400 (Thu, 06 Sep 2012)
New Revision: 4407

Modified:
   trunk/api/src/main/java/org/teiid/metadata/KeyRecord.java
   trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java
   trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java
   trunk/common-core/src/test/java/org/teiid/core/util/TestStringUtil.java
   trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
   trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
Log:
TEIID-2171 misc minor changes

Modified: trunk/api/src/main/java/org/teiid/metadata/KeyRecord.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/KeyRecord.java	2012-09-06 19:02:53 UTC (rev 4406)
+++ trunk/api/src/main/java/org/teiid/metadata/KeyRecord.java	2012-09-06 19:15:48 UTC (rev 4407)
@@ -39,13 +39,13 @@
 	private Type type;
 
 	public KeyRecord(Type type) {
+		if (type == Type.NonUnique) {
+			type = Type.Index;
+		}
 		this.type = type;
 	}
 	
 	public Type getType() {
-		if (type == Type.NonUnique) {
-			type = Type.Index;
-		}
 		return type;
 	}
 	

Modified: trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java	2012-09-06 19:02:53 UTC (rev 4406)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java	2012-09-06 19:15:48 UTC (rev 4407)
@@ -50,7 +50,7 @@
 	}
 	
 	public void addSchema(Schema schema) {
-		if (this.schemas.put(schema.getCanonicalName(), schema) != null) {
+		if (this.schemas.put(schema.getName(), schema) != null) {
 			throw new DuplicateRecordException(DataPlugin.Util.gs(DataPlugin.Event.TEIID60012, schema.getName()));
 		}		
 		this.schemaList.add(schema);

Modified: trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java	2012-09-06 19:02:53 UTC (rev 4406)
+++ trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java	2012-09-06 19:15:48 UTC (rev 4407)
@@ -364,8 +364,8 @@
 	 * @param delimiter Characters which are delimit tokens
 	 * @return List of string tokens contained in the tokenized string
 	 */
-	public static List getTokens(String str, String delimiter) {
-		ArrayList l = new ArrayList();
+	public static List<String> getTokens(String str, String delimiter) {
+		ArrayList<String> l = new ArrayList<String>();
 		StringTokenizer tokens = new StringTokenizer(str, delimiter);
 		while(tokens.hasMoreTokens()) {
 			l.add(tokens.nextToken());
@@ -835,22 +835,6 @@
     	return (!(str == null || str.trim().length() == 0));
     }
     
-    public static String toUpperCase(String str) {
-        String newStr = convertBasicLatinToUpper(str);
-        if (newStr == null) {
-            return str.toUpperCase();
-        }
-        return newStr;
-    }
-    
-    public static String toLowerCase(String str) {
-        String newStr = convertBasicLatinToLower(str);
-        if (newStr == null) {
-            return str.toLowerCase();
-        }
-        return newStr;
-    }
-    
     /**
      * Create a valid filename from the given String.
      * 
@@ -892,45 +876,12 @@
         return str.substring(0, 1).toUpperCase() + str.substring(1);
     }
     
-    private static String convertBasicLatinToUpper(String str) {
-        char[] chars = str.toCharArray();
-        for (int i = 0; i < chars.length; i++) {
-            if (isBasicLatinLowerCase(chars[i])) {
-                chars[i] = (char)('A' + (chars[i] - 'a'));
-            } else if (!isBasicLatinChar(chars[i])) {
-                return null;
-            }
-        }
-        return new String(chars);
-    }
-    
-    private static String convertBasicLatinToLower(String str) {
-        char[] chars = str.toCharArray();
-        for (int i = 0; i < chars.length; i++) {
-            if (isBasicLatinUpperCase(chars[i])) {
-                chars[i] = (char)('a' + (chars[i] - 'A'));
-            } else if (!isBasicLatinChar(chars[i])) {
-                return null;
-            }
-        }
-        return new String(chars);
-    }
-    
-    private static boolean isBasicLatinUpperCase(char c) {
-        return c >= 'A' && c <= 'Z';
-    }
-    private static boolean isBasicLatinLowerCase(char c) {
-        return c >= 'a' && c <= 'z';
-    }
     private static boolean isBasicLatinLetter(char c) {
         return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
     }
     private static boolean isBasicLatinDigit(char c) {
         return c >= '0' && c <= '9';
     }
-    private static boolean isBasicLatinChar(char c) {
-        return c <= '\u007F';
-    }   
     
     /**
      * Convert the given value to specified type. 

Modified: trunk/common-core/src/test/java/org/teiid/core/util/TestStringUtil.java
===================================================================
--- trunk/common-core/src/test/java/org/teiid/core/util/TestStringUtil.java	2012-09-06 19:02:53 UTC (rev 4406)
+++ trunk/common-core/src/test/java/org/teiid/core/util/TestStringUtil.java	2012-09-06 19:15:48 UTC (rev 4407)
@@ -22,27 +22,21 @@
 
 package org.teiid.core.util;
 
+import static org.junit.Assert.*;
+
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import junit.framework.TestCase;
+import org.junit.Test;
 
 /**
  * @version 	1.0
  * @author
  */
-public class TestStringUtil extends TestCase {
+public class TestStringUtil {
 
-    /**
-     * Constructor for TestStringUtil.
-     * @param name
-     */
-    public TestStringUtil(String name) {
-        super(name);
-    }
-
 	//  ********* H E L P E R   M E T H O D S  *********
 	public void helpTestEncloseInSingleQuotes(String input, String expectedResult){
 	    String result = StringUtil.enclosedInSingleQuotes(input);
@@ -80,133 +74,133 @@
 	}
 
 	//  ********* T E S T   S U I T E   M E T H O D S  *********
-	public void testEncloseInSingleQuotes() {
+	@Test public void testEncloseInSingleQuotes() {
 	    helpTestEncloseInSingleQuotes("testString", "\'testString\'"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testComputeDisplayableForm1() {
+	@Test public void testComputeDisplayableForm1() {
 	    helpTestComputeDisplayableForm("testString", "Test String"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testComputeDisplayableForm2() {
+	@Test public void testComputeDisplayableForm2() {
 	    helpTestComputeDisplayableForm("TEST STRING", "TEST STRING"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-    public void testComputeDisplayableForm3() {
+    @Test public void testComputeDisplayableForm3() {
         helpTestComputeDisplayableForm("TestSTRING", "Test STRING"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testComputeDisplayableForm4() {
+    @Test public void testComputeDisplayableForm4() {
         helpTestComputeDisplayableForm("MetaMatrix", "Meta Matrix"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testComputeDisplayableForm5() {
+    @Test public void testComputeDisplayableForm5() {
         helpTestComputeDisplayableForm("metaMatrix", "Meta Matrix"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testComputeDisplayableForm6() {
+    @Test public void testComputeDisplayableForm6() {
         helpTestComputeDisplayableForm("Metamatrix", "Metamatrix"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testComputeDisplayableForm7() {
+    @Test public void testComputeDisplayableForm7() {
         helpTestComputeDisplayableForm("SomeMetaMatrixEmbedded", "Some Meta Matrix Embedded"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testComputeDisplayableForm8() {
+    @Test public void testComputeDisplayableForm8() {
         helpTestComputeDisplayableForm("SomeMetaMetaMatrixMetaEmbedded", "Some Meta Meta Matrix Meta Embedded"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testComputeDisplayableForm9() {
+    @Test public void testComputeDisplayableForm9() {
         helpTestComputeDisplayableForm("SomemetaMatrixMetaMatrixMetaEmbedded", "Somemeta Matrix Meta Matrix Meta Embedded"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-	public void testComputePluralForm1() {
+	@Test public void testComputePluralForm1() {
 	    helpTestComputePluralForm("Test", "Tests"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testComputePluralForm2() {
+	@Test public void testComputePluralForm2() {
 	    helpTestComputePluralForm("ss", "sses"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testComputePluralForm3() {
+	@Test public void testComputePluralForm3() {
 	    helpTestComputePluralForm("x", "xes"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testComputePluralForm4() {
+	@Test public void testComputePluralForm4() {
 	    helpTestComputePluralForm("ch", "ches"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testComputePluralForm5() {
+	@Test public void testComputePluralForm5() {
 	    helpTestComputePluralForm("zy", "zies"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testComputePluralForm6() {
+	@Test public void testComputePluralForm6() {
 	    helpTestComputePluralForm("ay", "ays"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testComputePluralForm7() {
+	@Test public void testComputePluralForm7() {
 	    helpTestComputePluralForm("ey", "eys"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testComputePluralForm8() {
+	@Test public void testComputePluralForm8() {
 	    helpTestComputePluralForm("iy", "iys"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testComputePluralForm9() {
+	@Test public void testComputePluralForm9() {
 	    helpTestComputePluralForm("oy", "oys"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-    public void testComputePluralForm10() {
+    @Test public void testComputePluralForm10() {
         helpTestComputePluralForm("uy", "uys"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testComputePluralForm11() {
+    @Test public void testComputePluralForm11() {
         helpTestComputePluralForm("any", "anys"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testComputePluralForm12() {
+    @Test public void testComputePluralForm12() {
         helpTestComputePluralForm("classes", "classes"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-	public void testJoin1() {
-	    List input = new ArrayList();
+	@Test public void testJoin1() {
+	    List<String> input = new ArrayList<String>();
 	    input.add("One"); //$NON-NLS-1$
 	    input.add("Two"); //$NON-NLS-1$
 	    helpTestJoin(input, null, null);
 	}
 
-	public void testJoin2() {
+	@Test public void testJoin2() {
 	    helpTestJoin(null, "/", null); //$NON-NLS-1$
 	}
 
-	public void testJoin3() {
-	    List input = new ArrayList();
+	@Test public void testJoin3() {
+	    List<String> input = new ArrayList<String>();
 	    input.add("One"); //$NON-NLS-1$
 	    input.add("Two"); //$NON-NLS-1$
 	    helpTestJoin(input, "/", "One/Two"); //$NON-NLS-1$ //$NON-NLS-2$
 	}
 
-	public void testReplace1() {
+	@Test public void testReplace1() {
 	    helpTestReplace("12225", null, "234", "12225"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 
-	public void testReplace2() {
+	@Test public void testReplace2() {
 	    helpTestReplace("12225", "222", null, "12225"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 	}
 
-	public void testReplace3() {
+	@Test public void testReplace3() {
 	    helpTestReplace("12225", "222", "234", "12345"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
 	}
 
-	public void testReplaceAll() {
+	@Test public void testReplaceAll() {
 	    helpTestReplaceAll("1121121112", "2", "1", "1111111111"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
 	}
 
-    public void testTruncString() {
+    @Test public void testTruncString() {
         helpTestTruncString("123456", 5, "12345"); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testGetStackTrace() {
+    @Test public void testGetStackTrace() {
         final String expectedStackTrace = "java.lang.RuntimeException: Test"; //$NON-NLS-1$
         final Throwable t = new RuntimeException("Test"); //$NON-NLS-1$
         final String trace = StringUtil.getStackTrace(t);
@@ -215,15 +209,15 @@
         }
     }
 
-    public void testToString() {
+    @Test public void testToString() {
         final String[] input = new String[]{"string1","string2","string3"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         final String output = StringUtil.toString(input);
         assertEquals("[string1,string2,string3]", output); //$NON-NLS-1$
     }
 
-    public void testGetTokens() {
+    @Test public void testGetTokens() {
         final String input = "string with; tokens ; delimited by ; ; semicolons; there;; are 7 tokens."; //$NON-NLS-1$
-        final List tokens = StringUtil.getTokens(input,";"); //$NON-NLS-1$
+        final List<String> tokens = StringUtil.getTokens(input,";"); //$NON-NLS-1$
         assertEquals(7, tokens.size());
 		assertEquals("string with", tokens.get(0)); //$NON-NLS-1$
 		assertEquals(" tokens ", tokens.get(1)); //$NON-NLS-1$
@@ -234,8 +228,8 @@
 		assertEquals(" are 7 tokens.", tokens.get(6)); //$NON-NLS-1$
     }
 
-    public void testSplitOnEntireString() {
-        List result = StringUtil.splitOnEntireString("thisNEXTcanNEXTbe", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testSplitOnEntireString() {
+        List<String> result = StringUtil.splitOnEntireString("thisNEXTcanNEXTbe", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
         assertEquals(3, result.size());
         assertEquals("this", result.get(0)); //$NON-NLS-1$
         assertEquals("can", result.get(1)); //$NON-NLS-1$
@@ -243,33 +237,33 @@
 
     }
 
-    public void testSplitOnEntireStringEmptyString() {
-        List result = StringUtil.splitOnEntireString("", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testSplitOnEntireStringEmptyString() {
+        List<String> result = StringUtil.splitOnEntireString("", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
         assertEquals(1, result.size());
         assertEquals("", result.get(0)); //$NON-NLS-1$
     }
 
-    public void testSplitOnEntireStringEntireStringIsDelimiter() {
-        List result = StringUtil.splitOnEntireString("NEXT", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testSplitOnEntireStringEntireStringIsDelimiter() {
+        List<String> result = StringUtil.splitOnEntireString("NEXT", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
         assertEquals(2, result.size());
         assertEquals("", result.get(0)); //$NON-NLS-1$
         assertEquals("", result.get(1)); //$NON-NLS-1$
     }
 
-    public void testSplitOnEntireStringEmptyDelimiter() {
-        List result = StringUtil.splitOnEntireString("test", ""); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testSplitOnEntireStringEmptyDelimiter() {
+        List<String> result = StringUtil.splitOnEntireString("test", ""); //$NON-NLS-1$ //$NON-NLS-2$
         assertEquals(1, result.size());
         assertEquals("test", result.get(0)); //$NON-NLS-1$
     }
 
-    public void testSplitOnEntireStringEndsWithDelimiter() {
-        List result = StringUtil.splitOnEntireString("testNEXT", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
+    @Test public void testSplitOnEntireStringEndsWithDelimiter() {
+        List<String> result = StringUtil.splitOnEntireString("testNEXT", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
         assertEquals(2, result.size());
         assertEquals("test", result.get(0)); //$NON-NLS-1$
         assertEquals("", result.get(1)); //$NON-NLS-1$
     }
 
-    public void testIndexOfIgnoreCase() {
+    @Test public void testIndexOfIgnoreCase() {
         String text = "test"; //$NON-NLS-1$
         assertEquals(-1,StringUtil.indexOfIgnoreCase(null,text));
         assertEquals(-1,StringUtil.indexOfIgnoreCase("",text)); //$NON-NLS-1$
@@ -283,7 +277,7 @@
         assertEquals(2,StringUtil.indexOfIgnoreCase(text,"ST")); //$NON-NLS-1$
     }
 
-    public void testStartsWithIgnoreCase() {
+    @Test public void testStartsWithIgnoreCase() {
         String text = "test"; //$NON-NLS-1$
         assertEquals(false,StringUtil.startsWithIgnoreCase(null,text));
         assertEquals(false,StringUtil.startsWithIgnoreCase("",text)); //$NON-NLS-1$
@@ -298,7 +292,7 @@
         assertEquals(true,StringUtil.startsWithIgnoreCase(text,"TE")); //$NON-NLS-1$
     }
 
-    public void testEndsWithIgnoreCase() {
+    @Test public void testEndsWithIgnoreCase() {
         String text = "test"; //$NON-NLS-1$
         assertEquals(false,StringUtil.endsWithIgnoreCase(null,text));
         assertEquals(false,StringUtil.endsWithIgnoreCase("",text)); //$NON-NLS-1$
@@ -313,30 +307,30 @@
         assertEquals(true,StringUtil.endsWithIgnoreCase(text,"ST")); //$NON-NLS-1$
     }
 
-    public void testIsDigits() {
+    @Test public void testIsDigits() {
         assertTrue(StringUtil.isDigits("012872")); //$NON-NLS-1$
         assertTrue(StringUtil.isDigits("634644")); //$NON-NLS-1$
         assertFalse(StringUtil.isDigits("A634644")); //$NON-NLS-1$
         assertFalse(StringUtil.isDigits("634A644")); //$NON-NLS-1$
     }
 
-    public void testToFixedLengthNull() {
+    @Test public void testToFixedLengthNull() {
         assertEquals("    ", StringUtil.toFixedLength(null, 4)); //$NON-NLS-1$
     }
 
-    public void testToFixedLengthPad() {
+    @Test public void testToFixedLengthPad() {
         assertEquals("a   ", StringUtil.toFixedLength("a", 4)); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testToFixedLengthNoChange() {
+    @Test public void testToFixedLengthNoChange() {
         assertEquals("abcd", StringUtil.toFixedLength("abcd", 4)); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testToFixedLengthChop() {
+    @Test public void testToFixedLengthChop() {
         assertEquals("abcd", StringUtil.toFixedLength("abcdefgh", 4)); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testIsLetter() {
+    @Test public void testIsLetter() {
         assertTrue(StringUtil.isLetter('a'));
         assertTrue(StringUtil.isLetter('A'));
         assertFalse(StringUtil.isLetter('5'));
@@ -346,7 +340,7 @@
         assertTrue(StringUtil.isLetter('\u0905')); // Devanagiri letter
     }
 
-    public void testIsDigit() {
+    @Test public void testIsDigit() {
         assertFalse(StringUtil.isDigit('a'));
         assertFalse(StringUtil.isDigit('A'));
         assertTrue(StringUtil.isDigit('5'));
@@ -356,7 +350,7 @@
         assertFalse(StringUtil.isDigit('\u0905')); // Devanagiri letter
     }
 
-    public void testIsLetterOrDigit() {
+    @Test public void testIsLetterOrDigit() {
         assertTrue(StringUtil.isLetterOrDigit('a'));
         assertTrue(StringUtil.isLetterOrDigit('A'));
         assertTrue(StringUtil.isLetterOrDigit('5'));
@@ -366,21 +360,12 @@
         assertTrue(StringUtil.isLetterOrDigit('\u0905')); // Devanagiri letter
     }
 
-    public void testToUpperCase() {
-        assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", StringUtil.toUpperCase("abcdefghijklmnopqrstuvwxyz1234567890")); //$NON-NLS-1$ //$NON-NLS-2$
-        assertEquals("LATIN1_\u00c0", StringUtil.toUpperCase("Latin1_\u00e0")); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-    public void testToLowerCase() {
-        assertEquals("abcdefghijklmnopqrstuvwxyz1234567890", StringUtil.toLowerCase("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")); //$NON-NLS-1$ //$NON-NLS-2$
-        assertEquals("latin1_\u00e0", StringUtil.toLowerCase("Latin1_\u00c0")); //$NON-NLS-1$ //$NON-NLS-2$
-    }
-
-    public void testCreateFileName() {
+    @Test public void testCreateFileName() {
         assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", StringUtil.createFileName("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")); //$NON-NLS-1$ //$NON-NLS-2$
         assertEquals("http:__www.metamatrix.com_parm1=test;parm2=testy2", StringUtil.createFileName("http://www.metamatrix.com?parm1=test;parm2=testy2")); //$NON-NLS-1$ //$NON-NLS-2$
     }
 
-    public void testGetFirstToken(){
+    @Test public void testGetFirstToken(){
     	assertEquals("/foo/bar", StringUtil.getFirstToken("/foo/bar.vdb", "."));//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     	assertEquals("", StringUtil.getFirstToken("/foo/bar.vdb", "/"));//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     	assertEquals("/foo", StringUtil.getFirstToken("/foo./bar.vdb", "."));//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -388,12 +373,12 @@
     	assertEquals("vdb", StringUtil.getLastToken("/foo/bar.vdb", "."));//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     
-    public enum Test {
+    public enum EnumTest {
     	HELLO,
     	WORLD
     }
     
-    public void testValueOf() throws Exception {
+    @Test public void testValueOf() throws Exception {
     	assertEquals(Integer.valueOf(21), StringUtil.valueOf("21", Integer.class)); //$NON-NLS-1$
     	assertEquals(Boolean.valueOf(true), StringUtil.valueOf("true", Boolean.class)); //$NON-NLS-1$    	
     	assertEquals("Foo", StringUtil.valueOf("Foo", String.class)); //$NON-NLS-1$ //$NON-NLS-2$
@@ -415,7 +400,7 @@
     	assertEquals(3, m.size());
     	assertEquals(m.get("foo"), "bar"); //$NON-NLS-1$ //$NON-NLS-2$
     	assertEquals(m.get("x"), ""); //$NON-NLS-1$ //$NON-NLS-2$
-    	assertEquals(Test.HELLO, StringUtil.valueOf("HELLO", Test.class)); //$NON-NLS-1$ 
+    	assertEquals(EnumTest.HELLO, StringUtil.valueOf("HELLO", EnumTest.class)); //$NON-NLS-1$ 
     	
     	assertEquals(new URL("http://teiid.org"), StringUtil.valueOf("http://teiid.org", URL.class)); //$NON-NLS-1$ //$NON-NLS-2$
     }

Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java	2012-09-06 19:02:53 UTC (rev 4406)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java	2012-09-06 19:15:48 UTC (rev 4407)
@@ -391,7 +391,7 @@
 							break;
 						case KEYS:
 							for (KeyRecord key : table.getAllKeys()) {
-								rows.add(Arrays.asList(vdbName, table.getParent().getName(), table.getName(), key.getName(), key.getAnnotation(), key.getNameInSource(), key.getType().toString(), 
+								rows.add(Arrays.asList(vdbName, schema.getName(), table.getName(), key.getName(), key.getAnnotation(), key.getNameInSource(), key.getType().toString(), 
 										false, (key instanceof ForeignKey)?((ForeignKey)key).getUniqueKeyID():null, key.getUUID(), oid++));
 							}
 							break;

Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java	2012-09-06 19:02:53 UTC (rev 4406)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java	2012-09-06 19:15:48 UTC (rev 4407)
@@ -44,6 +44,7 @@
 import org.teiid.core.types.Transform;
 import org.teiid.core.types.DataTypeManager.DefaultDataClasses;
 import org.teiid.core.util.Assertion;
+import org.teiid.core.util.StringUtil;
 import org.teiid.core.util.TimestampWithTimezone;
 import org.teiid.language.SQLConstants;
 import org.teiid.language.Like.MatchMode;
@@ -98,7 +99,8 @@
     public static final CompareCriteria FALSE_CRITERIA = new CompareCriteria(new Constant(1, DataTypeManager.DefaultDataClasses.INTEGER), CompareCriteria.EQ, new Constant(0, DataTypeManager.DefaultDataClasses.INTEGER));
     public static final CompareCriteria UNKNOWN_CRITERIA = new CompareCriteria(new Constant(null, DataTypeManager.DefaultDataClasses.STRING), CompareCriteria.NE, new Constant(null, DataTypeManager.DefaultDataClasses.STRING));
     
-    private static final Map<String, String> ALIASED_FUNCTIONS = new HashMap<String, String>();
+    private static final Map<String, String> ALIASED_FUNCTIONS = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
+    private static final Set<String> PARSE_FORMAT_TYPES = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
     
     static {
     	ALIASED_FUNCTIONS.put("lower", SourceSystemFunctions.LCASE); //$NON-NLS-1$
@@ -107,12 +109,11 @@
     	ALIASED_FUNCTIONS.put("nvl", SourceSystemFunctions.IFNULL); //$NON-NLS-1$
     	ALIASED_FUNCTIONS.put("||", SourceSystemFunctions.CONCAT); //$NON-NLS-1$
     	ALIASED_FUNCTIONS.put("chr", SourceSystemFunctions.CHAR); //$NON-NLS-1$
-    }
-    
-    private static final Set<String> PARSE_FORMAT_TYPES = new HashSet<String>(Arrays.asList(DataTypeManager.DefaultDataTypes.TIME, 
+    	PARSE_FORMAT_TYPES.addAll(    Arrays.asList(DataTypeManager.DefaultDataTypes.TIME, 
     		DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BIG_DECIMAL, 
     		DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.LONG, 
     		DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.DOUBLE));
+    }
     
     // Constants used in simplifying mathematical criteria
     private final static Integer INTEGER_ZERO = new Integer(0);
@@ -1556,15 +1557,15 @@
         }
     	boolean isFormat = false;
     	Function leftFunction = (Function) crit.getLeftExpression();
-        String funcName = leftFunction.getName().toLowerCase();
+        String funcName = leftFunction.getName();
         String inverseFunction = null;
-        if(funcName.startsWith("parse")) { //$NON-NLS-1$
+        if(StringUtil.startsWithIgnoreCase(funcName, "parse")) { //$NON-NLS-1$
             String type = funcName.substring(5);
             if (!PARSE_FORMAT_TYPES.contains(type)) {
                 return crit;
             }
             inverseFunction = "format" + type; //$NON-NLS-1$
-        } else if(funcName.startsWith("format")) { //$NON-NLS-1$
+        } else if(StringUtil.startsWithIgnoreCase(funcName, "format")) { //$NON-NLS-1$
             String type = funcName.substring(6);
             if (!PARSE_FORMAT_TYPES.contains(type)) {
                 return crit;
@@ -2040,29 +2041,26 @@
 		return expression;
 	}
    
-    private static Map<String, Integer> FUNCTION_MAP = new HashMap<String, Integer>();
+    private static Map<String, Integer> FUNCTION_MAP = new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);
     
     static {
-    	FUNCTION_MAP.put(FunctionLibrary.SPACE.toLowerCase(), 0);
-    	FUNCTION_MAP.put(FunctionLibrary.FROM_UNIXTIME.toLowerCase(), 1);
-    	FUNCTION_MAP.put(FunctionLibrary.NULLIF.toLowerCase(), 2);
-    	FUNCTION_MAP.put(FunctionLibrary.COALESCE.toLowerCase(), 3);
-    	FUNCTION_MAP.put(FunctionLibrary.CONCAT2.toLowerCase(), 4);
-    	FUNCTION_MAP.put(FunctionLibrary.TIMESTAMPADD.toLowerCase(), 5);
-    	FUNCTION_MAP.put(FunctionLibrary.PARSEDATE.toLowerCase(), 6);
-    	FUNCTION_MAP.put(FunctionLibrary.PARSETIME.toLowerCase(), 7);
-    	FUNCTION_MAP.put(FunctionLibrary.FORMATDATE.toLowerCase(), 8);
-    	FUNCTION_MAP.put(FunctionLibrary.FORMATTIME.toLowerCase(), 9);
-    	FUNCTION_MAP.put(SourceSystemFunctions.TRIM.toLowerCase(), 10);
+    	FUNCTION_MAP.put(FunctionLibrary.SPACE, 0);
+    	FUNCTION_MAP.put(FunctionLibrary.FROM_UNIXTIME, 1);
+    	FUNCTION_MAP.put(FunctionLibrary.NULLIF, 2);
+    	FUNCTION_MAP.put(FunctionLibrary.COALESCE, 3);
+    	FUNCTION_MAP.put(FunctionLibrary.CONCAT2, 4);
+    	FUNCTION_MAP.put(FunctionLibrary.TIMESTAMPADD, 5);
+    	FUNCTION_MAP.put(FunctionLibrary.PARSEDATE, 6);
+    	FUNCTION_MAP.put(FunctionLibrary.PARSETIME, 7);
+    	FUNCTION_MAP.put(FunctionLibrary.FORMATDATE, 8);
+    	FUNCTION_MAP.put(FunctionLibrary.FORMATTIME, 9);
+    	FUNCTION_MAP.put(SourceSystemFunctions.TRIM, 10);
     }
     
 	private Expression rewriteFunction(Function function) throws TeiidComponentException, TeiidProcessingException{
-		if (function.isAggregate()) {
-			//AggregateSymbol as = new AggregateSymbol(function.getName(), aggregateFunction, isDistinct, expression)
-		}
 		//rewrite alias functions
-		String functionLowerName = function.getName().toLowerCase();
-		String actualName =ALIASED_FUNCTIONS.get(functionLowerName);
+		String functionName = function.getName();
+		String actualName =ALIASED_FUNCTIONS.get(functionName);
 		FunctionLibrary funcLibrary = this.metadata.getFunctionLibrary();
 
 		if (actualName != null) {
@@ -2076,8 +2074,8 @@
 			function.setFunctionDescriptor(descriptor);
 		}
 		
-		if(functionLowerName.startsWith("parse")) { //$NON-NLS-1$
-            String type = functionLowerName.substring(5);
+		if(StringUtil.startsWithIgnoreCase(functionName, "parse")) { //$NON-NLS-1$
+            String type = functionName.substring(5);
             if (PARSE_FORMAT_TYPES.contains(type) && Number.class.isAssignableFrom(function.getType()) && !type.equals(DataTypeManager.DefaultDataTypes.BIG_DECIMAL)) {
             	Function result = new Function(SourceSystemFunctions.PARSEBIGDECIMAL, function.getArgs());
 				FunctionDescriptor descriptor = 
@@ -2086,8 +2084,8 @@
 				result.setType(DataTypeManager.DefaultDataClasses.BIG_DECIMAL);
 				return rewriteFunction(ResolverUtil.getConversion(result, DataTypeManager.DefaultDataTypes.BIG_DECIMAL, DataTypeManager.getDataTypeName(function.getType()), false, metadata.getFunctionLibrary()));
             }
-        } else if(functionLowerName.startsWith("format")) { //$NON-NLS-1$
-            String type = functionLowerName.substring(6);
+        } else if(StringUtil.startsWithIgnoreCase(functionName, "format")) { //$NON-NLS-1$
+            String type = functionName.substring(6);
             if (PARSE_FORMAT_TYPES.contains(type) && Number.class.isAssignableFrom(function.getArg(0).getType()) && !type.equals(DataTypeManager.DefaultDataTypes.BIG_DECIMAL)) {
             	Function bigDecimalParam = ResolverUtil.getConversion(function.getArg(0), DataTypeManager.getDataTypeName(function.getArg(0).getType()), DataTypeManager.DefaultDataTypes.BIG_DECIMAL, false, metadata.getFunctionLibrary());
             	Function result = new Function(SourceSystemFunctions.FORMATBIGDECIMAL, new Expression[] {bigDecimalParam, function.getArg(1)});
@@ -2099,7 +2097,7 @@
             }
         }
 		
-		Integer code = FUNCTION_MAP.get(functionLowerName);
+		Integer code = FUNCTION_MAP.get(functionName);
 		if (code != null) {
 			switch (code) {
 			case 0: { //space(x) => repeat(' ', x)



More information about the teiid-commits mailing list