/*
 * Copyright 2013 the original author or authors.
 *
 * Licensed 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
 *
 *      http://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 leap.orm.sql.ast;

import java.util.HashSet;
import java.util.Set;


public class SqlSelect extends SqlQuery implements SqlTableSource {

	private boolean 	  distinct;
	private SqlTop		  top;
	private Set<String>   selectItemAliases;
	private SqlSelectList selectList;
	private boolean		  union;

	public boolean isDistinct() {
		return distinct;
	}

	public void setDistinct(boolean distinct) {
		this.distinct = distinct;
	}

	public SqlTop getTop() {
		return top;
	}

	public void setTop(SqlTop top) {
		this.top = top;
	}
	
	public SqlSelectList getSelectList() {
		return selectList;
	}

	public void setSelectList(SqlSelectList selectList) {
		this.selectList = selectList;
	}

	public boolean isSelectItemAlias(String name) {
		return null != selectItemAliases && selectItemAliases.contains(name.toLowerCase());
	}

	public void addSelectItemAlias(String alias) {
		if(null == selectItemAliases) {
			selectItemAliases = new HashSet<String>();
		}
		selectItemAliases.add(alias.toLowerCase());
	}

	public boolean isUnion() {
		return union;
	}

	public void setUnion(boolean union) {
		this.union = union;
	}
}
@@ -636,16 +636,42 @@
 l.ast;%0A%0A
+import java.util.HashMap;%0A
 import j
@@ -848,21 +848,31 @@
 ate 
-Set%3C
+HashMap%3CString, 
 String%3E
-  
  sel
@@ -1451,16 +1451,19 @@
 contains
+Key
 (name.to
@@ -1597,18 +1597,12 @@
 Hash
-Set%3CString
+Map%3C
 %3E();
@@ -1630,32 +1630,193 @@
 ses.
-add(alias.toLowerCase())
+put(alias.toLowerCase(),alias);%0A%09%7D%0A%0A%09public String getSelectItemAlias(String name)%7B%0A%09%09if(isSelectItemAlias(name))%7B%0A%09%09%09return selectItemAliases.get(name.toLowerCase());%0A%09%09%7D%0A%09%09return name
 ;%0A%09%7D

修改查询别名属性为HashMap，同时增加根据字段名获取别名的方法