Пример #1
0
  private static void printSubjectEntry(Subject se) {

    if (se == null) return;
    if (se.getSummary() != null) System.out.println("summary is " + se.getSummary().getPlainText());
    System.out.println("author is " + se.getAuthors().get(0).getName());
    System.out.println("title is " + se.getTitle().getPlainText());

    for (Attribute attr : se.getAttributes()) {
      System.out.println(attr.getName() + " : " + attr.getContent());
    }
    System.out.println("id is " + se.getId());
    for (Tag tag : se.getTags()) {
      System.out.println(tag.getName() + " : " + tag.getCount());
    }

    Rating rating = se.getRating();
    if (rating != null)
      System.out.println(
          "max is "
              + rating.getMax()
              + " min is "
              + rating.getMin()
              + " numRaters is "
              + rating.getNumRaters()
              + " average is "
              + rating.getAverage());
    System.out.println("********************");
  }
Пример #2
0
  private static void testWriteCollectionEntry(DoubanService myService) {
    try {
      CollectionEntry ce;

      Rating rating = new Rating();
      rating.setValue(4);

      ArrayList<Tag> tags = new ArrayList<Tag>(2);
      Tag t1 = new Tag();
      t1.setName("顾长卫");
      Tag t2 = new Tag();
      t2.setName("李樯");

      tags.add(t1);
      tags.add(t2);

      String movieId = "3036997"; // 立春(And the Spring Comes)
      SubjectEntry se = myService.getMovie(movieId);
      ce = myService.createCollection(new Status("watched"), se, tags, rating);

      printCollectionEntry(ce);

      myService.deleteCollection(ce);
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ServiceException e) {
      e.printStackTrace();
    }
  }
Пример #3
0
  private static void printCollectionEntry(CollectionEntry ce) {

    System.out.println("id is " + ce.getId());
    System.out.println("title is " + ce.getTitle().getPlainText());
    if (!ce.getAuthors().isEmpty()) {
      System.out.println("author name is : " + ce.getAuthors().get(0).getName());
      System.out.println("author URI is : " + ce.getAuthors().get(0).getUri());
    }
    System.out.println("status is " + ce.getStatus().getContent());

    printSubjectEntry(ce.getSubjectEntry());

    Rating rating = ce.getRating();
    if (rating != null)
      System.out.println(
          "max is "
              + rating.getMax()
              + " min is "
              + rating.getMin()
              + " value is "
              + rating.getValue()
              + " numRaters is "
              + rating.getNumRaters()
              + " average is "
              + rating.getAverage());
    System.out.println("Tags:");
    for (Tag tag : ce.getTags()) {
      System.out.println(tag.getName());
    }
  }