/** * Returns the value of the specified attribute or {@code null}. * @param name attribute to be found * @return attribute value */ public byte[] attribute(final byte[] name) { return attribute(new QNm(name)); }
/** * Returns the value of the specified attribute or {@code null}. * @param name attribute to be found * @return attribute value */ public byte[] attribute(final byte[] name) { return attribute(new QNm(name)); }
/** * Returns the value of the requested attribute, or an error. * @param pref error prefix * @param node node * @param name attribute name * @return value * @throws BaseXException database exception */ public static byte[] attribute(final String pref, final ANode node, final byte[] name) throws BaseXException { final byte[] value = node.attribute(name); if(value != null) return value; throw new BaseXException("%: Missing \"%\" attribute.", pref, name); }
/** * Returns the value of the requested attribute, or an error. * @param pref error prefix * @param node node * @param name attribute name * @return value * @throws BaseXException database exception */ public static byte[] attribute(final String pref, final ANode node, final byte[] name) throws BaseXException { final byte[] value = node.attribute(name); if(value != null) return value; throw new BaseXException("%: Missing \"%\" attribute.", pref, name); }
/** * Parses <dependency/>. * @param node node <dependency/> to be parsed * @return dependency container */ private PkgDep parseDependency(final ANode node) { final Function<byte[], String> attribute = att -> { final byte[] v = node.attribute(att); return v == null ? null : string(v); }; final PkgDep dep = new PkgDep(attribute.apply(A_PACKAGE)); dep.processor = attribute.apply(A_PROCESSOR); dep.versions = attribute.apply(A_VERSIONS); dep.semver = attribute.apply(A_SEMVER); dep.semverMin = attribute.apply(A_SEMVER_MIN); dep.semverMax = attribute.apply(A_SEMVER_MAX); return dep; }
/** * Parses <dependency/>. * @param node node <dependency/> to be parsed * @return dependency container */ private PkgDep parseDependency(final ANode node) { final Function<byte[], String> attribute = att -> { final byte[] v = node.attribute(att); return v == null ? null : string(v); }; final PkgDep dep = new PkgDep(attribute.apply(A_PACKAGE)); dep.processor = attribute.apply(A_PROCESSOR); dep.versions = attribute.apply(A_VERSIONS); dep.semver = attribute.apply(A_SEMVER); dep.semverMin = attribute.apply(A_SEMVER_MIN); dep.semverMax = attribute.apply(A_SEMVER_MAX); return dep; }
/** * Returns the value of the specified attribute. * @param elm element node * @param name attribute to be found * @param force if set to {@code true}, an exception is thrown if the * attribute is not found * @return attribute value * @throws QueryException query exception */ final String attribute(final ANode elm, final byte[] name, final boolean force) throws QueryException { final byte[] val = elm.attribute(name); if(val == null && force) throw ZIP_INVALID_X_X.get(info, elm.qname(), name); return val == null ? null : string(val); }
/** * Returns the value of the specified attribute. * @param elm element node * @param name attribute to be found * @param force if set to {@code true}, an exception is thrown if the * attribute is not found * @return attribute value * @throws QueryException query exception */ final String attribute(final ANode elm, final byte[] name, final boolean force) throws QueryException { final byte[] val = elm.attribute(name); if(val == null && force) throw ZIP_INVALID_X_X.get(info, elm.qname(), name); return val == null ? null : string(val); }
@Override protected boolean ignore(final ANode node) { if(ct > 0 && node.type == NodeType.ELM && eq(node.name(), META)) { final byte[] value = node.attribute(HTTP_EQUIV); return value != null && eq(trim(value), CONTENT_TYPE); } return false; }
@Override protected boolean ignore(final ANode node) { if(ct > 0 && node.type == NodeType.ELM && eq(node.name(), META)) { final byte[] value = node.attribute(HTTPEQUIV); return value != null && eq(trim(value), CONTENT_TYPE); } return false; }
/** * Parses package descriptor. * @param io XML input * @return package container * @throws QueryException query exception */ public Pkg parse(final IO io) throws QueryException { final ANode node; try { // checks root node node = childElements(new DBNode(new IOContent(io.read()))).next(); if(!eqNS(E_PACKAGE, node.qname())) throw REPO_DESCRIPTOR_X.get(info, Util.info(WHICHELEM, node.qname())); } catch(final IOException ex) { throw REPO_PARSE_X_X.get(info, io.name(), ex); } final QueryFunction<byte[], String> attribute = name -> { final byte[] v = node.attribute(name); if(v == null) throw REPO_DESCRIPTOR_X.get(info, Util.info(MISSATTR, name, E_PACKAGE)); return string(v); }; final Pkg pkg = new Pkg(attribute.apply(A_NAME)); pkg.abbrev = attribute.apply(A_ABBREV); pkg.spec = attribute.apply(A_SPEC); pkg.version = attribute.apply(A_VERSION); parseChildren(node, pkg); return pkg; }
/** * Parses package descriptor. * @param io XML input * @return package container * @throws QueryException query exception */ public Pkg parse(final IO io) throws QueryException { final ANode node; try { // checks root node node = childElements(new DBNode(new IOContent(io.read()))).next(); if(!eqNS(E_PACKAGE, node.qname())) throw REPO_DESCRIPTOR_X.get(info, Util.info(WHICHELEM, node.qname())); } catch(final IOException ex) { throw REPO_PARSE_X_X.get(info, io.name(), ex); } final QueryFunction<byte[], String> attribute = name -> { final byte[] v = node.attribute(name); if(v == null) throw REPO_DESCRIPTOR_X.get(info, Util.info(MISSATTR, name, E_PACKAGE)); return string(v); }; final Pkg pkg = new Pkg(attribute.apply(A_NAME)); pkg.abbrev = attribute.apply(A_ABBREV); pkg.spec = attribute.apply(A_SPEC); pkg.version = attribute.apply(A_VERSION); parseChildren(node, pkg); return pkg; }