You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2017/12/08 15:57:42 UTC
[1/4] [text] TEXT-106: Exception thrown in ExtendedMessageFormat
using quotes with custom registry
Repository: commons-text
Updated Branches:
refs/heads/master ee6017fcb -> b647f0496
TEXT-106: Exception thrown in ExtendedMessageFormat using quotes with custom registry
Applying patch provided by BenoƮt Moreau (thanks!).
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/1596501e
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/1596501e
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/1596501e
Branch: refs/heads/master
Commit: 1596501e610bca7955969bb94fe6c6bad397e361
Parents: e55d0ac
Author: Bruno P. Kinoshita <br...@yahoo.com.br>
Authored: Sun Oct 29 00:28:04 2017 +1300
Committer: Bruno P. Kinoshita <br...@yahoo.com.br>
Committed: Sun Oct 29 00:28:04 2017 +1300
----------------------------------------------------------------------
src/changes/changes.xml | 1 +
.../org/apache/commons/text/ExtendedMessageFormat.java | 5 ++++-
.../apache/commons/text/ExtendedMessageFormatTest.java | 11 +++++++++++
3 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/1596501e/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index e43bd8f..ec57b1f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
<body>
<release version="1.2" date="2017-MM-DD" description="Release 1.2">
+ <action issue="TEXT-106" type="fix" dev="kinow" due-to="Benoit Moreau">Exception thrown in ExtendedMessageFormat using quotes with custom registry</action>
<action issue="TEXT-100" type="fix" dev="kinow" due-to="Don Jeba">StringEscapeUtils#UnEscapeJson doesn't recognize escape signs correctly</action>
<action issue="TEXT-74" type="add" dev="chtompki" due-to="Ioannis Sermetziadis">StrSubstitutor: Ability to turn off substitution in values</action>
<action issue="TEXT-97" type="add" dev="chtompki" due-to="Amey Jadiye">RandomStringGenerator able to pass multiple ranges to .withinRange()</action>
http://git-wip-us.apache.org/repos/asf/commons-text/blob/1596501e/src/main/java/org/apache/commons/text/ExtendedMessageFormat.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/text/ExtendedMessageFormat.java b/src/main/java/org/apache/commons/text/ExtendedMessageFormat.java
index dcf0766..cfe1bf4 100644
--- a/src/main/java/org/apache/commons/text/ExtendedMessageFormat.java
+++ b/src/main/java/org/apache/commons/text/ExtendedMessageFormat.java
@@ -411,21 +411,24 @@ public class ExtendedMessageFormat extends MessageFormat {
seekNonWs(pattern, pos);
final int text = pos.getIndex();
int depth = 1;
- for (; pos.getIndex() < pattern.length(); next(pos)) {
+ while (pos.getIndex() < pattern.length()) {
switch (pattern.charAt(pos.getIndex())) {
case START_FE:
depth++;
+ next(pos);
break;
case END_FE:
depth--;
if (depth == 0) {
return pattern.substring(text, pos.getIndex());
}
+ next(pos);
break;
case QUOTE:
getQuotedString(pattern, pos);
break;
default:
+ next(pos);
break;
}
}
http://git-wip-us.apache.org/repos/asf/commons-text/blob/1596501e/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
index 640b5b0..7e32236 100644
--- a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
+++ b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
@@ -102,6 +102,17 @@ public class ExtendedMessageFormatTest {
}
/**
+ * Test Bug TEXT-106 - Exception while using ExtendedMessageFormat and choice format element with quote just before brace end
+ */
+ @Test
+ public void testChoiceQuoteJustBeforeBraceEnd_TEXT_106() {
+ final String pattern2 = "Message with choice format element with quote just before brace end ''{0,choice,0#0|0<'1'}''";
+ final ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern2, registry);
+ assertEquals("Message with choice format element with quote just before brace end '0'", emf.format(new Object[] {0}));
+ assertEquals("Message with choice format element with quote just before brace end '1'", emf.format(new Object[] {1}));
+ }
+
+ /**
* Test extended and built in formats.
*/
@Test
[4/4] [text] Merge branch 'TEXT-106' of
https://github.com/kinow/commons-text
Posted by ch...@apache.org.
Merge branch 'TEXT-106' of https://github.com/kinow/commons-text
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/b647f049
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/b647f049
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/b647f049
Branch: refs/heads/master
Commit: b647f0496d0548b8ce817e6504fc0e72af618bad
Parents: ee6017f 3554c40
Author: Rob Tompkins <ch...@apache.org>
Authored: Fri Dec 8 10:56:23 2017 -0500
Committer: Rob Tompkins <ch...@apache.org>
Committed: Fri Dec 8 10:56:23 2017 -0500
----------------------------------------------------------------------
src/changes/changes.xml | 1 +
.../org/apache/commons/text/ExtendedMessageFormat.java | 5 ++++-
.../apache/commons/text/ExtendedMessageFormatTest.java | 12 ++++++++++++
3 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/b647f049/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
----------------------------------------------------------------------
[3/4] [text] Merge pull request #1 from ben12/TEXT-106
Posted by ch...@apache.org.
Merge pull request #1 from ben12/TEXT-106
Resolve checkstyle errors.
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/3554c40a
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/3554c40a
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/3554c40a
Branch: refs/heads/master
Commit: 3554c40a09288ba85313219c58e8084f3dcd885f
Parents: 1596501 aa78991
Author: Bruno P. Kinoshita <ki...@users.noreply.github.com>
Authored: Sun Nov 5 00:31:49 2017 +1300
Committer: GitHub <no...@github.com>
Committed: Sun Nov 5 00:31:49 2017 +1300
----------------------------------------------------------------------
.../org/apache/commons/text/ExtendedMessageFormatTest.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
[2/4] [text] Resolve checkstyle errors.
Posted by ch...@apache.org.
Resolve checkstyle errors.
Project: http://git-wip-us.apache.org/repos/asf/commons-text/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-text/commit/aa789914
Tree: http://git-wip-us.apache.org/repos/asf/commons-text/tree/aa789914
Diff: http://git-wip-us.apache.org/repos/asf/commons-text/diff/aa789914
Branch: refs/heads/master
Commit: aa789914536355f863c7a756684959e4eac67f91
Parents: 1596501
Author: ben.12 <be...@yahoo.fr>
Authored: Sat Oct 28 17:12:28 2017 +0200
Committer: ben.12 <be...@yahoo.fr>
Committed: Sat Oct 28 17:12:28 2017 +0200
----------------------------------------------------------------------
.../org/apache/commons/text/ExtendedMessageFormatTest.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-text/blob/aa789914/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
index 7e32236..080fb59 100644
--- a/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
+++ b/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java
@@ -102,14 +102,15 @@ public class ExtendedMessageFormatTest {
}
/**
- * Test Bug TEXT-106 - Exception while using ExtendedMessageFormat and choice format element with quote just before brace end
+ * Test Bug TEXT-106 - Exception while using ExtendedMessageFormat and choice format element with quote just
+ * before brace end
*/
@Test
public void testChoiceQuoteJustBeforeBraceEnd_TEXT_106() {
- final String pattern2 = "Message with choice format element with quote just before brace end ''{0,choice,0#0|0<'1'}''";
+ final String pattern2 = "Choice format element with quote just before brace end ''{0,choice,0#0|0<'1'}''";
final ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern2, registry);
- assertEquals("Message with choice format element with quote just before brace end '0'", emf.format(new Object[] {0}));
- assertEquals("Message with choice format element with quote just before brace end '1'", emf.format(new Object[] {1}));
+ assertEquals("Choice format element with quote just before brace end '0'", emf.format(new Object[] {0}));
+ assertEquals("Choice format element with quote just before brace end '1'", emf.format(new Object[] {1}));
}
/**