@Override public Item item(final QueryContext qc, final InputInfo ii) throws QueryException { final String name = string(toToken(exprs[0], qc)); if (!Databases.validName(name)) throw BXDB_NAME_X.get(info, name); if (!qc.context.soptions.dbExists(name)) throw BXDB_WHICH_X.get(info, name); qc.resources.updates().add(new BackupCreate(name, info, qc), qc); return null; }
/** * Parses and returns a glob expression, which extends {@link #name(Cmd)} function with asterisks, * question marks and commands. * * @param cmd referring command; if specified, the result must not be empty * @return glob expression * @throws QueryException query exception */ private String glob(final Cmd cmd) throws QueryException { consumeWS(); final StringBuilder sb = new StringBuilder(); while (true) { final char ch = parser.curr(); if (!Databases.validChar(ch) && ch != '*' && ch != '?' && ch != ',') { return finish(eoc() || ws(ch) ? sb : null, cmd); } sb.append(parser.consume()); } }
/** * Parses and returns a name. A name may contain letters, numbers and any of the special * characters <code>!#$%&'()+-=@[]^_`{}~</code>. * * @param cmd referring command; if specified, the result must not be empty * @return name * @throws QueryException query exception */ private String name(final Cmd cmd) throws QueryException { consumeWS(); final StringBuilder sb = new StringBuilder(); while (Databases.validChar(parser.curr())) sb.append(parser.consume()); return finish(eoc() || ws(parser.curr()) ? sb : null, cmd); }