List parse()

in src/main/java/org/apache/sling/launchpad/base/impl/bootstrapcommands/BootstrapCommandFile.java [133:154]


    List<Command> parse(InputStream is) throws IOException {
        final List<Command> result = new ArrayList<Command>();
        final BufferedReader r = new BufferedReader(new InputStreamReader(is));
        String line = null;
        while( (line = r.readLine()) != null) {
            line = line.trim();
            if(line.length() > 0 && !line.startsWith(COMMENT_PREFIX)) {
                Command toAdd = null;
                for(Command proto : commandPrototypes) {
                    toAdd = proto.parse(line);
                    if(toAdd != null) {
                        break;
                    }
                }
                if (toAdd == null) {
                    throw new Command.ParseException("Invalid command '" + line + "'");
                }
                result.add(toAdd);
            }
        }
        return result;
    }