private String annotateConstants(String text)
{
Matcher rootMatch = CALL_REGEX.matcher(text);
String pack, method, fullCall;
JsonNode listNode;
StringBuffer out = new StringBuffer(text.length());
StringBuffer innerOut;
// search with regex.
while (rootMatch.find())
{
// helper variables
fullCall = rootMatch.group();
pack = rootMatch.group(1);
method = rootMatch.group(2);
Matcher constantMatcher = CONSTANT_REGEX.matcher(fullCall);
innerOut = new StringBuffer(fullCall.length());
// search for hardcoded numbers
while (constantMatcher.find())
{
// helper variables and return variable.
String constant = constantMatcher.group();
String answer = null;
// iterrate over the JSON
for (JsonNode group : json.getElements())
{
// the list part object
listNode = group.getElements().get(0);
// ensure that the package and method are defined
if (listNode.isNode(pack) && jsonArrayContains(listNode.getArrayNode(pack), method))
{
// now the map part object
listNode = group.getElements().get(1);
// itterrate through the map.
for (Map.Entry<JsonStringNode, JsonNode> entry : listNode.getFields().entrySet())
{
// find the actual constant for the number from the regex
if (entry.getValue().isNode(constant))
{
// construct the final line