use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class JSONTMLImpl method parseArrayMessageElement.
private void parseArrayMessageElement(Message arrayMessage, JsonParser jp) throws Exception {
Message m = NavajoFactory.getInstance().createMessage(arrayMessage.getRootDoc(), arrayMessage.getName());
arrayMessage.addElement(m);
if (jp.getCurrentToken() == JsonToken.START_OBJECT) {
// Array with sub message structure
parse(arrayMessage.getRootDoc(), m, jp);
} else {
String name = jp.getCurrentName();
String value = jp.getText();
parseProperty(name, value, m, jp);
}
}
use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class JSONTMLImpl method parse.
private Navajo parse(JsonParser jp) throws Exception {
Navajo n = NavajoFactory.getInstance().createNavajo();
Message parent = NavajoFactory.getInstance().createMessage(n, (topLevelMessageName != null ? topLevelMessageName : "Request"));
boolean first = true;
while (jp.nextToken() != null) {
if (first) {
n.addMessage(parent);
first = false;
}
parse(n, parent, jp);
}
return n;
}
use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class BasePropertyImpl method getEvaluatedValue.
public final Object getEvaluatedValue() {
Operand o;
// No evaluator present.
if (NavajoFactory.getInstance().getExpressionEvaluator() == null) {
return null;
}
try {
try {
if (!EXPRESSION_PROPERTY.equals(getType())) {
throw NavajoFactory.getInstance().createNavajoException("Can only evaluate expression type properties!");
}
try {
o = NavajoFactory.getInstance().getExpressionEvaluator().evaluate(getValue(), getRootDoc(), null, getParentMessage(), null);
evaluatedType = o.type;
return o.value;
} catch (Throwable e) {
logger.info("Exception while evaluating property: {} expression: {}", getFullPropertyName(), getValue());
return null;
}
} catch (NavajoException ex) {
logger.error("Error: ", ex);
if (myParent != null) {
Message pp = myParent.getArrayParentMessage();
if (pp != null && Message.MSG_TYPE_ARRAY.equals(pp.getType())) {
Message def = pp.getDefinitionMessage();
if (def != null) {
Property ppp = def.getProperty(getName());
if (ppp != null) {
evaluatedType = ppp.getType();
return null;
}
}
}
}
evaluatedType = "string";
return null;
}
} catch (Throwable ex1) {
evaluatedType = "string";
return null;
}
}
use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class BaseNavajoImpl method mask.
@Override
public Navajo mask(Navajo with, String method) {
// Find duplicate messages.
List<Message> superMessages = this.getAllMessages();
List<Message> subMessages = with.getAllMessages();
for (int i = 0; i < superMessages.size(); i++) {
Message superMsg = superMessages.get(i);
for (int j = 0; j < subMessages.size(); j++) {
Message subMsg = subMessages.get(j);
if (superMsg.getName().equals(subMsg.getName())) {
boolean matchMethod = method.equals("") || superMsg.getMethod().equals("") || subMsg.getMethod().equals("") || superMsg.getMethod().equals(method);
if (!matchMethod) {
this.removeMessage(superMsg);
}
// Found duplicate!
superMsg.maskMessage(subMsg, method);
}
}
}
// Find new messages.
for (int i = 0; i < subMessages.size(); i++) {
Message subMsg = subMessages.get(i);
boolean newMsg = true;
for (int j = 0; j < superMessages.size(); j++) {
Message superMsg = superMessages.get(j);
if (superMsg.getName().equals(subMsg.getName())) {
newMsg = false;
j = superMessages.size() + 1;
}
}
if (newMsg) {
this.addMessage(subMsg.copy(this));
}
}
return this;
}
use of com.dexels.navajo.document.Message in project navajo by Dexels.
the class BaseNavajoImpl method getProperties.
@Override
public List<Property> getProperties(String s) {
List<Property> props = new ArrayList<>();
Property prop = null;
List<Message> messages = null;
String property = null;
Message message = null;
StringTokenizer tok = new StringTokenizer(s, Navajo.MESSAGE_SEPARATOR);
String messageList = "";
int count = tok.countTokens();
for (int i = 0; i < count - 1; i++) {
property = tok.nextToken();
messageList += property;
if ((i + 1) < count - 1)
messageList += Navajo.MESSAGE_SEPARATOR;
}
String realProperty = tok.nextToken();
messages = this.getMessages(messageList);
for (int i = 0; i < messages.size(); i++) {
message = messages.get(i);
prop = message.getProperty(realProperty);
if (prop != null)
props.add(prop);
}
return props;
}
Aggregations