baseLength = baseName.length();
}
final String combinedName = mailboxExpression.getCombinedName()
.replace(freeWildcard, SQL_WILDCARD_CHAR)
.replace(localWildcard, SQL_WILDCARD_CHAR);
final MailboxPath search = new MailboxPath(mailboxExpression.getBase(), combinedName);
final MailboxMapper<Id> mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
final List<Mailbox<Id>> mailboxes = mapper.findMailboxWithPathLike(search);
final List<MailboxMetaData> results = new ArrayList<MailboxMetaData>(mailboxes.size());
for (Mailbox<Id> mailbox: mailboxes) {
final String name = mailbox.getName();
if (name.startsWith(baseName)) {
final String match = name.substring(baseLength);
if (mailboxExpression.isExpressionMatch(match)) {
final MailboxMetaData.Children inferiors;
if (mapper.hasChildren(mailbox, session.getPathDelimiter())) {
inferiors = MailboxMetaData.Children.HAS_CHILDREN;
} else {
inferiors = MailboxMetaData.Children.HAS_NO_CHILDREN;
}
MailboxPath mailboxPath = new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), name);
results.add(new SimpleMailboxMetaData(mailboxPath, getDelimiter(), inferiors, Selectability.NONE));
}
}
}
Collections.sort(results, new StandardMailboxMetaDataComparator());