use of org.structr.web.common.microformat.MicroformatParser in project structr by structr.
the class ParseFunction method apply.
@Override
public Object apply(final ActionContext ctx, final Object caller, final Object[] sources) {
if (sources != null && sources.length == 2) {
try {
final String source = sources[0].toString();
final String selector = sources[1].toString();
final List<Map<String, Object>> objects = new MicroformatParser().parse(source, selector);
final List<GraphObjectMap> elements = new LinkedList<>();
for (final Map<String, Object> map : objects) {
final GraphObjectMap obj = new GraphObjectMap();
elements.add(obj);
recursivelyConvertMapToGraphObjectMap(obj, map, 0);
}
return elements;
} catch (Throwable t) {
logException(caller, t, sources);
}
return "";
} else {
logParameterError(caller, sources, ctx.isJavaScriptContext());
}
return usage(ctx.isJavaScriptContext());
}
Aggregations