use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class BasePropertyImpl method setAllSelected.
public final void setAllSelected(boolean b) {
for (int i = 0; i < selectionList.size(); i++) {
Selection current = selectionList.get(i);
current.setSelected(b);
}
}
use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class BaseNavajoImpl method getSelection.
@Override
public Selection getSelection(String property) {
Selection sel = null;
Property prop = null;
StringTokenizer tok = new StringTokenizer(property, Navajo.MESSAGE_SEPARATOR);
Message message = null;
int count = tok.countTokens();
int index = 0;
while (tok.hasMoreElements()) {
property = tok.nextToken();
// Check if last message/property reached.
if (index == (count - 1)) {
// Reached property field.
if (message != null) {
// Check if name contains ":", which denotes a selection.
if (property.indexOf(':') != -1) {
StringTokenizer tok2 = new StringTokenizer(property, ":");
String propName = tok2.nextToken();
String selName = tok2.nextToken();
prop = message.getProperty(propName);
sel = prop.getSelection(selName);
} else {
// Does not contain a selection option.
return null;
}
}
} else {
// Descent message tree.
if (// First message.
index == 0)
message = this.getMessage(property);
else // Subsequent messages.
if (message == null)
return null;
else
message = message.getMessage(property);
}
index++;
}
return sel;
}
use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class TestSelection method testIsSelectedWithObject0.
@Test
public void testIsSelectedWithObject0() {
Selection selectionRet = NavajoFactory.getInstance().createSelection(testDoc, "firstselection", "0", Integer.valueOf(1));
selectionRet.setValue("1");
Assert.assertTrue(selectionRet.isSelected());
}
use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class TestSelection method testIsSelectedWithObject4.
@Test
public void testIsSelectedWithObject4() {
Selection selectionRet = NavajoFactory.getInstance().createSelection(testDoc, "firstselection", "0", Boolean.valueOf(false));
selectionRet.setValue("1");
Assert.assertTrue(!selectionRet.isSelected());
}
use of com.dexels.navajo.document.Selection in project navajo by Dexels.
the class ArraySelection method evaluate.
@Override
public Object evaluate() throws com.dexels.navajo.expression.api.TMLExpressionException {
if (getOperands().size() < 3) {
throw new TMLExpressionException(this, usage());
}
String messageName = getStringOperand(0);
String propertyName = getStringOperand(1);
String valuePropertyName = getStringOperand(2);
// Message parent = getCurrentMessage();
Navajo doc = getNavajo();
Message array = doc.getMessage(messageName);
if (array == null) {
throw new TMLExpressionException(this, "Empty or non existing array message: " + messageName);
}
List<Message> arrayMsg = array.getAllMessages();
List<Selection> result = new ArrayList<Selection>();
if (arrayMsg == null) {
throw new TMLExpressionException(this, "Empty or non existing array message: " + messageName);
}
for (int i = 0; i < arrayMsg.size(); i++) {
Message m = arrayMsg.get(i);
Property p = m.getProperty(propertyName);
Property val = m.getProperty(valuePropertyName);
Selection s = NavajoFactory.getInstance().createSelection(doc, "" + p.getTypedValue(), "" + val.getTypedValue(), false);
result.add(s);
}
return result;
}
Aggregations