s_logger.debug("read(query=\"" + query +"\")");
}
if (query.getWhere() == null || query.getWhere().getOrdinal() != EqualsOperator.ORDINAL)
{
throw new InvalidQueryException("err.persistence.file.query");
}
ComparisonOperator op = (ComparisonOperator)query.getWhere();
AttributeOperator aop;
ConstantOperator con;
if (op.getLeft().getOrdinal() == AttributeOperator.ORDINAL)
{
aop = (AttributeOperator)op.getLeft();
}
else if (op.getRight().getOrdinal() == AttributeOperator.ORDINAL)
{
aop = (AttributeOperator)op.getRight();
}
else
{
throw new InvalidQueryException("err.persistence.file.query");
}
if (op.getLeft().getOrdinal() == ConstantOperator.ORDINAL)
{
con = (ConstantOperator)op.getLeft();
}
else if (op.getRight().getOrdinal() == ConstantOperator.ORDINAL)
{
con = (ConstantOperator)op.getRight();
}
else
{
throw new InvalidQueryException("err.persistence.file.query");
}
OID oid;
/*
* Two kinds of queries:
* 1) Lookup by equating a class to an OID.
* 2) Lookup by equating name field to a string.
*/
if (aop.getType() instanceof Metaclass)
{
if(con.getValue() instanceof OIDHolder)
{
oid = ((OIDHolder)con.getValue()).getOID();
}
else
{
throw new InvalidQueryException("err.persistence.file.query");
}
}
else
{
if (con.getType() == Primitive.STRING)
{
oid = new OID(new Object[]{con.getValue()});
}
else
{
throw new InvalidQueryException("err.persistence.file.query");
}
}
String sDataFileName = mapOIDToFile(oid);