/** * Return the children of the PrjElement in parameter if it is an instance * of PrjNodeElement and if its name is the same as the name given in * parameter,else it throws a PrjParserException unless strict is false, it * then returns null. * * @param e the PrjElement to match * @param name the name of the desired PrjElement * @param strict true if the method must throw an exception instead of * return null */ private List<PrjElement> matchNode(PrjElement e, String name, boolean strict) { if (e instanceof PrjNodeElement) { PrjNodeElement n = (PrjNodeElement) e; if (n.getName().equalsIgnoreCase(name)) { return n.getChildren(); } } if (strict) { throw new PrjParserException("Failed to parse PRJ. Found '" + e + "', expected PrjNodeElement[" + name + "]."); } else { return null; } }
/** * Read the informations contains in the PrjElement in parameter using one * of the PrjNodeMatcher in parameter and put it into the set of parameters. * * @param e the PrjElement to parse * @param nn the PrjNodeMatcher to use to parse the given PrjElement * @param strict if true, the method throw a PrjParserException if it does * not manage to parse the PrjElement in parameter */ private void matchAnyNode(PrjElement e, PrjNodeMatcher[] nn, boolean strict) { if (e instanceof PrjNodeElement) { PrjNodeElement ne = (PrjNodeElement) e; for (PrjNodeMatcher m : nn) { if (ne.getName().equalsIgnoreCase(m.getName())) { m.run(ne.getChildren()); return; } } } if (strict) { throw new PrjParserException("Failed to parse PRJ. Found '" + e + "', completely unexpected!"); } }