Пример #1
0
 /**
  * getMovieInformation gets the movie description, the poster link, and the actors from the list
  * of movies as the parameter. They are returned in an ArrayList<Movie> as movie objects, which
  * you will be able to get all the movies information.
  *
  * @author defq0n
  * @param movieList is a multidimensional array from getMovieListInformation.
  * @return movieArray a ArrayList containing Movie objects.
  */
 private static ArrayList<Movie> getMovieInformation(String[][] movieList) {
   ArrayList<Movie> movieArray = new ArrayList<>();
   for (int i = 0; i < movieList[0].length; i++) {
     if (!movieList[3][i].equals("")) {
       if (movieList[3][i].toLowerCase().contains("movie")) {
         Movie tempMovie = new Movie(movieList[1][i]);
         String pageLink = movieList[0][i];
         tempMovie.setPageLink(pageLink);
         tempMovie.setMovieYear(movieList[2][i]);
         tempMovie.setMovieDescription(getMovieDescription(pageLink));
         tempMovie.setPosterLink(getPosterLink(pageLink));
         tempMovie.setActors(getMovieActors(pageLink));
         tempMovie.setGenre(getGenre(pageLink));
         tempMovie.setTrailerLink(getTrailer(tempMovie));
         movieArray.add(tempMovie);
       }
     }
   }
   return movieArray;
 }
Пример #2
0
  public static Movie parseMovie(Document doc) {
    LOGGER.info("Parsing movie");
    Movie movie = new Movie();

    Element root = doc.getDocumentElement();
    movie.setTitle(getTagValue("title", root));
    movie.setCountry(getTagValue("country", root));
    movie.setGenre(getTagValue("genre", root));
    movie.setSummary(getTagValue("summary", root));
    movie.setYear(getTagValue("year", root));

    NodeList nList = doc.getElementsByTagName("director");

    for (int i = 0; i < nList.getLength(); i++) {
      Node node = nList.item(i);
      if (node.getNodeType() == Node.ELEMENT_NODE) {
        Element directorElement = (Element) node;
        Person director = parsePerson(directorElement);
        movie.setDirector(director);
      }
    }

    nList = doc.getElementsByTagName("actor");

    for (int i = 0; i < nList.getLength(); i++) {
      Node node = nList.item(i);
      if (node.getNodeType() == Node.ELEMENT_NODE) {
        Element actorElement = (Element) node;
        Person actor = parsePerson(actorElement);
        String role = getTagValue("role", actorElement);
        movie.addActor(actor, role);
      }
    }

    return movie;
  }