LinkedHashMap<String, Object> typing = new LinkedHashMap<String, Object>();
Set<String> columnNames = new HashSet<String>();
for (ColumnDesc column : columns) {
boolean added = columnNames.add(column.getName());
if (!added) {
throw new ExprValidationException("Duplicate column name '" + column.getName() + "'");
}
Class plain = JavaClassHelper.getClassForSimpleName(column.getType());
if (plain != null) {
if (column.isArray()) {
plain = Array.newInstance(plain, 0).getClass();
}
typing.put(column.getName(), plain);
}
else {
// try imports first
Class resolved = null;
try {
resolved = engineImportService.resolveClass(column.getType());
}
catch (EngineImportException e) {
// expected
}
// resolve from classpath when not found
if (resolved == null) {
try {
resolved = JavaClassHelper.getClassForName(column.getType());
}
catch (ClassNotFoundException e) {
// expected
}
}
// Handle resolved classes here
if (resolved != null) {
if (column.isArray()) {
resolved = Array.newInstance(resolved, 0).getClass();
}
typing.put(column.getName(), resolved);
}
// Event types fall into here
else {
if (column.isArray()) {
typing.put(column.getName(), column.getType() + "[]");
}
else {
typing.put(column.getName(), column.getType());
}
}
}
}
if (copyFrom != null && !copyFrom.isEmpty()) {
for (String copyFromName : copyFrom) {
EventType type = eventAdapterService.getExistsTypeByName(copyFromName);
if (type == null) {
throw new ExprValidationException("Type by name '" + copyFromName + "' could not be located");
}
mergeType(typing, type);
}
}
return typing;