package dasherJava.core.alphabets.xml; import java.util.ArrayList; import java.util.List; import dasherJava.core.alphabets.actions.Action; import dasherJava.core.alphabets.actions.Action.TextCharAction; class Node { private final String label; private final int trainingUnicode; private final float fixedProbability; private final Group group; private final List actions = new ArrayList<>(); Node(String label, int trainingUnicode, float fixedProbability, Group group) { this.label=label; this.trainingUnicode=trainingUnicode; this.fixedProbability=fixedProbability; this.group=group; } String getLabel() { return label; } int getTrainingUnicode() { if (trainingUnicode>=0) return trainingUnicode; //if unspecified, infer from the first TextCharAction if present for (Action action : actions) { if (action instanceof TextCharAction) { TextCharAction textCharAction = (TextCharAction) action; return textCharAction.getUnicode(); } } //otherwise infer from the label if it consists of exactly one Unicode character if (label!=null && label.length()==1) return label.codePointAt(0); return -1; //error } float getFixedProbability() { return fixedProbability; } Group getGroup() { return group; } List getActions() { return actions; } void addAction(Action action) { actions.add(action); } }