use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class Map method invoke.
private static Query invoke(PageContext pc, Query qry, UDF udf, ExecutorService es, List<Future<Data<Object>>> futures, Query rtn) throws PageException {
Key[] colNames = qry.getColumnNames();
if (rtn == null) {
rtn = new QueryImpl(colNames, 0, qry.getName());
} else {
// check if we have the necessary columns
for (Key colName : colNames) {
if (rtn.getColumn(colName, null) == null) {
rtn.addColumn(colName, new ArrayImpl());
}
}
}
final int pid = pc.getId();
ForEachQueryIterator it = new ForEachQueryIterator(qry, pid);
int rowNbr;
Object row, res;
boolean async = es != null;
while (it.hasNext()) {
row = it.next();
rowNbr = qry.getCurrentrow(pid);
res = _inv(pc, udf, new Object[] { row, rowNbr, qry }, rowNbr, es, futures);
if (!async) {
addRow(Caster.toStruct(res), rtn);
}
}
return rtn;
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class ORMExecuteQuery method _call.
private static Object _call(PageContext pc, String hql, Object params, boolean unique, Struct queryOptions) throws PageException {
ORMSession session = ORMUtil.getSession(pc);
String dsn = null;
if (queryOptions != null)
dsn = Caster.toString(queryOptions.get(KeyConstants._datasource, null), null);
if (StringUtil.isEmpty(dsn, true))
dsn = ORMUtil.getDefaultDataSource(pc).getName();
if (params == null)
return toCFML(session.executeQuery(pc, dsn, hql, new ArrayImpl(), unique, queryOptions));
else if (Decision.isStruct(params))
return toCFML(session.executeQuery(pc, dsn, hql, Caster.toStruct(params), unique, queryOptions));
else if (Decision.isArray(params))
return toCFML(session.executeQuery(pc, dsn, hql, Caster.toArray(params), unique, queryOptions));
else if (Decision.isCastableToStruct(params))
return toCFML(session.executeQuery(pc, dsn, hql, Caster.toStruct(params), unique, queryOptions));
else if (Decision.isCastableToArray(params))
return toCFML(session.executeQuery(pc, dsn, hql, Caster.toArray(params), unique, queryOptions));
else
throw new FunctionException(pc, "ORMExecuteQuery", 2, "params", "cannot convert the params to a array or a struct");
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class HTTPClient method call.
@Override
public Object call(PageContext pc, Key methodName, Object[] arguments) throws PageException {
checkFunctionExistence(pc, methodName, false);
if (arguments.length == 0)
return _callWithNamedValues(pc, methodName, new StructImpl());
Struct m = checkFunctionExistence(pc, methodName, true);
Array args = Caster.toArray(m.get(KeyConstants._arguments, null), null);
if (args == null)
args = new ArrayImpl();
Struct sct = new StructImpl(), el;
String name;
for (int i = 0; i < arguments.length; i++) {
if (args.size() > i) {
el = Caster.toStruct(args.get(i + 1, null), null);
if (el != null) {
name = Caster.toString(el.get(KeyConstants._name, null), null);
if (!StringUtil.isEmpty(name)) {
sct.set(name, arguments[i]);
continue;
}
}
}
sct.set("arg" + (i + 1), arguments[i]);
}
return _callWithNamedValues(pc, methodName, sct);
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class MultiPartResponseUtils method getParts.
public static Array getParts(byte[] barr, String contentTypeHeader) throws IOException, PageException {
String boundary = extractBoundary(contentTypeHeader, "");
ByteArrayInputStream bis = new ByteArrayInputStream(barr);
MultipartStream stream;
Array result = new ArrayImpl();
//
stream = new MultipartStream(bis, getBytes(boundary, "UTF-8"));
boolean hasNextPart = stream.skipPreamble();
while (hasNextPart) {
result.append(getPartData(stream));
hasNextPart = stream.readBoundary();
}
return result;
}
use of lucee.runtime.type.ArrayImpl in project Lucee by lucee.
the class MailClient method getContent.
/**
* write content data to query
* @param qry
* @param content
* @param row
* @throws MessagingException
* @throws IOException
*/
private void getContent(Query query, Message message, int row) throws MessagingException, IOException {
StringBuffer body = new StringBuffer();
Struct cids = new StructImpl();
query.setAtEL(CIDS, row, cids);
if (message.isMimeType("text/plain")) {
String content = getConent(message);
query.setAtEL(TEXT_BODY, row, content);
body.append(content);
} else if (message.isMimeType("text/html")) {
String content = getConent(message);
query.setAtEL(HTML_BODY, row, content);
body.append(content);
} else {
Object content = message.getContent();
if (content instanceof MimeMultipart) {
Array attachments = new ArrayImpl();
Array attachmentFiles = new ArrayImpl();
getMultiPart(query, row, attachments, attachmentFiles, cids, (MimeMultipart) content, body);
if (attachments.size() > 0) {
try {
query.setAtEL(ATTACHMENTS, row, ListUtil.arrayToList(attachments, "\t"));
} catch (PageException pageexception) {
}
}
if (attachmentFiles.size() > 0) {
try {
query.setAtEL(ATTACHMENT_FILES, row, ListUtil.arrayToList(attachmentFiles, "\t"));
} catch (PageException pageexception1) {
}
}
}
}
query.setAtEL(BODY, row, body.toString());
}
Aggregations