Dave
Dave

Reputation: 19150

How in Java do I parse a Spring expression language-like array?

I’m using Spring 3.2.11.RELEASE and Java 6 (not an option to upgrade Java at this time). I’m writing my own annotation, in which one of the expressions could be expressed as a SpEL-like array …

key="{'org.mainco.subco.example.repo.MyDao', 'getExamples’}”

My question is, how, in Java, do I parse this into a String[] array? I figure there is already some pre-existing logic that Spring provides that will prevent me from having to write complex regular expressions to parse the text.

Upvotes: 1

Views: 667

Answers (1)

Stefan Ortgies
Stefan Ortgies

Reputation: 294

not sure if this works with Spring 3.2.11, tested it only with version 4.2.6.

String[] params = new SpelExpressionParser().parseExpression("{'foo', 'bar'}").getValue(String[].class);

Good luck!

Upvotes: 1

Related Questions