/** * Return the informations contains in the PrjElement in parameter if it is * a PrjStringParameter. * * @param e the PrjElement to parse */ private String getString(PrjElement e) { if (e instanceof PrjStringElement) { PrjStringElement s = (PrjStringElement) e; return s.getValue().trim(); } throw new PrjParserException("Failed to parse PRJ. Found '" + e + "', expected some PrjStringElement."); }
/** * Parses a String information into its PrjStringElement representation. * * @param s the Buffer to parse */ private PrjStringElement parseString(CharBuffer s) { int start = s.position(); int ll = 0; while (s.hasRemaining()) { char c = s.get(); if (c == '"') { break; } else { ll++; } } s.position(start); String str = s.subSequence(0, ll).toString(); s.position(start + ll + 1); return new PrjStringElement(str); }
} else { s.position(s.position() - 1); return new PrjStringElement(name);
/** * Read the informations contains in the PrjElement in parameter if it is a * PrjStringParameter and put it into the set of parameters. * * @param e the PrjElement to parse * @param name the key to use to put the string in the Map of parameters */ private void parseString(PrjElement e, String name) { if (e instanceof PrjStringElement) { PrjStringElement s = (PrjStringElement) e; params.put(name, s.getValue().trim()); } else { throw new PrjParserException("Failed to parse PRJ. Found '" + e + "', expected PrjStringElement with " + name + " in it."); } }