code: public String replaceAliaces(String str) {
  		if(str == null) return str;
  		// for performance
  		if(str.indexOf(CommonDefs.ALIAS_FIRST_CHAR) < 0) return str;
  		
  		PriorityQueue<AliasDefinition> aliasQueue = new PriorityQueue<AliasDefinition>(11, new Comparator<AliasDefinition>() {
  			public int compare(AliasDefinition alias1, AliasDefinition alias2) {
  				return alias2.getName().length() - alias1.getName().length();
  			}
  		});
  		
  		for(TableDefinition tableDef : getTableDefinitions().values()) {
  			for(AliasDefinition aliasDef : tableDef.getAliasDefinitions()) {
  				aliasQueue.add(aliasDef);					
  			}
  		}
  		while(true) {
  			String newstring = str; 
  			 while (aliasQueue.size() != 0) {			        
  				AliasDefinition aliasDef = aliasQueue.poll();
  		        newstring = newstring.replace(aliasDef.getName(), aliasDef.getExpression());
  			}	 
  			if(newstring.equals(str)) break;
  			str = newstring;
  		}
  		return str;
  	}
docs: Replaces of all occurences of aliases defined with this table, by their expressions.
  Now a simple string.replace is used.
  
  @param str string to replace
  @return string with replaced aliases. If there were no aliases, the string is unchanged.