You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been playing with jmapper (I love it!). However I've hit an issue I think is probably easy to solve.
I have an XML conversion configured to help out when converting between two JAXB2 generated classes. My conversion looks a little like this (package name redacted):
<class name=".....FlightLeg">
<global></global>
<conversion name="durationConversion" from="legDuration" to="legDuration" type="STATIC">
${destination.type} result = new ${destination.type}();
result.setMeasure(${source}.getMeasure());
return result;
</conversion>
</class>
When the jmapping config gets written by jmapper (version 1.3.3.1) I get: ERROR com.googlecode.jmapper.JMapper - IllegalArgumentException: Illegal group reference
I've traced the issue to com.googlecode.jmapper.util.GeneralUtility line 389, specifically the replaceAll operation. It looks like the var.getValue() (in my case replacing the mapping placeholder) string contains a $. As the second argument for the replaceAll function is also a REGEX (see https://stackoverflow.com/questions/11913709/why-does-replaceall-fail-with-illegal-group-reference) this causes the exception. The dollar needs to be escaped, or alternatively (from the String#replaceAll javadoc):
"Note that backslashes () and dollar signs ($) in the replacement string may cause the results to be different than if it were being treated as a literal replacement string; see Matcher.replaceAll. Use Matcher.quoteReplacement(java.lang.String) to suppress the special meaning of these characters, if desired."
I hope that helps you track the error. I'd love to recommend jmapper use in my project, it's a great innovation. If you need any more data please get in touch.