" FROM " + GMLHSQLIndex.TABLE_NAME + (refine_query_on_doc ? " WHERE " + docConstraint : "")
);
ResultSet rs = null;
try {
rs = ps.executeQuery();
ValueSequence result;
if (contextSet == null)
result = new ValueSequence();
else
result = new ValueSequence(contextSet.getLength());
while (rs.next()) {
DocumentImpl doc = null;
try {
doc = (DocumentImpl)broker.getXMLResource(XmldbURI.create(rs.getString("DOCUMENT_URI")));
} catch (PermissionDeniedException e) {
LOG.debug(e);
//Untested, but that is roughly what should be returned.
if (rs.getMetaData().getColumnClassName(1).equals(Boolean.class.getName())) {
result.add(AtomicValue.EMPTY_VALUE);
} else if (rs.getMetaData().getColumnClassName(1).equals(Double.class.getName())) {
result.add(AtomicValue.EMPTY_VALUE);
} else if (rs.getMetaData().getColumnClassName(1).equals(String.class.getName())) {
result.add(AtomicValue.EMPTY_VALUE);
} else if (rs.getMetaData().getColumnType(1) == java.sql.Types.BINARY) {
result.add(AtomicValue.EMPTY_VALUE);
} else
throw new SQLException("Unable to make an atomic value from '" + rs.getMetaData().getColumnClassName(1) + "'");
//Ignore since the broker has no right on the document
continue;
}
if (contextSet.getDocumentSet().contains(doc.getDocId())) {
NodeId nodeId = new DLN(rs.getInt("NODE_ID_UNITS"), rs.getBytes("NODE_ID"), 0);
NodeProxy p = new NodeProxy(doc, nodeId);
//Node is in the context : check if it is accurate
//contextSet.contains(p) would have made more sense but there is a problem with
//VirtualNodeSet when on the DESCENDANT_OR_SELF axis
if (contextSet.get(p) != null) {
if (rs.getMetaData().getColumnClassName(1).equals(Boolean.class.getName())) {
result.add(new BooleanValue(rs.getBoolean(1)));
} else if (rs.getMetaData().getColumnClassName(1).equals(Double.class.getName())) {
result.add(new DoubleValue(rs.getDouble(1)));
} else if (rs.getMetaData().getColumnClassName(1).equals(String.class.getName())) {
result.add(new StringValue(rs.getString(1)));
} else if (rs.getMetaData().getColumnType(1) == java.sql.Types.BINARY) {
result.add(BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(), new ByteArrayInputStream(rs.getBytes(1))));
} else
throw new SQLException("Unable to make an atomic value from '" + rs.getMetaData().getColumnClassName(1) + "'");
}
}
}