[jira] [Comment Edited] (WICKET-6318) To make PropertyResolver a configurable implementation
[ https://issues.apache.org/jira/browse/WICKET-6318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15860551#comment-15860551 ] Pedro Santos edited comment on WICKET-6318 at 2/27/17 6:27 AM: --- The property expression resolver resolution logic was moved to a configurable implementation of IPropertyExpressionResolver. The current resolver is now the OGNLPropertyExpressionResolver, and the new one will be implemented using the parser described in the ticket WICKET-4008 in PropertyExpressionResolver class. List of changes: ApplicationSettings --> holds a IPropertyExpressionResolver PropertyResolver implementation --> OGNLPropertyExpressionResolver ParsedPropertyExpressionResolver --> -created to be placeholder for the- new property expression resolver that will work using parsed input PropertyResolver reflection utility code --> moved to ReflectionUtility PropertyResolver API --> IPropertyExpressionResolver -IPropertyLocator --> renamed to IPropertyResolver- PropertyResolver.IGetAndSet --> moved to the reflection package IPropertyReflectionAwareModel --> removed since it's an unused and untested interface that was breaking AbstractPropertyModel coherence by adding methods that weren't meant to be an abstraction of the model property, but rather a reflection API utility that already exists in Wicket's API PropertyResolver static API > kept as a faced -for now- was (Author: pedrosans): The property expression resolver resolution logic was moved to a configurable implementation of IPropertyExpressionResolver. The current resolver is now the OGNLPropertyExpressionResolver, and the new one will be implemented using the parser described in the ticket WICKET-4008 in PropertyExpressionResolver class. List of changes: ApplicationSettings --> holds a IPropertyExpressionResolver PropertyResolver implementation --> OGNLPropertyExpressionResolver ParsedPropertyExpressionResolver --> -created to be placeholder for the- new property expression resolver that will work using parsed input PropertyResolver reflection utility code --> moved to ReflectionUtility PropertyResolver API --> IPropertyExpressionResolver -IPropertyLocator --> renamed to IPropertyResolver- PropertyResolver.IGetAndSet --> moved to the reflection package IPropertyReflectionAwareModel --> removed since it's an unused and untested interface that was breaking AbstractPropertyModel coherence by adding methods that weren't meant to be an abstraction of the model property, but rather a reflection API utility that already exists in Wicket's API PropertyResolver static API --> kept as a faced -for now- > To make PropertyResolver a configurable implementation > -- > > Key: WICKET-6318 > URL: https://issues.apache.org/jira/browse/WICKET-6318 > Project: Wicket > Issue Type: Sub-task > Components: wicket >Reporter: Pedro Santos > > To enable users to select each property resolver will be used, so if the new > implementation shows problematic it can be switched back to the a Wicket's < > 7 one. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Comment Edited] (WICKET-6318) To make PropertyResolver a configurable implementation
[ https://issues.apache.org/jira/browse/WICKET-6318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15860551#comment-15860551 ] Pedro Santos edited comment on WICKET-6318 at 2/27/17 6:26 AM: --- The property expression resolver resolution logic was moved to a configurable implementation of IPropertyExpressionResolver. The current resolver is now the OGNLPropertyExpressionResolver, and the new one will be implemented using the parser described in the ticket WICKET-4008 in PropertyExpressionResolver class. List of changes: ApplicationSettings --> holds a IPropertyExpressionResolver PropertyResolver implementation --> OGNLPropertyExpressionResolver ParsedPropertyExpressionResolver --> -created to be placeholder for the- new property expression resolver that will work using parsed input PropertyResolver reflection utility code --> moved to ReflectionUtility PropertyResolver API --> IPropertyExpressionResolver -IPropertyLocator --> renamed to IPropertyResolver- PropertyResolver.IGetAndSet --> moved to the reflection package IPropertyReflectionAwareModel --> removed since it's an unused and untested interface that was breaking AbstractPropertyModel coherence by adding methods that weren't meant to be an abstraction of the model property, but rather a reflection API utility that already exists in Wicket's API PropertyResolver static API --> kept as a faced -for now- was (Author: pedrosans): The property expression resolver resolution logic was moved to a configurable implementation of IPropertyExpressionResolver. The current resolver is now the OGNLPropertyExpressionResolver, and the new one will be implemented using the parser described in the ticket WICKET-4008 in PropertyExpressionResolver class. List of changes: ApplicationSettings --> holds a IPropertyExpressionResolver PropertyResolver implementation --> OGNLPropertyExpressionResolver PropertyExpressionResolver --> created to be placeholder for the new property expression resolver that will work using parsed input PropertyResolver reflection utility code --> moved to ReflectionUtility PropertyResolver API --> IPropertyExpressionResolver IPropertyLocator --> renamed to IPropertyResolver PropertyResolver.IGetAndSet --> moved to the reflection package IPropertyReflectionAwareModel --> removed since it's an unused and untested interface that was breaking AbstractPropertyModel coherence by adding methods that weren't meant to be an abstraction of the model property, but rather a reflection API utility that already exists in Wicket's API PropertyResolver static API --> kept as a faced for now > To make PropertyResolver a configurable implementation > -- > > Key: WICKET-6318 > URL: https://issues.apache.org/jira/browse/WICKET-6318 > Project: Wicket > Issue Type: Sub-task > Components: wicket >Reporter: Pedro Santos > > To enable users to select each property resolver will be used, so if the new > implementation shows problematic it can be switched back to the a Wicket's < > 7 one. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (WICKET-6318) To make PropertyResolver a configurable implementation
[ https://issues.apache.org/jira/browse/WICKET-6318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15885219#comment-15885219 ] ASF subversion and git services commented on WICKET-6318: - Commit 6a895f00dbf7aa7bea5ce06ebb7f937082ad6d20 in wicket's branch refs/heads/WICKET-6318-configurable-property-expression-resolver from Pedro Henrique Oliveira dos Santos [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=6a895f0 ] WICKET-6318 movign parser resolver to its package > To make PropertyResolver a configurable implementation > -- > > Key: WICKET-6318 > URL: https://issues.apache.org/jira/browse/WICKET-6318 > Project: Wicket > Issue Type: Sub-task > Components: wicket >Reporter: Pedro Santos > > To enable users to select each property resolver will be used, so if the new > implementation shows problematic it can be switched back to the a Wicket's < > 7 one. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (WICKET-4008) Improve PropertyResolver to use a parser
[ https://issues.apache.org/jira/browse/WICKET-4008?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15885216#comment-15885216 ] ASF subversion and git services commented on WICKET-4008: - Commit 47ffaab01a61b4adcdf53c85c8351d03cb881229 in wicket's branch refs/heads/WICKET-6318-configurable-property-expression-resolver from Pedro Henrique Oliveira dos Santos [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=47ffaab ] WICKET-4008 fixing test name > Improve PropertyResolver to use a parser > > > Key: WICKET-4008 > URL: https://issues.apache.org/jira/browse/WICKET-4008 > Project: Wicket > Issue Type: Improvement > Components: wicket >Affects Versions: 6.0.0-beta1 >Reporter: Pedro Santos >Assignee: Pedro Santos >Priority: Trivial > Attachments: WICKET-4004.patch > > > The usage of a parser is a improvement since it will be able to feedback > erroneous property expressions with meaningful exception messages. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (WICKET-6318) To make PropertyResolver a configurable implementation
[ https://issues.apache.org/jira/browse/WICKET-6318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15885220#comment-15885220 ] ASF subversion and git services commented on WICKET-6318: - Commit 7fd219c3b764f844665c3cff8d5cc719e77c6a99 in wicket's branch refs/heads/WICKET-6318-configurable-property-expression-resolver from Pedro Henrique Oliveira dos Santos [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=7fd219c ] WICKET-6318 adding ParsedPropertyExpressionResolver, a resolver that uses parsed property expressions; moving DefaultPropertyLocator, IPropertyResolver, CachingPropertyLocator back to OGNLPropertyExpressionResolverOGNLPropertyExpressionResolver; restoring IPropertyResolver name back to IPropertyLocator > To make PropertyResolver a configurable implementation > -- > > Key: WICKET-6318 > URL: https://issues.apache.org/jira/browse/WICKET-6318 > Project: Wicket > Issue Type: Sub-task > Components: wicket >Reporter: Pedro Santos > > To enable users to select each property resolver will be used, so if the new > implementation shows problematic it can be switched back to the a Wicket's < > 7 one. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (WICKET-4008) Improve PropertyResolver to use a parser
[ https://issues.apache.org/jira/browse/WICKET-4008?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15885217#comment-15885217 ] ASF subversion and git services commented on WICKET-4008: - Commit 1df4300c61fbd5165a0361f6547320927a0451c9 in wicket's branch refs/heads/WICKET-6318-configurable-property-expression-resolver from Pedro Henrique Oliveira dos Santos [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=1df4300 ] Merge branch 'WICKET-4008-property-expression-parser' into WICKET-6318-with-parser-resolver > Improve PropertyResolver to use a parser > > > Key: WICKET-4008 > URL: https://issues.apache.org/jira/browse/WICKET-4008 > Project: Wicket > Issue Type: Improvement > Components: wicket >Affects Versions: 6.0.0-beta1 >Reporter: Pedro Santos >Assignee: Pedro Santos >Priority: Trivial > Attachments: WICKET-4004.patch > > > The usage of a parser is a improvement since it will be able to feedback > erroneous property expressions with meaningful exception messages. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (WICKET-6318) To make PropertyResolver a configurable implementation
[ https://issues.apache.org/jira/browse/WICKET-6318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15885218#comment-15885218 ] ASF subversion and git services commented on WICKET-6318: - Commit 1df4300c61fbd5165a0361f6547320927a0451c9 in wicket's branch refs/heads/WICKET-6318-configurable-property-expression-resolver from Pedro Henrique Oliveira dos Santos [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=1df4300 ] Merge branch 'WICKET-4008-property-expression-parser' into WICKET-6318-with-parser-resolver > To make PropertyResolver a configurable implementation > -- > > Key: WICKET-6318 > URL: https://issues.apache.org/jira/browse/WICKET-6318 > Project: Wicket > Issue Type: Sub-task > Components: wicket >Reporter: Pedro Santos > > To enable users to select each property resolver will be used, so if the new > implementation shows problematic it can be switched back to the a Wicket's < > 7 one. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[03/11] wicket git commit: WICKET-4008 property expression parser implementation
WICKET-4008 property expression parser implementation Add some weird test cases Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/2f302dbf Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/2f302dbf Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/2f302dbf Branch: refs/heads/WICKET-6318-configurable-property-expression-resolver Commit: 2f302dbfdc7bd60afca76bccbfac81ccbcbf6af1 Parents: cd96fb1 Author: Martin Tzvetanov GrigorovAuthored: Tue Sep 20 22:33:13 2016 +0200 Committer: Martin Tzvetanov Grigorov Committed: Tue Sep 20 22:33:13 2016 +0200 -- .../util/lang/PropertyExpressionParser.java | 6 +++--- .../util/lang/PropertyExpressionParserTest.java | 22 +--- 2 files changed, 22 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/wicket/blob/2f302dbf/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java -- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java index 4588218..08fd061 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java @@ -98,7 +98,7 @@ public class PropertyExpressionParser case END_OF_EXPRESSION : return expression; default : - throw new ParserException("expecting a new expression but got: " + currentToken); + throw new ParserException("expecting a new expression but got: '" + currentToken + "'"); } } @@ -164,9 +164,9 @@ public class PropertyExpressionParser { if (lookaheadToken != ')') { - throw new ParserException("expecting a method sign but got: " + currentToken); + throw new ParserException("expecting a method sign but got: '" + currentToken + "'"); } advance();// skips right bracket return true; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/wicket/blob/2f302dbf/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java -- diff --git a/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java b/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java index 96d3739..d6c2803 100644 --- a/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java @@ -3,11 +3,9 @@ package org.apache.wicket.core.util.lang; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import org.apache.wicket.core.util.lang.ParserException; -import org.apache.wicket.core.util.lang.PropertyExpression; -import org.apache.wicket.core.util.lang.PropertyExpressionParser; import org.apache.wicket.core.util.lang.PropertyExpression.Property; import org.hamcrest.CoreMatchers; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -35,6 +33,24 @@ public class PropertyExpressionParserTest assertThat(parse.next, CoreMatchers.nullValue()); } + // TODO mgrigorov: @pedrosans: I'd expect the error message to complain about the space, not 'r' + @Test + public void shouldFailParsePropertyExpressionsWithSpace() + { + expectedException.expect(ParserException.class); + expectedException + .expectMessage("expecting a new expression but got: ' '"); + parser.parse("per son"); + } + + // TODO mgrigorov: @pedrosans: IMO this should pass. Or otherwise should complain about the space, not '(' + @Test + public void shouldParsePropertyExpressionsWithSpaceInMethod() + { + final PropertyExpression parse = parser.parse("person( )"); + assertThat(parse.property, is(new Property("person", null, true))); + } + @Test public void shouldParseIndexedPropertyExpressions() {
[05/11] wicket git commit: WICKET-4008 parser differentiates java identifiers from bean properties
WICKET-4008 parser differentiates java identifiers from bean properties Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/697052f7 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/697052f7 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/697052f7 Branch: refs/heads/WICKET-6318-configurable-property-expression-resolver Commit: 697052f713345484b93f4ef61163587473b7b202 Parents: b0f7da8 Author: Pedro Henrique Oliveira dos SantosAuthored: Tue Sep 20 22:09:36 2016 -0300 Committer: Pedro Henrique Oliveira dos Santos Committed: Tue Sep 20 22:09:36 2016 -0300 -- .../core/util/lang/PropertyExpression.java | 70 ++--- .../util/lang/PropertyExpressionParser.java | 69 ++-- .../util/lang/PropertyExpressionParserTest.java | 82 +++- .../wicket/util/lang/PropertyResolverTest.java | 10 ++- 4 files changed, 160 insertions(+), 71 deletions(-) -- http://git-wip-us.apache.org/repos/asf/wicket/blob/697052f7/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java -- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java index 635f95e..dab79ec 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java @@ -18,21 +18,76 @@ package org.apache.wicket.core.util.lang; public class PropertyExpression { - Property property; + JavaProperty javaProperty; + BeanProperty beanProperty; CharSequence index; PropertyExpression next; - static class Property + static class BeanProperty + { + CharSequence propertyName; + CharSequence index; + + public BeanProperty() + { + } + + public BeanProperty(String name, String index) + { + this.propertyName = name; + this.index = index; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + ((index == null) ? 0 : index.hashCode()); + result = prime * result + ((propertyName == null) ? 0 : propertyName.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + BeanProperty other = (BeanProperty)obj; + if (index == null) + { + if (other.index != null) + return false; + } + else if (!index.equals(other.index)) + return false; + if (propertyName == null) + { + if (other.propertyName != null) + return false; + } + else if (!propertyName.equals(other.propertyName)) + return false; + return true; + } + + } + + static class JavaProperty { CharSequence javaIdentifier; CharSequence index; public boolean hasMethodSign; - public Property() + public JavaProperty() { } - public Property(String javaIdentifier, String index, boolean hasMethodSign) + public JavaProperty(String javaIdentifier, String index, boolean hasMethodSign) { this.javaIdentifier = javaIdentifier; this.index = index; @@ -59,7 +114,7 @@ public class PropertyExpression return false; if (getClass() != obj.getClass()) return false; - Property other = (Property)obj; + JavaProperty other = (JavaProperty)obj; if (hasMethodSign
[jira] [Commented] (WICKET-4008) Improve PropertyResolver to use a parser
[ https://issues.apache.org/jira/browse/WICKET-4008?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15885212#comment-15885212 ] ASF subversion and git services commented on WICKET-4008: - Commit 2f302dbfdc7bd60afca76bccbfac81ccbcbf6af1 in wicket's branch refs/heads/WICKET-6318-configurable-property-expression-resolver from [~mgrigorov] [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=2f302db ] WICKET-4008 property expression parser implementation Add some weird test cases > Improve PropertyResolver to use a parser > > > Key: WICKET-4008 > URL: https://issues.apache.org/jira/browse/WICKET-4008 > Project: Wicket > Issue Type: Improvement > Components: wicket >Affects Versions: 6.0.0-beta1 >Reporter: Pedro Santos >Assignee: Pedro Santos >Priority: Trivial > Attachments: WICKET-4004.patch > > > The usage of a parser is a improvement since it will be able to feedback > erroneous property expressions with meaningful exception messages. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (WICKET-4008) Improve PropertyResolver to use a parser
[ https://issues.apache.org/jira/browse/WICKET-4008?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15885213#comment-15885213 ] ASF subversion and git services commented on WICKET-4008: - Commit b0f7da85e45ea4c798366940ec34cd53528cd549 in wicket's branch refs/heads/WICKET-6318-configurable-property-expression-resolver from Pedro Henrique Oliveira dos Santos [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=b0f7da8 ] WICKET-4008 edge test cases plus breaking property into different types in the grammar > Improve PropertyResolver to use a parser > > > Key: WICKET-4008 > URL: https://issues.apache.org/jira/browse/WICKET-4008 > Project: Wicket > Issue Type: Improvement > Components: wicket >Affects Versions: 6.0.0-beta1 >Reporter: Pedro Santos >Assignee: Pedro Santos >Priority: Trivial > Attachments: WICKET-4004.patch > > > The usage of a parser is a improvement since it will be able to feedback > erroneous property expressions with meaningful exception messages. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[04/11] wicket git commit: WICKET-4008 edge test cases plus breaking property into different types in the grammar
WICKET-4008 edge test cases plus breaking property into different types in the grammar Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/b0f7da85 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/b0f7da85 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/b0f7da85 Branch: refs/heads/WICKET-6318-configurable-property-expression-resolver Commit: b0f7da85e45ea4c798366940ec34cd53528cd549 Parents: 2f302db Author: Pedro Henrique Oliveira dos SantosAuthored: Tue Sep 20 18:51:37 2016 -0300 Committer: Pedro Henrique Oliveira dos Santos Committed: Tue Sep 20 19:33:01 2016 -0300 -- .../core/util/lang/PropertyExpression.java | 1 + .../util/lang/PropertyExpressionParser.java | 60 .../util/lang/PropertyExpressionParserTest.java | 138 --- .../wicket/util/lang/PropertyResolverTest.java | 113 --- 4 files changed, 222 insertions(+), 90 deletions(-) -- http://git-wip-us.apache.org/repos/asf/wicket/blob/b0f7da85/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java -- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java index 2021c21..635f95e 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java @@ -19,6 +19,7 @@ package org.apache.wicket.core.util.lang; public class PropertyExpression { Property property; + CharSequence index; PropertyExpression next; static class Property http://git-wip-us.apache.org/repos/asf/wicket/blob/b0f7da85/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java -- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java index 08fd061..3ecb81e 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java @@ -31,11 +31,14 @@ import org.apache.wicket.core.util.lang.PropertyExpression.Property; * index char = char - "]" * * java identifier= java letter , {java letter or digit} - * method sign= "(" , ")" + * property name = java letter or digit , {java letter or digit} + * method sign= "(" , { " " } , ")" * index = "[" , index char , {index char} , "]" ; * - * property = java identifier , [ index | method sign ]; - * property expression= property , { "." , property expression } ; + * bean property = property name, [ index ] + * java property = java identifier , [ index | method sign ] + * map property = index + * property expression= [ bean property | java property | map property ], { "." , property expression } ; * * * @@ -55,12 +58,17 @@ public class PropertyExpressionParser { currentPosition = nextPosition; currentToken = lookaheadToken; - nextPosition += 1; if (nextPosition >= text.length()) + { + lookaheadToken = END_OF_EXPRESSION; + } else + { + lookaheadToken = text.charAt(nextPosition); + } return currentToken; } @@ -71,7 +79,8 @@ public class PropertyExpressionParser { throw new ParserException("No expression was given to be parsed."); } - else if (text.length() == 1) + currentToken = text.charAt(0); + if (text.length() == 1) { lookaheadToken = END_OF_EXPRESSION; } @@ -79,7 +88,6 @@ public class PropertyExpressionParser { lookaheadToken = text.charAt(1); } - currentToken = text.charAt(0); return expression(); } @@ -87,7 +95,14 @@ public class PropertyExpressionParser private PropertyExpression expression() {
[08/11] wicket git commit: Merge branch 'WICKET-4008-property-expression-parser' into WICKET-6318-with-parser-resolver
Merge branch 'WICKET-4008-property-expression-parser' into WICKET-6318-with-parser-resolver Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/1df4300c Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/1df4300c Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/1df4300c Branch: refs/heads/WICKET-6318-configurable-property-expression-resolver Commit: 1df4300c61fbd5165a0361f6547320927a0451c9 Parents: fa0f126 47ffaab Author: Pedro Henrique Oliveira dos SantosAuthored: Sat Feb 25 20:45:30 2017 -0300 Committer: Pedro Henrique Oliveira dos Santos Committed: Sat Feb 25 20:45:30 2017 -0300 -- .../wicket/core/util/lang/ParserException.java | 33 +++ .../core/util/lang/PropertyExpression.java | 144 .../util/lang/PropertyExpressionParser.java | 220 +++ .../util/lang/PropertyExpressionParserTest.java | 189 .../OGNLPropertyExpressionResolverTest.java | 95 5 files changed, 681 insertions(+) -- http://git-wip-us.apache.org/repos/asf/wicket/blob/1df4300c/wicket-core/src/test/java/org/apache/wicket/util/lang/OGNLPropertyExpressionResolverTest.java -- diff --cc wicket-core/src/test/java/org/apache/wicket/util/lang/OGNLPropertyExpressionResolverTest.java index 6168142,000..af87541 mode 100644,00..100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/lang/OGNLPropertyExpressionResolverTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/lang/OGNLPropertyExpressionResolverTest.java @@@ -1,842 -1,0 +1,937 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.util.lang; + ++import static org.hamcrest.CoreMatchers.is; ++ +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Vector; + +import org.apache.wicket.ConverterLocator; +import org.apache.wicket.IConverterLocator; +import org.apache.wicket.WicketRuntimeException; ++import org.apache.wicket.core.util.lang.DefaultPropertyLocator; +import org.apache.wicket.core.util.lang.OGNLPropertyExpressionResolver; ++import org.apache.wicket.core.util.lang.PropertyResolver; +import org.apache.wicket.core.util.lang.PropertyResolverConverter; ++import org.apache.wicket.core.util.reflection.AbstractGetAndSet; ++import org.apache.wicket.core.util.reflection.CachingPropertyLocator; ++import org.apache.wicket.core.util.reflection.IGetAndSet; +import org.apache.wicket.util.convert.ConversionException; +import org.apache.wicket.util.convert.IConverter; +import org.apache.wicket.util.convert.converter.AbstractConverter; +import org.apache.wicket.util.tester.WicketTestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * @author jcompagner + * + */ +public class OGNLPropertyExpressionResolverTest extends WicketTestCase +{ + + private static final PropertyResolverConverter CONVERTER = new PropertyResolverConverter( + new ConverterLocator(), Locale.US); + OGNLPropertyExpressionResolver ognlResolver = new OGNLPropertyExpressionResolver(); ++ ++ private static final int AN_INTEGER = 10; + private Person person; ++ private Map integerMap = new HashMap (); ++ private WeirdList integerList = new WeirdList(); + + /** + * @throws Exception + */ + @Before + public void before() + { + person = new Person(); + } + + /** + * @throws Exception + */ + @After + public void after() + { +//ognlResolver.destroy(tester.getApplication()); + } + + /** + * @throws Exception + */ + @Test +
[07/11] wicket git commit: WICKET-4008 fixing test name
WICKET-4008 fixing test name Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/47ffaab0 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/47ffaab0 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/47ffaab0 Branch: refs/heads/WICKET-6318-configurable-property-expression-resolver Commit: 47ffaab01a61b4adcdf53c85c8351d03cb881229 Parents: c61080e Author: Pedro Henrique Oliveira dos SantosAuthored: Sun Sep 25 03:20:44 2016 -0300 Committer: Pedro Henrique Oliveira dos Santos Committed: Sun Sep 25 03:20:44 2016 -0300 -- .../wicket/core/util/lang/PropertyExpressionParserTest.java| 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/wicket/blob/47ffaab0/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java -- diff --git a/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java b/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java index f49d6b5..3651b94 100644 --- a/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/core/util/lang/PropertyExpressionParserTest.java @@ -169,12 +169,12 @@ public class PropertyExpressionParserTest } @Test - public void shouldFailParseInvalidMethodName() + public void shouldFailParseInvalidBeanProperty() { expectedException.expect(ParserException.class); expectedException.expectMessage( - "Expecting a new expression but got the invalid character '#' at: 'repository.get#<--'"); - parser.parse("repository.get#name()"); + "Expecting a new expression but got the invalid character '#' at: 'repository.prop#<--'"); + parser.parse("repository.prop#name"); } @Test
[01/11] wicket git commit: WICKET-4008 property expression parser implementation
Repository: wicket Updated Branches: refs/heads/WICKET-6318-configurable-property-expression-resolver fa0f12624 -> 7fd219c3b WICKET-4008 property expression parser implementation Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/1e5618f1 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/1e5618f1 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/1e5618f1 Branch: refs/heads/WICKET-6318-configurable-property-expression-resolver Commit: 1e5618f13c396ab6c06cc04d607db276ba67b1fb Parents: 5b7547f Author: Pedro Henrique Oliveira dos SantosAuthored: Wed Sep 7 00:45:23 2016 -0300 Committer: Pedro Henrique Oliveira dos Santos Committed: Thu Sep 15 02:09:51 2016 -0300 -- .../wicket/core/util/lang/ParserException.java | 33 .../core/util/lang/PropertyExpression.java | 88 ++ .../util/lang/PropertyExpressionParser.java | 172 +++ .../util/lang/PropertyExpressionParserTest.java | 121 + .../wicket/util/lang/PropertyResolverTest.java | 80 ++--- 5 files changed, 473 insertions(+), 21 deletions(-) -- http://git-wip-us.apache.org/repos/asf/wicket/blob/1e5618f1/wicket-core/src/main/java/org/apache/wicket/core/util/lang/ParserException.java -- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/ParserException.java b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/ParserException.java new file mode 100644 index 000..62712e8 --- /dev/null +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/ParserException.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.core.util.lang; + +/** + * @author Pedro Santos + */ +public class ParserException extends RuntimeException +{ + private static final long serialVersionUID = 1L; + + /** +* @param message +*/ + public ParserException(String message) + { + super(message); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/wicket/blob/1e5618f1/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java -- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java new file mode 100644 index 000..2021c21 --- /dev/null +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.core.util.lang; + +public class PropertyExpression +{ + Property property; + PropertyExpression next; + + static class Property + { + CharSequence javaIdentifier; + CharSequence index; + public boolean hasMethodSign; + + public Property() + { + } + + public Property(String javaIdentifier, String index, boolean hasMethodSign) + { + this.javaIdentifier
[jira] [Commented] (WICKET-4008) Improve PropertyResolver to use a parser
[ https://issues.apache.org/jira/browse/WICKET-4008?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15885211#comment-15885211 ] ASF subversion and git services commented on WICKET-4008: - Commit 1e5618f13c396ab6c06cc04d607db276ba67b1fb in wicket's branch refs/heads/WICKET-6318-configurable-property-expression-resolver from Pedro Henrique Oliveira dos Santos [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=1e5618f ] WICKET-4008 property expression parser implementation > Improve PropertyResolver to use a parser > > > Key: WICKET-4008 > URL: https://issues.apache.org/jira/browse/WICKET-4008 > Project: Wicket > Issue Type: Improvement > Components: wicket >Affects Versions: 6.0.0-beta1 >Reporter: Pedro Santos >Assignee: Pedro Santos >Priority: Trivial > Attachments: WICKET-4004.patch > > > The usage of a parser is a improvement since it will be able to feedback > erroneous property expressions with meaningful exception messages. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[11/11] wicket git commit: WICKET-6318 adding ParsedPropertyExpressionResolver, a resolver that uses parsed property expressions; moving DefaultPropertyLocator, IPropertyResolver, CachingPropertyLocat
WICKET-6318 adding ParsedPropertyExpressionResolver, a resolver that uses parsed property expressions; moving DefaultPropertyLocator, IPropertyResolver, CachingPropertyLocator back to OGNLPropertyExpressionResolverOGNLPropertyExpressionResolver; restoring IPropertyResolver name back to IPropertyLocator Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/7fd219c3 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/7fd219c3 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/7fd219c3 Branch: refs/heads/WICKET-6318-configurable-property-expression-resolver Commit: 7fd219c3b764f844665c3cff8d5cc719e77c6a99 Parents: 6a895f0 Author: Pedro Henrique Oliveira dos SantosAuthored: Mon Feb 27 03:13:43 2017 -0300 Committer: Pedro Henrique Oliveira dos Santos Committed: Mon Feb 27 03:15:27 2017 -0300 -- .../validation/DefaultPropertyResolver.java | 2 +- .../core/util/lang/DefaultPropertyLocator.java | 160 .../util/lang/IPropertyExpressionResolver.java | 22 +- .../core/util/lang/IPropertyResolver.java | 18 - .../lang/OGNLPropertyExpressionResolver.java| 393 +--- .../wicket/core/util/lang/PropertyResolver.java | 97 +- .../ParsedPropertyExpressionResolver.java | 173 .../core/util/parser/PropertyExpression.java| 25 + .../util/parser/PropertyExpressionResolver.java | 21 - .../util/reflection/CachingPropertyLocator.java | 70 -- .../reflection/IndexedPropertyGetAndSet.java| 2 +- .../core/util/reflection/MethodGetAndSet.java | 51 +- .../util/reflection/ObjectWithGetAndSet.java| 8 +- .../core/util/reflection/ReflectionUtility.java | 78 +- .../wicket/model/AbstractPropertyModel.java | 2 +- .../ParsedPropertyExpressionResolverTest.java | 103 +++ .../parser/PropertyExpressionParserTest.java| 16 + .../OGNLPropertyExpressionResolverTest.java | 916 +-- .../lang/PropertyExpressionResolverTest.java| 852 + .../org/apache/wicket/util/lang/WeirdList.java | 48 + .../org/apache/wicket/util/lang/WeirdMap.java | 48 + 21 files changed, 1721 insertions(+), 1384 deletions(-) -- http://git-wip-us.apache.org/repos/asf/wicket/blob/7fd219c3/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/DefaultPropertyResolver.java -- diff --git a/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/DefaultPropertyResolver.java b/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/DefaultPropertyResolver.java index 174598a..e6a4985 100644 --- a/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/DefaultPropertyResolver.java +++ b/wicket-bean-validation/src/main/java/org/apache/wicket/bean/validation/DefaultPropertyResolver.java @@ -35,7 +35,7 @@ public class DefaultPropertyResolver implements IPropertyResolver String expression = delegate.getPropertyExpression(); IPropertyExpressionResolver propertyExpressionResolver = Application.get().getApplicationSettings().getPropertyExpressionResolver(); - ObjectWithGetAndSet objectWithGetAndSet = propertyExpressionResolver.resolve(expression, target, target.getClass()); + ObjectWithGetAndSet objectWithGetAndSet = propertyExpressionResolver.resolve(expression, target, target.getClass(), IPropertyExpressionResolver.RESOLVE_CLASS); Method getter = objectWithGetAndSet.getGetter(); if (getter != null) http://git-wip-us.apache.org/repos/asf/wicket/blob/7fd219c3/wicket-core/src/main/java/org/apache/wicket/core/util/lang/DefaultPropertyLocator.java -- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/DefaultPropertyLocator.java b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/DefaultPropertyLocator.java deleted file mode 100644 index c8803c7..000 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/DefaultPropertyLocator.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.apache.wicket.core.util.lang; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Map; - -import org.apache.wicket.WicketRuntimeException; -import org.apache.wicket.core.util.reflection.ArrayGetAndSet; -import org.apache.wicket.core.util.reflection.ArrayLengthGetAndSet; -import org.apache.wicket.core.util.reflection.FieldGetAndSet; -import org.apache.wicket.core.util.reflection.IGetAndSet; -import org.apache.wicket.core.util.reflection.IndexedPropertyGetAndSet; -import org.apache.wicket.core.util.reflection.ListGetAndSet;
[09/11] wicket git commit: WICKET-6318 movign parser resolver to its package
WICKET-6318 movign parser resolver to its package Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/6a895f00 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/6a895f00 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/6a895f00 Branch: refs/heads/WICKET-6318-configurable-property-expression-resolver Commit: 6a895f00dbf7aa7bea5ce06ebb7f937082ad6d20 Parents: 1df4300 Author: Pedro Henrique Oliveira dos SantosAuthored: Sat Feb 25 20:51:20 2017 -0300 Committer: Pedro Henrique Oliveira dos Santos Committed: Sun Feb 26 07:18:36 2017 -0300 -- .../wicket/core/util/lang/ParserException.java | 33 --- .../core/util/lang/PropertyExpression.java | 144 .../util/lang/PropertyExpressionParser.java | 220 --- .../core/util/parser/ParserException.java | 33 +++ .../core/util/parser/PropertyExpression.java| 144 .../util/parser/PropertyExpressionParser.java | 220 +++ .../util/lang/PropertyExpressionParserTest.java | 189 .../parser/PropertyExpressionParserTest.java| 189 8 files changed, 586 insertions(+), 586 deletions(-) -- http://git-wip-us.apache.org/repos/asf/wicket/blob/6a895f00/wicket-core/src/main/java/org/apache/wicket/core/util/lang/ParserException.java -- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/ParserException.java b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/ParserException.java deleted file mode 100644 index 62712e8..000 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/ParserException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.core.util.lang; - -/** - * @author Pedro Santos - */ -public class ParserException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - /** -* @param message -*/ - public ParserException(String message) - { - super(message); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/wicket/blob/6a895f00/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java -- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java deleted file mode 100644 index 6596651..000 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.core.util.lang; - -/** - * Abstract syntax tree of a expression property - * - * @author Pedro Santos - */ -public class PropertyExpression -{ - JavaProperty javaProperty; - BeanProperty beanProperty; - String index; - PropertyExpression next; - - static class BeanProperty - { - String propertyName; - String index; - - public BeanProperty()
[06/11] wicket git commit: WICKET-4008 changing PropertyResolver tokenizer to use parsed input
WICKET-4008 changing PropertyResolver tokenizer to use parsed input Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/c61080e0 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/c61080e0 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/c61080e0 Branch: refs/heads/WICKET-6318-configurable-property-expression-resolver Commit: c61080e0a8687d775cee88dd24fbc1dc157c967c Parents: 697052f Author: Pedro Henrique Oliveira dos SantosAuthored: Fri Sep 23 00:32:08 2016 -0300 Committer: Pedro Henrique Oliveira dos Santos Committed: Sun Sep 25 02:51:05 2016 -0300 -- .../core/util/lang/PropertyExpression.java | 15 +- .../util/lang/PropertyExpressionParser.java | 25 +++- .../wicket/core/util/lang/PropertyResolver.java | 136 + .../util/lang/PropertyExpressionParserTest.java | 4 +- .../wicket/util/lang/PropertyResolverTest.java | 150 +++ 5 files changed, 224 insertions(+), 106 deletions(-) -- http://git-wip-us.apache.org/repos/asf/wicket/blob/c61080e0/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java -- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java index dab79ec..6596651 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpression.java @@ -16,17 +16,22 @@ */ package org.apache.wicket.core.util.lang; +/** + * Abstract syntax tree of a expression property + * + * @author Pedro Santos + */ public class PropertyExpression { JavaProperty javaProperty; BeanProperty beanProperty; - CharSequence index; + String index; PropertyExpression next; static class BeanProperty { - CharSequence propertyName; - CharSequence index; + String propertyName; + String index; public BeanProperty() { @@ -79,8 +84,8 @@ public class PropertyExpression static class JavaProperty { - CharSequence javaIdentifier; - CharSequence index; + String javaIdentifier; + String index; public boolean hasMethodSign; public JavaProperty() http://git-wip-us.apache.org/repos/asf/wicket/blob/c61080e0/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java -- diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java index 2102456..ef05599 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/lang/PropertyExpressionParser.java @@ -31,9 +31,10 @@ import org.apache.wicket.core.util.lang.PropertyExpression.JavaProperty; * char = java letter or digit | "." | "(" | ")" | "[" | "]" | "!" | "@" | "#" | (...); * index char = char - "]"; * + * empty space= { " " }; * java identifier= java letter , {java letter or digit}; * property name = java letter or digit , {java letter or digit}; - * method sign= "(" , { " " } , ")"; + * method sign= "(" , empty space , ")"; * index = "[" , index char , { index char } , "]"; * * bean property = property name, [ index ]; @@ -120,6 +121,9 @@ public class PropertyExpressionParser return expression; case END_OF_EXPRESSION : return expression; + case '(' : + throw new ParserException(format("Expecting a valid method name but got: '%s<--'", + text.substring(0, nextPosition + 1))); default : throw new ParserException(format( "Expecting a new expression but got the invalid character '%s' at: '%s<--'", @@ -157,7 +161,7 @@ public class PropertyExpressionParser return property; } - private CharSequence
[10/11] wicket git commit: WICKET-6318 adding ParsedPropertyExpressionResolver, a resolver that uses parsed property expressions; moving DefaultPropertyLocator, IPropertyResolver, CachingPropertyLocat
http://git-wip-us.apache.org/repos/asf/wicket/blob/7fd219c3/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyExpressionResolverTest.java -- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyExpressionResolverTest.java b/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyExpressionResolverTest.java new file mode 100644 index 000..1ab1a37 --- /dev/null +++ b/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyExpressionResolverTest.java @@ -0,0 +1,852 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.util.lang; + +import static org.apache.wicket.core.util.lang.IPropertyExpressionResolver.RESOLVE_CLASS; +import static org.hamcrest.CoreMatchers.is; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Vector; + +import org.apache.wicket.ConverterLocator; +import org.apache.wicket.IConverterLocator; +import org.apache.wicket.WicketRuntimeException; +import org.apache.wicket.core.util.lang.IPropertyExpressionResolver; +import org.apache.wicket.core.util.lang.OGNLPropertyExpressionResolver; +import org.apache.wicket.core.util.lang.PropertyResolver; +import org.apache.wicket.core.util.lang.PropertyResolverConverter; +import org.apache.wicket.core.util.parser.ParsedPropertyExpressionResolver; +import org.apache.wicket.util.convert.ConversionException; +import org.apache.wicket.util.convert.IConverter; +import org.apache.wicket.util.convert.converter.AbstractConverter; +import org.apache.wicket.util.tester.WicketTestCase; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +/** + * @author jcompagner + * + */ +@RunWith(Parameterized.class) +public class PropertyExpressionResolverTest extends WicketTestCase +{ + +@Parameters +public static Collection configs() { + return Arrays.asList(new OGNLPropertyExpressionResolver(), new ParsedPropertyExpressionResolver()); +} + private static final PropertyResolverConverter CONVERTER = new PropertyResolverConverter( + new ConverterLocator(), Locale.US); + + private static final int AN_INTEGER = 10; + + private IPropertyExpressionResolver resolver; + private Person person; + private MapintegerMap = new HashMap (); + private WeirdList integerList = new WeirdList(); + + public PropertyExpressionResolverTest(IPropertyExpressionResolver resolver) + { + this.resolver = resolver; + } + /** +* @throws Exception +*/ + @Before + public void before() + { + tester.getApplication().getApplicationSettings().setPropertyExpressionResolver(resolver); + person = new Person(); + } + + /** +* @throws Exception +*/ + @After + public void after() + { +// ognlResolver.destroy(tester.getApplication()); + } + + /** +* @throws Exception +*/ + @Test + public void simpleExpression() throws Exception + { + String name = (String)PropertyResolver.getValue("name", person); + assertNull(name); + + PropertyResolver.setValue("name", person, "wicket", CONVERTER); + name = (String)PropertyResolver.getValue("name", person); + assertEquals(name, "wicket"); + } + + /** +* @throws Exception +*/ + @Test(expected = ConversionException.class) + public void primitiveValue() throws Exception + { + Integer integer = (Integer)PropertyResolver.getValue("age", person); + assertTrue(integer == 0); + +
[02/11] wicket git commit: restoring PropertyResolverTest.java
restoring PropertyResolverTest.java Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/cd96fb1c Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/cd96fb1c Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/cd96fb1c Branch: refs/heads/WICKET-6318-configurable-property-expression-resolver Commit: cd96fb1c565ca59434900636827729a1f99f717d Parents: 1e5618f Author: Pedro Henrique Oliveira dos SantosAuthored: Thu Sep 15 02:15:02 2016 -0300 Committer: Pedro Henrique Oliveira dos Santos Committed: Thu Sep 15 02:15:02 2016 -0300 -- .../wicket/util/lang/PropertyResolverTest.java | 80 +--- 1 file changed, 21 insertions(+), 59 deletions(-) -- http://git-wip-us.apache.org/repos/asf/wicket/blob/cd96fb1c/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java -- diff --git a/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java b/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java index c2a19e6..1a3278d 100644 --- a/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java +++ b/wicket-core/src/test/java/org/apache/wicket/util/lang/PropertyResolverTest.java @@ -16,8 +16,6 @@ */ package org.apache.wicket.util.lang; -import static org.hamcrest.CoreMatchers.is; - import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; @@ -54,13 +52,10 @@ import org.junit.Test; public class PropertyResolverTest extends WicketTestCase { - private static final int AN_INTEGER = 10; - private static final PropertyResolverConverter CONVERTER = new PropertyResolverConverter( new ConverterLocator(), Locale.US); private Person person; - private Map integerMap = new HashMap (); /** * @throws Exception @@ -86,7 +81,7 @@ public class PropertyResolverTest extends WicketTestCase @Test public void simpleExpression() throws Exception { - String name = (String)PropertyResolver.getValue("name", person); + String name = (String) PropertyResolver.getValue("name", person); assertNull(name); PropertyResolver.setValue("name", person, "wicket", CONVERTER); @@ -213,28 +208,6 @@ public class PropertyResolverTest extends WicketTestCase * @throws Exception */ @Test - public void shouldAccessConflictingMapEntries() throws Exception - { - PropertyResolver.setValue("integerMap.class", this, AN_INTEGER, CONVERTER); - assertThat(PropertyResolver.getValue("integerMap.class", this), is(AN_INTEGER)); - } - - /** -* @throws Exception -*/ - @Test - public void mapMethodExpressionasdf() throws Exception - { - HashMap map = new HashMap (); - PropertyResolver.setValue("class", map, 10, CONVERTER); - Integer mySize = (Integer)PropertyResolver.getValue("class", map); - assertEquals(mySize, new Integer(1)); - } - - /** -* @throws Exception -*/ - @Test public void mapWithDotLookup() throws Exception { Address address = new Address(); @@ -244,8 +217,7 @@ public class PropertyResolverTest extends WicketTestCase assertNotNull(hm.get("address.test")); PropertyResolver.setValue("addressMap[address.test].street", person, "wicket-street", CONVERTER); - String street = (String)PropertyResolver.getValue("addressMap[address.test].street", - person); + String street = (String)PropertyResolver.getValue("addressMap[address.test].street", person); assertEquals(street, "wicket-street"); } @@ -774,73 +746,63 @@ public class PropertyResolverTest extends WicketTestCase Object actual = converter.convert(date, Long.class); assertEquals(date.getTime(), actual); } - + /** * WICKET-5623 custom properties */ @Test - public void custom() - { + public void custom() { Document document = new Document(); document.setType("type"); document.setProperty("string", "string"); - + Document nestedCustom = new Document(); nestedCustom.setProperty("string", "string2"); document.setProperty("nested", nestedCustom); - -
[jira] [Commented] (WICKET-4008) Improve PropertyResolver to use a parser
[ https://issues.apache.org/jira/browse/WICKET-4008?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15885214#comment-15885214 ] ASF subversion and git services commented on WICKET-4008: - Commit 697052f713345484b93f4ef61163587473b7b202 in wicket's branch refs/heads/WICKET-6318-configurable-property-expression-resolver from Pedro Henrique Oliveira dos Santos [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=697052f ] WICKET-4008 parser differentiates java identifiers from bean properties > Improve PropertyResolver to use a parser > > > Key: WICKET-4008 > URL: https://issues.apache.org/jira/browse/WICKET-4008 > Project: Wicket > Issue Type: Improvement > Components: wicket >Affects Versions: 6.0.0-beta1 >Reporter: Pedro Santos >Assignee: Pedro Santos >Priority: Trivial > Attachments: WICKET-4004.patch > > > The usage of a parser is a improvement since it will be able to feedback > erroneous property expressions with meaningful exception messages. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (WICKET-4008) Improve PropertyResolver to use a parser
[ https://issues.apache.org/jira/browse/WICKET-4008?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15885215#comment-15885215 ] ASF subversion and git services commented on WICKET-4008: - Commit c61080e0a8687d775cee88dd24fbc1dc157c967c in wicket's branch refs/heads/WICKET-6318-configurable-property-expression-resolver from Pedro Henrique Oliveira dos Santos [ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=c61080e ] WICKET-4008 changing PropertyResolver tokenizer to use parsed input > Improve PropertyResolver to use a parser > > > Key: WICKET-4008 > URL: https://issues.apache.org/jira/browse/WICKET-4008 > Project: Wicket > Issue Type: Improvement > Components: wicket >Affects Versions: 6.0.0-beta1 >Reporter: Pedro Santos >Assignee: Pedro Santos >Priority: Trivial > Attachments: WICKET-4004.patch > > > The usage of a parser is a improvement since it will be able to feedback > erroneous property expressions with meaningful exception messages. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
wicket-site git commit: Servlet 3.x with Spring Framework example
Repository: wicket-site Updated Branches: refs/heads/asf-site 3708504ee -> 11c9ba777 Servlet 3.x with Spring Framework example - Generated files Project: http://git-wip-us.apache.org/repos/asf/wicket-site/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket-site/commit/11c9ba77 Tree: http://git-wip-us.apache.org/repos/asf/wicket-site/tree/11c9ba77 Diff: http://git-wip-us.apache.org/repos/asf/wicket-site/diff/11c9ba77 Branch: refs/heads/asf-site Commit: 11c9ba7773035eef9769043d1122428d0e19be6c Parents: 3708504 Author: Tobias SoloschenkoAuthored: Mon Feb 27 06:28:18 2017 +0100 Committer: Tobias Soloschenko Committed: Mon Feb 27 06:30:49 2017 +0100 -- content/atom.xml | 2 +- content/learn/examples/servlet3x.html | 14 -- content/start/quickstart.html | 6 +++--- 3 files changed, 12 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/wicket-site/blob/11c9ba77/content/atom.xml -- diff --git a/content/atom.xml b/content/atom.xml index 038903d..52f4870 100644 --- a/content/atom.xml +++ b/content/atom.xml @@ -3,7 +3,7 @@ Apache Wicket http://wicket.apache.org/atom.xml; rel="self"/> http://wicket.apache.org/"/> -2017-02-24T11:37:16+01:00 +2017-02-27T06:29:22+01:00 http://wicket.apache.org/ Apache Wicket http://git-wip-us.apache.org/repos/asf/wicket-site/blob/11c9ba77/content/learn/examples/servlet3x.html -- diff --git a/content/learn/examples/servlet3x.html b/content/learn/examples/servlet3x.html index ab27bfc..a1b9f50 100644 --- a/content/learn/examples/servlet3x.html +++ b/content/learn/examples/servlet3x.html @@ -72,17 +72,19 @@ those Spring components are initialized with specific annotations like @Componen example. You have to place them into the scanned package or in sub packages. (com.my.package in this case) import javax.servlet.annotation.WebListener; import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; @WebListener public class MyContextLoaderListener extends ContextLoaderListener { - private static AnnotationConfigWebApplicationContext context; - static { -context = new AnnotationConfigWebApplicationContext(); + public MyContextLoaderListener() { +super(getWebApplicationContext()); + } + private static WebApplicationContext getWebApplicationContext() { +AnnotationConfigWebApplicationContext context + = new AnnotationConfigWebApplicationContext(); context.scan("com.my.package"); context.refresh(); - } - public MyContextLoaderListener() { -super(context); +return context; } } MyRequestContextListener.java http://git-wip-us.apache.org/repos/asf/wicket-site/blob/11c9ba77/content/start/quickstart.html -- diff --git a/content/start/quickstart.html b/content/start/quickstart.html index 90168e4..1205fd5 100644 --- a/content/start/quickstart.html +++ b/content/start/quickstart.html @@ -153,9 +153,9 @@ generated (e.g. for Eclipse users this would be your workspace folder). Paste the command line into your terminal window and press «enter» to execute the command. You can create your quickstart interactively too with the following Maven command: -mvn archetype:generate -DarchetypeCatalog=http://wicket.apache.org - - +shell +mvn archetype:generate -DarchetypeCatalog=http://wicket.apache.org + Result of the Maven command Executing the Maven command line will result the following directory structure:
wicket-site git commit: Servlet 3.x with Spring Framework example
Repository: wicket-site Updated Branches: refs/heads/asf-site 26fcaca36 -> 3708504ee Servlet 3.x with Spring Framework example - Moved context init into static method Project: http://git-wip-us.apache.org/repos/asf/wicket-site/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket-site/commit/3708504e Tree: http://git-wip-us.apache.org/repos/asf/wicket-site/tree/3708504e Diff: http://git-wip-us.apache.org/repos/asf/wicket-site/diff/3708504e Branch: refs/heads/asf-site Commit: 3708504eef1757c828e8a0019a6eb47d9ec75682 Parents: 26fcaca Author: Tobias SoloschenkoAuthored: Mon Feb 27 06:28:18 2017 +0100 Committer: Tobias Soloschenko Committed: Mon Feb 27 06:28:18 2017 +0100 -- learn/examples/servlet3x.md | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/wicket-site/blob/3708504e/learn/examples/servlet3x.md -- diff --git a/learn/examples/servlet3x.md b/learn/examples/servlet3x.md index 3cd3daf..b34f5e8 100644 --- a/learn/examples/servlet3x.md +++ b/learn/examples/servlet3x.md @@ -38,21 +38,22 @@ example. You have to place them into the scanned package or in sub packages. (co {% highlight java %} import javax.servlet.annotation.WebListener; import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; @WebListener public class MyContextLoaderListener extends ContextLoaderListener { - private static AnnotationConfigWebApplicationContext context; + public MyContextLoaderListener() { +super(getWebApplicationContext()); + } - static { -context = new AnnotationConfigWebApplicationContext(); + private static WebApplicationContext getWebApplicationContext() { +AnnotationConfigWebApplicationContext context + = new AnnotationConfigWebApplicationContext(); context.scan("com.my.package"); context.refresh(); - } - - public MyContextLoaderListener() { -super(context); +return context; } } {% endhighlight %}
[jira] [Created] (WICKET-6327) PropertyResover doesn't resolve a property expression to its field if it's in a Map object
Pedro Santos created WICKET-6327: Summary: PropertyResover doesn't resolve a property expression to its field if it's in a Map object Key: WICKET-6327 URL: https://issues.apache.org/jira/browse/WICKET-6327 Project: Wicket Issue Type: Bug Affects Versions: 6.26.0, 8.0.0-M3, 7.6.0 Reporter: Pedro Santos Priority: Minor Property resolver will always resolve a property expression to a map key, even if it isn't using the map[key] syntax. e.g. class MyMap implements Map{ public Object myProperty; } in this case PropertyResolver.getValue("map[myProperty]", this) will work fine, but any attempt to access "myProperty" using a property expression will fail since PropertyResolver.getValue("map.myProperty", this) will resolve "myProperty" to a map key. -- This message was sent by Atlassian JIRA (v6.3.15#6346)