JBoss Rich Faces SVN: r17672 - root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-06-25 11:23:04 -0400 (Fri, 25 Jun 2010)
New Revision: 17672
Modified:
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/1.html
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/ComboBox.js
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/SelectBase.js
Log:
https://jira.jboss.org/browse/RF-8875
Modified: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/1.html
===================================================================
--- root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/1.html 2010-06-25 14:54:44 UTC (rev 17671)
+++ root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/1.html 2010-06-25 15:23:04 UTC (rev 17672)
@@ -17,7 +17,7 @@
.cb_field_width{ width : 150px;}
.cb_list_width{ width : 250px;}
- .cb_list_height{ height : 100px;}
+ .cb_list_height{ max-height : 100px;}
.cb_font{color : #000000/*generalTextColor*/}
.cb_input {border : 0px; background : none; width : 100%;}
@@ -30,8 +30,8 @@
.cb_list_cord{ position : relative; font-size : 0px;display : none}/*DDL is hidden!!!!!*/
.cb_list_position{ position : absolute; top: 0px; left: -1px; }
.cb_list_decoration{ border : 1px solid #A6A6A6 /*panelBorderColor*/; padding : 0px; background : #FFFFFF; /*tableBackgroundColor*/}
- .cb_list_scroll{ overflow : auto; overflow-x : hidden;}
- .cb_option{ padding : 2px; white-space : nowrap; cursor : default;}
+ .cb_list_scroll{ overflow : auto; overflow-x : hidden; list-style: none; margin:0px; padding:0px;}
+ .cb_option{ padding : 2px; white-space : nowrap; cursor : default; display:block; margin:0px; overflow:hidden;}
.cb_select{ padding : 1px; width : 100%; background-color: #DFE8F6; border : 1px dotted #a3bae9;/*generalTextColor*/}
.cb_list_shadow{ position : absolute; width : 260px; height : 109px; margin-left : -4px; margin-top : -2px;}
@@ -56,17 +56,20 @@
<img src="images/bg_shadow.png" class="cb_list_shadow">
<div class="cb_list_position cb_list_width">
<div class="cb_list_decoration">
- <div id="myComboItems" class="cb_list_scroll cb_list_height">
- <div class="cb_option cb_font">Option 1</div>
- <div class="cb_option cb_font">Option 2</div>
- <div class="cb_option cb_font">Option 3</div>
- <div class="cb_option cb_font">Option 4</div>
- <div class="cb_option cb_font">Option 6</div>
- <div class="cb_option cb_font">Option 7</div>
- <div class="cb_option cb_font">Option 8</div>
- <div class="cb_option cb_font">Option 9</div>
- <div class="cb_option cb_font">Option 0</div>
- </div>
+ <ul id="myComboItems" class="cb_list_scroll cb_list_height">
+ <li class="cb_option cb_font">December</li>
+ <li class="cb_option cb_font"><span>November</span><img src="images/down.gif" width="20" height="20"/></li>
+ <li class="cb_option cb_font">October</li>
+ <li class="cb_option cb_font">September</li>
+ <li class="cb_option cb_font">August</li>
+ <li class="cb_option cb_font">July</li>
+ <li class="cb_option cb_font">June</li>
+ <li class="cb_option cb_font">May</li>
+ <li class="cb_option cb_font">April</li>
+ <li class="cb_option cb_font">March</li>
+ <li class="cb_option cb_font">February</li>
+ <li class="cb_option cb_font">January</li>
+ </ul>
</div>
</div>
</div>
Modified: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/ComboBox.js
===================================================================
--- root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/ComboBox.js 2010-06-25 14:54:44 UTC (rev 17671)
+++ root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/ComboBox.js 2010-06-25 15:23:04 UTC (rev 17672)
@@ -1,14 +1,45 @@
(function ($, rf) {
+ rf.utils = rf.utils || {};
+
+ rf.utils.Cache = function (data, options) {
+ this.data = data || [];
+ this.values = options.parse && options.parse(this.data) || this.data;
+ };
+
+ var getItems = function (str) {
+ if (!str || str.length==0) {
+ return this.data;
+ }
+ var newData = [];
+ for (var i = 0; i<this.values.length; i++) {
+ var value = this.values[i].toLowerCase();
+ var p = value.indexOf(str.toLowerCase());
+ p == 0 && newData.push(this.data[i]);
+ }
+ return newData;
+ };
+
+ $.extend(rf.utils.Cache.prototype, (function () {
+ return {
+ getItems: getItems
+ };
+ })());
+
+})(jQuery, RichFaces);
+
+(function ($, rf) {
+
rf.ui = rf.ui || {};
// Constructor definition
rf.ui.ComboBox = function(componentId, fieldId, options) {
this.namespace = "."+rf.Event.createNamespace(this.name, this.componentId);
+ this.options = {};
// call constructor of parent class
$super.constructor.call(this, componentId+ID.SELECT, fieldId, options);
$p.attachToDom(componentId);
this.componentId = componentId;
- this.options = $.extend({}, defaultOptions, options);
+ this.options = $.extend(this.options, defaultOptions, options);
//this.currentValue = rf.getDomElement(this.fieldId).value;
this.index = -1;
updateItemsList.call(this);
@@ -24,7 +55,8 @@
var $super = rf.ui.ComboBox.$super;
var defaultOptions = {
- selectedItemClass:'cb_select'
+ selectedItemClass:'cb_select',
+ autoFill:true
};
var ID = {
@@ -33,23 +65,38 @@
};
var bindEventHandlers = function () {
- rf.Event.bindById(this.componentId+ID.ITEMS, "mouseover"+this.namespace, onClick, this);
+ rf.Event.bindById(this.componentId+ID.ITEMS, "mouseover"+this.namespace, onMouseOver, this);
};
- var onClick = function(event) {
+ var onMouseOver = function(event) {
+ console && console.log && console.log("mouseOver");
var element = event.target;
while (element.parentNode && element.parentNode!=event.currentTarget) {
element = element.parentNode;
};
if (element.parentNode) {
- this.selectItem(this.items.index(element));
+ var index = this.items.index(element);
+ if (index!=this.index) {
+ this.selectItem(index);
+ }
}
- }
+ };
var updateItemsList = function () {
this.items = $(rf.getDomElement(this.componentId+ID.ITEMS)).children();
+ this.cache = new rf.utils.Cache(this.items, {
+ parse: getData
+ });
};
+ var getData = function (nodeList) {
+ var data = [];
+ nodeList.each(function () {
+ data.push($(this).text());
+ });
+ return data;
+ };
+
var scrollToSelectedItem = function() {
var offset = 0;
this.items.slice(0, this.index).each(function() {
@@ -66,6 +113,14 @@
}
};
+ var autoFill = function (inputValue, value) {
+ if( this.options.autoFill) {
+ var field = rf.getDomElement(this.fieldId);
+ field.value = field.value + value.substring(inputValue.length);
+ rf.Selection.set(field, inputValue.length, field.value.length);
+ }
+ };
+
// Add new properties and methods
$.extend(rf.ui.SelectBase.prototype, (function () {
return {
@@ -84,8 +139,13 @@
this.items.eq(this.index).removeClass(this.options.selectedItemClass);
}
+ if (index==undefined) {
+ this.index = -1;
+ return;
+ }
+
if (isOffset) {
- this.index += offset;
+ this.index += index;
if ( this.index<0 ) {
this.index = this.items.length - 1;
} else if (this.index >= this.items.length) {
@@ -120,20 +180,29 @@
},
- onChange: function () {
+ onChange: function (event, value) {
+ this.selectItem();
+ var newItems = this.cache.getItems(value);
+ this.items = $(newItems);
+ $(rf.getDomElement(this.componentId+ID.ITEMS)).empty().append(newItems);
+ this.index = -1;
+ this.selectItem(0);
+ // getFirstValue
+ $(this.items).first().text();
+ if (event.which != rf.KEYS.BACKSPACE) {
+ autoFill.call(this, value, $(this.items).first().text());
+ }
},
onShow: function () {
if (this.items.length>0) {
+ //??TODO it's nessesary only if not changed value
this.selectItem(0);
}
},
onHide: function () {
- if (this.index!=-1) {
- this.items.eq(this.index).removeClass(this.options.selectedItemClass);
- this.index=-1;
- }
+ this.selectItem();
}
};
})());
Modified: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/SelectBase.js
===================================================================
--- root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/SelectBase.js 2010-06-25 14:54:44 UTC (rev 17671)
+++ root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/SelectBase.js 2010-06-25 15:23:04 UTC (rev 17672)
@@ -20,6 +20,22 @@
}
});
+(function (rf) {
+ rf.KEYS = {
+ BACKSPACE: 8,
+ TAB: 9,
+ RETURN: 13,
+ ESC: 27,
+ PAGEUP: 33,
+ PAGEDOWN: 34,
+ LEFT: 37,
+ UP: 38,
+ RIGHT: 39,
+ DOWN: 40,
+ DEL: 46,
+ }
+})(RichFaces);
+
(function ($, rf) {
rf.ui = rf.ui || {};
@@ -45,22 +61,9 @@
var $super = rf.ui.SelectBase.$super;
var defaultOptions = {
+ changeDelay:8
};
- var KEYS = {
- BACKSPACE: 8,
- TAB: 9,
- RETURN: 13,
- ESC: 27,
- PAGEUP: 33,
- PAGEDOWN: 34,
- LEFT: 37,
- UP: 38,
- RIGHT: 39,
- DOWN: 40,
- DEL: 46,
- };
-
var bindEventHandlers = function() {
if (this.options.buttonId) {
rf.Event.bindById(this.options.buttonId, "mousedown"+this.namespace, onButtonShow, this);
@@ -132,12 +135,13 @@
var onChange = function (event) {
var value = rf.getDomElement(this.fieldId).value;
var flag = value != this.currentValue;
- if (event.which == KEYS.LEFT || event.which == KEYS.RIGHT || flag) {
+ if (event.which == rf.KEYS.LEFT || event.which == rf.KEYS.RIGHT || flag) {
// TODO: call onchange
if (flag && !this.isVisible) {
this.show();
}
if (flag) {
+ this.onChange(event, value);
this.currentValue = value;
}
}
@@ -151,13 +155,13 @@
var onKeyDown = function (event) {
switch(event.which) {
- case KEYS.UP:
+ case rf.KEYS.UP:
event.preventDefault();
if (this.isVisible) {
this.selectPrevItem();
}
break;
- case KEYS.DOWN:
+ case rf.KEYS.DOWN:
event.preventDefault();
if (this.isVisible) {
this.selectNextItem();
@@ -165,20 +169,20 @@
this.show();
}
break;
- case KEYS.PAGEUP:
+ case rf.KEYS.PAGEUP:
event.preventDefault();
if (this.isVisible) {
this.selectPageUp();
}
break;
- case KEYS.PAGEDOWN:
+ case rf.KEYS.PAGEDOWN:
event.preventDefault();
if (this.isVisible) {
this.selectPageDown();
}
break;
- case KEYS.TAB:
- case KEYS.RETURN:
+ case rf.KEYS.TAB:
+ case rf.KEYS.RETURN:
event.preventDefault();
/*if( selectCurrent() ) {
event.preventDefault();
@@ -188,17 +192,14 @@
}*/
this.hide();
break;
- case KEYS.ESC:
+ case rf.KEYS.ESC:
this.hide();
break;
default:
if (!this.options.selectOnly) {
- if (this.options.changeDelay) {
- var _this = this;
- this.changeTimerId = window.setTimeout(function(){onChange.call(_this, event);}, this.options.changeDelay)
- } else {
- onChange.call(this, event);
- }
+ var _this = this;
+ window.clearTimeout(this.changeTimerId);
+ this.changeTimerId = window.setTimeout(function(){onChange.call(_this, event);}, this.options.changeDelay)
}
break;
}
14 years, 6 months
JBoss Rich Faces SVN: r17671 - root/ui/iteration/trunk/tables/api/src/main/java/org/richfaces/event.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-06-25 10:54:44 -0400 (Fri, 25 Jun 2010)
New Revision: 17671
Modified:
root/ui/iteration/trunk/tables/api/src/main/java/org/richfaces/event/ToggleEvent.java
Log:
RF-8658
Modified: root/ui/iteration/trunk/tables/api/src/main/java/org/richfaces/event/ToggleEvent.java
===================================================================
--- root/ui/iteration/trunk/tables/api/src/main/java/org/richfaces/event/ToggleEvent.java 2010-06-25 14:54:42 UTC (rev 17670)
+++ root/ui/iteration/trunk/tables/api/src/main/java/org/richfaces/event/ToggleEvent.java 2010-06-25 14:54:44 UTC (rev 17671)
@@ -33,14 +33,31 @@
public class ToggleEvent extends FacesEvent {
private static final long serialVersionUID = 2916560585918250885L;
+
+ private String togglerId;
private boolean expanded;
+
+
public ToggleEvent(UIComponent source, boolean expanded) {
+ this(source, expanded, null);
+ }
+
+ public ToggleEvent(UIComponent source, boolean expanded, String toggerId) {
super(source);
this.expanded = expanded;
+ this.togglerId = toggerId;
}
+
+ public String getTogglerId() {
+ return togglerId;
+ }
+ public void setTogglerId(String togglerId) {
+ this.togglerId = togglerId;
+ }
+
public boolean isExpanded() {
return this.expanded;
}
14 years, 6 months
JBoss Rich Faces SVN: r17670 - in root/ui/iteration/trunk/tables/ui/src/main: java/org/richfaces/renderkit and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-06-25 10:54:42 -0400 (Fri, 25 Jun 2010)
New Revision: 17670
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/subtable-toggler.js
root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/subtable.js
Log:
RF-8658
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-06-25 00:01:41 UTC (rev 17669)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-06-25 14:54:42 UTC (rev 17670)
@@ -66,8 +66,16 @@
valueExpression.setValue(elContext, newValue);
}
- String render = resolveClientId(facesContext, this, BODY);
- getFacesContext().getPartialViewContext().getRenderIds().add(render);
+ if(getFacesContext().getPartialViewContext().isAjaxRequest()) {
+ String render = resolveClientId(facesContext, this, BODY);
+
+ getFacesContext().getPartialViewContext().getRenderIds().add(render);
+
+ String togglerId = toggleEvent.getTogglerId();
+ if(togglerId != null) {
+ getFacesContext().getPartialViewContext().getRenderIds().add(togglerId);
+ }
+ }
}
super.broadcast(event);
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-25 00:01:41 UTC (rev 17669)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-25 14:54:42 UTC (rev 17670)
@@ -87,9 +87,12 @@
String clientId = subTable.getClientId(facesContext);
Map<String, String> requestMap = facesContext.getExternalContext().getRequestParameterMap();
+ String optionsId = clientId + OPTIONS;
+ String togglerId = requestMap.get(optionsId);
+
String stateId = clientId + STATE;
String state = (String)requestMap.get(stateId);
-
+
boolean isExpand = true;
if(state != null) {
int newValue = Integer.parseInt(state);
@@ -99,7 +102,7 @@
}
if(subTable.isExpanded() != isExpand) {
- new ToggleEvent(subTable, isExpand).queue();
+ new ToggleEvent(subTable, isExpand, togglerId).queue();
}
}
}
Modified: root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/subtable-toggler.js
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/subtable-toggler.js 2010-06-25 00:01:41 UTC (rev 17669)
+++ root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/subtable-toggler.js 2010-06-25 14:54:42 UTC (rev 17670)
@@ -23,7 +23,12 @@
toggle: function(e) {
var subtable = richfaces.$(this.forId);
if(subtable) {
- this.toggleControl(subtable.isExpand());
+ var mode = subtable.getMode();
+
+ if(richfaces.ui.SubTable.MODE_CLNT == mode) {
+ this.toggleControl(subtable.isExpand());
+ }
+
subtable.setOption(this.id);
subtable.toggle(e);
}
Modified: root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/subtable.js
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/subtable.js 2010-06-25 00:01:41 UTC (rev 17669)
+++ root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/subtable.js 2010-06-25 14:54:42 UTC (rev 17670)
@@ -103,7 +103,11 @@
setOption: function(option) {
optionsInputElem.call(this).val(option);
- }
+ },
+
+ getMode: function() {
+ return this.expandMode;
+ }
};
})());
14 years, 6 months
JBoss Rich Faces SVN: r17669 - in root/cdk/branches/RF8755/plugins/generator/src: main/java/org/richfaces/cdk/templatecompiler/builder/model and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-06-24 20:01:41 -0400 (Thu, 24 Jun 2010)
New Revision: 17669
Added:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/StatementImpl.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELType.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactoryImpl.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConstantReturnMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToBooleanMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToStringMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EmptinessCheckingMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EncodeMethodPrefaceStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EndElementStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EqualsCheckingMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfElseStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StartElementStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StatementsContainer.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java
Removed:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatementsContainer.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConstantReturnMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToStringMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EndElementStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ForEachStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfElseStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBody.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatement.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementImpl.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/Type.java
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaField.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaMethod.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/Variables.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserUtils.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELVisitor.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractBinaryOperationTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractMethodTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstBracketSuffixTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstChoiceTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstDeferredOrDynamicExpressionTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstEmptyTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFloatingPointTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFunctionTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIdentifierTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIntegerTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstLiteralTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstPropertySuffixTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstStringTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticIntegerOperationTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticOperationTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanOperationTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanResultOperationTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/ConstantValueTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/EqualityTestTreeNode.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ComplexType.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/NullType.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/PlainClassType.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ReferencedType.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactory.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/ELParserTest.java
root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/TypesFactoryTest.java
Log:
convert EL parser to guice
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatementsContainer.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatementsContainer.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatementsContainer.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatementsContainer;
-
-/**
- * @author Nick Belaevski
- */
-public class AbstractTemplateMethodBodyStatementsContainer extends MethodBodyStatementsContainer {
-
- private String templateName;
-
- protected AbstractTemplateMethodBodyStatementsContainer(String templateName) {
- super();
- this.templateName = templateName;
- }
-
- @Override
- public String getCode(FreeMarkerRenderer renderer) {
- return renderer.renderSnippet(templateName, this);
- }
-
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatement;
-
-/**
- * @author Nick Belaevski
- */
-public class BaseTemplateMethodBodyStatement implements MethodBodyStatement {
-
- private String templateName;
-
- protected BaseTemplateMethodBodyStatement(String templateName) {
- super();
- this.templateName = templateName;
- }
-
- @Override
- public String getCode(FreeMarkerRenderer renderer) {
- return renderer.renderSnippet(templateName, this);
- }
-
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConstantReturnMethodBodyStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConstantReturnMethodBodyStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConstantReturnMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class ConstantReturnMethodBodyStatement extends BaseTemplateMethodBodyStatement {
-
- private String returnValue;
-
- public ConstantReturnMethodBodyStatement(String returnValue) {
- super("constant-return");
-
- this.returnValue = returnValue;
- }
-
- public String getReturnValue() {
- return returnValue;
- }
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-/**
- * @author Nick Belaevski
- */
-public class ConversionToBooleanMethodBodyStatement extends HelperMethodBodyStatement {
-
- public ConversionToBooleanMethodBodyStatement() {
- super("conversion-to-boolean-method", new String[] {"object"});
- }
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToStringMethodBodyStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToStringMethodBodyStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToStringMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-/**
- * @author Nick Belaevski
- */
-public class ConversionToStringMethodBodyStatement extends HelperMethodBodyStatement {
-
- public ConversionToStringMethodBodyStatement() {
- super("conversion-to-string-method", new String[] {"object"});
- }
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-import org.richfaces.cdk.templatecompiler.el.Type;
-
-/**
- * @author Nick Belaevski
- */
-public class DefineObjectStatement extends BaseTemplateMethodBodyStatement {
-
- private Type type;
-
- private String name;
-
- private String initializationExpression;
-
- public DefineObjectStatement(Type type, String name, String initializationExpression) {
- super("define-object");
-
- this.type = type;
- this.name = name;
- this.initializationExpression = initializationExpression != null ? initializationExpression : "";
- }
-
- /**
- * @return the type
- */
- public Type getType() {
- return type;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return the initializationExpression
- */
- public String getInitializationExpression() {
- return initializationExpression;
- }
-
-}
Added: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,19 @@
+package org.richfaces.cdk.templatecompiler;
+
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.templatecompiler.builder.model.Variables;
+import org.richfaces.cdk.templatecompiler.el.ELType;
+import org.richfaces.cdk.templatecompiler.el.ParsingException;
+import org.richfaces.cdk.templatecompiler.statements.TemplateStatement;
+
+public interface ELParser {
+
+ TemplateStatement parse(String expression, Variables variables, ELType expectedType) throws ParsingException;
+
+ ELType getType(Class<?> targetClass);
+
+ ELType getType(String classExpression);
+
+ ELType getType(ClassName targetClass);
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ELParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-/**
- * @author Nick Belaevski
- */
-public class EmptinessCheckingMethodBodyStatement extends HelperMethodBodyStatement {
-
- public EmptinessCheckingMethodBodyStatement() {
- super("emptiness-check-method", new String[] {"object"});
- }
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-/**
- * @author Nick Belaevski
- */
-public class EncodeMethodPrefaceStatement extends BaseTemplateMethodBodyStatement {
-
- /**
- * @param templateName
- */
- public EncodeMethodPrefaceStatement() {
- super("encode-method-preface");
- }
-
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EndElementStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EndElementStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EndElementStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-public class EndElementStatement extends StartElementStatement {
-
- public EndElementStatement(String elementName) {
- super("end-element", elementName);
- }
-
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class EqualsCheckingMethodBodyStatement extends HelperMethodBodyStatement {
-
- public EqualsCheckingMethodBodyStatement() {
- super("equals-check-method", new String[] {"o1", "o2"});
- }
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ForEachStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ForEachStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ForEachStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-/**
- * @author Nick Belaevski
- */
-public class ForEachStatement extends AbstractTemplateMethodBodyStatementsContainer {
-
- private String itemsExpression;
-
- private String var;
-
- private String varType;
-
- public ForEachStatement(String itemsExpression,
- String var, String varType) {
- super("for-each");
- this.itemsExpression = itemsExpression;
- this.var = var;
- this.varType = varType;
- }
-
- /**
- * @return the itemsExpression
- */
- public String getItemsExpression() {
- return itemsExpression;
- }
-
- /**
- * @return the var
- */
- public String getVar() {
- return var;
- }
-
- /**
- * @return the varType
- */
- public String getVarType() {
- return varType;
- }
-
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class HelperMethodBodyStatement extends BaseTemplateMethodBodyStatement {
-
- private String[] argumentNames;
-
- protected HelperMethodBodyStatement(String templateName, String[] argumentNames) {
- super(templateName);
-
- this.argumentNames = argumentNames;
- }
-
- public String[] getArgumentNames() {
- return argumentNames;
- }
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfElseStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfElseStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfElseStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,34 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-public class IfElseStatement extends AbstractTemplateMethodBodyStatementsContainer {
-
- public IfElseStatement() {
- super("if-else");
- }
-
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatementsContainer;
-
-public final class IfStatement extends MethodBodyStatementsContainer {
-
- private String test;
-
- public IfStatement(String test) {
- super();
- this.test = test;
- }
-
- public String getTest() {
- return test;
- }
-}
\ No newline at end of file
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/JavaClassModelWrapper.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,6 +1,6 @@
package org.richfaces.cdk.templatecompiler;
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaStatement;
import freemarker.ext.beans.BeansWrapper;
import freemarker.template.ObjectWrapper;
@@ -21,8 +21,8 @@
// TODO wrap specified model classes.
TemplateModel templateModel;
- if (obj instanceof MethodBodyStatement) {
- templateModel = new MethodBodyTemplateModel((MethodBodyStatement) obj, this);
+ if (obj instanceof JavaStatement) {
+ templateModel = new MethodBodyTemplateModel((JavaStatement) obj, this);
} else {
templateModel = super.wrap(obj);
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/MethodBodyTemplateModel.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -23,7 +23,7 @@
package org.richfaces.cdk.templatecompiler;
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaStatement;
import freemarker.ext.beans.BeanModel;
import freemarker.template.TemplateModel;
@@ -38,7 +38,7 @@
private static final String CODE_ATTRIBUTE_NAME = "code";
- private final MethodBodyStatement statement;
+ private final JavaStatement statement;
private final JavaClassModelWrapper modelWrapper;
/**
@@ -47,7 +47,7 @@
* @param statement
* @param javaClassModelWrapper
*/
- public MethodBodyTemplateModel(MethodBodyStatement statement, JavaClassModelWrapper javaClassModelWrapper) {
+ public MethodBodyTemplateModel(JavaStatement statement, JavaClassModelWrapper javaClassModelWrapper) {
super(statement, javaClassModelWrapper);
this.statement = statement;
this.modelWrapper = javaClassModelWrapper;
@@ -56,7 +56,7 @@
@Override
public TemplateModel get(String key) throws TemplateModelException {
if (CODE_ATTRIBUTE_NAME.equals(key)) {
- String statementCode = statement.getCode(modelWrapper.getConfiguration());
+ String statementCode = statement.getCode();
return modelWrapper.wrap(statementCode);
}
return super.get(key);
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -55,16 +55,15 @@
import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
import org.richfaces.cdk.templatecompiler.builder.model.JavaMethod;
import org.richfaces.cdk.templatecompiler.builder.model.JavaModifier;
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBody;
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatement;
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatementImpl;
-import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatementsContainer;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaStatement;
+import org.richfaces.cdk.templatecompiler.builder.model.StatementImpl;
import org.richfaces.cdk.templatecompiler.el.ELParserUtils;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.HelperMethod;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactoryImpl;
import org.richfaces.cdk.templatecompiler.model.AnyElement;
import org.richfaces.cdk.templatecompiler.model.CdkBodyElement;
import org.richfaces.cdk.templatecompiler.model.CdkCallElement;
@@ -78,11 +77,30 @@
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
import org.richfaces.cdk.templatecompiler.model.Template;
import org.richfaces.cdk.templatecompiler.model.TemplateVisitor;
+import org.richfaces.cdk.templatecompiler.statements.ConstantReturnMethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.statements.ConversionToBooleanMethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.statements.ConversionToStringMethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.statements.DefineObjectStatement;
+import org.richfaces.cdk.templatecompiler.statements.EmptinessCheckingMethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.statements.EncodeMethodPrefaceStatement;
+import org.richfaces.cdk.templatecompiler.statements.EndElementStatement;
+import org.richfaces.cdk.templatecompiler.statements.EqualsCheckingMethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.statements.ForEachStatement;
+import org.richfaces.cdk.templatecompiler.statements.HelperMethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.statements.IfElseStatement;
+import org.richfaces.cdk.templatecompiler.statements.IfStatement;
+import org.richfaces.cdk.templatecompiler.statements.StartElementStatement;
+import org.richfaces.cdk.templatecompiler.statements.StatementsContainer;
+import org.richfaces.cdk.templatecompiler.statements.TemplateStatement;
+import org.richfaces.cdk.templatecompiler.statements.WriteAttributeStatement;
+import org.richfaces.cdk.templatecompiler.statements.WriteAttributesSetStatement;
+import org.richfaces.cdk.templatecompiler.statements.WriteTextStatement;
import org.richfaces.cdk.util.Strings;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableSet;
+import com.google.inject.Injector;
/**
* <p class="changed_added_4_0">
@@ -142,30 +160,28 @@
private final Logger log;
- private MethodBodyStatementsContainer currentStatement;
+ private StatementsContainer currentStatement;
- private final Schema attributesSchema;
private JavaClass generatedClass;
private CompositeInterface compositeInterface;
- private final ClassLoader classLoader;
+ private final ELParser parser;
private Set<HelperMethod> addedHelperMethods = EnumSet.noneOf(HelperMethod.class);
- private Type lastCompiledExpressionType;
+ private ELType lastCompiledExpressionType;
private int passThroughCounter;
private final Collection<PropertyBase> attributes;
- private final VisitorFactoryImpl visitorFactoryImpl;
+ private final Injector injector;
- public RendererClassVisitor(CompositeInterface compositeInterface, Collection<PropertyBase> attributes,
- VisitorFactoryImpl factory) {
+ public RendererClassVisitor(CompositeInterface compositeInterface, Collection<PropertyBase> attributes, Logger log,
+ Injector injector, ELParser parser) {
this.compositeInterface = compositeInterface;
this.attributes = attributes;
- this.visitorFactoryImpl = factory;
- this.classLoader = factory.classLoader;
- this.log = factory.log;
- this.attributesSchema = factory.attributesSchema;
+ this.injector = injector;
+ this.parser = parser;
+ this.log = log;
}
private void initializeJavaClass() {
@@ -185,6 +201,10 @@
this.createMethodContext();
}
+ private <T extends TemplateStatement> T createStatement(Class<T> statementClass) {
+ return this.injector.getInstance(statementClass);
+ }
+
private void addHelperMethod(HelperMethod helperMethod) {
if (addedHelperMethods.add(helperMethod)) {
HelperMethodBodyStatement methodBodyStatement = HELPER_METHOD_BODIES.get(helperMethod);
@@ -206,9 +226,7 @@
helperJavaMethod.addModifier(JavaModifier.STATIC);
helperJavaMethod.addModifier(JavaModifier.FINAL);
- MethodBody helperJavaMethodBody = new MethodBody(helperJavaMethod);
- helperJavaMethod.setMethodBody(helperJavaMethodBody);
- helperJavaMethodBody.addStatement(methodBodyStatement);
+ helperJavaMethod.setMethodBody(methodBodyStatement);
generatedClass.addMethod(helperJavaMethod);
}
@@ -217,7 +235,7 @@
private String compileEl(String expression, Class<?> type) {
try {
ELVisitor elVisitor = new ELVisitor();
- elVisitor.parse(expression, currentStatement, TypesFactory.getType(type));
+ elVisitor.parse(expression, currentStatement, TypesFactoryImpl.getType(type));
lastCompiledExpressionType = elVisitor.getExpressionType();
String parsedExpression = elVisitor.getParsedExpression();
@@ -246,14 +264,14 @@
return false;
}
- private Type createTypeOfKnownClass(JavaClass initialClass, Class<?> knownSuperClass) {
+ private ELType createTypeOfKnownClass(JavaClass initialClass, Class<?> knownSuperClass) {
assert !knownSuperClass.isInterface();
- Type result = null;
+ ELType result = null;
JavaClass javaClass = initialClass;
while (javaClass != null) {
- Type type = TypesFactory.getType(javaClass.getName(), classLoader);
+ ELType type = TypesFactoryImpl.getType(javaClass.getName(), parser);
if (knownSuperClass.isAssignableFrom(type.getRawType())) {
result = type;
break;
@@ -263,7 +281,7 @@
}
if (result == null) {
- result = TypesFactory.getType(knownSuperClass);
+ result = TypesFactoryImpl.getType(knownSuperClass);
}
return result;
@@ -350,31 +368,25 @@
fieldValue.append("))");
- passThroughField.setValue(fieldValue.toString());
+ passThroughField.setValue(new StatementImpl(fieldValue.toString()));
generatedClass.addField(passThroughField);
return fieldName;
}
- private void addRendererUtilsImport() {
- if (!Strings.isEmpty(this.visitorFactoryImpl.rendererUtilsClassName)) {
- generatedClass.addImport("static " + this.visitorFactoryImpl.rendererUtilsClassName + ".*");
- }
- }
-
private void createMethodContext() {
- this.currentStatement = new MethodBody();
- currentStatement.setVariable(FACES_CONTEXT_VARIABLE, TypesFactory.getType(FacesContext.class));
- currentStatement.setVariable(RESPONSE_WRITER_VARIABLE, TypesFactory.getType(ResponseWriter.class));
- currentStatement.setVariable(CLIENT_ID_VARIABLE, TypesFactory.getType(String.class));
+ this.currentStatement = new StatementsContainer();
+ currentStatement.setVariable(FACES_CONTEXT_VARIABLE, TypesFactoryImpl.getType(FacesContext.class));
+ currentStatement.setVariable(RESPONSE_WRITER_VARIABLE, TypesFactoryImpl.getType(ResponseWriter.class));
+ currentStatement.setVariable(CLIENT_ID_VARIABLE, TypesFactoryImpl.getType(String.class));
// TODO: try load component class
- currentStatement.setVariable(COMPONENT_VARIABLE, TypesFactory.getType(UIComponent.class));
+ currentStatement.setVariable(COMPONENT_VARIABLE, TypesFactoryImpl.getType(UIComponent.class));
- Type generatedClassType = createTypeOfKnownClass(generatedClass, Renderer.class);
+ ELType generatedClassType = createTypeOfKnownClass(generatedClass, Renderer.class);
currentStatement.setVariable(THIS_VARIABLE, generatedClassType);
- Type generatedClassSuperType = createTypeOfKnownClass(generatedClass.getSuperClass(), Renderer.class);
+ ELType generatedClassSuperType = createTypeOfKnownClass(generatedClass.getSuperClass(), Renderer.class);
currentStatement.setVariable(SUPER_VARIABLE, generatedClassSuperType);
}
@@ -387,24 +399,30 @@
javaMethod.addModifier(JavaModifier.PUBLIC);
javaMethod.addAnnotation(Override.class);
javaMethod.getExceptions().add(IOException.class);
+ currentStatement.addStatement(0, new EncodeMethodPrefaceStatement());
- MethodBody methodBody = (MethodBody) currentStatement;
- javaMethod.setMethodBody(methodBody);
+ javaMethod.setMethodBody(currentStatement);
- methodBody.addStatement(0, new EncodeMethodPrefaceStatement());
generatedClass.addMethod(javaMethod);
- Collection<Class<?>> importsList = currentStatement.getImports();
- if (importsList != null) {
- for (Class<?> importedClass : importsList) {
- generatedClass.addImport(importedClass);
+ Iterable<ELType> importsList = currentStatement.getRequiredImports();
+ for (ELType importedClass : importsList) {
+ generatedClass.addImport(importedClass.getRawType());
+ for (Class<?> classToImport : importedClass.getImportsList()) {
+ generatedClass.addImport(classToImport);
}
}
+ for (HelperMethod helper : currentStatement.getRequiredMethods()) {
+ addHelperMethod(helper);
+ }
+ for(JavaField field : currentStatement.getRequiredFields()){
+ generatedClass.addField(field);
+ }
}
createMethodContext();
}
- private void defineObject(Type type, String name, String initializationExpression) {
+ private void defineObject(ELType type, String name, String initializationExpression) {
addStatement(new DefineObjectStatement(type, name, initializationExpression));
currentStatement.setVariable(name, type);
}
@@ -416,17 +434,15 @@
rendersChildrenMethod.addModifier(JavaModifier.PUBLIC);
rendersChildrenMethod.addAnnotation(Override.class);
- MethodBody methodBody = new MethodBody();
- rendersChildrenMethod.setMethodBody(methodBody);
+ rendersChildrenMethod.setMethodBody(new ConstantReturnMethodBodyStatement(Boolean
+ .toString(compositeInterface.getRendersChildren())));
generatedClass.addMethod(rendersChildrenMethod);
- methodBody.addStatement(new ConstantReturnMethodBodyStatement(Boolean.toString(compositeInterface
- .getRendersChildren())));
}
}
- protected void pushStatement(MethodBodyStatementsContainer container) {
+ protected void pushStatement(StatementsContainer container) {
addStatement(container);
currentStatement = container;
}
@@ -435,7 +451,7 @@
currentStatement = currentStatement.getParent();
}
- protected void addStatement(MethodBodyStatement statement) {
+ protected void addStatement(JavaStatement statement) {
// TODO - add imports, fields and helper methods required by statement.
addStatement(statement);
}
@@ -519,8 +535,8 @@
String attributeLocalName = attributeName.getLocalPart();
if (writtenAttributes.add(attributeLocalName)) {
addRendererUtilsImport();
- addStatement(new WriteAttributeStatement(attributeLocalName, compileEl(attributeValue
- .toString(), Object.class)));
+ addStatement(new WriteAttributeStatement(attributeLocalName, compileEl(
+ attributeValue.toString(), Object.class)));
}
}
}
@@ -529,8 +545,8 @@
Element attributesElement = attributesSchema.getElements().get(elementName.getLocalPart());
if (attributesElement != null) {
// make a copy of original set
- TreeMap<String, Attribute> actualAttributesMap = new TreeMap<String, Attribute>(attributesElement
- .getAttributes());
+ TreeMap<String, Attribute> actualAttributesMap = new TreeMap<String, Attribute>(
+ attributesElement.getAttributes());
if (passThroughExclusions != null) {
for (String passThroughExclusion : passThroughExclusions) {
@@ -595,7 +611,7 @@
expression = cdkCallElement.getBodyValue();
}
- addStatement(new MethodBodyStatementImpl(expression + ";"));
+ addStatement(new StatementImpl(expression + ";"));
}
/*
@@ -723,9 +739,9 @@
typeString += "<" + typeArgumentsString + ">";
}
- Type type = null;
+ ELType type = null;
if (!Strings.isEmpty(typeString)) {
- type = TypesFactory.getType(typeString, classLoader);
+ type = TypesFactoryImpl.getType(typeString, parser);
}
if (!Strings.isEmpty(value)) {
@@ -743,7 +759,7 @@
}
if (type == null) {
- type = TypesFactory.getType(Object.class);
+ type = TypesFactory.OBJECT_TYPE;
}
defineObject(type, name, value);
@@ -767,8 +783,8 @@
collectionElementClass = Object.class;
}
- pushStatement(new ForEachStatement(itemsExpression, cdkForEachElement.getVar(), collectionElementClass
- .getName()));
+ pushStatement(new ForEachStatement(itemsExpression, cdkForEachElement.getVar(),
+ collectionElementClass.getName()));
currentStatement.setVariable(cdkForEachElement.getVar(), lastCompiledExpressionType.getContainerType());
}
@@ -801,7 +817,7 @@
}
public static void clearCaches() {
- TypesFactory.clearCaches();
+ TypesFactoryImpl.clearCaches();
ELParserUtils.clearCaches();
}
}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-public class StartElementStatement extends BaseTemplateMethodBodyStatement {
-
- private String elementName;
-
- public StartElementStatement(String elementName) {
- this("start-element", elementName);
- }
-
- protected StartElementStatement(String templateName, String elementName) {
- super(templateName);
- this.elementName = elementName;
- }
-
- /**
- * @return the elementName
- */
- public String getElementName() {
- return elementName;
- }
-
-}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -25,11 +25,17 @@
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.attributes.Schema;
+import org.richfaces.cdk.templatecompiler.el.ELParserImpl;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactoryImpl;
+import org.richfaces.cdk.templatecompiler.model.Template;
import com.google.inject.AbstractModule;
import com.google.inject.Singleton;
import com.google.inject.TypeLiteral;
import com.google.inject.multibindings.Multibinder;
+import com.google.inject.name.Names;
/**
* <p class="changed_added_4_0"></p>
@@ -48,6 +54,9 @@
Multibinder.newSetBinder(binder(), CdkWriter.class).addBinding().to(RendererClassGenerator.class);
bind(new TypeLiteral<TemplateVisitorFactory<RendererClassVisitor>>(){}).to(VisitorFactoryImpl.class).in(Singleton.class);
bind(FreeMarkerRenderer.class).to(JavaClassConfiguration.class);
+ bind(TypesFactory.class).to(TypesFactoryImpl.class);
+ bind(ELParser.class).to(ELParserImpl.class);
+ bind(Schema.class).annotatedWith(Names.named(Template.XHTML_EL_NAMESPACE)).toProvider(XhtmlElSchemaProvider.class).in(Singleton.class);
}
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/VisitorFactoryImpl.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -25,19 +25,12 @@
import java.util.Collection;
-import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.Generator;
import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.attributes.Schema;
-import org.richfaces.cdk.attributes.SchemaSet;
import org.richfaces.cdk.model.PropertyBase;
import org.richfaces.cdk.templatecompiler.model.CompositeInterface;
-import org.richfaces.cdk.templatecompiler.model.Template;
-import org.richfaces.cdk.xmlconfig.JAXB;
import com.google.inject.Inject;
-import com.google.inject.internal.Nullable;
-import com.google.inject.name.Named;
+import com.google.inject.Injector;
/**
* <p class="changed_added_4_0"></p>
@@ -46,10 +39,9 @@
*/
public class VisitorFactoryImpl implements TemplateVisitorFactory<RendererClassVisitor> {
- final CdkClassLoader classLoader;
+ final ELParser parser;
final Logger log;
- final Schema attributesSchema;
- final String rendererUtilsClassName;
+ final Injector injector;
/**
* <p class="changed_added_4_0"></p>
@@ -58,12 +50,10 @@
* @param log
*/
@Inject
- public VisitorFactoryImpl(CdkClassLoader classLoader, JAXB jaxbBinding, Logger log,(a)Named(Generator.RENDERER_UTILS_CLASS) @Nullable String rendererUtilsClassName) {
- this.classLoader = classLoader;
+ public VisitorFactoryImpl(ELParser parser, Logger log, Injector injector) {
+ this.parser = parser;
this.log = log;
- SchemaSet schemaSet = jaxbBinding.unmarshal("urn:attributes:xhtml-el.xml", null, SchemaSet.class);
- this.attributesSchema = schemaSet.getSchemas().get(Template.XHTML_EL_NAMESPACE);
- this.rendererUtilsClassName = rendererUtilsClassName;
+ this.injector = injector;
}
/* (non-Javadoc)
@@ -71,7 +61,7 @@
*/
@Override
public RendererClassVisitor createVisitor(CompositeInterface composite, Collection<PropertyBase> attributes) {
- return new RendererClassVisitor(composite, attributes, this);
+ return new RendererClassVisitor(composite, attributes, log,injector,parser);
}
}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-/**
- * @author Nick Belaevski
- */
-public class WriteAttributeStatement extends BaseTemplateMethodBodyStatement {
-
- private String attributeName;
-
- private String valueExpression;
-
- public WriteAttributeStatement(String attributeName, String valueExpression) {
- super("write-attribute");
- this.attributeName = attributeName;
- this.valueExpression = valueExpression;
- }
-
- public String getAttributeName() {
- return attributeName;
- }
-
- public String getValueExpression() {
- return valueExpression;
- }
-
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-
-/**
- * @author Nick Belaevski
- */
-public class WriteAttributesSetStatement extends BaseTemplateMethodBodyStatement {
-
- private String passThroughFieldName;
-
- public WriteAttributesSetStatement(String passThroughFieldName) {
- super("write-attributes-set");
- this.passThroughFieldName = passThroughFieldName;
- }
-
- /**
- * @return the passThroughFieldName
- */
- public String getPassThroughFieldName() {
- return passThroughFieldName;
- }
-
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler;
-
-/**
- * @author Nick Belaevski
- */
-public class WriteTextStatement extends BaseTemplateMethodBodyStatement {
-
- private String textExpression;
-
- public WriteTextStatement(String textExpression) {
- super("write-text");
- this.textExpression = textExpression;
- }
-
- public String getTextExpression() {
- return textExpression;
- }
-
-}
Added: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,33 @@
+/**
+ *
+ */
+package org.richfaces.cdk.templatecompiler;
+
+import org.richfaces.cdk.attributes.Schema;
+import org.richfaces.cdk.attributes.SchemaSet;
+import org.richfaces.cdk.templatecompiler.model.Template;
+import org.richfaces.cdk.xmlconfig.JAXB;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class XhtmlElSchemaProvider implements Provider<Schema> {
+
+ private final JAXB jaxbBinding;
+
+ @Inject
+ public XhtmlElSchemaProvider(JAXB jaxbBinding) {
+ this.jaxbBinding = jaxbBinding;
+ }
+
+ @Override
+ public Schema get() {
+ SchemaSet schemaSet = jaxbBinding.unmarshal("urn:attributes:xhtml-el.xml", null, SchemaSet.class);
+ return schemaSet.getSchemas().get(Template.XHTML_EL_NAMESPACE);
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/XhtmlElSchemaProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaClass.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -170,15 +170,6 @@
}
}
- MethodBody methodBody = method.getMethodBody();
-
- if (methodBody != null) {
- Set<Class<?>> usedClasses = methodBody.getUsedClasses();
-
- for (Class<?> class1 : usedClasses) {
- addImport(class1);
- }
- }
}
public JavaPackage getPakg() {
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaField.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaField.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaField.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -30,7 +30,7 @@
public class JavaField extends JavaLanguageElement {
private JavaClass type;
- private Object value;
+ private JavaStatement value;
private JavaClass[] genericArguments;
@@ -42,11 +42,11 @@
this(type, name, null);
}
- public JavaField(Class<?> type, String name, Object value) {
+ public JavaField(Class<?> type, String name, JavaStatement value) {
this(new JavaClass(type), name, value);
}
- public JavaField(JavaClass type, String name, Object value) {
+ public JavaField(JavaClass type, String name, JavaStatement value) {
super(name);
this.type = type;
this.value = value;
@@ -56,11 +56,11 @@
return type;
}
- public Object getValue() {
+ public JavaStatement getValue() {
return value;
}
- public void setValue(Object value) {
+ public void setValue(JavaStatement value) {
this.value = value;
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaMethod.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaMethod.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaMethod.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -31,7 +31,7 @@
public class JavaMethod extends JavaLanguageElement {
private List<Argument> arguments = new ArrayList<Argument>();
private List<Class<? extends Throwable>> exceptions = new ArrayList<Class<? extends Throwable>>();
- private MethodBody methodBody;
+ private JavaStatement methodBody;
private JavaClass returnType;
public JavaMethod(String name) {
@@ -63,7 +63,7 @@
return arguments;
}
- public MethodBody getMethodBody() {
+ public JavaStatement getMethodBody() {
return methodBody;
}
@@ -71,11 +71,7 @@
return returnType;
}
- public void setMethodBody(MethodBody methodBody) {
+ public void setMethodBody(JavaStatement methodBody) {
this.methodBody = methodBody;
-
- if (methodBody != null) {
- methodBody.setMethod(this);
- }
}
}
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.builder.model;
+
+
+/**
+ * @author Nick Belaevski
+ */
+public interface JavaStatement {
+
+ public String getCode();
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/JavaStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBody.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBody.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBody.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,59 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.cdk.templatecompiler.builder.model;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Maksim Kaszynski
- * @author Nick Belaevski
- */
-public class MethodBody extends MethodBodyStatementsContainer {
- private Set<Class<?>> usedClasses = new HashSet<Class<?>>();
- private JavaMethod method;
-
- public MethodBody() {
- }
-
- public MethodBody(JavaMethod method) {
- super();
- this.method = method;
- }
-
- protected JavaMethod getMethod() {
- return method;
- }
-
- protected void setMethod(JavaMethod method) {
- this.method = method;
- }
-
- public void addType(Class<?> clazz) {
- usedClasses.add(clazz);
- }
-
- public Set<Class<?>> getUsedClasses() {
- return usedClasses;
- }
-
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatement.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler.builder.model;
-
-import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
-
-/**
- * @author Nick Belaevski
- */
-public interface MethodBodyStatement {
-
- public String getCode(FreeMarkerRenderer renderer);
-
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementImpl.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementImpl.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementImpl.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler.builder.model;
-
-import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
-
-/**
- * @author Nick Belaevski
- */
-public class MethodBodyStatementImpl implements MethodBodyStatement {
-
- private String code;
-
- public MethodBodyStatementImpl(String code) {
- super();
- this.code = code;
- }
-
- @Override
- public String getCode(FreeMarkerRenderer renderer) {
- return code;
- }
-
-}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,132 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.cdk.templatecompiler.builder.model;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
-import org.richfaces.cdk.templatecompiler.el.Type;
-
-import com.google.common.collect.Maps;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-public class MethodBodyStatementsContainer implements MethodBodyStatement, Variables {
-
- private List<MethodBodyStatement> statements = new ArrayList<MethodBodyStatement>();
-
- private MethodBodyStatementsContainer parent;
-
- private final Map<String, Type> localVariablesMap = Maps.newHashMap();
-
-
- public List<MethodBodyStatement> getStatements() {
- return statements;
- }
-
- public void addStatement(MethodBodyStatement statement) {
- setParent(statement);
- statements.add(statement);
- }
-
- public void addStatement(int index,MethodBodyStatement statement) {
- setParent(statement);
- statements.add(index,statement);
- }
-
- private void setParent(MethodBodyStatement statement) {
- if (statement instanceof MethodBodyStatementsContainer) {
- MethodBodyStatementsContainer container = (MethodBodyStatementsContainer) statement;
- container.setParent(this);
- }
- }
-
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param parent the parent to set
- */
- public void setParent(MethodBodyStatementsContainer parent) {
- this.parent = parent;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the parent
- */
- public MethodBodyStatementsContainer getParent() {
- return parent;
- }
-
- public boolean isEmpty() {
- return statements.isEmpty();
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatement#getCode()
- */
- @Override
- public String getCode(FreeMarkerRenderer renderer) {
- StringBuilder sb = new StringBuilder();
- for (MethodBodyStatement statement : statements) {
- sb.append(statement.getCode(renderer));
- sb.append('\n');
- }
-
- return sb.toString();
- }
-
- @Override
- public Type getVariable(String name) {
- Type type = localVariablesMap.get(name);
- if(null == type && null != parent){
- type = parent.getVariable(name);
- }
- return type;
- }
-
- @Override
- public boolean isDefined(String name) {
- boolean defined = localVariablesMap.containsKey(name);
- if(!defined && null != parent){
- defined = parent.isDefined(name);
- }
- return defined;
- }
-
- @Override
- public Type setVariable(String name, Type type) {
- Type variable = getVariable(name);
- localVariablesMap.put(name, type);
- return variable;
- }
-
- public Collection<Class<?>> getImports() {
- // TODO Auto-generated method stub
- return null;
- }
-}
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/StatementImpl.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementImpl.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/StatementImpl.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/StatementImpl.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.builder.model;
+
+
+/**
+ * @author Nick Belaevski
+ */
+public class StatementImpl implements JavaStatement {
+
+ private String code;
+
+ public StatementImpl(String code) {
+ super();
+ this.code = code;
+ }
+
+ @Override
+ public String getCode() {
+ return code;
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/StatementImpl.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/Variables.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/Variables.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/Variables.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,14 +1,14 @@
package org.richfaces.cdk.templatecompiler.builder.model;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
public interface Variables {
- public Type getVariable(String name) throws ParsingException;
+ public ELType getVariable(String name) throws ParsingException;
public boolean isDefined(String name) throws ParsingException;
- public Type setVariable(String name, Type type) throws ParsingException;
+ public ELType setVariable(String name, ELType type) throws ParsingException;
}
Added: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,66 @@
+/**
+ *
+ */
+package org.richfaces.cdk.templatecompiler.el;
+
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.model.ClassName;
+import org.richfaces.cdk.templatecompiler.ELParser;
+import org.richfaces.cdk.templatecompiler.builder.model.Variables;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import org.richfaces.cdk.templatecompiler.statements.TemplateStatement;
+
+import com.google.inject.Inject;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ELParserImpl implements ELParser {
+
+ private final TypesFactory typesFactory;
+ private final Logger log;
+ private final ELParserUtils utils;
+
+ @Inject
+ public ELParserImpl(TypesFactory typesFactory, ELParserUtils utils, Logger log) {
+ this.typesFactory = typesFactory;
+ this.utils = utils;
+ this.log = log;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.ELParser#parse(java.lang.String, org.richfaces.cdk.templatecompiler.builder.model.Variables, org.richfaces.cdk.templatecompiler.el.ELType)
+ */
+ @Override
+ public TemplateStatement parse(String expression, Variables variables, ELType expectedType) throws ParsingException {
+ ELVisitor visitor = new ELVisitor(log,typesFactory,utils);
+ visitor.parse(expression, variables, expectedType);
+ return visitor;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.ELParser#getType(java.lang.Class)
+ */
+ @Override
+ public ELType getType(Class<?> targetClass) {
+ return typesFactory.getType(targetClass);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.ELParser#getType(java.lang.String)
+ */
+ @Override
+ public ELType getType(String classExpression) {
+ return typesFactory.getType(classExpression);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.cdk.templatecompiler.ELParser#getType(org.richfaces.cdk.model.ClassName)
+ */
+ @Override
+ public ELType getType(ClassName targetClass) {
+ return typesFactory.getType(targetClass.toString());
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserUtils.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserUtils.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELParserUtils.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -28,7 +28,6 @@
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -70,6 +69,7 @@
import org.jboss.el.parser.AstTrue;
import org.jboss.el.parser.AstValue;
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.Logger;
import org.richfaces.cdk.templatecompiler.el.node.AstBracketSuffixTreeNode;
import org.richfaces.cdk.templatecompiler.el.node.AstChoiceTreeNode;
import org.richfaces.cdk.templatecompiler.el.node.AstDeferredOrDynamicExpressionTreeNode;
@@ -94,6 +94,9 @@
import org.richfaces.cdk.templatecompiler.el.node.ITreeNode;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import com.google.inject.Inject;
+import com.google.inject.internal.Maps;
+
/**
* Class, that encapsulate all functionality, related to Reflection calls, such as loading classes, get property
* descriptors etc...
@@ -149,13 +152,18 @@
}
}
- private static Map<Class<?>, ClassDataHolder> classDataCache = Collections
- .synchronizedMap(new HashMap<Class<?>, ClassDataHolder>());
+ private final Map<Class<?>, ClassDataHolder> classDataCache = Maps.newHashMap();
- private ELParserUtils() {
+ private final TypesFactory typesFactory;
+ private final Logger log;
+
+ @Inject
+ public ELParserUtils(Logger log, TypesFactory typesFactory) {
+ this.log = log;
+ this.typesFactory = typesFactory;
}
- private static ClassDataHolder resolveClassPropertiesAndMethods(Class<?> initialClass) throws ParsingException {
+ private ClassDataHolder resolveClassPropertiesAndMethods(Class<?> initialClass) throws ParsingException {
ClassDataHolder classDataHolder = classDataCache.get(initialClass);
if (classDataHolder == null) {
classDataHolder = new ClassDataHolder();
@@ -260,7 +268,7 @@
* @throws ParsingException
* if error occured.
*/
- public static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String propertyName) throws ParsingException {
+ public PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String propertyName) throws ParsingException {
if (clazz == null) {
return null;
@@ -346,11 +354,11 @@
* @throws ParsingException
* if error occured.
*/
- public static Type getMatchingVisibleMethodReturnType(Class<?> clazz, final String methodName, Type[] parameterTypes)
+ public ELType getMatchingVisibleMethodReturnType(Class<?> clazz, final String methodName, ELType[] parameterTypes)
throws ParsingException {
if (clazz == null) {
- return TypesFactory.getType(Object.class);
+ return TypesFactory.OBJECT_TYPE;
}
ClassDataHolder classDataHolder = resolveClassPropertiesAndMethods(clazz);
@@ -370,7 +378,7 @@
}
// compare parameters
- Type[] methodsParams = TypesFactory.getTypesArray(resolvedMethod.getParameterTypes());
+ ELType[] methodsParams = typesFactory.getTypesArray(resolvedMethod.getParameterTypes());
int methodParamSize = methodsParams.length;
if (methodParamSize == paramSize) {
@@ -397,9 +405,9 @@
}
if (bestMatch != null) {
- return TypesFactory.getType(bestMatch.getGenericReturnType());
+ return typesFactory.getType(bestMatch.getGenericReturnType());
} else {
- return TypesFactory.getType(Object.class);
+ return TypesFactory.OBJECT_TYPE;
}
}
@@ -457,22 +465,5 @@
}
}
- public static void clearCaches() {
- classDataCache.clear();
- }
- public static String coerceToType(String valueString, ELVisitor visitor, Type expectedType) {
- if (!expectedType.isAssignableFrom(visitor.getExpressionType())) {
- for (HelperMethod conversionMethod : HelperMethod.getConversionMethods()) {
- Type returnType = TypesFactory.getType(conversionMethod.getReturnType());
- if (expectedType.isAssignableFrom(returnType)) {
- visitor.getUsedHelperMethods().add(conversionMethod);
- visitor.setExpressionType(returnType);
- return conversionMethod.getName() + "(" + valueString + ")";
- }
- }
- }
-
- return valueString;
- }
}
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELType.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/Type.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELType.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELType.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.el;
+
+import java.util.Collection;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+//TODO unit-test thoroughly all implementations of this interface
+public interface ELType {
+
+ public String getCode();
+
+ public Collection<Class<?>> getImportsList();
+
+ public boolean isNullType();
+
+ public boolean isArray();
+
+ public Class<?> getRawType();
+
+ public ELType getContainerType();
+
+ public ELType[] getTypeArguments();
+
+ public boolean isAssignableFrom(ELType anotherType);
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELType.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELVisitor.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELVisitor.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/ELVisitor.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -21,69 +21,83 @@
package org.richfaces.cdk.templatecompiler.el;
-import static org.richfaces.cdk.templatecompiler.el.HelperMethod.*;
-import static org.richfaces.cdk.util.JavaUtils.*;
+import static org.richfaces.cdk.templatecompiler.el.HelperMethod.TO_STRING_CONVERSION;
+import static org.richfaces.cdk.util.JavaUtils.getEscapedString;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Type;
import java.text.MessageFormat;
+import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;
import org.jboss.el.parser.AstCompositeExpression;
import org.jboss.el.parser.ELParser;
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
import org.richfaces.cdk.templatecompiler.builder.model.Variables;
import org.richfaces.cdk.templatecompiler.el.node.ITreeNode;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import org.richfaces.cdk.templatecompiler.statements.TemplateStatement;
/**
* Entry point for parsing EL expressions. @see parse() method.
*
* @author amarkhel
*/
-public final class ELVisitor {
+public final class ELVisitor implements TemplateStatement {
private String parsedExpression = null;
- private Type expressionType = null;
+ private ELType expressionType = null;
private Variables variables = null;
- private Set<HelperMethod> usedHelperMethods = EnumSet.noneOf(HelperMethod.class);
+ private Set<HelperMethod> usedHelperMethods = EnumSet.noneOf(HelperMethod.class);
- private Set<HelperMethod> usedConversionMethods = EnumSet.noneOf(HelperMethod.class);
+ private final Logger log;
- public Type getExpressionType() {
+ private final TypesFactory typesFactory;
+
+ private final ELParserUtils utils;
+
+ private boolean mixedExpression;
+
+
+ public ELVisitor(Logger log, TypesFactory typesFactory, ELParserUtils utils) {
+ this.log = log;
+ this.typesFactory = typesFactory;
+ this.utils = utils;
+ }
+
+
+ public boolean isMixedExpression() {
+ return mixedExpression;
+ }
+
+
+ public ELType getExpressionType() {
return expressionType;
}
- public void setExpressionType(Type variableType) {
+ public void setExpressionType(ELType variableType) {
this.expressionType = variableType;
}
- public Type getVariable(String name) throws ParsingException {
- Type variableType = variables.getVariable(name);
- if (variableType == null) {
- throw new ParsingException(MessageFormat.format(
+ public ELType getVariable(String name) throws ParsingException {
+ ELType variableType;
+ if(variables.isDefined(name)){
+ variableType = variables.getVariable(name);
+ } else {
+ log.warn(MessageFormat.format(
"No type found in context for identifier ''{0}'', handling as generic Object", name));
+ variableType = TypesFactory.OBJECT_TYPE;
}
return variableType;
}
/**
- * @return the uses
- */
- public Set<HelperMethod> getUsedHelperMethods() {
- return usedHelperMethods;
- }
-
- /**
- * @return the parsedExpression
- */
- public String getParsedExpression() {
- return parsedExpression;
- }
-
- /**
* Parse specified EL expression and return Java code, that represent this expression
*
* @param expression - expression to resolve
@@ -91,7 +105,7 @@
* @return generated Java code.
* @throws ParsingException - if error occurred during parsing.
*/
- public void parse(String expression, Variables contextVariables, Type expectedType) throws ParsingException {
+ public void parse(String expression, Variables contextVariables, ELType expectedType) throws ParsingException {
reset();
Node ret = ELParser.parse(expression);
@@ -99,19 +113,36 @@
if (ret instanceof AstCompositeExpression && ret.jjtGetNumChildren() >= 2) {
//AstCompositeExpression with 2+ children is a mixed expression
- getUsedHelperMethods().add(TO_STRING_CONVERSION);
+ usedHelperMethods.add(TO_STRING_CONVERSION);
+ this.mixedExpression = true;
}
if (ret != null && ret.jjtGetNumChildren() > 0) {
parsedExpression = this.visit(ret);
} else {
parsedExpression = getEscapedString("");
- expressionType = TypesFactory.getType(String.class);
+ expressionType = TypesFactory.STRING_TYPE;
}
- parsedExpression = ELParserUtils.coerceToType(parsedExpression, this, expectedType);
+ parsedExpression = coerceToType(parsedExpression, expectedType);
}
+
+ public String coerceToType(String valueString, ELType expectedType) {
+ if (!expectedType.isAssignableFrom(getExpressionType())) {
+ for (HelperMethod conversionMethod : HelperMethod.getConversionMethods()) {
+ ELType returnType = typesFactory.getType(conversionMethod.getReturnType());
+ if (expectedType.isAssignableFrom(returnType)) {
+ usedHelperMethods.add(conversionMethod);
+ setExpressionType(returnType);
+ return conversionMethod.getName() + "(" + valueString + ")";
+ }
+ }
+ }
+
+ return valueString;
+ }
+
private String visit(Node node) throws ParsingException {
int numChildren = node.jjtGetNumChildren();
StringBuilder sb = new StringBuilder();
@@ -138,4 +169,45 @@
expressionType = null;
}
+ @Override
+ public String getCode() {
+ return parsedExpression;
+ }
+
+ @Override
+ public Iterable<ELType> getRequiredImports() {
+ return Collections.singleton(getExpressionType());
+ }
+
+ @Override
+ public Iterable<JavaField> getRequiredFields() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Iterable<HelperMethod> getRequiredMethods() {
+ return usedHelperMethods;
+ }
+
+
+ public ELType getMatchingVisibleMethodReturnType(String methodName, ELType[] parameterTypes) throws ParsingException {
+
+ return utils.getMatchingVisibleMethodReturnType(getExpressionType().getRawType(), methodName, parameterTypes);
+ }
+
+
+ public PropertyDescriptor getPropertyDescriptor(String propertyName) throws ParsingException {
+ return utils.getPropertyDescriptor(getExpressionType().getRawType(), propertyName);
+ }
+
+
+ public ELType getType(Type genericReturnType) {
+ return typesFactory.getType(genericReturnType);
+ }
+
+
+ public void addHelperMethods(HelperMethod helper) {
+ usedHelperMethods.add(helper);
+ }
+
}
Deleted: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/Type.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/Type.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/Type.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.cdk.templatecompiler.el;
-
-import java.util.Collection;
-
-/**
- * @author Nick Belaevski
- *
- */
-//TODO unit-test thoroughly all implementations of this interface
-public interface Type {
-
- public String getCode();
-
- public Collection<Class<?>> getImportsList();
-
- public boolean isNullType();
-
- public boolean isArray();
-
- public Class<?> getRawType();
-
- public Type getContainerType();
-
- public Type[] getTypeArguments();
-
- public boolean isAssignableFrom(Type anotherType);
-}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractBinaryOperationTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractBinaryOperationTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractBinaryOperationTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -25,7 +25,7 @@
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
/**
* <p>
@@ -47,7 +47,7 @@
this.operatorString = operatorString;
}
- protected abstract Type getOperationType(Type firstArgumentType, Type secondArgumentType);
+ protected abstract ELType getOperationType(ELType firstArgumentType, ELType secondArgumentType);
protected abstract String getCoercedChildOutput(int childIndex, ELVisitor visitor)
throws ParsingException;
@@ -61,9 +61,9 @@
@Override
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
String firstChildOutput = getCoercedChildOutput(0, visitor);
- Type firstChildType = visitor.getExpressionType();
+ ELType firstChildType = visitor.getExpressionType();
String secondChildOutput = getCoercedChildOutput(1, visitor);
- Type secondChildType = visitor.getExpressionType();
+ ELType secondChildType = visitor.getExpressionType();
sb.append(ELNodeConstants.LEFT_BRACKET);
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractMethodTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractMethodTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractMethodTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -26,10 +26,9 @@
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
-import org.richfaces.cdk.templatecompiler.el.ELParserUtils;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -38,7 +37,7 @@
*/
public abstract class AbstractMethodTreeNode extends AbstractTreeNode {
- private static final Type[] EMPTY_TYPES_ARRAY = new Type[0];
+ private static final ELType[] EMPTY_TYPES_ARRAY = new ELType[0];
/**
* @param node
@@ -50,8 +49,7 @@
protected void visitMethod(StringBuilder sb, ELVisitor visitor, String methodName)
throws ParsingException {
- Class<?> methodHolderClass = visitor.getExpressionType().getRawType();
- List<Type> argumentTypes = new ArrayList<Type>();
+ List<ELType> argumentTypes = new ArrayList<ELType>();
sb.append(ELNodeConstants.DOT);
sb.append(methodName);
@@ -72,14 +70,14 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
- Type returnType = null;
+ ELType returnType = null;
try {
- returnType = ELParserUtils.getMatchingVisibleMethodReturnType(methodHolderClass, methodName, argumentTypes
+ returnType = visitor.getMatchingVisibleMethodReturnType( methodName, argumentTypes
.toArray(EMPTY_TYPES_ARRAY));
} catch (ParsingException e) {
// TODO: handle exception
- returnType = TypesFactory.getType(Object.class);
+ returnType = TypesFactory.OBJECT_TYPE;
}
visitor.setExpressionType(returnType);
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AbstractTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -25,7 +25,6 @@
import org.richfaces.cdk.templatecompiler.el.ELParserUtils;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -61,8 +60,7 @@
}
protected String coerceToBoolean(String value, ELVisitor visitor) {
- Type booleanType = TypesFactory.getType(Boolean.TYPE);
- return ELParserUtils.coerceToType(value, visitor, booleanType);
+ return visitor.coerceToType(value, TypesFactory.BOOLEAN_TYPE);
}
/**
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstBracketSuffixTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstBracketSuffixTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstBracketSuffixTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -24,9 +24,9 @@
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -41,7 +41,7 @@
@Override
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
String suffixValue = getChildOutput(0, visitor);
if (variableType.isArray()) {
@@ -56,9 +56,9 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
}
- Type containerType = variableType.getContainerType();
+ ELType containerType = variableType.getContainerType();
if (containerType == null) {
- containerType = TypesFactory.getType(Object.class);
+ containerType = TypesFactory.OBJECT_TYPE;
}
visitor.setExpressionType(containerType);
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstChoiceTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstChoiceTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstChoiceTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -28,7 +28,7 @@
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
/**
* This class extend AbstractTreeNode and wrap AstChoice node.
@@ -46,9 +46,9 @@
//condition ? correctConditionBranch : incorrectConditionBranch
String condition = coerceToBoolean(getChildOutput(0, visitor), visitor);
String correctConditionBranch = getChildOutput(1, visitor);
- Type correctConditionBranchType = visitor.getExpressionType();
+ ELType correctConditionBranchType = visitor.getExpressionType();
String incorrectConditionBranch = getChildOutput(2, visitor);
- Type incorrectConditionBranchType = visitor.getExpressionType();
+ ELType incorrectConditionBranchType = visitor.getExpressionType();
sb.append(ELNodeConstants.LEFT_BRACKET);
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstDeferredOrDynamicExpressionTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstDeferredOrDynamicExpressionTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstDeferredOrDynamicExpressionTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -21,8 +21,6 @@
package org.richfaces.cdk.templatecompiler.el.node;
-import static org.richfaces.cdk.templatecompiler.el.HelperMethod.*;
-
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
@@ -45,7 +43,7 @@
int childrenCount = getChildrenCount();
for (int i = 0; i < childrenCount; i++) {
- if (visitor.getUsedHelperMethods().contains(TO_STRING_CONVERSION)) {
+ if (visitor.isMixedExpression()) {
sb.append(ELNodeConstants.CONVERT_TO_STRING_FUNCTION);
sb.append(ELNodeConstants.LEFT_BRACKET);
}
@@ -54,9 +52,9 @@
treeNode.visit(sb, visitor);
- if (visitor.getUsedHelperMethods().contains(TO_STRING_CONVERSION)) {
+ if (visitor.isMixedExpression()) {
sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.setExpressionType(TypesFactory.getType(String.class));
+ visitor.setExpressionType(TypesFactory.STRING_TYPE);
} /* otherwise variableType will be set in child's visit invocation */
}
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstEmptyTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstEmptyTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstEmptyTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -23,7 +23,7 @@
package org.richfaces.cdk.templatecompiler.el.node;
-import static org.richfaces.cdk.templatecompiler.el.HelperMethod.*;
+import static org.richfaces.cdk.templatecompiler.el.HelperMethod.EMPTINESS_CHECK;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
@@ -44,9 +44,9 @@
@Override
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
- visitor.getUsedHelperMethods().add(EMPTINESS_CHECK);
+ visitor.addHelperMethods(EMPTINESS_CHECK);
- sb.append(ELNodeConstants.IS_EMPTY_FUNCTION);
+ sb.append(EMPTINESS_CHECK.getName());
sb.append(ELNodeConstants.LEFT_BRACKET);
String childOutput = getChildOutput(0, visitor);
@@ -54,6 +54,6 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.setExpressionType(TypesFactory.getType(Boolean.TYPE));
+ visitor.setExpressionType(TypesFactory.BOOLEAN_TYPE);
}
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFloatingPointTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFloatingPointTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFloatingPointTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -48,6 +48,6 @@
sb.append(getNode().getImage());
sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.setExpressionType(TypesFactory.getType(Double.TYPE));
+ visitor.setExpressionType(TypesFactory.DOUBLE_TYPE);
}
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFunctionTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFunctionTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstFunctionTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -27,7 +27,7 @@
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.util.Strings;
/**
@@ -58,7 +58,7 @@
sb.append(identifierName);
- Type identifierType = visitor.getVariable(identifierName);
+ ELType identifierType = visitor.getVariable(identifierName);
visitor.setExpressionType(identifierType);
visitMethod(sb, visitor, functionName);
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIdentifierTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIdentifierTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIdentifierTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -25,7 +25,7 @@
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
/**
* This class extend AbstractTreeNode and wrap AstIdentifier node.
@@ -42,7 +42,7 @@
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
String identifierName = getNode().getImage();
- Type identifierType = visitor.getVariable(identifierName);
+ ELType identifierType = visitor.getVariable(identifierName);
//TODO: implement variable mapper like "utils" -> "this.getUtils()"
visitor.setExpressionType(identifierType);
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIntegerTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIntegerTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstIntegerTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -43,6 +43,6 @@
@Override
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
sb.append(getNode().getImage());
- visitor.setExpressionType(TypesFactory.getType(Integer.TYPE));
+ visitor.setExpressionType(TypesFactory.INT_TYPE);
}
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstLiteralTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstLiteralTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstLiteralTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -24,7 +24,7 @@
package org.richfaces.cdk.templatecompiler.el.node;
-import static org.richfaces.cdk.util.JavaUtils.*;
+import static org.richfaces.cdk.util.JavaUtils.getEscapedString;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
@@ -47,7 +47,7 @@
if (getNode().getImage() != null) {
sb.append(getEscapedString(getNode().getImage()));
- visitor.setExpressionType(TypesFactory.getType(String.class));
+ visitor.setExpressionType(TypesFactory.STRING_TYPE);
}
}
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstPropertySuffixTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstPropertySuffixTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstPropertySuffixTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -26,10 +26,9 @@
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
-import org.richfaces.cdk.templatecompiler.el.ELParserUtils;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -49,14 +48,10 @@
return new String(chars);
}
- private Method getReadMethod(Class<?> clazz, String propertyName) {
- if (clazz == null) {
- return null;
- }
-
+ private Method getReadMethod(ELVisitor visitor, String propertyName) {
PropertyDescriptor propertyDescriptor = null;
try {
- propertyDescriptor = ELParserUtils.getPropertyDescriptor(clazz, propertyName);
+ propertyDescriptor = visitor.getPropertyDescriptor(propertyName);
} catch (ParsingException e) {
// TODO: handle exception
}
@@ -72,19 +67,16 @@
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
String propertyName = getNode().getImage();
- Type variableType = visitor.getExpressionType();
- Class<?> clazz = variableType.getRawType();
-
String readMethodName;
- Type readMethodReturnType;
+ ELType readMethodReturnType;
- Method readMethod = getReadMethod(clazz, propertyName);
+ Method readMethod = getReadMethod(visitor, propertyName);
if (readMethod != null) {
readMethodName = readMethod.getName();
- readMethodReturnType = TypesFactory.getType(readMethod.getGenericReturnType());
+ readMethodReturnType = visitor.getType(readMethod.getGenericReturnType());
} else {
readMethodName = ELNodeConstants.GETTER_PREFIX + capitalize(propertyName);
- readMethodReturnType = TypesFactory.getType(Object.class);
+ readMethodReturnType = TypesFactory.OBJECT_TYPE;
}
visitor.setExpressionType(readMethodReturnType);
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstStringTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstStringTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/AstStringTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -24,7 +24,7 @@
package org.richfaces.cdk.templatecompiler.el.node;
-import static org.richfaces.cdk.util.JavaUtils.*;
+import static org.richfaces.cdk.util.JavaUtils.getEscapedString;
import org.jboss.el.parser.AstString;
import org.jboss.el.parser.Node;
@@ -47,6 +47,6 @@
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
sb.append(getEscapedString(((AstString) getNode()).getString()));
- visitor.setExpressionType(TypesFactory.getType(String.class));
+ visitor.setExpressionType(TypesFactory.STRING_TYPE);
}
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticIntegerOperationTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticIntegerOperationTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticIntegerOperationTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -23,9 +23,9 @@
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -46,9 +46,9 @@
* @see org.richfaces.cdk.templatecompiler.el.node.AbstractBinaryOperationTreeNode#getOperationType(java.lang.reflect.Type, java.lang.reflect.Type)
*/
@Override
- protected Type getOperationType(Type firstArgumentType,
- Type secondArgumentType) {
- return TypesFactory.getType(Integer.TYPE);
+ protected ELType getOperationType(ELType firstArgumentType,
+ ELType secondArgumentType) {
+ return TypesFactory.INT_TYPE;
}
/* (non-Javadoc)
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticOperationTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticOperationTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryArithmeticOperationTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -22,9 +22,9 @@
package org.richfaces.cdk.templatecompiler.el.node;
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -46,18 +46,18 @@
*/
@Override
- protected Type getOperationType(Type firstArgumentType,
- Type secondArgumentType) {
+ protected ELType getOperationType(ELType firstArgumentType,
+ ELType secondArgumentType) {
- Type doubleType = TypesFactory.getType(Double.class);
+ ELType doubleType = TypesFactory.DOUBLE_TYPE;
if (doubleType.isAssignableFrom(firstArgumentType)
|| doubleType.isAssignableFrom(secondArgumentType)) {
- return TypesFactory.getType(Double.TYPE);
+ return TypesFactory.DOUBLE_TYPE;
}
- return TypesFactory.getType(Integer.TYPE);
+ return TypesFactory.INT_TYPE;
}
/* (non-Javadoc)
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanOperationTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanOperationTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanOperationTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -22,9 +22,9 @@
package org.richfaces.cdk.templatecompiler.el.node;
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -45,9 +45,9 @@
* @see org.richfaces.cdk.templatecompiler.el.node.AbstractBinaryOperationTreeNode#getOperationType(java.lang.reflect.Type, java.lang.reflect.Type)
*/
@Override
- protected Type getOperationType(Type firstArgumentType,
- Type secondArgumentType) {
- return TypesFactory.getType(Boolean.TYPE);
+ protected ELType getOperationType(ELType firstArgumentType,
+ ELType secondArgumentType) {
+ return TypesFactory.BOOLEAN_TYPE;
}
@Override
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanResultOperationTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanResultOperationTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/BinaryBooleanResultOperationTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -22,9 +22,9 @@
package org.richfaces.cdk.templatecompiler.el.node;
import org.jboss.el.parser.Node;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -45,9 +45,9 @@
* @see org.richfaces.cdk.templatecompiler.el.node.AbstractBinaryOperationTreeNode#getOperationType(java.lang.reflect.Type, java.lang.reflect.Type)
*/
@Override
- protected Type getOperationType(Type firstArgumentType,
- Type secondArgumentType) {
- return TypesFactory.getType(Boolean.TYPE);
+ protected ELType getOperationType(ELType firstArgumentType,
+ ELType secondArgumentType) {
+ return TypesFactory.BOOLEAN_TYPE;
}
@Override
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/ConstantValueTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/ConstantValueTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/ConstantValueTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -23,9 +23,10 @@
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.types.NullType;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -36,19 +37,19 @@
// XXX what class to use for null object: Void.class or null - special NullType be used
public static final ConstantValueTreeNode NULL_NODE = new ConstantValueTreeNode(ELNodeConstants.NULL_VALUE,
- TypesFactory.getNullType());
+ NullType.INSTANCE);
public static final ConstantValueTreeNode TRUE_NODE = new ConstantValueTreeNode(ELNodeConstants.TRUE_VALUE,
- TypesFactory.getType(Boolean.TYPE));
+ TypesFactory.BOOLEAN_TYPE);
public static final ConstantValueTreeNode FALSE_NODE = new ConstantValueTreeNode(ELNodeConstants.FALSE_VALUE,
- TypesFactory.getType(Boolean.TYPE));
+ TypesFactory.BOOLEAN_TYPE);
private final String value;
- private final Type type;
+ private final ELType type;
- private ConstantValueTreeNode(String value, Type type) {
+ private ConstantValueTreeNode(String value, ELType type) {
super(null);
this.value = value;
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/EqualityTestTreeNode.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/EqualityTestTreeNode.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/node/EqualityTestTreeNode.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -21,13 +21,13 @@
*/
package org.richfaces.cdk.templatecompiler.el.node;
-import static org.richfaces.cdk.templatecompiler.el.HelperMethod.*;
+import static org.richfaces.cdk.templatecompiler.el.HelperMethod.EQUALS_CHECK;
import org.jboss.el.parser.Node;
import org.richfaces.cdk.templatecompiler.el.ELNodeConstants;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
/**
@@ -51,11 +51,11 @@
this.negateValue = negateValue;
}
- private boolean isPrimitive(Type type) {
+ private boolean isPrimitive(ELType type) {
return type.getRawType().isPrimitive();
}
- private boolean useIsEqualsMethod(Type firstType, Type secondType) {
+ private boolean useIsEqualsMethod(ELType firstType, ELType secondType) {
if (firstType.isNullType() && !isPrimitive(secondType)) {
return false;
}
@@ -77,9 +77,9 @@
@Override
public void visit(StringBuilder sb, ELVisitor visitor) throws ParsingException {
String firstChildOutput = getChildOutput(0, visitor);
- Type firstChildType = visitor.getExpressionType();
+ ELType firstChildType = visitor.getExpressionType();
String secondChildOutput = getChildOutput(1, visitor);
- Type secondChildType = visitor.getExpressionType();
+ ELType secondChildType = visitor.getExpressionType();
if (useIsEqualsMethod(firstChildType, secondChildType)) {
@@ -89,7 +89,7 @@
//do nothing
}
- sb.append(ELNodeConstants.IS_EQUAL_FUNCTION);
+ sb.append(EQUALS_CHECK.getName());
sb.append(ELNodeConstants.LEFT_BRACKET);
sb.append(firstChildOutput);
@@ -97,7 +97,7 @@
sb.append(secondChildOutput);
sb.append(ELNodeConstants.RIGHT_BRACKET);
- visitor.getUsedHelperMethods().add(EQUALS_CHECK);
+ visitor.addHelperMethods(EQUALS_CHECK);
} else {
sb.append(ELNodeConstants.LEFT_BRACKET);
@@ -114,7 +114,7 @@
sb.append(ELNodeConstants.RIGHT_BRACKET);
}
- visitor.setExpressionType(TypesFactory.getType(Boolean.TYPE));
+ visitor.setExpressionType(TypesFactory.BOOLEAN_TYPE);
}
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ComplexType.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ComplexType.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ComplexType.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -27,24 +27,24 @@
import java.util.LinkedHashSet;
import java.util.Set;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.util.ArrayUtils;
/**
* @author Nick Belaevski
*
*/
-public class ComplexType implements Type {
+public class ComplexType implements ELType {
- private Type clearComponentType;
+ private ELType clearComponentType;
- private Type[] typeArguments;
+ private ELType[] typeArguments;
private Class<?> cachedRawType;
private int arrayDepth;
- public ComplexType(Type clearComponentType, Type[] typeArguments, int arrayDepth) {
+ public ComplexType(ELType clearComponentType, ELType[] typeArguments, int arrayDepth) {
super();
this.clearComponentType = clearComponentType;
this.typeArguments = typeArguments;
@@ -54,14 +54,14 @@
/*
* (non-Javadoc)
*
- * @see org.richfaces.cdk.templatecompiler.el.Type#getImportsList()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getImportsList()
*/
@Override
public Collection<Class<?>> getImportsList() {
Set<Class<?>> result = new LinkedHashSet<Class<?>>();
result.addAll(clearComponentType.getImportsList());
- for (Type typeArgument : typeArguments) {
+ for (ELType typeArgument : typeArguments) {
result.addAll(typeArgument.getImportsList());
}
@@ -71,7 +71,7 @@
/*
* (non-Javadoc)
*
- * @see org.richfaces.cdk.templatecompiler.el.Type#isNullType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isNullType()
*/
@Override
public boolean isNullType() {
@@ -81,22 +81,22 @@
/*
* (non-Javadoc)
*
- * @see org.richfaces.cdk.templatecompiler.el.Type#getTypeArguments()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getTypeArguments()
*/
@Override
- public Type[] getTypeArguments() {
+ public ELType[] getTypeArguments() {
return typeArguments;
}
@Override
- public Type getContainerType() {
+ public ELType getContainerType() {
if (arrayDepth != 0) {
return new ComplexType(clearComponentType, typeArguments, arrayDepth - 1);
} else {
if (!ArrayUtils.isEmpty(typeArguments)) {
return typeArguments[typeArguments.length - 1];
} else {
- return TypesFactory.getType(Object.class);
+ return TypesFactory.OBJECT_TYPE;
}
}
}
@@ -104,7 +104,7 @@
/*
* (non-Javadoc)
*
- * @see org.richfaces.cdk.templatecompiler.el.Type#getCode()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getCode()
*/
@Override
public String getCode() {
@@ -114,7 +114,7 @@
if (!ArrayUtils.isEmpty(typeArguments)) {
sb.append("<");
for (int i = 0; i < typeArguments.length; i++) {
- Type typeArgument = typeArguments[i];
+ ELType typeArgument = typeArguments[i];
if (i != 0) {
sb.append(", ");
@@ -178,7 +178,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getRawType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getRawType()
*/
@Override
public Class<?> getRawType() {
@@ -199,7 +199,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isArray()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isArray()
*/
@Override
public boolean isArray() {
@@ -207,20 +207,20 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.Type)
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.ELType)
*/
@Override
- public boolean isAssignableFrom(Type anotherType) {
- Class<?> thisWrapperClass = TypesFactory.getWrapperClass(getRawType());
- Class<?> anotherWrapperClass = TypesFactory.getWrapperClass(anotherType.getRawType());
+ public boolean isAssignableFrom(ELType anotherType) {
+ Class<?> thisWrapperClass = TypesFactoryImpl.getWrapperClass(getRawType());
+ Class<?> anotherWrapperClass = TypesFactoryImpl.getWrapperClass(anotherType.getRawType());
if (thisWrapperClass.isAssignableFrom(anotherWrapperClass)) {
- Type[] thisTypeArguments = getTypeArguments();
+ ELType[] thisTypeArguments = getTypeArguments();
if (ArrayUtils.isEmpty(thisTypeArguments)) {
return true;
}
- Type[] anotherTypeArguments = anotherType.getTypeArguments();
+ ELType[] anotherTypeArguments = anotherType.getTypeArguments();
if (ArrayUtils.isEmpty(anotherTypeArguments)) {
return true;
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/NullType.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/NullType.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/NullType.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -24,25 +24,25 @@
import java.util.Collection;
import java.util.Collections;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
/**
* @author Nick Belaevski
*
*/
-public final class NullType implements Type {
+public final class NullType implements ELType {
/**
* Singleton instance of {@link NullType}
*/
- public static final Type INSTANCE = new NullType();
+ public static final ELType INSTANCE = new NullType();
private NullType() {
//this class is a singleton, thus has private ctor
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getCode()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getCode()
*/
@Override
public String getCode() {
@@ -50,7 +50,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getImportsIterator()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getImportsIterator()
*/
@Override
public Collection<Class<?>> getImportsList() {
@@ -58,7 +58,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isNullType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isNullType()
*/
@Override
public boolean isNullType() {
@@ -66,7 +66,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getRawType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getRawType()
*/
@Override
public Class<?> getRawType() {
@@ -74,10 +74,10 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getTypeArguments()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getTypeArguments()
*/
@Override
- public Type[] getTypeArguments() {
+ public ELType[] getTypeArguments() {
return null;
}
@@ -90,15 +90,15 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getContainerType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getContainerType()
*/
@Override
- public Type getContainerType() {
+ public ELType getContainerType() {
return null;
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isArray()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isArray()
*/
@Override
public boolean isArray() {
@@ -106,10 +106,10 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.Type)
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.ELType)
*/
@Override
- public boolean isAssignableFrom(Type anotherType) {
+ public boolean isAssignableFrom(ELType anotherType) {
return true;
}
}
\ No newline at end of file
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/PlainClassType.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/PlainClassType.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/PlainClassType.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -25,15 +25,15 @@
import java.util.Arrays;
import java.util.Collection;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
/**
* @author Nick Belaevski
*
*/
-public class PlainClassType implements Type {
+public final class PlainClassType implements ELType {
- private Class<?> clazz;
+ private final Class<?> clazz;
public PlainClassType(Class<?> clazz) {
super();
@@ -46,7 +46,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getCode()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getCode()
*/
@Override
public String getCode() {
@@ -54,7 +54,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getImportsIterator()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getImportsIterator()
*/
@Override
public Collection<Class<?>> getImportsList() {
@@ -62,7 +62,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isNullType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isNullType()
*/
@Override
public boolean isNullType() {
@@ -70,7 +70,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getRawType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getRawType()
*/
@Override
public Class<?> getRawType() {
@@ -78,10 +78,10 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getTypeArguments()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getTypeArguments()
*/
@Override
- public Type[] getTypeArguments() {
+ public ELType[] getTypeArguments() {
return null;
}
@@ -130,15 +130,15 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getCompositeType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getCompositeType()
*/
@Override
- public Type getContainerType() {
+ public ELType getContainerType() {
return null;
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isArray()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isArray()
*/
@Override
public boolean isArray() {
@@ -146,15 +146,15 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.Type)
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.ELType)
*/
@Override
- public boolean isAssignableFrom(Type anotherType) {
+ public boolean isAssignableFrom(ELType anotherType) {
if (anotherType.isNullType()) {
return !clazz.isPrimitive();
} else {
- Class<?> thisWrapperClass = TypesFactory.getWrapperClass(clazz);
- Class<?> anotherWrapperClass = TypesFactory.getWrapperClass(anotherType.getRawType());
+ Class<?> thisWrapperClass = TypesFactoryImpl.getWrapperClass(clazz);
+ Class<?> anotherWrapperClass = TypesFactoryImpl.getWrapperClass(anotherType.getRawType());
return thisWrapperClass.isAssignableFrom(anotherWrapperClass);
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ReferencedType.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ReferencedType.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/ReferencedType.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -25,13 +25,13 @@
import java.util.Collection;
import java.util.Collections;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
/**
* @author Nick Belaevski
*
*/
-public class ReferencedType implements Type {
+public class ReferencedType implements ELType {
private String classCodeString;
@@ -46,7 +46,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getCode()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getCode()
*/
@Override
public String getCode() {
@@ -54,7 +54,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getImportsList()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getImportsList()
*/
@Override
public Collection<Class<?>> getImportsList() {
@@ -62,7 +62,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getRawType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getRawType()
*/
@Override
public Class<?> getRawType() {
@@ -70,7 +70,7 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isNullType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isNullType()
*/
@Override
public boolean isNullType() {
@@ -78,10 +78,10 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getTypeArguments()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getTypeArguments()
*/
@Override
- public Type[] getTypeArguments() {
+ public ELType[] getTypeArguments() {
return null;
}
@@ -130,15 +130,15 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#getCompositeType()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#getCompositeType()
*/
@Override
- public Type getContainerType() {
+ public ELType getContainerType() {
return null;
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isArray()
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isArray()
*/
@Override
public boolean isArray() {
@@ -146,10 +146,10 @@
}
/* (non-Javadoc)
- * @see org.richfaces.cdk.templatecompiler.el.Type#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.Type)
+ * @see org.richfaces.cdk.templatecompiler.el.ELType#isAssignableFrom(org.richfaces.cdk.templatecompiler.el.ELType)
*/
@Override
- public boolean isAssignableFrom(Type anotherType) {
+ public boolean isAssignableFrom(ELType anotherType) {
if (anotherType instanceof ReferencedType) {
ReferencedType anotherReferencedType = (ReferencedType) anotherType;
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactory.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactory.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactory.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -21,298 +21,26 @@
*/
package org.richfaces.cdk.templatecompiler.el.types;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.ParameterizedType;
-import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import org.richfaces.cdk.templatecompiler.el.ELType;
-import javax.faces.application.Application;
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.Behavior;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.event.FacesEvent;
-import javax.faces.model.DataModel;
-import javax.faces.render.Renderer;
-import javax.faces.validator.Validator;
-
-import org.richfaces.cdk.JavaLogger;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.templatecompiler.el.Type;
-import org.richfaces.cdk.util.ArrayUtils;
-
/**
* @author Nick Belaevski
*
*/
-public final class TypesFactory {
+public interface TypesFactory {
- private static Logger log = new JavaLogger();
- private static final Map<java.lang.reflect.Type, Type> REFLECTION_TYPES_CACHE = Collections
- .synchronizedMap(new HashMap<java.lang.reflect.Type, Type>());
-
- private static final Map<String, Type> REFERENCED_TYPES_CACHE = Collections
- .synchronizedMap(new HashMap<String, Type>());
-
- private static final Map<Class<?>, Class<?>> PRIMITIVE_TO_WRAPPER_CLASSES_MAP;
- private static final Map<String, Class<?>> PRIMITIVE_CLASSES_MAP;
-
- static {
- Map<Class<?>, Class<?>> primitiveToWrapperClassesMap = new HashMap<Class<?>, Class<?>>();
- primitiveToWrapperClassesMap.put(Boolean.TYPE, Boolean.class);
- primitiveToWrapperClassesMap.put(Float.TYPE, Float.class);
- primitiveToWrapperClassesMap.put(Long.TYPE, Long.class);
- primitiveToWrapperClassesMap.put(Integer.TYPE, Integer.class);
- primitiveToWrapperClassesMap.put(Short.TYPE, Short.class);
- primitiveToWrapperClassesMap.put(Byte.TYPE, Byte.class);
- primitiveToWrapperClassesMap.put(Double.TYPE, Double.class);
- primitiveToWrapperClassesMap.put(Character.TYPE, Character.class);
-
- PRIMITIVE_TO_WRAPPER_CLASSES_MAP = Collections.unmodifiableMap(primitiveToWrapperClassesMap);
-
- Map<String, Class<?>> primitiveClassesMap = new HashMap<String, Class<?>>();
- for (Class<?> primitiveClass : PRIMITIVE_TO_WRAPPER_CLASSES_MAP.keySet()) {
- primitiveClassesMap.put(primitiveClass.getName(), primitiveClass);
- }
-
- PRIMITIVE_CLASSES_MAP = Collections.unmodifiableMap(primitiveClassesMap);
- }
-
- private static final Pattern CLASS_SIGNATURE_PATTERN = Pattern.compile("^" + "\\s*([^\\[<]+)\\s*" + // class name
- "(?:<\\s*(.*)\\s*>)?\\s*" + // generic signature
- "((?:\\[\\s*\\]\\s*)+)?\\s*" + // array signature
- "$");
-
- private static final int CLASS_NAME_GROUP_IDX = 1;
-
- private static final int TYPE_ARGUMENTS_GROUP_IDX = 2;
-
- private static final int ARRAY_SIGNATURE_GROUP_IDX = 3;
-
- private static final int ARRAY_SIGNATURE_LENGTH = "[]".length();
-
- private static final String[] GUESS_PACKAGES;
-
- static {
- Class<?>[] guessPackagesClasses = {
- UIComponent.class, Behavior.class, Converter.class, Validator.class,
- FacesContext.class, Application.class, FacesEvent.class, DataModel.class, Renderer.class,
- Collection.class, Object.class };
-
- GUESS_PACKAGES = new String[guessPackagesClasses.length];
- int i = 0;
- for (Class<?> guessPackageClass : guessPackagesClasses) {
- GUESS_PACKAGES[i++] = guessPackageClass.getPackage().getName();
- }
- }
-
- private TypesFactory() {
- }
-
- private static Type getPlainClassType(Class<?> plainClass) {
- Type plainClassType = REFLECTION_TYPES_CACHE.get(plainClass);
- if (plainClassType == null) {
- plainClassType = new PlainClassType(plainClass);
- REFLECTION_TYPES_CACHE.put(plainClass, plainClassType);
- }
-
- return plainClassType;
- }
-
- private static Type getReferencedType(String classCodeString) {
- Type type = REFERENCED_TYPES_CACHE.get(classCodeString);
- if (type == null) {
- type = new ReferencedType(classCodeString);
- REFERENCED_TYPES_CACHE.put(classCodeString, type);
- }
-
- return type;
- }
-
- private static Class<?> tryLoadClas(String className, ClassLoader classLoader) throws ClassNotFoundException {
- int dotIndex = className.indexOf('.');
- if (dotIndex < 0) {
- // guess type
- for (String guessPackage : GUESS_PACKAGES) {
- String guessTypeName = guessPackage + "." + className;
- try {
- //while by default initialize = true for Class.forName(String) method
- //initialize = false used here prevents loading of dependencies that
- //are accessible only in runtime, e.g. static log initializer from API
- //depends on the concrete logger implementation provided in runtime only
- return Class.forName(guessTypeName, false, classLoader);
- } catch (ClassNotFoundException e) {
- // ignore
- } catch (LinkageError e) {
- if (log.isInfoEnabled()) {
- log.info(MessageFormat.format("Class {0} couldn''t be loaded because of: {1}", guessTypeName,
- e.getMessage()));
- }
- }
- }
- }
-
- Class<?> result = PRIMITIVE_CLASSES_MAP.get(className);
- if (result == null) {
- try {
- //initialize = false here for the same reason as already mentioned for the previous load block
- result = Class.forName(className, false, classLoader);
- } catch (LinkageError e) {
- String errorMessage = MessageFormat.format("Class {0} couldn''t be loaded because of: {1}", className,
- e.getMessage());
- if (log.isInfoEnabled()) {
- log.info(errorMessage);
- }
- throw new ClassNotFoundException(errorMessage, e);
- }
- }
-
- return result;
- }
+ ELType OBJECT_TYPE = new PlainClassType(Object.class);
+ ELType STRING_TYPE = new PlainClassType(String.class);
+ ELType BOOLEAN_TYPE = new PlainClassType(Boolean.class);
+ ELType DOUBLE_TYPE = new PlainClassType(Double.class);
+ ELType INTEGER_TYPE = new PlainClassType(Integer.class);
+ ELType INT_TYPE = new PlainClassType(Integer.TYPE);
- static Type[] parseTypeArgumentsString(String typeArguments, ClassLoader classLoader) {
- if (typeArguments == null) {
- return null;
- }
+ ELType getType(String typeString);
+
+ ELType getType(java.lang.reflect.Type reflectionType);
+
+ ELType[] getTypesArray(java.lang.reflect.Type[] reflectionTypes);
- String[] typeArgumentsSplit = typeArguments.trim().split(",");
-
- Type[] types = new Type[typeArgumentsSplit.length];
- for (int i = 0; i < typeArgumentsSplit.length; i++) {
- types[i] = getType(typeArgumentsSplit[i], classLoader);
- }
-
- return types;
- }
-
- public static Type getType(String typeString, ClassLoader classLoader) {
- Matcher matcher = CLASS_SIGNATURE_PATTERN.matcher(typeString);
- boolean matchResult = matcher.matches();
- if (matchResult) {
- String className = matcher.group(CLASS_NAME_GROUP_IDX).trim();
-
- String typeArgumentsString = matcher.group(TYPE_ARGUMENTS_GROUP_IDX);
- Type[] typeArguments = parseTypeArgumentsString(typeArgumentsString, classLoader);
-
- String arraySignature = matcher.group(ARRAY_SIGNATURE_GROUP_IDX);
- int arrayDepth = 0;
- if (arraySignature != null) {
- arrayDepth = arraySignature.replaceAll("\\s+", "").length() / ARRAY_SIGNATURE_LENGTH;
- }
-
- Type baseType;
- try {
- // NB: loadedClass can have name that differs from className!
- Class<?> loadedClas = tryLoadClas(className, classLoader);
-
- baseType = getType(loadedClas);
- } catch (ClassNotFoundException e) {
- baseType = getReferencedType(className);
- }
-
- if (arrayDepth != 0 || !ArrayUtils.isEmpty(typeArguments)) {
- return new ComplexType(baseType, typeArguments, arrayDepth);
- } else {
- return baseType;
- }
- } else {
- if (log.isWarnEnabled()) {
- log.warn(MessageFormat.format("Cannot parse type signature: ''{0}''", typeString));
- }
- return getReferencedType(typeString);
- }
- }
-
- static Type createType(java.lang.reflect.Type reflectionType) {
- java.lang.reflect.Type[] actualTypeArguments = null;
- Class<?> rawType = null;
- int arrayDepth = 0;
-
- java.lang.reflect.Type localReflectionType = reflectionType;
-
- while (localReflectionType instanceof GenericArrayType) {
- localReflectionType = ((GenericArrayType) localReflectionType).getGenericComponentType();
- arrayDepth++;
- }
-
- if (localReflectionType instanceof ParameterizedType) {
- ParameterizedType parameterizedType = (ParameterizedType) localReflectionType;
-
- actualTypeArguments = parameterizedType.getActualTypeArguments();
- rawType = (Class<?>) parameterizedType.getRawType();
- } else if (localReflectionType instanceof Class<?>) {
- rawType = (Class<?>) localReflectionType;
- }
-
- if (rawType != null) {
- while (rawType.isArray()) {
- arrayDepth++;
- rawType = rawType.getComponentType();
- }
-
- Type[] typeArguments = null;
- if (!ArrayUtils.isEmpty(actualTypeArguments)) {
- typeArguments = getTypesArray(actualTypeArguments);
- }
-
- Type clearComponentType = getPlainClassType(rawType);
- if (!ArrayUtils.isEmpty(typeArguments) || arrayDepth != 0) {
- return new ComplexType(clearComponentType, typeArguments, arrayDepth);
- } else {
- return clearComponentType;
- }
- } else {
- //TODO better way of handling unknown types
- return getReferencedType(reflectionType.toString());
- }
- }
-
- public static Type getType(java.lang.reflect.Type reflectionType) {
- Type result = REFLECTION_TYPES_CACHE.get(reflectionType);
- if (result == null) {
- result = createType(reflectionType);
- REFLECTION_TYPES_CACHE.put(reflectionType, result);
- }
-
- return result;
- }
-
- public static Type[] getTypesArray(java.lang.reflect.Type[] reflectionTypes) {
- Type[] types = new Type[reflectionTypes.length];
- for (int i = 0; i < reflectionTypes.length; i++) {
- types[i] = getType(reflectionTypes[i]);
- }
-
- return types;
- }
-
- public static Type getNullType() {
- return NullType.INSTANCE;
- }
-
- public static void clearCaches() {
- REFLECTION_TYPES_CACHE.clear();
- REFERENCED_TYPES_CACHE.clear();
- }
-
- /**
- * Returns wrapper classes for passed-in class. If type is primitive, then corresponding wrapper class is returned
- * (e.g. boolean -> Boolean), otherwise does nothing and returns passed-in class.
- *
- * @return wrapper for primitive types, or passed-in class
- */
- static Class<?> getWrapperClass(Class<?> inClazz) {
- if (inClazz.isPrimitive()) {
- return PRIMITIVE_TO_WRAPPER_CLASSES_MAP.get(inClazz);
- } else {
- return inClazz;
- }
- }
-
}
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactoryImpl.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactory.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactoryImpl.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactoryImpl.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,327 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.el.types;
+
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.Behavior;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.event.FacesEvent;
+import javax.faces.model.DataModel;
+import javax.faces.render.Renderer;
+import javax.faces.validator.Validator;
+
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.templatecompiler.el.ELType;
+import org.richfaces.cdk.util.ArrayUtils;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableCollection;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class TypesFactoryImpl implements TypesFactory {
+
+ private static final ImmutableMap<Class<?>, Class<?>> PRIMITIVE_TO_WRAPPER_CLASSES_MAP = ImmutableMap
+ .<Class<?>, Class<?>> builder().put(Boolean.TYPE, Boolean.class).put(Float.TYPE, Float.class)
+ .put(Long.TYPE, Long.class).put(Integer.TYPE, Integer.class).put(Short.TYPE, Short.class)
+ .put(Byte.TYPE, Byte.class).put(Double.TYPE, Double.class).put(Character.TYPE, Character.class).build();
+
+ private static final ImmutableMap<String, Class<?>> PRIMITIVE_CLASSES_MAP;
+
+ static {
+
+ Builder<String, Class<?>> builder = ImmutableMap.<String, Class<?>> builder();
+ for (Class<?> primitiveClass : PRIMITIVE_TO_WRAPPER_CLASSES_MAP.keySet()) {
+ builder.put(primitiveClass.getName(), primitiveClass);
+ }
+ PRIMITIVE_CLASSES_MAP = builder.build();
+ }
+
+ private static final Pattern CLASS_SIGNATURE_PATTERN = Pattern.compile("^" + "\\s*([^\\[<]+)\\s*" + // class name
+ "(?:<\\s*(.*)\\s*>)?\\s*" + // generic signature
+ "((?:\\[\\s*\\]\\s*)+)?\\s*" + // array signature
+ "$");
+
+ private static final int CLASS_NAME_GROUP_IDX = 1;
+
+ private static final int TYPE_ARGUMENTS_GROUP_IDX = 2;
+
+ private static final int ARRAY_SIGNATURE_GROUP_IDX = 3;
+
+ private static final int ARRAY_SIGNATURE_LENGTH = "[]".length();
+
+ private static final Function<Class<?>, String> PACKAGE_NAME_FUNCTION = new Function<Class<?>, String>() {
+
+ @Override
+ public String apply(Class<?> from) {
+ return from.getPackage().getName();
+ }
+ };
+
+ private static final ImmutableCollection<String> GUESS_PACKAGES = ImmutableSet.<String> copyOf(Iterables.transform(
+ ImmutableSet.<Class<?>> of(UIComponent.class, Behavior.class, Converter.class, Validator.class,
+ FacesContext.class, Application.class, FacesEvent.class, DataModel.class, Renderer.class, Collection.class,
+ Object.class), PACKAGE_NAME_FUNCTION
+ ));
+
+ private final ClassLoader classLoader;
+
+ private final Logger log;
+
+ private final Map<java.lang.reflect.Type, ELType> reflectionTypesCache = new ConcurrentHashMap<java.lang.reflect.Type, ELType>();
+
+ private final Map<String, ELType> refferencedTypesCache = new ConcurrentHashMap<String, ELType>();
+
+ @Inject
+ public TypesFactoryImpl(Logger log, ClassLoader classLoader) {
+ this.log = log;
+ this.classLoader = classLoader;
+ }
+
+ private ELType getPlainClassType(Class<?> plainClass) {
+ ELType plainClassType = reflectionTypesCache.get(plainClass);
+ if (plainClassType == null) {
+ plainClassType = new PlainClassType(plainClass);
+ reflectionTypesCache.put(plainClass, plainClassType);
+ }
+
+ return plainClassType;
+ }
+
+ private ELType getReferencedType(String classCodeString) {
+ ELType type = refferencedTypesCache.get(classCodeString);
+ if (type == null) {
+ type = new ReferencedType(classCodeString);
+ refferencedTypesCache.put(classCodeString, type);
+ }
+
+ return type;
+ }
+
+ private Class<?> tryLoadClas(String className) throws ClassNotFoundException {
+ int dotIndex = className.indexOf('.');
+ if (dotIndex < 0) {
+ // guess type
+ for (String guessPackage : GUESS_PACKAGES) {
+ String guessTypeName = guessPackage + "." + className;
+ try {
+ // while by default initialize = true for Class.forName(String) method
+ // initialize = false used here prevents loading of dependencies that
+ // are accessible only in runtime, e.g. log initializer from API
+ // depends on the concrete logger implementation provided in runtime only
+ return Class.forName(guessTypeName, false, classLoader);
+ } catch (ClassNotFoundException e) {
+ // ignore
+ } catch (LinkageError e) {
+ if (log.isInfoEnabled()) {
+ log.info(MessageFormat.format("Class {0} couldn''t be loaded because of: {1}", guessTypeName,
+ e.getMessage()));
+ }
+ }
+ }
+ }
+
+ Class<?> result = PRIMITIVE_CLASSES_MAP.get(className);
+ if (result == null) {
+ try {
+ // initialize = false here for the same reason as already mentioned for the previous load block
+ result = Class.forName(className, false, classLoader);
+ } catch (LinkageError e) {
+ String errorMessage = MessageFormat.format("Class {0} couldn''t be loaded because of: {1}", className,
+ e.getMessage());
+ if (log.isInfoEnabled()) {
+ log.info(errorMessage);
+ }
+ throw new ClassNotFoundException(errorMessage, e);
+ }
+ }
+
+ return result;
+ }
+
+ ELType[] parseTypeArgumentsString(String typeArguments) {
+ if (typeArguments == null) {
+ return null;
+ }
+
+ String[] typeArgumentsSplit = typeArguments.trim().split(",");
+
+ ELType[] types = new ELType[typeArgumentsSplit.length];
+ for (int i = 0; i < typeArgumentsSplit.length; i++) {
+ types[i] = getType(typeArgumentsSplit[i]);
+ }
+
+ return types;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.templatecompiler.el.types.TypesFactory#getType(java.lang.String)
+ */
+ @Override
+ public ELType getType(String typeString) {
+ Matcher matcher = CLASS_SIGNATURE_PATTERN.matcher(typeString);
+ boolean matchResult = matcher.matches();
+ if (matchResult) {
+ String className = matcher.group(CLASS_NAME_GROUP_IDX).trim();
+
+ String typeArgumentsString = matcher.group(TYPE_ARGUMENTS_GROUP_IDX);
+ ELType[] typeArguments = parseTypeArgumentsString(typeArgumentsString);
+
+ String arraySignature = matcher.group(ARRAY_SIGNATURE_GROUP_IDX);
+ int arrayDepth = 0;
+ if (arraySignature != null) {
+ arrayDepth = arraySignature.replaceAll("\\s+", "").length() / ARRAY_SIGNATURE_LENGTH;
+ }
+
+ ELType baseType;
+ try {
+ // NB: loadedClass can have name that differs from className!
+ Class<?> loadedClas = tryLoadClas(className);
+
+ baseType = getType(loadedClas);
+ } catch (ClassNotFoundException e) {
+ baseType = getReferencedType(className);
+ }
+
+ if (arrayDepth != 0 || !ArrayUtils.isEmpty(typeArguments)) {
+ return new ComplexType(baseType, typeArguments, arrayDepth);
+ } else {
+ return baseType;
+ }
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn(MessageFormat.format("Cannot parse type signature: ''{0}''", typeString));
+ }
+ return getReferencedType(typeString);
+ }
+ }
+
+ ELType createType(java.lang.reflect.Type reflectionType) {
+ java.lang.reflect.Type[] actualTypeArguments = null;
+ Class<?> rawType = null;
+ int arrayDepth = 0;
+
+ java.lang.reflect.Type localReflectionType = reflectionType;
+
+ while (localReflectionType instanceof GenericArrayType) {
+ localReflectionType = ((GenericArrayType) localReflectionType).getGenericComponentType();
+ arrayDepth++;
+ }
+
+ if (localReflectionType instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType) localReflectionType;
+
+ actualTypeArguments = parameterizedType.getActualTypeArguments();
+ rawType = (Class<?>) parameterizedType.getRawType();
+ } else if (localReflectionType instanceof Class<?>) {
+ rawType = (Class<?>) localReflectionType;
+ }
+
+ if (rawType != null) {
+ while (rawType.isArray()) {
+ arrayDepth++;
+ rawType = rawType.getComponentType();
+ }
+
+ ELType[] typeArguments = null;
+ if (!ArrayUtils.isEmpty(actualTypeArguments)) {
+ typeArguments = getTypesArray(actualTypeArguments);
+ }
+
+ ELType clearComponentType = getPlainClassType(rawType);
+ if (!ArrayUtils.isEmpty(typeArguments) || arrayDepth != 0) {
+ return new ComplexType(clearComponentType, typeArguments, arrayDepth);
+ } else {
+ return clearComponentType;
+ }
+ } else {
+ // TODO better way of handling unknown types
+ return getReferencedType(reflectionType.toString());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.templatecompiler.el.types.TypesFactory#getType(java.lang.reflect.Type)
+ */
+ @Override
+ public ELType getType(java.lang.reflect.Type reflectionType) {
+ ELType result = reflectionTypesCache.get(reflectionType);
+ if (result == null) {
+ result = createType(reflectionType);
+ reflectionTypesCache.put(reflectionType, result);
+ }
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.templatecompiler.el.types.TypesFactory#getTypesArray(java.lang.reflect.Type[])
+ */
+ @Override
+ public ELType[] getTypesArray(java.lang.reflect.Type[] reflectionTypes) {
+ ELType[] types = new ELType[reflectionTypes.length];
+ for (int i = 0; i < reflectionTypes.length; i++) {
+ types[i] = getType(reflectionTypes[i]);
+ }
+
+ return types;
+ }
+
+ /**
+ * Returns wrapper classes for passed-in class. If type is primitive, then corresponding wrapper class is returned
+ * (e.g. boolean -> Boolean), otherwise does nothing and returns passed-in class.
+ *
+ * @return wrapper for primitive types, or passed-in class
+ */
+ static Class<?> getWrapperClass(Class<?> inClazz) {
+ if (inClazz.isPrimitive()) {
+ return PRIMITIVE_TO_WRAPPER_CLASSES_MAP.get(inClazz);
+ } else {
+ return inClazz;
+ }
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/el/types/TypesFactoryImpl.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/AbstractTemplateMethodBodyStatementsContainer.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+
+/**
+ * @author Nick Belaevski
+ */
+public class AbstractTemplateMethodBodyStatementsContainer extends StatementsContainer {
+
+ private String templateName;
+
+ protected AbstractTemplateMethodBodyStatementsContainer(String templateName) {
+ super();
+ this.templateName = templateName;
+ }
+
+ @Override
+ public String getCode() {
+ return renderer.renderSnippet(templateName, this);
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/AbstractTemplateMethodBodyStatementsContainer.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/BaseTemplateMethodBodyStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+import java.util.Collections;
+
+import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaStatement;
+import org.richfaces.cdk.templatecompiler.el.HelperMethod;
+import org.richfaces.cdk.templatecompiler.el.ELType;
+
+/**
+ * @author Nick Belaevski
+ */
+public class BaseTemplateMethodBodyStatement implements TemplateStatement {
+
+ private String templateName;
+
+ protected BaseTemplateMethodBodyStatement(String templateName) {
+ super();
+ this.templateName = templateName;
+ }
+
+ @Override
+ public String getCode() {
+ return renderer.renderSnippet(templateName, this);
+ }
+
+ @Override
+ public Iterable<ELType> getRequiredImports() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Iterable<JavaField> getRequiredFields() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Iterable<HelperMethod> getRequiredMethods() {
+ return Collections.emptySet();
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/BaseTemplateMethodBodyStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConstantReturnMethodBodyStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConstantReturnMethodBodyStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConstantReturnMethodBodyStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConstantReturnMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ConstantReturnMethodBodyStatement extends BaseTemplateMethodBodyStatement {
+
+ private String returnValue;
+
+ public ConstantReturnMethodBodyStatement(String returnValue) {
+ super("constant-return");
+
+ this.returnValue = returnValue;
+ }
+
+ public String getReturnValue() {
+ return returnValue;
+ }
+}
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToBooleanMethodBodyStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToBooleanMethodBodyStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToBooleanMethodBodyStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToBooleanMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+/**
+ * @author Nick Belaevski
+ */
+public class ConversionToBooleanMethodBodyStatement extends HelperMethodBodyStatement {
+
+ public ConversionToBooleanMethodBodyStatement() {
+ super("conversion-to-boolean-method", new String[] {"object"});
+ }
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToBooleanMethodBodyStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToStringMethodBodyStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ConversionToStringMethodBodyStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToStringMethodBodyStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToStringMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+/**
+ * @author Nick Belaevski
+ */
+public class ConversionToStringMethodBodyStatement extends HelperMethodBodyStatement {
+
+ public ConversionToStringMethodBodyStatement() {
+ super("conversion-to-string-method", new String[] {"object"});
+ }
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ConversionToStringMethodBodyStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/DefineObjectStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+import org.richfaces.cdk.templatecompiler.el.ELType;
+
+/**
+ * @author Nick Belaevski
+ */
+public class DefineObjectStatement extends BaseTemplateMethodBodyStatement {
+
+ private ELType type;
+
+ private String name;
+
+ private String initializationExpression;
+
+ public DefineObjectStatement(ELType type, String name, String initializationExpression) {
+ super("define-object");
+
+ this.type = type;
+ this.name = name;
+ this.initializationExpression = initializationExpression != null ? initializationExpression : "";
+ }
+
+ /**
+ * @return the type
+ */
+ public ELType getType() {
+ return type;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the initializationExpression
+ */
+ public String getInitializationExpression() {
+ return initializationExpression;
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/DefineObjectStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EmptinessCheckingMethodBodyStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EmptinessCheckingMethodBodyStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EmptinessCheckingMethodBodyStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EmptinessCheckingMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+/**
+ * @author Nick Belaevski
+ */
+public class EmptinessCheckingMethodBodyStatement extends HelperMethodBodyStatement {
+
+ public EmptinessCheckingMethodBodyStatement() {
+ super("emptiness-check-method", new String[] {"object"});
+ }
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EmptinessCheckingMethodBodyStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EncodeMethodPrefaceStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EncodeMethodPrefaceStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EncodeMethodPrefaceStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EncodeMethodPrefaceStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+/**
+ * @author Nick Belaevski
+ */
+public class EncodeMethodPrefaceStatement extends BaseTemplateMethodBodyStatement {
+
+ /**
+ * @param templateName
+ */
+ public EncodeMethodPrefaceStatement() {
+ super("encode-method-preface");
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EncodeMethodPrefaceStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EndElementStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EndElementStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EndElementStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EndElementStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public class EndElementStatement extends StartElementStatement {
+
+ public EndElementStatement(String elementName) {
+ super("end-element", elementName);
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EndElementStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EqualsCheckingMethodBodyStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/EqualsCheckingMethodBodyStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EqualsCheckingMethodBodyStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EqualsCheckingMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class EqualsCheckingMethodBodyStatement extends HelperMethodBodyStatement {
+
+ public EqualsCheckingMethodBodyStatement() {
+ super("equals-check-method", new String[] {"o1", "o2"});
+ }
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/EqualsCheckingMethodBodyStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/ForEachStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+/**
+ * @author Nick Belaevski
+ */
+public class ForEachStatement extends AbstractTemplateMethodBodyStatementsContainer {
+
+ private String itemsExpression;
+
+ private String var;
+
+ private String varType;
+
+ public ForEachStatement(String itemsExpression,
+ String var, String varType) {
+ super("for-each");
+ this.itemsExpression = itemsExpression;
+ this.var = var;
+ this.varType = varType;
+ }
+
+ /**
+ * @return the itemsExpression
+ */
+ public String getItemsExpression() {
+ return itemsExpression;
+ }
+
+ /**
+ * @return the var
+ */
+ public String getVar() {
+ return var;
+ }
+
+ /**
+ * @return the varType
+ */
+ public String getVarType() {
+ return varType;
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/ForEachStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodBodyStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/HelperMethodBodyStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodBodyStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodBodyStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class HelperMethodBodyStatement extends BaseTemplateMethodBodyStatement {
+
+ private String[] argumentNames;
+
+ protected HelperMethodBodyStatement(String templateName, String[] argumentNames) {
+ super(templateName);
+
+ this.argumentNames = argumentNames;
+ }
+
+ public String[] getArgumentNames() {
+ return argumentNames;
+ }
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/HelperMethodBodyStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfElseStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfElseStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfElseStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfElseStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public class IfElseStatement extends AbstractTemplateMethodBodyStatementsContainer {
+
+ public IfElseStatement() {
+ super("if-else");
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfElseStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/IfStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+
+public final class IfStatement extends StatementsContainer {
+
+ private String test;
+
+ public IfStatement(String test) {
+ super();
+ this.test = test;
+ }
+
+ public String getTest() {
+ return test;
+ }
+}
\ No newline at end of file
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/IfStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StartElementStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/StartElementStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StartElementStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StartElementStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public class StartElementStatement extends BaseTemplateMethodBodyStatement {
+
+ private String elementName;
+
+ public StartElementStatement(String elementName) {
+ this("start-element", elementName);
+ }
+
+ protected StartElementStatement(String templateName, String elementName) {
+ super(templateName);
+ this.elementName = elementName;
+ }
+
+ /**
+ * @return the elementName
+ */
+ public String getElementName() {
+ return elementName;
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StartElementStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StatementsContainer.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StatementsContainer.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StatementsContainer.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,179 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk.templatecompiler.statements;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
+import org.richfaces.cdk.templatecompiler.builder.model.Variables;
+import org.richfaces.cdk.templatecompiler.el.HelperMethod;
+import org.richfaces.cdk.templatecompiler.el.ELType;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public class StatementsContainer implements TemplateStatement, Variables {
+
+ private static final Function<TemplateStatement, Iterable<ELType>> IMPORTS_TRANSFORM = new Function<TemplateStatement, Iterable<ELType>>() {
+
+ @Override
+ public Iterable<ELType> apply(TemplateStatement from) {
+ return from.getRequiredImports();
+ }
+ };
+
+ private static final Function<TemplateStatement, Iterable<JavaField>> FIELDS_TRANSFORM = new Function<TemplateStatement, Iterable<JavaField>>() {
+
+ @Override
+ public Iterable<JavaField> apply(TemplateStatement from) {
+ return from.getRequiredFields();
+ }
+ };
+
+ private static final Function<TemplateStatement, Iterable<HelperMethod>> HELPER_METHODS_TRANSFORM = new Function<TemplateStatement, Iterable<HelperMethod>>() {
+
+ @Override
+ public Iterable<HelperMethod> apply(TemplateStatement from) {
+ return from.getRequiredMethods();
+ }
+ };
+
+ private List<TemplateStatement> statements = new ArrayList<TemplateStatement>();
+
+ private StatementsContainer parent;
+
+ private final Map<String, ELType> localVariablesMap = Maps.newHashMap();
+
+ public List<TemplateStatement> getStatements() {
+ return statements;
+ }
+
+ public void addStatement(TemplateStatement statement) {
+ setParent(statement);
+ statements.add(statement);
+ }
+
+ public void addStatement(int index, TemplateStatement statement) {
+ setParent(statement);
+ statements.add(index, statement);
+ }
+
+ private void setParent(TemplateStatement statement) {
+ if (statement instanceof StatementsContainer) {
+ StatementsContainer container = (StatementsContainer) statement;
+ container.setParent(this);
+ }
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param parent
+ * the parent to set
+ */
+ public void setParent(StatementsContainer parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the parent
+ */
+ public StatementsContainer getParent() {
+ return parent;
+ }
+
+ public boolean isEmpty() {
+ return statements.isEmpty();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.templatecompiler.builder.model.JavaStatement#getCode()
+ */
+ @Override
+ public String getCode() {
+ StringBuilder sb = new StringBuilder();
+ for (TemplateStatement statement : statements) {
+ sb.append(statement.getCode());
+ sb.append('\n');
+ }
+
+ return sb.toString();
+ }
+
+ @Override
+ public ELType getVariable(String name) {
+ ELType type = localVariablesMap.get(name);
+ if (null == type && null != parent) {
+ type = parent.getVariable(name);
+ }
+ return type;
+ }
+
+ @Override
+ public boolean isDefined(String name) {
+ boolean defined = localVariablesMap.containsKey(name);
+ if (!defined && null != parent) {
+ defined = parent.isDefined(name);
+ }
+ return defined;
+ }
+
+ @Override
+ public ELType setVariable(String name, ELType type) {
+ ELType variable = getVariable(name);
+ localVariablesMap.put(name, type);
+ return variable;
+ }
+
+ private <T> Iterable<T> concatStatements(Function<TemplateStatement, Iterable<T>> transform) {
+ Iterable<T> imports = Iterables.concat(Iterables.transform(statements, transform));
+ return imports;
+ }
+
+ @Override
+ public Iterable<ELType> getRequiredImports() {
+ return concatStatements(IMPORTS_TRANSFORM);
+ }
+
+ @Override
+ public Iterable<JavaField> getRequiredFields() {
+ return concatStatements(FIELDS_TRANSFORM);
+ }
+
+ @Override
+ public Iterable<HelperMethod> getRequiredMethods() {
+ return concatStatements(HELPER_METHODS_TRANSFORM);
+ }
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/StatementsContainer.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Added: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatement.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,23 @@
+/**
+ *
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+import org.richfaces.cdk.templatecompiler.builder.model.JavaField;
+import org.richfaces.cdk.templatecompiler.builder.model.JavaStatement;
+import org.richfaces.cdk.templatecompiler.el.HelperMethod;
+import org.richfaces.cdk.templatecompiler.el.ELType;
+
+/**
+ * @author asmirnov
+ *
+ */
+public interface TemplateStatement extends JavaStatement {
+
+ public Iterable<ELType> getRequiredImports();
+
+ public Iterable<JavaField> getRequiredFields();
+
+ public Iterable<HelperMethod> getRequiredMethods();
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/TemplateStatement.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributeStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+/**
+ * @author Nick Belaevski
+ */
+public class WriteAttributeStatement extends BaseTemplateMethodBodyStatement {
+
+ private String attributeName;
+
+ private String valueExpression;
+
+ public WriteAttributeStatement(String attributeName, String valueExpression) {
+ super("write-attribute");
+ this.attributeName = attributeName;
+ this.valueExpression = valueExpression;
+ }
+
+ public String getAttributeName() {
+ return attributeName;
+ }
+
+ public String getValueExpression() {
+ return valueExpression;
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributeStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteAttributesSetStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+
+/**
+ * @author Nick Belaevski
+ */
+public class WriteAttributesSetStatement extends BaseTemplateMethodBodyStatement {
+
+ private String passThroughFieldName;
+
+ public WriteAttributesSetStatement(String passThroughFieldName) {
+ super("write-attributes-set");
+ this.passThroughFieldName = passThroughFieldName;
+ }
+
+ /**
+ * @return the passThroughFieldName
+ */
+ public String getPassThroughFieldName() {
+ return passThroughFieldName;
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteAttributesSetStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Copied: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java (from rev 17668, root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/WriteTextStatement.java)
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java (rev 0)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk.templatecompiler.statements;
+
+/**
+ * @author Nick Belaevski
+ */
+public class WriteTextStatement extends BaseTemplateMethodBodyStatement {
+
+ private String textExpression;
+
+ public WriteTextStatement(String textExpression) {
+ super("write-text");
+ this.textExpression = textExpression;
+ }
+
+ public String getTextExpression() {
+ return textExpression;
+ }
+
+}
Property changes on: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/statements/WriteTextStatement.java
___________________________________________________________________
Name: svn:keywords
+ LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
Modified: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/ELParserTest.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/ELParserTest.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/ELParserTest.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -31,27 +31,93 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.As;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.Mock;
+import org.richfaces.cdk.MockController;
+import org.richfaces.cdk.templatecompiler.ELParser;
import org.richfaces.cdk.templatecompiler.builder.model.Variables;
+import org.richfaces.cdk.templatecompiler.el.ELParserImpl;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
+import org.richfaces.cdk.templatecompiler.el.HelperMethod;
import org.richfaces.cdk.templatecompiler.el.ParsingException;
-import org.richfaces.cdk.templatecompiler.el.Type;
+import org.richfaces.cdk.templatecompiler.el.ELType;
import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactoryImpl;
+import org.richfaces.cdk.templatecompiler.statements.TemplateStatement;
-public class ELParserTest {
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
- private ELVisitor visitor;
+(a)RunWith(CdkTestRunner.class)
+public class ELParserTest extends CdkTestBase {
- private void parseExpression(String expression) throws ParsingException {
- parseExpression(expression, Object.class);
+ @Inject
+ @As(ELParserImpl.class)
+ private ELParser parser;
+
+ @Mock
+ Logger log;
+
+ @Inject
+ @As(TypesFactoryImpl.class)
+ private TypesFactory typesFactory;
+
+ @Inject
+ private MockController controller;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(ClassLoader.class).toInstance(createClassLoader());
}
- private void parseExpression(String expression, Class<?> returnType) throws ParsingException {
- final Map<String, Type> contextMap = new HashMap<String, Type>();
+ private TemplateStatement parseExpression(String expression) throws ParsingException {
+ return parseExpression(expression, Object.class);
+ }
- Variables variables = new Variables(){
+ private TemplateStatement parseAndCheck(String expression, String expected, HelperMethod... requiredMethods)
+ throws ParsingException {
+ return parseAndCheck(expression, Object.class, expected, requiredMethods);
+ }
+ private TemplateStatement parseAndCheck(String expression, Class<?> returnType, String expected,
+ Class<?> expectedType, HelperMethod... requiredMethods) throws ParsingException {
+ TemplateStatement statement = parseAndCheck(expression, returnType, expected, requiredMethods);
+ ELVisitor visitor = (ELVisitor) statement;
+ assertEquals(expectedType, visitor.getExpressionType().getRawType());
+ return statement;
+ }
+
+ private TemplateStatement parseAndCheck(String expression, Class<?> returnType, String expected,
+ HelperMethod... requiredMethods) throws ParsingException {
+ controller.replay();
+ TemplateStatement parseExpression = parseExpression(expression, returnType);
+ controller.verify();
+ assertEquals(expected, parseExpression.getCode());
+ for (HelperMethod helperMethod : requiredMethods) {
+ assertTrue("Expect helper method " + helperMethod.getName(),
+ Iterables.contains(parseExpression.getRequiredMethods(), helperMethod));
+ }
+ for (HelperMethod helperMethod : parseExpression.getRequiredMethods()) {
+ assertTrue("Unexpected helper method " + helperMethod.getName(),
+ Iterables.contains(ImmutableSet.of(requiredMethods), helperMethod));
+ }
+ return parseExpression;
+ }
+
+ private TemplateStatement parseExpression(String expression, Class<?> returnType) throws ParsingException {
+ final Map<String, ELType> contextMap = new HashMap<String, ELType>();
+
+ Variables variables = new Variables() {
+
@Override
- public Type getVariable(String name) throws ParsingException {
+ public ELType getVariable(String name) throws ParsingException {
return contextMap.get(name);
}
@@ -61,104 +127,86 @@
}
@Override
- public Type setVariable(String name, Type type) throws ParsingException {
+ public ELType setVariable(String name, ELType type) throws ParsingException {
return contextMap.put(name, type);
}
-
+
};
- contextMap.put("action", TypesFactory.getType(org.richfaces.cdk.templatecompiler.parser.el.test.Bean.class));
- contextMap.put("clientId", TypesFactory.getType(String.class));
- contextMap.put("test", TypesFactory.getType(boolean.class));
- contextMap.put("otherTest", TypesFactory.getType(boolean.class));
- contextMap.put("this", TypesFactory.getType(Object.class));
- contextMap.put("super", TypesFactory.getType(Object.class));
- contextMap.put("objectVar", TypesFactory.getType(Object.class));
+ contextMap.put("action", this.getType(org.richfaces.cdk.templatecompiler.parser.el.test.Bean.class));
+ contextMap.put("clientId", this.getType(String.class));
+ contextMap.put("test", this.getType(boolean.class));
+ contextMap.put("otherTest", this.getType(boolean.class));
+ contextMap.put("this", this.getType(Object.class));
+ contextMap.put("super", this.getType(Object.class));
+ contextMap.put("objectVar", this.getType(Object.class));
- visitor.parse(expression, variables, TypesFactory.getType(returnType));
+ return parser.parse(expression, variables, this.getType(returnType));
}
- @Before
- public void setUp() {
- visitor = new ELVisitor();
+ private ELType getType(Class<?> returnType) {
+ return typesFactory.getType(returnType);
}
- @After
- public void tearDown() {
- visitor = null;
+ @Test
+ public void testAnd() throws Exception {
+ parseAndCheck("#{test and otherTest}", "(test && otherTest)");
}
@Test
- public void testAnd() throws Exception {
- parseExpression("#{test and otherTest}");
- assertEquals("(test && otherTest)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ public void testAnd1() throws Exception {
+ parseAndCheck("#{otherTest && test}", "(otherTest && test)");
+ // assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ }
- parseExpression("#{otherTest && test}");
- assertEquals("(otherTest && test)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ @Test
+ public void testAnd2() throws Exception {
+ parseAndCheck("#{action and otherTest}", "(convertToBoolean(action) && otherTest)", TO_BOOLEAN_CONVERSION);
+ }
- parseExpression("#{action and otherTest}");
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
- assertEquals("(convertToBoolean(action) && otherTest)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
-
- parseExpression("#{test && action}");
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
- assertEquals("(test && convertToBoolean(action))", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ @Test
+ public void testAnd3() throws Exception {
+ parseAndCheck("#{test && action}", "(test && convertToBoolean(action))", TO_BOOLEAN_CONVERSION);
+ // assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
}
@Test
public void testBooleanReturnType() throws Exception {
- parseExpression("#{clientId}", Boolean.TYPE);
+ parseAndCheck("#{clientId}", Boolean.TYPE, "convertToBoolean(clientId)",Boolean.TYPE, TO_BOOLEAN_CONVERSION);
+ }
- assertEquals("convertToBoolean(clientId)", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
-
- parseExpression("#{test}", Boolean.TYPE);
-
- assertEquals("test", visitor.getParsedExpression());
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
- assertFalse(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+ @Test
+ public void testBooleanReturnType1() throws Exception {
+ parseAndCheck("#{test}", Boolean.TYPE, "test", Boolean.TYPE);
}
@Test
public void testChoice() throws Exception {
- parseExpression("#{test ? 2 : 3}");
- assertEquals("(test ? 2 : 3)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
+ parseAndCheck("#{test ? 2 : 3}",Object.class,"(test ? 2 : 3)",Integer.TYPE);
+ }
- parseExpression("#{test ? null : 'string'}");
- assertEquals("(test ? null : \"string\")", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
+ @Test
+ public void testChoice1() throws Exception {
+ parseAndCheck("#{test ? null : 'string'}",Object.class,"(test ? null : \"string\")", String.class);
+ }
- parseExpression("#{action ? null : 'string'}");
- assertEquals("(convertToBoolean(action) ? null : \"string\")", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
- assertTrue(visitor.getUsedHelperMethods().contains(TO_BOOLEAN_CONVERSION));
+ @Test
+ public void testChoice2() throws Exception {
+ parseAndCheck("#{action ? null : 'string'}",Object.class,"(convertToBoolean(action) ? null : \"string\")", TO_BOOLEAN_CONVERSION);
}
@Test
public void testDiv() throws Exception {
- parseExpression("#{1/2}");
- assertEquals("(1 / 2)", visitor.getParsedExpression());
- assertEquals(Integer.TYPE, visitor.getExpressionType().getRawType());
+ parseAndCheck("#{1/2}",Object.class,"(1 / 2)",Integer.TYPE);
}
@Test
public void testEmpty() throws Exception {
- parseExpression("#{empty action.array}");
- assertEquals("isEmpty(action.getArray())", visitor.getParsedExpression());
- assertTrue(visitor.getUsedHelperMethods().contains(EMPTINESS_CHECK));
- assertEquals(Boolean.TYPE, visitor.getExpressionType().getRawType());
+ parseAndCheck("#{empty action.array}",Object.class,"isEmpty(action.getArray())", Boolean.TYPE,EMPTINESS_CHECK);
}
@Test
public void testEmptyString() throws Exception {
- parseExpression("");
- assertEquals("\"\"", visitor.getParsedExpression());
- assertEquals(String.class, visitor.getExpressionType().getRawType());
+ parseAndCheck("",Object.class,"\"\"", String.class);
}
@Test
@@ -226,7 +274,7 @@
public void testFunction() throws Exception {
parseExpression("#{super:getType()}");
assertEquals("super.getType()", visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
}
@Test
@@ -337,7 +385,7 @@
public void testMethodReturnList() throws Exception {
parseExpression("#{action.components}");
assertEquals("action.getComponents()", visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
assertEquals(List.class, variableType.getRawType());
assertEquals(UIComponent.class, variableType.getContainerType().getRawType());
}
@@ -365,7 +413,7 @@
public void testMethodReturnMap() throws Exception {
parseExpression("#{action.facets}");
assertEquals("action.getFacets()", visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
assertEquals(Map.class, variableType.getRawType());
assertEquals(UIComponent.class, variableType.getContainerType().getRawType());
@@ -407,10 +455,10 @@
@Test
public void testMethodWithParam() throws Exception {
parseExpression("#{getType(action.array[0].rendered, action.readOnly, true)}");
- assertEquals("this.getType(action.getArray()[0].isRendered(),action.isReadOnly(),true)", visitor
- .getParsedExpression());
+ assertEquals("this.getType(action.getArray()[0].isRendered(),action.isReadOnly(),true)",
+ visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
parseExpression("#{action.count(123)}");
assertEquals("action.count(123)", visitor.getParsedExpression());
@@ -611,7 +659,7 @@
public void testThisFunction() throws Exception {
parseExpression("#{getType()}");
assertEquals("this.getType()", visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
parseExpression("#{this.getType()}");
assertEquals("this.getType()", visitor.getParsedExpression());
@@ -628,7 +676,7 @@
public void testVariableFunction() throws Exception {
parseExpression("#{objectVar.getType()}");
assertEquals("objectVar.getType()", visitor.getParsedExpression());
- Type variableType = visitor.getExpressionType();
+ ELType variableType = visitor.getExpressionType();
}
@Test
Modified: root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/TypesFactoryTest.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/TypesFactoryTest.java 2010-06-24 14:18:53 UTC (rev 17668)
+++ root/cdk/branches/RF8755/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/parser/el/test/TypesFactoryTest.java 2010-06-25 00:01:41 UTC (rev 17669)
@@ -21,22 +21,43 @@
*/
package org.richfaces.cdk.templatecompiler.parser.el.test;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import java.io.Writer;
import java.util.List;
import java.util.Map;
import org.junit.Test;
-import org.richfaces.cdk.templatecompiler.el.Type;
-import org.richfaces.cdk.templatecompiler.el.types.TypesFactory;
+import org.junit.runner.RunWith;
+import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.CdkTestRunner;
+import org.richfaces.cdk.templatecompiler.el.ELType;
+import org.richfaces.cdk.templatecompiler.el.types.TypesFactoryImpl;
+import com.google.inject.Binder;
+import com.google.inject.Inject;
+
/**
* @author Nick Belaevski
*
*/
-public class TypesFactoryTest {
+(a)RunWith(CdkTestRunner.class)
+public class TypesFactoryTest extends CdkTestBase {
+ @Inject
+ TypesFactoryImpl typesFactory;
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(ClassLoader.class).toInstance(createClassLoader());
+ }
+
private static final class ParameterizedTypesHolder {
@SuppressWarnings("unused")
@@ -78,173 +99,159 @@
@Test
public void testCaching() throws Exception {
- Type objectType = TypesFactory.getType(Object.class);
- Type objectType2 = TypesFactory.getType(Object.class);
+ ELType objectType = typesFactory.getType(Object.class);
+ ELType objectType2 = typesFactory.getType(Object.class);
assertNotNull(objectType);
assertNotNull(objectType2);
assertSame(objectType, objectType2);
- TypesFactory.clearCaches();
-
- Type objectType3 = TypesFactory.getType(Object.class);
- assertNotNull(objectType3);
-
- assertNotSame(objectType, objectType3);
}
- @Test
- public void testGetNullType() throws Exception {
- Type nullType = TypesFactory.getNullType();
- assertNotNull(nullType);
- assertTrue(nullType.isNullType());
- }
@Test
public void testGetTypeFromReflectionType() throws Exception {
- Type integerType = TypesFactory.getType(Integer.TYPE);
+ ELType integerType = typesFactory.getType(Integer.TYPE);
assertNotNull(integerType);
assertEquals(Integer.TYPE, integerType.getRawType());
assertNull(integerType.getTypeArguments());
assertFalse(integerType.isArray());
assertFalse(integerType.isNullType());
- Type stringType = TypesFactory.getType(String.class);
+ ELType stringType = typesFactory.getType(String.class);
assertNotNull(stringType);
assertEquals(String.class, stringType.getRawType());
assertNull(stringType.getTypeArguments());
assertFalse(stringType.isArray());
assertFalse(stringType.isNullType());
- Type arrayType = TypesFactory.getType(String[].class);
+ ELType arrayType = typesFactory.getType(String[].class);
assertNotNull(arrayType);
assertNull(arrayType.getTypeArguments());
assertTrue(arrayType.isArray());
assertEquals(String.class, arrayType.getContainerType().getRawType());
assertFalse(arrayType.isNullType());
- Type multiDimArrayType = TypesFactory.getType(String[][][].class);
+ ELType multiDimArrayType = typesFactory.getType(String[][][].class);
assertNotNull(multiDimArrayType);
assertNull(multiDimArrayType.getTypeArguments());
assertTrue(multiDimArrayType.isArray());
assertEquals(String[][].class, multiDimArrayType.getContainerType().getRawType());
assertFalse(multiDimArrayType.isNullType());
- Type parameterizedMapType = TypesFactory.getType(getParameterizedMapType());
+ ELType parameterizedMapType = typesFactory.getType(getParameterizedMapType());
assertNotNull(parameterizedMapType);
assertFalse(parameterizedMapType.isArray());
assertEquals(Map.class, parameterizedMapType.getRawType());
- Type[] parameterizedMapTypeArguments = parameterizedMapType.getTypeArguments();
+ ELType[] parameterizedMapTypeArguments = parameterizedMapType.getTypeArguments();
assertNotNull(parameterizedMapTypeArguments);
assertEquals(2, parameterizedMapTypeArguments.length);
assertEquals(String.class, parameterizedMapTypeArguments[0].getRawType());
assertEquals(Object.class, parameterizedMapTypeArguments[1].getRawType());
- Type parameterizedArrayType = TypesFactory.getType(getParameterizedArrayType());
+ ELType parameterizedArrayType = typesFactory.getType(getParameterizedArrayType());
assertNotNull(parameterizedArrayType);
assertTrue(parameterizedArrayType.isArray());
assertEquals(List[].class, parameterizedArrayType.getRawType());
- Type[] parameterizedArrayTypeArguments = parameterizedArrayType.getTypeArguments();
+ ELType[] parameterizedArrayTypeArguments = parameterizedArrayType.getTypeArguments();
assertNotNull(parameterizedArrayTypeArguments);
assertEquals(1, parameterizedArrayTypeArguments.length);
- Type parameterizedArrayTypeArgument = parameterizedArrayTypeArguments[0];
+ ELType parameterizedArrayTypeArgument = parameterizedArrayTypeArguments[0];
assertEquals(String.class, parameterizedArrayTypeArgument.getRawType());
assertFalse(parameterizedArrayTypeArgument.isArray());
- Type typeVariableType = TypesFactory.getType(getTypeVariableType());
+ ELType typeVariableType = typesFactory.getType(getTypeVariableType());
assertNotNull(typeVariableType);
assertEquals("Abc", typeVariableType.getCode());
- Type wildcardTypeHolder = TypesFactory.getType(getWildcardType());
+ ELType wildcardTypeHolder = typesFactory.getType(getWildcardType());
assertNotNull(wildcardTypeHolder);
assertEquals(List.class, wildcardTypeHolder.getRawType());
- Type[] wildcardTypeHolderArguments = wildcardTypeHolder.getTypeArguments();
+ ELType[] wildcardTypeHolderArguments = wildcardTypeHolder.getTypeArguments();
assertNotNull(wildcardTypeHolderArguments);
assertEquals(1, wildcardTypeHolderArguments.length);
- Type wildcardType = wildcardTypeHolderArguments[0];
+ ELType wildcardType = wildcardTypeHolderArguments[0];
assertEquals("? extends java.lang.String", wildcardType.getCode());
}
@Test
public void testGetTypeFromString() throws Exception {
- ClassLoader classLoader = getClass().getClassLoader();
- Type primitiveIntType = TypesFactory.getType("int", classLoader);
+ ELType primitiveIntType = typesFactory.getType("int");
assertNotNull(primitiveIntType);
assertEquals(Integer.TYPE, primitiveIntType.getRawType());
- Type guessedMapType = TypesFactory.getType("Map", classLoader);
+ ELType guessedMapType = typesFactory.getType("Map");
assertNotNull(guessedMapType);
assertEquals(Map.class, guessedMapType.getRawType());
assertNull(guessedMapType.getTypeArguments());
- Type writerType = TypesFactory.getType(java.io.Writer.class.getName(), classLoader);
+ ELType writerType = typesFactory.getType(java.io.Writer.class.getName());
assertNotNull(writerType);
assertEquals(Writer.class, writerType.getRawType());
assertNull(writerType.getTypeArguments());
- Type genericMapType = TypesFactory.getType("Map<String, Object>", classLoader);
+ ELType genericMapType = typesFactory.getType("Map<String, Object>");
assertNotNull(genericMapType);
assertEquals(Map.class, genericMapType.getRawType());
- Type[] genericMapTypeArguments = genericMapType.getTypeArguments();
+ ELType[] genericMapTypeArguments = genericMapType.getTypeArguments();
assertNotNull(genericMapTypeArguments);
assertFalse(genericMapType.isArray());
assertEquals(2, genericMapTypeArguments.length);
- Type genericMapTypeKeyArgument = genericMapTypeArguments[0];
+ ELType genericMapTypeKeyArgument = genericMapTypeArguments[0];
assertEquals(String.class, genericMapTypeKeyArgument.getRawType());
- Type genericMapTypeValueArgument = genericMapTypeArguments[1];
+ ELType genericMapTypeValueArgument = genericMapTypeArguments[1];
assertEquals(Object.class, genericMapTypeValueArgument.getRawType());
- Type arrayType = TypesFactory.getType("String[]", classLoader);
+ ELType arrayType = typesFactory.getType("String[]");
assertNotNull(arrayType);
assertTrue(arrayType.isArray());
assertEquals(String[].class, arrayType.getRawType());
- Type genericArrayType = TypesFactory.getType("List<String>[]", classLoader);
+ ELType genericArrayType = typesFactory.getType("List<String>[]");
assertNotNull(genericArrayType);
assertTrue(genericArrayType.isArray());
assertEquals(List[].class, genericArrayType.getRawType());
- Type[] genericArrayTypeArguments = genericArrayType.getTypeArguments();
+ ELType[] genericArrayTypeArguments = genericArrayType.getTypeArguments();
assertNotNull(genericArrayTypeArguments);
assertEquals(1, genericArrayTypeArguments.length);
- Type genericArrayTypeArgument = genericArrayTypeArguments[0];
+ ELType genericArrayTypeArgument = genericArrayTypeArguments[0];
assertEquals(String.class, genericArrayTypeArgument.getRawType());
}
@Test
public void testReferencedType() throws Exception {
- ClassLoader classLoader = getClass().getClassLoader();
String className = "some.not.available.Class";
- Type plainReferencedType = TypesFactory.getType(className, classLoader);
+ ELType plainReferencedType = typesFactory.getType(className);
assertNotNull(plainReferencedType);
assertEquals(className, plainReferencedType.getCode());
String arraySignature = className + "[]";
- Type arrayReferencedType = TypesFactory.getType(arraySignature, classLoader);
+ ELType arrayReferencedType = typesFactory.getType(arraySignature);
assertNotNull(arrayReferencedType);
assertTrue(arrayReferencedType.isArray());
assertEquals(arraySignature, arrayReferencedType.getCode());
String genericSignature = className + "<String>";
- Type genericReferenceType = TypesFactory.getType(genericSignature, classLoader);
+ ELType genericReferenceType = typesFactory.getType(genericSignature);
assertNotNull(genericReferenceType);
assertEquals(genericSignature, genericReferenceType.getCode());
- Type[] genericTypeArguments = genericReferenceType.getTypeArguments();
+ ELType[] genericTypeArguments = genericReferenceType.getTypeArguments();
assertNotNull(genericTypeArguments);
assertEquals(1, genericTypeArguments.length);
- Type genericTypeArgument = genericTypeArguments[0];
+ ELType genericTypeArgument = genericTypeArguments[0];
assertEquals(String.class, genericTypeArgument.getRawType());
}
}
14 years, 6 months
JBoss Rich Faces SVN: r17668 - in root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces: renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-06-24 10:18:53 -0400 (Thu, 24 Jun 2010)
New Revision: 17668
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableDataIterator.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableFixedChildrenIterator.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
Log:
small code clean up
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableDataIterator.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableDataIterator.java 2010-06-24 14:10:07 UTC (rev 17667)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableDataIterator.java 2010-06-24 14:18:53 UTC (rev 17668)
@@ -44,23 +44,15 @@
UIComponent nextColumn = null;
while (nextColumn == null && childrenIterator.hasNext()) {
UIComponent child = childrenIterator.next();
- // TODO nick - why non-rendered children are filtered?
- // TODO nick - should be (child instanceof UIColumn || child instanceof Column)?
if ((child instanceof UIColumn) || (child instanceof Column)) {
nextColumn = child;
- } else if (checkAjaxComponent(child)) {
- nextColumn = child;
- }
+ }
}
// TODO nick - free childrenIterator
- // ???
while (nextColumn == null && facetsIterator.hasNext()) {
- UIComponent component = facetsIterator.next();
- if (checkAjaxComponent(component)) {
- nextColumn = component;
- }
+ nextColumn = facetsIterator.next();
}
// TODO nick - free facetsIterator
@@ -76,9 +68,4 @@
return this.childrenIterator;
}
- // TODO nick - what's this for?
- protected boolean checkAjaxComponent(UIComponent child) {
- return false;
- }
-
}
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableFixedChildrenIterator.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableFixedChildrenIterator.java 2010-06-24 14:10:07 UTC (rev 17667)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/DataTableFixedChildrenIterator.java 2010-06-24 14:18:53 UTC (rev 17668)
@@ -50,9 +50,7 @@
if ((child instanceof UIColumn) && child.isRendered()) {
currentColumnIterator = getChildFacetIterator(child);
next = nextItem();
- } else if (checkAjaxComponent(child)) {
- next = child;
- }
+ }
}
}
@@ -64,8 +62,7 @@
protected UIComponent getNextFacet() {
Iterator<UIComponent> facetsIterator = getFacetsIterator();
- // TODO nick - while -> if
- while (facetsIterator.hasNext()) {
+ if(facetsIterator.hasNext()) {
return facetsIterator.next();
}
return null;
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-06-24 14:10:07 UTC (rev 17667)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-06-24 14:18:53 UTC (rev 17668)
@@ -92,11 +92,11 @@
}
public UIComponent getHeader() {
- return getFacet("header");
+ return getFacet(HEADER);
}
public UIComponent getFooter() {
- return getFacet("footer");
+ return getFacet(FOOTER);
}
public UIComponent getNoData() {
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-06-24 14:10:07 UTC (rev 17667)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-06-24 14:18:53 UTC (rev 17668)
@@ -41,7 +41,12 @@
public static final String MODE_SERVER = "server";
public static final String MODE_CLIENT = "client";
+
+ public static final int EXPAND_STATE = 1;
+
+ public static final int COLLAPSE_STATE = 0;
+
enum PropertyKeys {
expandMode, expanded, toggleExpression
}
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2010-06-24 14:10:07 UTC (rev 17667)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2010-06-24 14:18:53 UTC (rev 17668)
@@ -56,6 +56,7 @@
} catch (IOException e) {
throw new FacesException(e);
}
+
holder.nextRow();
return DataVisitResult.CONTINUE;
}
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java 2010-06-24 14:10:07 UTC (rev 17667)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java 2010-06-24 14:18:53 UTC (rev 17668)
@@ -51,13 +51,7 @@
public static final String BREAK_ROW_BEFORE = "breakRowBefore";
- public static final String ROWSPAN_STRING = "rowspan";
-
- public static final String COLSPAN_STRING = "colspan";
-
-
public void encodeColumn(FacesContext context, ResponseWriter writer, UIColumn component, RowHolder rowHolder) throws IOException {
-
String parentId = rowHolder.getParentClientId();
if (component instanceof org.richfaces.component.UIColumn) {
@@ -71,11 +65,13 @@
if (rowHolder.isRowStart()) {
int currentRow = rowHolder.getCurrentRow();
+
if (rowHolder.getCurrentRow() == 0) {
encodeFirstRowStart(writer, context, parentId, currentRow, component);
} else {
encodeRowStart(writer, context, parentId, currentRow, component);
}
+
rowHolder.setRowStart(false);
}
@@ -96,14 +92,14 @@
if (component instanceof org.richfaces.component.UIColumn) {
Map<String, Object> attributes = component.getAttributes();
- int rowspan = (Integer) attributes.get(ROWSPAN_STRING);
+ int rowspan = (Integer) attributes.get(HTML.ROWSPAN_ATTRIBUTE);
if (rowspan != Integer.MIN_VALUE) {
- writer.writeAttribute(ROWSPAN_STRING, Integer.valueOf(rowspan), null);
+ writer.writeAttribute(HTML.ROWSPAN_ATTRIBUTE, Integer.valueOf(rowspan), null);
}
- int colspan = (Integer) attributes.get(COLSPAN_STRING);
+ int colspan = (Integer) attributes.get(HTML.COLSPAN_ATTRIBUTE);
if (colspan != Integer.MIN_VALUE) {
- writer.writeAttribute(COLSPAN_STRING, Integer.valueOf(colspan), null);
+ writer.writeAttribute(HTML.COLSPAN_ATTRIBUTE, Integer.valueOf(colspan), null);
}
}
}
@@ -237,7 +233,7 @@
}
currentLength = 0;
}
- Integer colspan = (Integer) attributes.get(COLSPAN_STRING);
+ Integer colspan = (Integer) attributes.get(HTML.COLSPAN_ATTRIBUTE);
// Append colspan of this column
if (null != colspan && colspan.intValue() != Integer.MIN_VALUE) {
currentLength += colspan.intValue();
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-06-24 14:10:07 UTC (rev 17667)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-06-24 14:18:53 UTC (rev 17668)
@@ -102,7 +102,7 @@
}
protected boolean isEncodeHeaders(UIDataTableBase table) {
- return table.isColumnFacetPresent("header") || isColumnAttributeSet(table, "sortBy")
+ return table.isColumnFacetPresent(UIDataTableBase.HEADER) || isColumnAttributeSet(table, "sortBy")
|| isColumnAttributeSet(table, "comparator")
|| isColumnAttributeSet(table, "filterBy");
}
@@ -163,7 +163,7 @@
writer.startElement(HTML.TR_ELEMENT, dataTableBase);
writer.startElement(HTML.TD_ELEM, dataTableBase);
- writer.writeAttribute("colspan", columns, null);
+ writer.writeAttribute(HTML.COLSPAN_ATTRIBUTE, columns, null);
String styleClass = (String) dataTableBase.getAttributes().get("noDataStyleClass");
styleClass = styleClass != null ? getNoDataClass() + " " + styleClass : getNoDataClass();
@@ -270,7 +270,7 @@
writer.startElement(HTML.TFOOT_ELEMENT, dataTable);
writer.writeAttribute(HTML.ID_ATTRIBUTE, footerClientId, null);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-tfoot", null);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rd-dt-tfoot", null);
}
int columns = getColumnsCount(dataTable);
@@ -301,7 +301,7 @@
writer.writeAttribute(HTML.ID_ATTRIBUTE, targetId, null);
encodeStyleClass(writer, facesContext, dataTable, null, rowClass);
- encodeColumnFacet(facesContext, writer, dataTable, "footer",columns, cellClass);
+ encodeColumnFacet(facesContext, writer, dataTable, UIDataTableBase.FOOTER,columns, cellClass);
writer.endElement(HTML.TR_ELEMENT);
if (encodePartialUpdateForChildren) {
@@ -320,7 +320,7 @@
firstClass = mergeStyleClasses("footerFirstClass", firstClass, dataTable);
// TODO nick - rename method "encodeTableHeaderFacet"
saveRowStyles(facesContext, id, firstClass, rowClass, cellClass);
- encodeTableFacet(facesContext, writer, id, columns, footer, "footer", rowClass, cellClass,
+ encodeTableFacet(facesContext, writer, id, columns, footer, UIDataTableBase.FOOTER, rowClass, cellClass,
encodePartialUpdateForChildren);
}
@@ -367,7 +367,7 @@
writer.startElement(HTML.THEAD_ELEMENT, dataTable);
writer.writeAttribute(HTML.ID_ATTRIBUTE, headerClientId, null);
- writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-thead", null);
+ writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rf-dt-thead", null);
}
int columns = getColumnsCount(dataTable);
@@ -386,11 +386,12 @@
firstClass = mergeStyleClasses("headerFirstClass", firstClass, dataTable);
saveRowStyles(facesContext, id, firstClass, rowClass, cellClass);
- encodeTableFacet(facesContext, writer, id, columns, header, "header", rowClass, cellClass,
+ encodeTableFacet(facesContext, writer, id, columns, header, UIDataTableBase.HEADER, rowClass, cellClass,
encodePartialUpdateForChildren);
}
if (isEncodeHeaders) {
+
String rowClass = getColumnHeaderSkinClass();
String cellClass = getColumnHeaderCellSkinClass();
String firstClass = getColumnHeaderFirstSkinClass();
@@ -411,7 +412,7 @@
encodeStyleClass(writer, facesContext, dataTable, null, rowClass);
- encodeColumnFacet(facesContext, writer, dataTable, "header", columns, cellClass);
+ encodeColumnFacet(facesContext, writer, dataTable, UIDataTableBase.HEADER, columns, cellClass);
writer.endElement(HTML.TR_ELEMENT);
if (encodePartialUpdateForChildren) {
@@ -431,7 +432,6 @@
}
protected void encodeColumnFacet(FacesContext context, ResponseWriter writer, UIDataTableBase dataTableBase, String facetName, int colCount, String cellClass) throws IOException {
-
int tColCount = 0;
String id = dataTableBase.getClientId(context);
String element = getCellElement(context, id);
@@ -446,7 +446,7 @@
continue;
}
- Integer colspan = (Integer) column.getAttributes().get("colspan");
+ Integer colspan = (Integer) column.getAttributes().get(HTML.COLSPAN_ATTRIBUTE);
if (colspan != null && colspan.intValue() > 0) {
tColCount += colspan.intValue();
} else {
@@ -461,8 +461,8 @@
encodeStyleClass(writer, context, column, null, cellClass);
- writer.writeAttribute("scope", "col", null);
- getUtils().encodeAttribute(context, column, "colspan");
+ writer.writeAttribute(HTML.SCOPE_ATTRIBUTE, HTML.COL_ELEMENT, null);
+ getUtils().encodeAttribute(context, column, HTML.COLSPAN_ATTRIBUTE);
EncodeStrategy strategy = getHeaderEncodeStrategy(column, facetName);
if(strategy != null) {
@@ -504,10 +504,10 @@
encodeStyleClass(writer, facesContext, footer, null, cellClass);
if (columns > 0) {
- writer.writeAttribute("colspan", String.valueOf(columns), null);
+ writer.writeAttribute(HTML.COLSPAN_ATTRIBUTE, String.valueOf(columns), null);
}
- writer.writeAttribute("scope", "colgroup", null);
+ writer.writeAttribute(HTML.SCOPE_ATTRIBUTE, HTML.COLGROUP_ELEMENT, null);
}
if (encodePartialUpdate && !partialUpdateEncoded) {
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-06-24 14:10:07 UTC (rev 17667)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-06-24 14:18:53 UTC (rev 17668)
@@ -42,6 +42,7 @@
import org.richfaces.component.UIDataTable;
import org.richfaces.component.UIDataTableBase;
import org.richfaces.component.UISubTable;
+import org.richfaces.component.util.HtmlUtil;
/**
* @author Anton Belevich
@@ -74,10 +75,9 @@
public void begin(ResponseWriter writer, FacesContext context, UIComponent component, Object [] params) throws IOException {
org.richfaces.component.UIColumn column = (org.richfaces.component.UIColumn) component;
- writer.writeAttribute("id", column.getClientId(context), null);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, column.getClientId(context), null);
- boolean sortableColumn = isSortable(column);
- if (sortableColumn) {
+ if (isSortable(column)) {
//TODO :anton -> should component be selfSorted
writer.startElement(HTML.SPAN_ELEM, column);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, "rich-table-sortable-header", null);
@@ -94,26 +94,27 @@
public void encodeTableStructure(ResponseWriter writer, FacesContext context, UIDataTableBase dataTable)
throws IOException {
-
if (dataTable instanceof UIDataTable) {
encodeCaption(writer, context, (UIDataTable) dataTable);
// TODO nick - do we need this element if "columnsWidth" is absent?
- // TODO nick - use constants from HTML class for attribute/element names
- writer.startElement("colgroup", dataTable);
+ writer.startElement(HTML.COLGROUP_ELEMENT, dataTable);
+
int columns = getColumnsCount(dataTable);
-
writer.writeAttribute(HTML.SPAN_ELEM, String.valueOf(columns), null);
String columnsWidth = (String) dataTable.getAttributes().get("columnsWidth");
- if (null != columnsWidth) {
+ if (columnsWidth != null) {
+
String[] widths = columnsWidth.split(",");
for (int i = 0; i < widths.length; i++) {
- writer.startElement("col", dataTable);
- writer.writeAttribute("width", widths[i], null);
- writer.endElement("col");
+ writer.startElement(HTML.COL_ELEMENT, dataTable);
+ writer.writeAttribute(HTML.WIDTH_ATTRIBUTE, widths[i], null);
+ writer.endElement(HTML.COL_ELEMENT);
}
+
}
- writer.endElement("colgroup");
+
+ writer.endElement(HTML.COLGROUP_ELEMENT);
}
}
@@ -139,7 +140,6 @@
public void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase holder) throws IOException {
-
RowHolder rowHolder = (RowHolder) holder;
Row row = rowHolder.getRow();
@@ -153,38 +153,35 @@
Iterator<UIComponent> components = row.columns();
while (components.hasNext()) {
-
+
UIComponent child = components.next();
if(child instanceof Row) {
boolean isSubtable = (child instanceof UISubTable);
//new row -> close </tr>
if (rowHolder.getProcessCell() != 0) {
encodeRowEnd(writer);
- //only SubTables could have <tbody>
+
if(isSubtable) {
encodeTableBodyEnd(writer);
tbodyStart = false;
+
if (partialUpdate) {
partialEnd(facesContext);
}
- }
+ }
}
rowHolder.nextCell();
- if(isSubtable){
+ if(isSubtable && partialUpdate){
String id = dataTable.getRelativeClientId(facesContext) + ":"+ child.getId() +":c";
- if(partialUpdate) {
- partialStart(facesContext, id);
- }
+ partialStart(facesContext, id);
}
child.encodeAll(facesContext);
- if (isSubtable) {
- if(partialUpdate) {
- partialEnd(facesContext);
- }
+ if (isSubtable && partialUpdate) {
+ partialEnd(facesContext);
}
} else if(child instanceof UIColumn) {
@@ -193,6 +190,7 @@
if (partialUpdate) {
partialStart(facesContext, dataTable.getRelativeClientId(facesContext) + ":tb");
}
+
encodeTableBodyStart(writer, facesContext, dataTable);
rowHolder.setRowStart(true);
tbodyStart = true;
@@ -206,6 +204,7 @@
if(!parentTbodyStart && tbodyStart) {
encodeTableBodyEnd(writer);
tbodyStart = false;
+
if(partialUpdate) {
partialEnd(facesContext);
}
@@ -226,35 +225,20 @@
}
protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- if (!shouldProceed(component)) {
- return;
- }
-
UIDataTableBase dataTable = (UIDataTableBase) component;
encodeTableStart(writer, context, dataTable);
encodeTableFacets(writer, context, dataTable);
}
protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- if (!shouldProceed(component)) {
- return;
- }
-
- if (component instanceof UIDataTable) {
- encodeTableEnd(writer);
- }
+ encodeTableEnd(writer);
}
- protected boolean shouldProceed(UIComponent component) {
- return component instanceof UIDataTableBase;
- }
-
protected Class<? extends UIComponent> getComponentClass() {
return UIDataTable.class;
}
public void encodeCaption(ResponseWriter writer, FacesContext context, UIDataTable dataTable) throws IOException {
-
UIComponent caption = dataTable.getCaption();
if (caption == null) {
@@ -269,12 +253,11 @@
String captionClass = (String) dataTable.getAttributes().get("captionClass");
String captionSkinClass = getCaptionSkinClass();
- captionClass = captionClass != null ? captionClass + " " + captionClass : captionSkinClass;
+ captionClass = HtmlUtil.concatClasses(captionClass, captionSkinClass);
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, captionClass, "captionClass");
-
+
String captionStyle = (String) dataTable.getAttributes().get("captionStyle");
-
if (captionStyle != null && captionStyle.trim().length() != 0) {
writer.writeAttribute(HTML.STYLE_ATTRIBUTE, captionStyle, "captionStyle");
}
@@ -284,10 +267,8 @@
writer.endElement(HTML.CAPTION_ELEMENT);
}
- public EncodeStrategy getHeaderEncodeStrategy(UIComponent column, String tableFacetName) {
-
- return (column instanceof org.richfaces.component.UIColumn && "header".equals(tableFacetName))
- ? new RichHeaderEncodeStrategy() : new SimpleHeaderEncodeStrategy();
+ public EncodeStrategy getHeaderEncodeStrategy(UIComponent column, String facetName) {
+ return (column instanceof org.richfaces.component.UIColumn && UIDataTableBase.HEADER.equals(facetName)) ? new RichHeaderEncodeStrategy() : new SimpleHeaderEncodeStrategy();
}
public boolean containsThead() {
@@ -303,17 +284,17 @@
}
public void encodeClientScript(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase) throws IOException {
-
UIDataTable dataTable = (UIDataTable) dataTableBase;
+
writer.startElement(HTML.SCRIPT_ELEM, dataTable);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.JAVASCRIPT_TYPE, null);
JSFunction function = new JSFunction("new RichFaces.ui.DataTable");
function.addParameter(dataTable.getClientId(facesContext));
- Map<String, Object> options = new HashMap<String, Object>();
-
AjaxEventOptions ajaxEventOptions = AjaxRendererUtils.buildEventOptions(facesContext, dataTable);
+
+ Map<String, Object> options = new HashMap<String, Object>();
options.put("ajaxEventOptions", ajaxEventOptions.getParameters());
function.addParameter(options);
@@ -322,8 +303,7 @@
}
@Override
- public void encodeHiddenInput(ResponseWriter writer, FacesContext context, UIDataTableBase component)
- throws IOException {
+ public void encodeHiddenInput(ResponseWriter writer, FacesContext context, UIDataTableBase component) throws IOException {
}
public String getTableSkinClass() {
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-24 14:10:07 UTC (rev 17667)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-24 14:18:53 UTC (rev 17668)
@@ -55,14 +55,15 @@
private static final String OPTIONS = ":options";
- private static final String HIDDEN_STYLE = "display: none";
+ private static final String DISPLAY_NONE = "display: none;";
private class SubTableHiddenEncodeStrategy implements EncodeStrategy {
+
public void begin(ResponseWriter writer, FacesContext context, UIComponent component, Object[] params) throws IOException {
UISubTable subTable = (UISubTable)component;
writer.startElement(HTML.TR_ELEMENT, subTable);
writer.writeAttribute(HTML.ID_ATTRIBUTE, subTable.getClientId(context) + HIDDEN_CONTAINER_ID, null);
- writer.writeAttribute(HTML.STYLE_ATTRIBUTE, HIDDEN_STYLE, null);
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
writer.startElement(HTML.TD_ELEM, subTable);
}
@@ -77,16 +78,16 @@
}
}
}
+
};
protected void doDecode(FacesContext facesContext, UIComponent component) {
UISubTable subTable = (UISubTable)component;
-
+
String clientId = subTable.getClientId(facesContext);
-
- String stateId = clientId + STATE;
Map<String, String> requestMap = facesContext.getExternalContext().getRequestParameterMap();
-
+
+ String stateId = clientId + STATE;
String state = (String)requestMap.get(stateId);
boolean isExpand = true;
@@ -138,15 +139,14 @@
@Override
public void encodeTableBodyStart(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase) throws IOException {
UISubTable subTable = (UISubTable)dataTableBase;
+
UIDataTableBase component = findParent(subTable);
if(component instanceof UIDataTable) {
-
writer.startElement(HTML.TBODY_ELEMENT, null);
writer.writeAttribute(HTML.ID_ATTRIBUTE, component.getRelativeClientId(facesContext) + ":" + subTable.getId() + TB_ROW, null);
-
- String predefinedStyles = !subTable.isExpanded() ? "display: none;" : null;
-
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, getTableSkinClass(), null);
+
+ String predefinedStyles = !subTable.isExpanded() ? DISPLAY_NONE : null;
encodeStyle(writer, facesContext, subTable, predefinedStyles);
}
}
@@ -162,7 +162,7 @@
private void encodeSubTableDomElement(ResponseWriter writer, FacesContext facesContext, UISubTable subTable) throws IOException{
writer.startElement(HTML.TR_ELEMENT, subTable);
- writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "display: none", null);
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, DISPLAY_NONE, null);
writer.writeAttribute(HTML.ID_ATTRIBUTE, subTable.getClientId(facesContext), null);
writer.startElement(HTML.TD_ELEM, subTable);
writer.endElement(HTML.TD_ELEM);
@@ -212,15 +212,11 @@
@Override
public boolean encodeParentTBody(UIDataTableBase dataTableBase) {
UIDataTableBase parent = findParent((UISubTable)dataTableBase);
- if(parent instanceof UIDataTable) {
- return true;
- }
- return false;
+ return (parent instanceof UIDataTable);
}
public void encodeHiddenInput(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase)
throws IOException {
-
UISubTable subTable = (UISubTable) dataTableBase;
String stateId = subTable.getClientId(facesContext) + STATE;
@@ -229,7 +225,9 @@
writer.writeAttribute(HTML.ID_ATTRIBUTE, stateId, null);
writer.writeAttribute(HTML.NAME_ATTRIBUTE, stateId, null);
writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
- int state = subTable.isExpanded() ? 1 : 0;
+
+ int state = subTable.isExpanded() ? UISubTable.EXPAND_STATE : UISubTable.COLLAPSE_STATE;
+
writer.writeAttribute(HTML.VALUE_ATTRIBUTE, state, null);
writer.endElement(HTML.INPUT_ELEM);
@@ -273,7 +271,7 @@
jsFunction.addParameter(options);
writer.startElement(HTML.SCRIPT_ELEM, subTable);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.JAVASCRIPT_TYPE, null);
writer.writeText(jsFunction.toScript(), null);
writer.endElement(HTML.SCRIPT_ELEM);
}
@@ -361,7 +359,6 @@
@Override
public void encodeMetaComponent(FacesContext facesContext, UIComponent component, String metaComponentId)
throws IOException {
-
UISubTable subTable = (UISubTable)component;
setupTableStartElement(facesContext, subTable);
@@ -369,7 +366,7 @@
ResponseWriter writer = facesContext.getResponseWriter();
UIDataTableBase dataTableBase = findParent(subTable);
- String updateId = dataTableBase.getRelativeClientId(facesContext) + ":" + subTable.getId() +TB_ROW;
+ String updateId = dataTableBase.getRelativeClientId(facesContext) + ":" + subTable.getId() + TB_ROW;
partialStart(facesContext, updateId);
encodeTableRows(writer, facesContext, subTable, false);
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-06-24 14:10:07 UTC (rev 17667)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-06-24 14:18:53 UTC (rev 17668)
@@ -47,14 +47,14 @@
private static final String DISPLAY_NONE = "display: none;";
- private static final String EXPAND_STATE = "expand";
-
- private static final String COLLAPSE_STATE = "collapse";
-
private static final String UP_ICON_URL = "up_icon.gif";
private static final String DOWN_ICON_URL = "down_icon.gif";
+
+ private static final String EXPAND_STATE = "expand";
+ private static final String COLLAPSE_STATE = "collapse";
+
@Override
protected void doDecode(FacesContext context, UIComponent component) {
context.getPartialViewContext().getRenderIds().add(component.getClientId(context));
@@ -65,19 +65,17 @@
UISubTable subTable = findComponent(context, toggleControl);
if (subTable != null) {
- ResponseWriter writer = context.getResponseWriter();
-
- String toggleId = toggleControl.getClientId(context);
- Map<String, Object> options = encodeOptions(context, toggleControl, subTable);
String switchType = subTable.getExpandMode();
-
boolean expanded = subTable.isExpanded();
-
+
+ ResponseWriter writer = context.getResponseWriter();
encodeControl(context, writer, toggleControl, switchType, expanded, false);
encodeControl(context, writer, toggleControl, switchType, !expanded, true);
JSFunction jsFunction = new JSFunction("new RichFaces.ui.SubTableToggler");
+ String toggleId = toggleControl.getClientId(context);
jsFunction.addParameter(toggleId);
+ Map<String, Object> options = encodeOptions(context, toggleControl, subTable);
jsFunction.addParameter(options);
writer.startElement(HTML.SCRIPT_ELEM, subTable);
@@ -108,9 +106,9 @@
if (controlFacet != null && controlFacet.isRendered()) {
if (!visible) {
- String facetStyle = (String) controlFacet.getAttributes().get("style");
- facetStyle = facetStyle != null ? facetStyle + "; display: none" : "; display: none";
- controlFacet.getAttributes().put("style", facetStyle);
+ String facetStyle = (String) controlFacet.getAttributes().get(HTML.STYLE_ATTRIBUTE);
+ facetStyle = facetStyle != null ? facetStyle + ";" + DISPLAY_NONE : DISPLAY_NONE;
+ controlFacet.getAttributes().put(HTML.STYLE_ATTRIBUTE, facetStyle);
}
controlFacet.encodeAll(context);
encodeDefault = false;
@@ -152,7 +150,6 @@
writer.writeAttribute(HTML.ALT_ATTRIBUTE, "", null);
writer.endElement(HTML.IMG_ELEMENT);
}
-
}
writer.endElement(HTML.SPAN_ELEM);
@@ -189,7 +186,6 @@
if (subTable instanceof UISubTable) {
return (UISubTable) subTable;
}
-
}
return null;
}
14 years, 6 months
JBoss Rich Faces SVN: r17667 - root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-06-24 10:10:07 -0400 (Thu, 24 Jun 2010)
New Revision: 17667
Modified:
root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
Log:
add attributes, refactor
Modified: root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2010-06-24 12:06:26 UTC (rev 17666)
+++ root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2010-06-24 14:10:07 UTC (rev 17667)
@@ -1143,54 +1143,88 @@
*
*/
public interface HTML {
- public static final String ACCEPT_ATTRIBUTE = "accept";
- public static final String ACCEPT_CHARSET_ATTRIBUTE = "accept-charset";
- public static final String ACCESSKEY_ATTRIBUTE = "accesskey";
- public static final String ACTION_ATTRIBUTE = "action";
- public static final String ALIGN_ATTRIBUTE = "align";
- public static final String ALT_ATTRIBUTE = "alt";
- public static final String AUTOCOMPLETE_ATTRIBUTE = "autocomplete";
+ // elements
public static final String A_ELEMENT = "a";
- public static final String BGCOLOR_ATTRIBUTE = "bgcolor";
public static final String BODY_ELEMENT = "body";
- public static final String BORDER_ATTRIBUTE = "border";
-
- // elements
+ public static final String IMG_ELEMENT = "img";
+ public static final String INPUT_ELEM = "input";
+ public static final String INPUT_TYPE_HIDDEN = "hidden";
public static final String BUTTON = "button";
public static final String CAPTION_ELEMENT = "caption";
- public static final String CELLPADDING_ATTRIBUTE = "cellpadding";
- public static final String CELLSPACING_ATTRIBUTE = "cellspacing";
public static final String CHARSET_ATTR = "charset";
- public static final String CLASS_ATTRIBUTE = "class";
- public static final String COLS_ATTRIBUTE = "cols";
public static final String COORDS_ATTR = "coords";
- public static final String DIR_ATTRIBUTE = "dir";
+ public static final String COLGROUP_ELEMENT = "colgroup";
+ public static final String COL_ELEMENT = "col";
public static final String DISABLED_ATTR = "disabled";
public static final String DIV_ELEM = "div";
public static final String DL_ELEMENT = "dl";
public static final String DT_ELEMENT = "dt";
- public static final String ENCTYPE_ATTRIBUTE = "enctype";
public static final String FORM_ELEMENT = "form";
- public static final String FRAME_ATTRIBUTE = "frame";
public static final String HEAD_ELEMENT = "head";
public static final String HEIGHT_ATTRIBUTE = "height";
public static final String HREFLANG_ATTR = "hreflang";
public static final String HREF_ATTR = "href";
public static final String HTML_ELEMENT = "html";
+ public static final String LINK_ELEMENT = "link";
+ public static final String SCRIPT_ELEM = "script";
+ public static final String SPAN_ELEM = "span";
+ public static final String TFOOT_ELEMENT = "tfoot";
+ public static final String THEAD_ELEMENT = "thead";
+ public static final String TABLE_ELEMENT = "table";
+ public static final String TBODY_ELEMENT = "tbody";
+ public static final String TD_ELEM = "td";
+ public static final String TR_ELEMENT = "tr";
+ public static final String TH_ELEM = "th";
+ public static final String TITLE_ELEM = "title";
// attributes
+ public static final String FRAME_ATTRIBUTE = "frame";
+ public static final String BORDER_ATTRIBUTE = "border";
+ public static final String BGCOLOR_ATTRIBUTE = "bgcolor";
+ public static final String ACCEPT_ATTRIBUTE = "accept";
+ public static final String ACCEPT_CHARSET_ATTRIBUTE = "accept-charset";
+ public static final String ACCESSKEY_ATTRIBUTE = "accesskey";
+ public static final String ACTION_ATTRIBUTE = "action";
+ public static final String ALIGN_ATTRIBUTE = "align";
+ public static final String ALT_ATTRIBUTE = "alt";
+ public static final String AUTOCOMPLETE_ATTRIBUTE = "autocomplete";
+ public static final String CLASS_ATTRIBUTE = "class";
+ public static final String COLS_ATTRIBUTE = "cols";
+ public static final String COLSPAN_ATTRIBUTE = "colspan";
+ public static final String CELLPADDING_ATTRIBUTE = "cellpadding";
+ public static final String CELLSPACING_ATTRIBUTE = "cellspacing";
+ public static final String DIR_ATTRIBUTE = "dir";
+ public static final String ENCTYPE_ATTRIBUTE = "enctype";
+
public static final String ID_ATTRIBUTE = "id";
- public static final String IMG_ELEMENT = "img";
- public static final String INPUT_ELEM = "input";
- public static final Object INPUT_TYPE_HIDDEN = "hidden";
public static final String LANG_ATTRIBUTE = "lang";
- public static final String LINK_ELEMENT = "link";
public static final String LONGDESC_ATTRIBUTE = "longdesc";
public static final String MAXLENGTH_ATTRIBUTE = "maxlength";
public static final String MEDIA_ATTRIBUTE = "media";
public static final String METHOD_ATTRIBUTE = "method";
public static final String NAME_ATTRIBUTE = "name";
public static final String NOWRAP_ATTRIBUTE = "nowrap";
+ public static final String ROWS_ATTRIBUTE = "rows";
+ public static final String RULES_ATTRIBUTE = "rules";
+ public static final String ROWSPAN_ATTRIBUTE = "rowspan";
+ public static final String READONLY_ATTRIBUTE = "readonly";
+ public static final String SIZE_ATTRIBUTE = "size";
+ public static final String SRC_ATTRIBUTE = "src";
+ public static final String STYLE_ATTRIBUTE = "style";
+ public static final String SUMMARY_ATTRIBUTE = "summary";
+ public static final String SCOPE_ATTRIBUTE = "scope";
+ public static final String TABINDEX_ATTRIBUTE = "tabindex";
+ public static final String TITLE_ATTRIBUTE = "title";
+ public static final String TARGET_ATTRIBUTE = "target";
+ public static final String TYPE_ATTR = "type";
+
+ public static final String USEMAP_ATTRIBUTE = "usemap";
+
+ public static final String VALIGN_ATTRIBUTE = "valign";
+ public static final String VALUE_ATTRIBUTE = "value";
+ public static final String WIDTH_ATTRIBUTE = "width";
+
+
public static final String ONBLUR_ATTRIBUTE = "onblur";
public static final String ONCHANGE_ATTRIBUTE = "onchange";
public static final String ONCLICK_ATTRIBUTE = "onclick";
@@ -1209,7 +1243,14 @@
public static final String ONSELECT_ATTRIBUTE = "onselect";
public static final String ONSUBMIT_ATTRIBUTE = "onsubmit";
public static final String ONUNLOAD_ATTRIBUTE = "onunload";
+
+ public static final String REL_ATTR = "rel";
+ public static final String REV_ATTR = "rev";
+ public static final String SHAPE_ATTR = "shape";
+ public static final String STYLE_CLASS_ATTR = "styleClass";
+
+
// public static final String ONRESET_ATTRIBUTE = "onreset";
// attributes sets.
public static final String[] PASS_THRU = {
@@ -1244,37 +1285,9 @@
public static final String[] PASS_THRU_URI = {
"usemap", "background", "codebase", "cite", "data", "classid", "href", "longdesc", "profile", "src"
};
- public static final String READONLY_ATTRIBUTE = "readonly";
- public static final String REL_ATTR = "rel";
- public static final String REV_ATTR = "rev";
- public static final String ROWS_ATTRIBUTE = "rows";
- public static final String RULES_ATTRIBUTE = "rules";
- public static final String SCRIPT_ELEM = "script";
- public static final String SHAPE_ATTR = "shape";
- public static final String SIZE_ATTRIBUTE = "size";
- public static final String SPAN_ELEM = "span";
- public static final String SRC_ATTRIBUTE = "src";
- public static final String STYLE_ATTRIBUTE = "style";
- public static final String STYLE_CLASS_ATTR = "styleClass";
- public static final String SUMMARY_ATTRIBUTE = "summary";
- public static final String TABINDEX_ATTRIBUTE = "tabindex";
- public static final String TABLE_ELEMENT = "table";
- public static final String TARGET_ATTRIBUTE = "target";
- public static final String TBODY_ELEMENT = "tbody";
- public static final String TD_ELEM = "td";
+
+
public static final String TEXT_JAVASCRIPT_TYPE = "text/javascript";
- public static final String TFOOT_ELEMENT = "tfoot";
- public static final String THEAD_ELEMENT = "thead";
- public static final String TH_ELEM = "th";
- public static final String TITLE_ATTRIBUTE = "title";
- public static final String TITLE_ELEM = "title";
- public static final String TR_ELEMENT = "tr";
- public static final String TYPE_ATTR = "type";
- public static final String USEMAP_ATTRIBUTE = "usemap";
- public static final String VALIGN_ATTRIBUTE = "valign";
- public static final String VALUE_ATTRIBUTE = "value";
- public static final String WIDTH_ATTRIBUTE = "width";
-
public static final String REL_STYLESHEET = "stylesheet";
public static final String CSS_TYPE = "text/css";
public static final String JAVASCRIPT_TYPE = "text/javascript";
14 years, 6 months
JBoss Rich Faces SVN: r17666 - in root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces: renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-06-24 08:06:26 -0400 (Thu, 24 Jun 2010)
New Revision: 17666
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
Log:
change getHiddenContainerStrategy method signature, refactoring
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-06-24 12:05:05 UTC (rev 17665)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-06-24 12:06:26 UTC (rev 17666)
@@ -125,7 +125,7 @@
}
return result;
}
-
+
public boolean getRendersChildren() {
return true;
}
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-06-24 12:05:05 UTC (rev 17665)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-06-24 12:06:26 UTC (rev 17666)
@@ -34,6 +34,7 @@
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.Row;
import org.richfaces.component.UIDataTableBase;
+import org.richfaces.component.util.HtmlUtil;
/**
* @author Anton Belevich
@@ -45,20 +46,9 @@
public static final String HIDDEN_CONTAINER_ID =":sc";
- public abstract EncodeStrategy getHiddenContainerStrategy();
+ public abstract EncodeStrategy getHiddenContainerStrategy(UIDataTableBase dataTableBase);
- /**
- * Returns true if specified attribute (when present on the column) should generate header even if it is not
- * specified on the table
- *
- * @param table
- * - rendered UIDataTable
- * @param attributeName
- * - attribute name
- * @return true if specified attribute should generate header on the table
- */
- // TODO nick - rename this method
- public boolean isHeaderFactoryColumnAttributePresent(UIDataTableBase table, String attributeName) {
+ public boolean isColumnAttributeSet(UIDataTableBase table, String attributeName) {
Iterator<UIComponent> columns = table.columns();
boolean result = false;
while (columns.hasNext() && !result) {
@@ -111,11 +101,10 @@
super.encodeRows(facesContext, rowHolder);
}
- //TODO: anton -> refactor this
protected boolean isEncodeHeaders(UIDataTableBase table) {
- return table.isColumnFacetPresent("header") || isHeaderFactoryColumnAttributePresent(table, "sortBy")
- || isHeaderFactoryColumnAttributePresent(table, "comparator")
- || isHeaderFactoryColumnAttributePresent(table, "filterBy");
+ return table.isColumnFacetPresent("header") || isColumnAttributeSet(table, "sortBy")
+ || isColumnAttributeSet(table, "comparator")
+ || isColumnAttributeSet(table, "filterBy");
}
protected int getColumnsCount(UIDataTableBase table) {
@@ -200,32 +189,15 @@
if(encodePartialUpdate) {
String id = dataTableBase.getClientId(facesContext) + HIDDEN_CONTAINER_ID;
- facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(id);
+ partialStart(facesContext, id);
}
encodeHiddens(writer, facesContext, dataTableBase, new Object[]{encodeParentTBody});
if(encodePartialUpdate) {
- facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
+ partialEnd(facesContext);
}
- /*
- * DataTable
- * <tbody id="row">
- * </tbody>
- * <tbody id="hidden">
- * </tbody>
- *
- * SubTable
- * <tbody>
- * <tr id="row">
- * </tr
- * <tr id="hidden">
- * </tr
- * </tbody>
- *
- */
-
dataTableBase.setRowKey(facesContext, key);
dataTableBase.restoreOrigValue(facesContext);
}
@@ -244,13 +216,15 @@
}
protected void encodeHiddens(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase, Object [] params) throws IOException {
- EncodeStrategy encodeStrategy = getHiddenContainerStrategy();
- encodeStrategy.begin(writer, facesContext, dataTableBase, params);
-
- encodeClientScript(writer, facesContext, dataTableBase);
- encodeHiddenInput(writer, facesContext, dataTableBase);
-
- encodeStrategy.end(writer, facesContext, dataTableBase, params);
+ EncodeStrategy encodeStrategy = getHiddenContainerStrategy(dataTableBase);
+ if(encodeStrategy != null) {
+ encodeStrategy.begin(writer, facesContext, dataTableBase, params);
+
+ encodeClientScript(writer, facesContext, dataTableBase);
+ encodeHiddenInput(writer, facesContext, dataTableBase);
+
+ encodeStrategy.end(writer, facesContext, dataTableBase, params);
+ }
}
public void encodeTableEnd(ResponseWriter writer) throws IOException {
@@ -276,7 +250,7 @@
writer.endElement(HTML.TBODY_ELEMENT);
}
- public void encodeFooterFacet(ResponseWriter writer, FacesContext context, UIDataTableBase dataTable,
+ public void encodeFooterFacet(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTable,
boolean encodePartialUpdate) throws IOException {
UIComponent footer = dataTable.getFooter();
@@ -287,11 +261,11 @@
boolean encodeTfoot = containsThead();
if (encodeTfoot) {
- String footerClientId = dataTable.getClientId(context) + ":tf";
+ String footerClientId = dataTable.getClientId(facesContext) + ":tf";
if (encodePartialUpdate) {
partialUpdateEncoded = true;
- context.getPartialViewContext().getPartialResponseWriter().startUpdate(footerClientId);
+ partialStart(facesContext, footerClientId);
}
writer.startElement(HTML.TFOOT_ELEMENT, dataTable);
@@ -300,7 +274,7 @@
}
int columns = getColumnsCount(dataTable);
- String id = dataTable.getClientId(context);
+ String id = dataTable.getClientId(facesContext);
boolean encodePartialUpdateForChildren = (encodePartialUpdate && !partialUpdateEncoded);
@@ -315,23 +289,23 @@
cellClass = mergeStyleClasses("columnFooterCellClass", cellClass, dataTable);
firstClass = mergeStyleClasses("firstColumnFooterClass", firstClass, dataTable);
- saveRowStyles(context,id, firstClass, rowClass, cellClass);
+ saveRowStyles(facesContext,id, firstClass, rowClass, cellClass);
String targetId = id + ":cf";
if (encodePartialUpdateForChildren) {
- context.getPartialViewContext().getPartialResponseWriter().startUpdate(targetId);
+ partialStart(facesContext, targetId);
}
writer.startElement(HTML.TR_ELEMENT, dataTable);
writer.writeAttribute(HTML.ID_ATTRIBUTE, targetId, null);
- encodeStyleClass(writer, context, dataTable, null, rowClass);
- encodeColumnFacet(context, writer, dataTable, "footer",columns, cellClass);
+ encodeStyleClass(writer, facesContext, dataTable, null, rowClass);
+ encodeColumnFacet(facesContext, writer, dataTable, "footer",columns, cellClass);
writer.endElement(HTML.TR_ELEMENT);
if (encodePartialUpdateForChildren) {
- context.getPartialViewContext().getPartialResponseWriter().endUpdate();
+ partialEnd(facesContext);
}
}
@@ -345,8 +319,8 @@
cellClass = mergeStyleClasses("footerCellClass", cellClass, dataTable);
firstClass = mergeStyleClasses("footerFirstClass", firstClass, dataTable);
// TODO nick - rename method "encodeTableHeaderFacet"
- saveRowStyles(context, id, firstClass, rowClass, cellClass);
- encodeTableFacet(context, writer, id, columns, footer, "footer", rowClass, cellClass,
+ saveRowStyles(facesContext, id, firstClass, rowClass, cellClass);
+ encodeTableFacet(facesContext, writer, id, columns, footer, "footer", rowClass, cellClass,
encodePartialUpdateForChildren);
}
@@ -354,30 +328,25 @@
writer.endElement(HTML.TFOOT_ELEMENT);
if (partialUpdateEncoded) {
- context.getPartialViewContext().getPartialResponseWriter().endUpdate();
+ partialEnd(facesContext);
}
}
}
}
- //TODO nick - use org.richfaces.component.util.HtmlUtil.concatClasses(String...)
protected String mergeStyleClasses(String classAttribibute, String skinClass, UIComponent component) {
- String styleClass = null;
String resultClass = skinClass;
-
+
+ String styleClass = null;
if(classAttribibute != null && component != null ) {
styleClass = (String)component.getAttributes().get(classAttribibute);
}
-
- if(styleClass != null && styleClass.trim().length() > 0) {
- resultClass = resultClass + " " + styleClass;
- }
-
- return resultClass;
+
+ return HtmlUtil.concatClasses(resultClass, styleClass);
}
- public void encodeHeaderFacet(ResponseWriter writer, FacesContext context, UIDataTableBase dataTable,
+ public void encodeHeaderFacet(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTable,
boolean encodePartialUpdate) throws IOException {
UIComponent header = dataTable.getHeader();
@@ -389,11 +358,11 @@
boolean partialUpdateEncoded = false;
if (encodeThead) {
- String headerClientId = dataTable.getClientId(context) + ":th";
+ String headerClientId = dataTable.getClientId(facesContext) + ":th";
if (encodePartialUpdate) {
partialUpdateEncoded = true;
- context.getPartialViewContext().getPartialResponseWriter().startUpdate(headerClientId);
+ partialStart(facesContext, headerClientId);
}
writer.startElement(HTML.THEAD_ELEMENT, dataTable);
@@ -402,7 +371,7 @@
}
int columns = getColumnsCount(dataTable);
- String id = dataTable.getClientId(context);
+ String id = dataTable.getClientId(facesContext);
boolean encodePartialUpdateForChildren = (encodePartialUpdate && !partialUpdateEncoded);
@@ -415,9 +384,9 @@
rowClass = mergeStyleClasses("headerClass", rowClass, dataTable);
cellClass = mergeStyleClasses("headerCellClass", cellClass, dataTable);
firstClass = mergeStyleClasses("headerFirstClass", firstClass, dataTable);
- saveRowStyles(context, id, firstClass, rowClass, cellClass);
+ saveRowStyles(facesContext, id, firstClass, rowClass, cellClass);
- encodeTableFacet(context, writer, id, columns, header, "header", rowClass, cellClass,
+ encodeTableFacet(facesContext, writer, id, columns, header, "header", rowClass, cellClass,
encodePartialUpdateForChildren);
}
@@ -429,24 +398,24 @@
rowClass = mergeStyleClasses("columnHeaderClass", rowClass, dataTable);
cellClass = mergeStyleClasses("columnHeaderCellClass", cellClass, dataTable);
firstClass = mergeStyleClasses("columnHeaderFirstClass", firstClass, dataTable);
- saveRowStyles(context, id, firstClass, rowClass, cellClass);
+ saveRowStyles(facesContext, id, firstClass, rowClass, cellClass);
String targetId = id + ":ch";
if (encodePartialUpdateForChildren) {
- context.getPartialViewContext().getPartialResponseWriter().startUpdate(targetId);
+ partialStart(facesContext, targetId);
}
writer.startElement(HTML.TR_ELEMENT, dataTable);
writer.writeAttribute(HTML.ID_ATTRIBUTE, targetId, null);
- encodeStyleClass(writer, context, dataTable, null, rowClass);
+ encodeStyleClass(writer, facesContext, dataTable, null, rowClass);
- encodeColumnFacet(context, writer, dataTable, "header", columns, cellClass);
+ encodeColumnFacet(facesContext, writer, dataTable, "header", columns, cellClass);
writer.endElement(HTML.TR_ELEMENT);
if (encodePartialUpdateForChildren) {
- context.getPartialViewContext().getPartialResponseWriter().endUpdate();
+ partialEnd(facesContext);
}
}
@@ -454,7 +423,7 @@
writer.endElement(HTML.THEAD_ELEMENT);
if (partialUpdateEncoded) {
- context.getPartialViewContext().getPartialResponseWriter().endUpdate();
+ partialEnd(facesContext);
}
}
}
@@ -509,11 +478,11 @@
}
}
- protected void encodeTableFacet(FacesContext context, ResponseWriter writer, String id, int columns,
+ protected void encodeTableFacet(FacesContext facesContext, ResponseWriter writer, String id, int columns,
UIComponent footer, String facetName, String rowClass, String cellClass, boolean encodePartialUpdate) throws IOException {
boolean isColumnGroup = (footer instanceof Row);
- String element = getCellElement(context, id);
+ String element = getCellElement(facesContext, id);
boolean partialUpdateEncoded = false;
@@ -522,17 +491,17 @@
if (encodePartialUpdate) {
partialUpdateEncoded = true;
- context.getPartialViewContext().getPartialResponseWriter().startUpdate(targetId);
+ partialStart(facesContext, targetId);
}
writer.startElement(HTML.TR_ELEMENT, footer);
writer.writeAttribute(HTML.ID_ATTRIBUTE, targetId, null);
- encodeStyleClass(writer, context, footer, null, rowClass);
+ encodeStyleClass(writer, facesContext, footer, null, rowClass);
writer.startElement(element, footer);
- encodeStyleClass(writer, context, footer, null, cellClass);
+ encodeStyleClass(writer, facesContext, footer, null, cellClass);
if (columns > 0) {
writer.writeAttribute("colspan", String.valueOf(columns), null);
@@ -542,13 +511,13 @@
}
if (encodePartialUpdate && !partialUpdateEncoded) {
- context.getPartialViewContext().getPartialResponseWriter().startUpdate(footer.getClientId(context));
+ partialStart(facesContext, footer.getClientId(facesContext));
}
- footer.encodeAll(context);
+ footer.encodeAll(facesContext);
if (encodePartialUpdate && !partialUpdateEncoded) {
- context.getPartialViewContext().getPartialResponseWriter().endUpdate();
+ partialEnd(facesContext);
}
if (!isColumnGroup){
@@ -556,7 +525,7 @@
writer.endElement(HTML.TR_ELEMENT);
if (partialUpdateEncoded) {
- context.getPartialViewContext().getPartialResponseWriter().endUpdate();
+ partialEnd(facesContext);
}
}
}
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-06-24 12:05:05 UTC (rev 17665)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-06-24 12:06:26 UTC (rev 17666)
@@ -121,7 +121,7 @@
public void encodeBeforeRows(ResponseWriter writer, FacesContext facesContext,UIDataTableBase dataTableBase, boolean encodeParentTBody, boolean partialUpdate) throws IOException {
if(encodeParentTBody) {
if(partialUpdate) {
- facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(dataTableBase.getClientId(facesContext) +":tb");
+ partialStart(facesContext, dataTableBase.getClientId(facesContext) +":tb");
}
encodeTableBodyStart(writer, facesContext, dataTableBase);
}
@@ -132,7 +132,7 @@
if(encodeParentTBody) {
encodeTableBodyEnd(writer);
if(partialUpdate) {
- facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
+ partialEnd(facesContext);
}
}
}
@@ -402,7 +402,7 @@
put(context, component.getClientId(context), CELL_ELEMENT_KEY, HTML.TH_ELEM);
}
- public EncodeStrategy getHiddenContainerStrategy() {
+ public EncodeStrategy getHiddenContainerStrategy(UIDataTableBase dataTableBase) {
return new DataTableHiddenEncodeStrategy();
}
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-24 12:05:05 UTC (rev 17665)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-24 12:06:26 UTC (rev 17666)
@@ -169,29 +169,28 @@
writer.endElement(HTML.TR_ELEMENT);
}
- public void encodeRow(ResponseWriter writer, FacesContext context, RowHolderBase holder) throws IOException {
+ public void encodeRow(ResponseWriter writer, FacesContext facesContext, RowHolderBase holder) throws IOException {
RowHolder rowHolder = (RowHolder)holder;
Row row = rowHolder.getRow();
rowHolder.setRowStart(true);
Iterator<UIComponent> components = row.columns();
if (rowHolder.isUpdatePartial()) {
- context.getPartialViewContext().getPartialResponseWriter().startUpdate(
- ((UISubTable) row).getRelativeClientId(context) + ":b");
+ partialStart(facesContext,((UISubTable) row).getRelativeClientId(facesContext) + ":b");
}
while (components.hasNext()) {
UIComponent component = components.next();
if(component instanceof UIColumn) {
- encodeColumn(context, writer, (UIColumn)component , rowHolder);
+ encodeColumn(facesContext, writer, (UIColumn)component , rowHolder);
} else if (component instanceof UISubTable) {
if(component.isRendered()) {
encodeRowEnd(writer);
}
- component.encodeAll(context);
+ component.encodeAll(facesContext);
rowHolder.setRowStart(true);
}
}
@@ -199,7 +198,7 @@
encodeRowEnd(writer);
if (rowHolder.isUpdatePartial()) {
- context.getPartialViewContext().getPartialResponseWriter().endUpdate();
+ partialEnd(facesContext);
}
}
@@ -219,25 +218,28 @@
return false;
}
- public void encodeHiddenInput(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase) throws IOException {
- UISubTable subTable = (UISubTable)dataTableBase;
+ public void encodeHiddenInput(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase)
+ throws IOException {
+ UISubTable subTable = (UISubTable) dataTableBase;
+
String stateId = subTable.getClientId(facesContext) + STATE;
writer.startElement(HTML.INPUT_ELEM, subTable);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, stateId , null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, stateId , null);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, stateId, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, stateId, null);
writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
int state = subTable.isExpanded() ? 1 : 0;
writer.writeAttribute(HTML.VALUE_ATTRIBUTE, state, null);
writer.endElement(HTML.INPUT_ELEM);
-
+
String optionsId = subTable.getClientId(facesContext) + OPTIONS;
writer.startElement(HTML.INPUT_ELEM, subTable);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, optionsId , null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, optionsId , null);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, optionsId, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, optionsId, null);
writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
writer.endElement(HTML.INPUT_ELEM);
+
}
public boolean containsThead() {
@@ -250,26 +252,28 @@
}
- public void encodeClientScript(ResponseWriter writer, FacesContext facesContext, UIDataTableBase component) throws IOException {
- UISubTable subTable = (UISubTable)component;
+ public void encodeClientScript(ResponseWriter writer, FacesContext facesContext, UIDataTableBase component)
+ throws IOException {
+ UISubTable subTable = (UISubTable) component;
+
String id = subTable.getClientId(facesContext);
UIComponent nestingForm = getUtils().getNestingForm(facesContext, subTable);
String formId = nestingForm != null ? nestingForm.getClientId(facesContext) : "";
-
+
Map<String, Object> options = new HashMap<String, Object>();
- options.put("stateInput", subTable.getClientId(facesContext) +STATE);
- options.put("optionsInput", subTable.getClientId(facesContext) +OPTIONS);
+ options.put("stateInput", subTable.getClientId(facesContext) + STATE);
+ options.put("optionsInput", subTable.getClientId(facesContext) + OPTIONS);
options.put("expandMode", subTable.getExpandMode());
options.put("eventOptions", AjaxRendererUtils.buildEventOptions(facesContext, subTable));
-
+
JSFunction jsFunction = new JSFunction("new RichFaces.ui.SubTable");
jsFunction.addParameter(id);
jsFunction.addParameter(formId);
jsFunction.addParameter(options);
writer.startElement(HTML.SCRIPT_ELEM, subTable);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript",null);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
writer.writeText(jsFunction.toScript(), null);
writer.endElement(HTML.SCRIPT_ELEM);
}
@@ -366,15 +370,15 @@
UIDataTableBase dataTableBase = findParent(subTable);
String updateId = dataTableBase.getRelativeClientId(facesContext) + ":" + subTable.getId() +TB_ROW;
-
- facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(updateId);
+
+ partialStart(facesContext, updateId);
encodeTableRows(writer, facesContext, subTable, false);
- facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
+ partialEnd(facesContext);
}
}
@Override
- public EncodeStrategy getHiddenContainerStrategy() {
+ public EncodeStrategy getHiddenContainerStrategy(UIDataTableBase dataTableBase) {
return new SubTableHiddenEncodeStrategy();
}
14 years, 6 months
JBoss Rich Faces SVN: r17665 - root/ui/iteration/trunk/tables/api/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-06-24 08:05:05 -0400 (Thu, 24 Jun 2010)
New Revision: 17665
Modified:
root/ui/iteration/trunk/tables/api/src/main/java/org/richfaces/component/SortOrder.java
Log:
add license header
Modified: root/ui/iteration/trunk/tables/api/src/main/java/org/richfaces/component/SortOrder.java
===================================================================
--- root/ui/iteration/trunk/tables/api/src/main/java/org/richfaces/component/SortOrder.java 2010-06-24 05:18:38 UTC (rev 17664)
+++ root/ui/iteration/trunk/tables/api/src/main/java/org/richfaces/component/SortOrder.java 2010-06-24 12:05:05 UTC (rev 17665)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.component;
14 years, 6 months
JBoss Rich Faces SVN: r17664 - in root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler: builder/model and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-06-24 01:18:38 -0400 (Thu, 24 Jun 2010)
New Revision: 17664
Modified:
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java
Log:
refactor template generator
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-06-23 17:11:45 UTC (rev 17663)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererClassVisitor.java 2010-06-24 05:18:38 UTC (rev 17664)
@@ -23,17 +23,16 @@
package org.richfaces.cdk.templatecompiler;
-import static org.richfaces.cdk.templatecompiler.QNameComparator.*;
-import static org.richfaces.cdk.util.JavaUtils.*;
+import static org.richfaces.cdk.templatecompiler.QNameComparator.QNAME_COMPARATOR;
+import static org.richfaces.cdk.util.JavaUtils.getEscapedString;
+import static org.richfaces.cdk.util.JavaUtils.getEscapedStringsArray;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -57,6 +56,8 @@
import org.richfaces.cdk.templatecompiler.builder.model.JavaMethod;
import org.richfaces.cdk.templatecompiler.builder.model.JavaModifier;
import org.richfaces.cdk.templatecompiler.builder.model.MethodBody;
+import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatement;
+import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatementImpl;
import org.richfaces.cdk.templatecompiler.builder.model.MethodBodyStatementsContainer;
import org.richfaces.cdk.templatecompiler.el.ELParserUtils;
import org.richfaces.cdk.templatecompiler.el.ELVisitor;
@@ -82,12 +83,11 @@
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @author asmirnov(a)exadel.com
*/
public class RendererClassVisitor implements TemplateVisitor {
@@ -130,8 +130,8 @@
private static final Set<String> DEFAULT_NAMESPACES = ImmutableSet.of(Template.XHTML_EL_NAMESPACE,
Template.XHTML_NAMESPACE);
- private static final EnumMap<HelperMethod, HelperMethodBodyStatement> HELPER_METHOD_BODIES =
- new EnumMap<HelperMethod, HelperMethodBodyStatement>(HelperMethod.class);
+ private static final EnumMap<HelperMethod, HelperMethodBodyStatement> HELPER_METHOD_BODIES = new EnumMap<HelperMethod, HelperMethodBodyStatement>(
+ HelperMethod.class);
static {
HELPER_METHOD_BODIES.put(HelperMethod.EMPTINESS_CHECK, new EmptinessCheckingMethodBodyStatement());
@@ -144,13 +144,10 @@
private MethodBodyStatementsContainer currentStatement;
- private final Schema attributesSchema ;
+ private final Schema attributesSchema;
private JavaClass generatedClass;
private CompositeInterface compositeInterface;
- private final LinkedList<MethodBodyStatementsContainer> statements = Lists.newLinkedList();
-
- private Map<String, Type> localsTypesMap;
private final ClassLoader classLoader;
private Set<HelperMethod> addedHelperMethods = EnumSet.noneOf(HelperMethod.class);
@@ -158,11 +155,11 @@
private Type lastCompiledExpressionType;
private int passThroughCounter;
private final Collection<PropertyBase> attributes;
-
+
private final VisitorFactoryImpl visitorFactoryImpl;
public RendererClassVisitor(CompositeInterface compositeInterface, Collection<PropertyBase> attributes,
- VisitorFactoryImpl factory) {
+ VisitorFactoryImpl factory) {
this.compositeInterface = compositeInterface;
this.attributes = attributes;
this.visitorFactoryImpl = factory;
@@ -202,8 +199,8 @@
arguments[i] = new Argument(argumentNames[i], argumentTypes[i]);
}
- JavaMethod helperJavaMethod = new JavaMethod(helperMethod.getName(),
- helperMethod.getReturnType(), arguments);
+ JavaMethod helperJavaMethod = new JavaMethod(helperMethod.getName(), helperMethod.getReturnType(),
+ arguments);
helperJavaMethod.addModifier(JavaModifier.PRIVATE);
helperJavaMethod.addModifier(JavaModifier.STATIC);
@@ -334,8 +331,8 @@
generatedClass.addImport(Collections.class);
// TODO - get rid of FQNs for classes via imports
- passThroughField.setGenericArguments(new JavaClass[]{new JavaClass(String.class),
- new JavaClass("org.richfaces.renderkit.ComponentAttribute")});
+ passThroughField.setGenericArguments(new JavaClass[] { new JavaClass(String.class),
+ new JavaClass("org.richfaces.renderkit.ComponentAttribute") });
StringBuilder fieldValue = new StringBuilder("Collections.unmodifiableMap(ComponentAttribute.createMap(");
boolean isFirstArgument = true;
@@ -367,19 +364,18 @@
private void createMethodContext() {
this.currentStatement = new MethodBody();
- this.localsTypesMap = new HashMap<String, Type>();
- localsTypesMap.put(FACES_CONTEXT_VARIABLE, TypesFactory.getType(FacesContext.class));
- localsTypesMap.put(RESPONSE_WRITER_VARIABLE, TypesFactory.getType(ResponseWriter.class));
- localsTypesMap.put(CLIENT_ID_VARIABLE, TypesFactory.getType(String.class));
+ currentStatement.setVariable(FACES_CONTEXT_VARIABLE, TypesFactory.getType(FacesContext.class));
+ currentStatement.setVariable(RESPONSE_WRITER_VARIABLE, TypesFactory.getType(ResponseWriter.class));
+ currentStatement.setVariable(CLIENT_ID_VARIABLE, TypesFactory.getType(String.class));
// TODO: try load component class
- localsTypesMap.put(COMPONENT_VARIABLE, TypesFactory.getType(UIComponent.class));
+ currentStatement.setVariable(COMPONENT_VARIABLE, TypesFactory.getType(UIComponent.class));
Type generatedClassType = createTypeOfKnownClass(generatedClass, Renderer.class);
- localsTypesMap.put(THIS_VARIABLE, generatedClassType);
+ currentStatement.setVariable(THIS_VARIABLE, generatedClassType);
Type generatedClassSuperType = createTypeOfKnownClass(generatedClass.getSuperClass(), Renderer.class);
- localsTypesMap.put(SUPER_VARIABLE, generatedClassSuperType);
+ currentStatement.setVariable(SUPER_VARIABLE, generatedClassSuperType);
}
private void flushToEncodeMethod(String encodeMethodName) {
@@ -397,15 +393,10 @@
methodBody.addStatement(0, new EncodeMethodPrefaceStatement());
generatedClass.addMethod(javaMethod);
-
- Collection<Type> variableTypes = localsTypesMap.values();
- for (Type variableType : variableTypes) {
-
- Collection<Class<?>> importsList = variableType.getImportsList();
- if (importsList != null) {
- for (Class<?> importedClass : importsList) {
- generatedClass.addImport(importedClass);
- }
+ Collection<Class<?>> importsList = currentStatement.getImports();
+ if (importsList != null) {
+ for (Class<?> importedClass : importsList) {
+ generatedClass.addImport(importedClass);
}
}
}
@@ -414,8 +405,8 @@
}
private void defineObject(Type type, String name, String initializationExpression) {
- currentStatement.addStatement(new DefineObjectStatement(type, name, initializationExpression));
- localsTypesMap.put(name, type);
+ addStatement(new DefineObjectStatement(type, name, initializationExpression));
+ currentStatement.setVariable(name, type);
}
private void createRendersChildrenMethod() {
@@ -424,31 +415,35 @@
JavaMethod rendersChildrenMethod = new JavaMethod("getRendersChildren", Boolean.TYPE);
rendersChildrenMethod.addModifier(JavaModifier.PUBLIC);
rendersChildrenMethod.addAnnotation(Override.class);
-
+
MethodBody methodBody = new MethodBody();
rendersChildrenMethod.setMethodBody(methodBody);
generatedClass.addMethod(rendersChildrenMethod);
-
- methodBody.addStatement(
- new ConstantReturnMethodBodyStatement(Boolean.toString(compositeInterface.getRendersChildren())));
+
+ methodBody.addStatement(new ConstantReturnMethodBodyStatement(Boolean.toString(compositeInterface
+ .getRendersChildren())));
}
}
-
+
protected void pushStatement(MethodBodyStatementsContainer container) {
- currentStatement.addStatement(container);
- statements.push(currentStatement);
+ addStatement(container);
currentStatement = container;
}
protected void popStatement() {
- currentStatement = statements.pop();
+ currentStatement = currentStatement.getParent();
}
+ protected void addStatement(MethodBodyStatement statement) {
+ // TODO - add imports, fields and helper methods required by statement.
+ addStatement(statement);
+ }
+
/**
* <p class="changed_added_4_0">
* </p>
- *
+ *
* @return the rendererClass
*/
public JavaClass getGeneratedClass() {
@@ -496,7 +491,7 @@
return;
}
- currentStatement.addStatement(new StartElementStatement(elementName.getLocalPart()));
+ addStatement(new StartElementStatement(elementName.getLocalPart()));
if (elementAttributes != null) {
Set<String> writtenAttributes = new HashSet<String>();
@@ -524,8 +519,8 @@
String attributeLocalName = attributeName.getLocalPart();
if (writtenAttributes.add(attributeLocalName)) {
addRendererUtilsImport();
- currentStatement.addStatement(new WriteAttributeStatement(attributeLocalName, compileEl(
- attributeValue.toString(), Object.class)));
+ addStatement(new WriteAttributeStatement(attributeLocalName, compileEl(attributeValue
+ .toString(), Object.class)));
}
}
}
@@ -550,7 +545,7 @@
if (!actualAttributesMap.isEmpty()) {
String passThroughFieldName = createPassThroughField(actualAttributesMap);
addRendererUtilsImport();
- currentStatement.addStatement(new WriteAttributesSetStatement(passThroughFieldName));
+ addStatement(new WriteAttributesSetStatement(passThroughFieldName));
}
}
}
@@ -567,7 +562,7 @@
@Override
public void endElement(AnyElement anyElement) throws CdkException {
QName elementName = anyElement.getName();
- currentStatement.addStatement(new EndElementStatement(elementName.getLocalPart()));
+ addStatement(new EndElementStatement(elementName.getLocalPart()));
}
/*
@@ -581,7 +576,7 @@
if (text != null) {
String trimmedText = text.trim();
if (!Strings.isEmpty(trimmedText)) {
- currentStatement.addStatement(new WriteTextStatement(compileEl(trimmedText, String.class)));
+ addStatement(new WriteTextStatement(compileEl(trimmedText, String.class)));
}
}
}
@@ -600,7 +595,7 @@
expression = cdkCallElement.getBodyValue();
}
- currentStatement.addStatement(expression + ";");
+ addStatement(new MethodBodyStatementImpl(expression + ";"));
}
/*
@@ -774,7 +769,7 @@
pushStatement(new ForEachStatement(itemsExpression, cdkForEachElement.getVar(), collectionElementClass
.getName()));
- localsTypesMap.put(cdkForEachElement.getVar(), lastCompiledExpressionType.getContainerType());
+ currentStatement.setVariable(cdkForEachElement.getVar(), lastCompiledExpressionType.getContainerType());
}
/*
@@ -786,7 +781,6 @@
@Override
public void endElement(CdkForEachElement cdkForEachElement) {
- localsTypesMap.remove(cdkForEachElement.getVar());
popStatement();
}
Modified: root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java
===================================================================
--- root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java 2010-06-23 17:11:45 UTC (rev 17663)
+++ root/cdk/branches/RF8755/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/builder/model/MethodBodyStatementsContainer.java 2010-06-24 05:18:38 UTC (rev 17664)
@@ -22,11 +22,11 @@
package org.richfaces.cdk.templatecompiler.builder.model;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.richfaces.cdk.templatecompiler.FreeMarkerRenderer;
-import org.richfaces.cdk.templatecompiler.el.ParsingException;
import org.richfaces.cdk.templatecompiler.el.Type;
import com.google.common.collect.Maps;
@@ -49,24 +49,22 @@
}
public void addStatement(MethodBodyStatement statement) {
- if (statement instanceof MethodBodyStatementsContainer) {
- MethodBodyStatementsContainer container = (MethodBodyStatementsContainer) statement;
- container.setParent(this);
- }
+ setParent(statement);
statements.add(statement);
}
- public void addStatement(int index, MethodBodyStatement statement) {
- statements.add(index, statement);
+ public void addStatement(int index,MethodBodyStatement statement) {
+ setParent(statement);
+ statements.add(index,statement);
}
- public void addStatement(String statementCode) {
- addStatement(new MethodBodyStatementImpl(statementCode));
+ private void setParent(MethodBodyStatement statement) {
+ if (statement instanceof MethodBodyStatementsContainer) {
+ MethodBodyStatementsContainer container = (MethodBodyStatementsContainer) statement;
+ container.setParent(this);
+ }
}
- public void addStatement(int index, String statementCode) {
- addStatement(index, new MethodBodyStatementImpl(statementCode));
- }
/**
* <p class="changed_added_4_0"></p>
@@ -103,7 +101,7 @@
}
@Override
- public Type getVariable(String name) throws ParsingException {
+ public Type getVariable(String name) {
Type type = localVariablesMap.get(name);
if(null == type && null != parent){
type = parent.getVariable(name);
@@ -112,7 +110,7 @@
}
@Override
- public boolean isDefined(String name) throws ParsingException {
+ public boolean isDefined(String name) {
boolean defined = localVariablesMap.containsKey(name);
if(!defined && null != parent){
defined = parent.isDefined(name);
@@ -121,9 +119,14 @@
}
@Override
- public Type setVariable(String name, Type type) throws ParsingException {
+ public Type setVariable(String name, Type type) {
Type variable = getVariable(name);
localVariablesMap.put(name, type);
return variable;
}
+
+ public Collection<Class<?>> getImports() {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
14 years, 6 months
JBoss Rich Faces SVN: r17663 - in root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces: renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-06-23 13:11:45 -0400 (Wed, 23 Jun 2010)
New Revision: 17663
Modified:
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTableToggleControl.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
Log:
RF-8718, RF-8714
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-06-23 16:27:39 UTC (rev 17662)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UIDataTableBase.java 2010-06-23 17:11:45 UTC (rev 17663)
@@ -325,5 +325,9 @@
}
super.queueEvent(event);
}
+
+ public static Set<String> getSupportedMetaComponents() {
+ return SUPPORTED_META_COMPONENTS;
+ }
}
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-06-23 16:27:39 UTC (rev 17662)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTable.java 2010-06-23 17:11:45 UTC (rev 17663)
@@ -22,22 +22,13 @@
package org.richfaces.component;
-import java.util.HashSet;
-import java.util.Set;
-
import javax.el.ELContext;
import javax.el.ValueExpression;
import javax.faces.application.ResourceDependency;
-import javax.faces.component.UIComponent;
-import javax.faces.component.visit.VisitCallback;
-import javax.faces.component.visit.VisitContext;
-import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
-import org.richfaces.context.ExtendedVisitContext;
-import org.richfaces.context.ExtendedVisitContextMode;
import org.richfaces.event.ToggleEvent;
import org.richfaces.event.ToggleListener;
@@ -50,18 +41,6 @@
public static final String MODE_SERVER = "server";
public static final String MODE_CLIENT = "client";
-
- public static final String PARENT_PARTIAL = "partial";
-
- public static final String TB_ID = ":c";
-
- public static final String SUBTABLE = "subtable";
-
- private static final Set<String> SUPPORTED_META_COMPONENTS = new HashSet<String>();
-
- static {
- SUPPORTED_META_COMPONENTS.add(SUBTABLE);
- }
enum PropertyKeys {
expandMode, expanded, toggleExpression
@@ -82,7 +61,7 @@
valueExpression.setValue(elContext, newValue);
}
- String render = resolveClientId(facesContext, this, SUBTABLE);
+ String render = resolveClientId(facesContext, this, BODY);
getFacesContext().getPartialViewContext().getRenderIds().add(render);
}
@@ -134,32 +113,6 @@
getStateHelper().put(PropertyKeys.expandMode, expandMode);
}
- @Override
- public String resolveClientId(FacesContext facesContext, UIComponent contextComponent, String metaComponentId) {
- String clientId = super.resolveClientId(facesContext, contextComponent, metaComponentId);
- if(clientId == null && SUPPORTED_META_COMPONENTS.contains(metaComponentId)) {
- return getClientId(facesContext) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + metaComponentId;
- //TODO: LOG
- }
- return null;
- }
-
- @Override
- protected boolean visitDataChildren(VisitContext visitContext, VisitCallback callback, boolean visitRows) {
- if(visitContext instanceof ExtendedVisitContext) {
- ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext)visitContext;
- if (extendedVisitContext.getVisitMode() == ExtendedVisitContextMode.RENDER) {
- VisitResult result = extendedVisitContext.invokeMetaComponentVisitCallback(this, callback, SUBTABLE);
- if(result == VisitResult.ACCEPT) {
- //TODO:
- } else {
- return result == VisitResult.COMPLETE;
- }
- }
- }
- return super.visitDataChildren(visitContext, callback, visitRows);
- }
-
public void setIterationState(Object stateObject) {
Object[] state = (Object[]) stateObject;
if (state != null) {
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTableToggleControl.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTableToggleControl.java 2010-06-23 16:27:39 UTC (rev 17662)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/component/UISubTableToggleControl.java 2010-06-23 17:11:45 UTC (rev 17663)
@@ -21,26 +21,20 @@
*/
package org.richfaces.component;
-import java.io.IOException;
-
import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-import org.richfaces.event.ToggleEvent;
-import org.richfaces.event.ToggleListener;
-
/**
* @author Anton Belevich
*
*/
-public class UISubTableToggleControl extends UIComponentBase implements ToggleListener {
+public class UISubTableToggleControl extends UIComponentBase {
public static final String COMPONENT_TYPE = "org.richfaces.SubTableToggleControl";
public static final String COMPONENT_FAMILY = "org.richfaces.SubTableToggleControl";
enum PropertyKeys {
- expandIcon, collapseIcon, expandLabel, collapseLabel, forId, switchType, event
+ expandIcon, collapseIcon, expandLabel, collapseLabel, forId, event
}
public String getFamily() {
@@ -95,14 +89,4 @@
public void setEvent(String event) {
getStateHelper().put(PropertyKeys.event, event);
}
-
- @Override
- public void encodeEnd(FacesContext context) throws IOException {
- // TODO Auto-generated method stub
- super.encodeEnd(context);
- }
-
- public void processToggle(ToggleEvent event) {
- getFacesContext().getPartialViewContext().getRenderIds().add(getClientId(getFacesContext()));
- }
}
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-06-23 16:27:39 UTC (rev 17662)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-06-23 17:11:45 UTC (rev 17663)
@@ -167,7 +167,6 @@
boolean encodeParentTBody = encodeParentTBody(dataTableBase);
encodeBeforeRows(writer, facesContext, dataTableBase, encodeParentTBody, encodePartialUpdate);
-
if (rowCount > 0) {
processRows(writer, facesContext, dataTableBase, new Object[] {encodePartialUpdate, encodeParentTBody});
} else {
@@ -204,7 +203,7 @@
facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(id);
}
- encodeHiddens(writer, facesContext, dataTableBase);
+ encodeHiddens(writer, facesContext, dataTableBase, new Object[]{encodeParentTBody});
if(encodePartialUpdate) {
facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
@@ -244,14 +243,14 @@
encodeStyleClass(writer, context, component, HTML.STYLE_CLASS_ATTR, styleClass);
}
- protected void encodeHiddens(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase) throws IOException {
+ protected void encodeHiddens(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase, Object [] params) throws IOException {
EncodeStrategy encodeStrategy = getHiddenContainerStrategy();
- encodeStrategy.begin(writer, facesContext, dataTableBase, null);
+ encodeStrategy.begin(writer, facesContext, dataTableBase, params);
encodeClientScript(writer, facesContext, dataTableBase);
encodeHiddenInput(writer, facesContext, dataTableBase);
- encodeStrategy.end(writer, facesContext, dataTableBase, null);
+ encodeStrategy.end(writer, facesContext, dataTableBase, params);
}
public void encodeTableEnd(ResponseWriter writer) throws IOException {
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-06-23 16:27:39 UTC (rev 17662)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-06-23 17:11:45 UTC (rev 17663)
@@ -146,8 +146,6 @@
UIDataTable dataTable = (UIDataTable)row;
boolean partialUpdate = rowHolder.isUpdatePartial();
-
- //TODO: try to use rowHolder for storing current <tbody> open/close state
boolean parentTbodyStart = rowHolder.isEncodeParentTBody();
boolean tbodyStart = parentTbodyStart;
@@ -179,15 +177,11 @@
if(partialUpdate) {
partialStart(facesContext, id);
}
-
- writer.startElement(HTML.TBODY_ELEMENT, child);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, id, null);
}
child.encodeAll(facesContext);
if (isSubtable) {
- writer.endElement(HTML.TBODY_ELEMENT);
if(partialUpdate) {
partialEnd(facesContext);
}
@@ -200,6 +194,7 @@
partialStart(facesContext, dataTable.getRelativeClientId(facesContext) + ":tb");
}
encodeTableBodyStart(writer, facesContext, dataTable);
+ rowHolder.setRowStart(true);
tbodyStart = true;
}
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-23 16:27:39 UTC (rev 17662)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-06-23 17:11:45 UTC (rev 17663)
@@ -48,6 +48,8 @@
*
*/
public class SubTableRenderer extends AbstractTableRenderer {
+
+ public static final String TB_ROW = ":c";
private static final String STATE = ":state";
@@ -55,9 +57,7 @@
private static final String HIDDEN_STYLE = "display: none";
-
private class SubTableHiddenEncodeStrategy implements EncodeStrategy {
-
public void begin(ResponseWriter writer, FacesContext context, UIComponent component, Object[] params) throws IOException {
UISubTable subTable = (UISubTable)component;
writer.startElement(HTML.TR_ELEMENT, subTable);
@@ -69,8 +69,14 @@
public void end(ResponseWriter writer, FacesContext context, UIComponent component, Object[] params) throws IOException {
writer.endElement(HTML.TD_ELEM);
writer.endElement(HTML.TR_ELEMENT);
+
+ if(params != null && params.length ==1) {
+ boolean endTbody = (Boolean)params[0];
+ if(endTbody) {
+ encodeTableBodyEnd(writer);
+ }
+ }
}
-
};
protected void doDecode(FacesContext facesContext, UIComponent component) {
@@ -135,11 +141,11 @@
UIDataTableBase component = findParent(subTable);
if(component instanceof UIDataTable) {
-// writer.startElement(HTML.TBODY_ELEMENT, null);
-// writer.writeAttribute(HTML.ID_ATTRIBUTE, dataTable.getRelativeClientId(facesContext) + ":" + subTable.getId() + ":c", null);
-
+ writer.startElement(HTML.TBODY_ELEMENT, null);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, component.getRelativeClientId(facesContext) + ":" + subTable.getId() + TB_ROW, null);
+
String predefinedStyles = !subTable.isExpanded() ? "display: none;" : null;
-
+
writer.writeAttribute(HTML.CLASS_ATTRIBUTE, getTableSkinClass(), null);
encodeStyle(writer, facesContext, subTable, predefinedStyles);
}
@@ -148,13 +154,6 @@
@Override
public void encodeBeforeRows(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase, boolean encodeParentTBody, boolean partialUpdate) throws IOException {
UISubTable subTable = (UISubTable)dataTableBase;
-
- UIDataTableBase parent = findParent(subTable);
-
- if(parent instanceof UISubTable) {
- encodeTableBodyEnd(writer);
- }
-
encodeTableBodyStart(writer, facesContext, subTable);
encodeSubTableDomElement(writer, facesContext, subTable);
setupTableStartElement(facesContext, subTable);
@@ -182,7 +181,19 @@
}
while (components.hasNext()) {
- encodeColumn(context, writer, (UIColumn) components.next(), rowHolder);
+ UIComponent component = components.next();
+
+ if(component instanceof UIColumn) {
+ encodeColumn(context, writer, (UIColumn)component , rowHolder);
+
+ } else if (component instanceof UISubTable) {
+ if(component.isRendered()) {
+ encodeRowEnd(writer);
+ }
+
+ component.encodeAll(context);
+ rowHolder.setRowStart(true);
+ }
}
encodeRowEnd(writer);
@@ -197,12 +208,15 @@
boolean encodeParentTBody, boolean partialUpdate) throws IOException {
UISubTable subTable = (UISubTable)dataTableBase;
encodeFooterFacet(writer, facesContext, subTable, false);
-// encodeTableBodyEnd(writer);
}
@Override
public boolean encodeParentTBody(UIDataTableBase dataTableBase) {
- return true;
+ UIDataTableBase parent = findParent((UISubTable)dataTableBase);
+ if(parent instanceof UIDataTable) {
+ return true;
+ }
+ return false;
}
public void encodeHiddenInput(ResponseWriter writer, FacesContext facesContext, UIDataTableBase dataTableBase) throws IOException {
@@ -347,18 +361,15 @@
UISubTable subTable = (UISubTable)component;
setupTableStartElement(facesContext, subTable);
- if(UISubTable.SUBTABLE.equals(metaComponentId)) {
+ if(UISubTable.BODY.equals(metaComponentId)) {
ResponseWriter writer = facesContext.getResponseWriter();
UIDataTableBase dataTableBase = findParent(subTable);
- String updateId = dataTableBase.getRelativeClientId(facesContext) + ":" + subTable.getId() +":c";
-
+ String updateId = dataTableBase.getRelativeClientId(facesContext) + ":" + subTable.getId() +TB_ROW;
+
facesContext.getPartialViewContext().getPartialResponseWriter().startUpdate(updateId);
encodeTableRows(writer, facesContext, subTable, false);
facesContext.getPartialViewContext().getPartialResponseWriter().endUpdate();
-
- }else {
- super.encodeMetaComponent(facesContext, component, metaComponentId);
}
}
Modified: root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-06-23 16:27:39 UTC (rev 17662)
+++ root/ui/iteration/trunk/tables/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-06-23 17:11:45 UTC (rev 17663)
@@ -83,8 +83,6 @@
writer.startElement(HTML.SCRIPT_ELEM, subTable);
writer.writeText(jsFunction.toScript(), null);
writer.endElement(HTML.SCRIPT_ELEM);
-
- subTable.addToggleListener(toggleControl);
}
}
14 years, 6 months