if (path == null || path.length() == 0 || path.equals("/")) {
isRoot = true;
return;
}
Database db = getDatabase(path);
if (db == null) {
collection = null;
name = null;
return;
}
StringBuffer buf = new StringBuffer(path);
// strip database name
String dbName = db.getName();
buf.delete(0, dbName.length() + 1);
Collection col;
if (buf.length() == 0 || (buf.length() == 1 && buf.charAt(0) == '/')) {
col = db;
} else {
col = db.getCollection(buf.toString());
}
String resourceName = null;
if (col == null) { // no collection found -> try resource
if (buf.charAt(buf.length() - 1) == '/') {
buf.deleteCharAt(buf.length() - 1);
}
int split = buf.lastIndexOf("/");
resourceName = buf.substring(split + 1, buf.length());
String colPath = buf.substring(0, split);
if (colPath.length() > 0) {
col = db.getCollection(colPath);
} else {
col = db;
}
}