Commit 2929ab7e authored by Nico Mack's avatar Nico Mack

Replaced splitter by regex matcher to extract variables from trigger

condition
parent 27b373d4
......@@ -32,8 +32,6 @@ import lu.list.itis.dkd.tui.cps.variable.Variable;
import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.utility.Externalization;
import com.google.common.base.Splitter;
import org.jdom2.Element;
import java.awt.Graphics2D;
......@@ -43,6 +41,8 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Base64;
import java.util.LinkedHashSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.imageio.ImageIO;
import javax.sound.sampled.AudioFormat;
......@@ -80,6 +80,8 @@ public class Scene extends Content {
private AudioInputStream audioStream;
private boolean isPlaying;
private static final Pattern VARIABLE_PATTERN = Pattern.compile("([a-z0-9\\_]+)", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
/**
* Constructor initializing all fields.
*
......@@ -97,13 +99,14 @@ public class Scene extends Content {
final String triggerCondition = element.getChildText(Externalization.TRIGGER_CONDITION_NODE);
for (final String _name : Splitter.on(Externalization.SPACE).trimResults().omitEmptyStrings().split(triggerCondition)) {
// System.out.println(_name);
final Matcher variableMatcher = VARIABLE_PATTERN.matcher(triggerCondition);
while (variableMatcher.find()) {
final String _name = variableMatcher.group(1);
final Variable variable = Scenario.retrieveVariableByName(_name);
if (null != variable) {
variables.add(variable);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment