示例#1
0
 public void parseImages(ImageBuilderFactory imageBuilderFactory) {
   int imageCounter = 0;
   while (true) {
     String imagePrefix = "/Images/" + imageCounter++;
     String imageId = getString(imagePrefix + "/ID", null);
     if (imageId == null) {
       break;
     }
     String albumId = getString(imagePrefix + "/Album", null);
     String key = getString(imagePrefix + "/Key", null);
     String title = getString(imagePrefix + "/Title", null);
     String description = getString(imagePrefix + "/Description", null);
     Long creationTime = getLong(imagePrefix + "/CreationTime", null);
     Integer width = getInt(imagePrefix + "/Width", null);
     Integer height = getInt(imagePrefix + "/Height", null);
     if (albumAttributesAreInvalid(
         albumId, key, title, description, creationTime, width, height)) {
       throw new InvalidImageFound();
     }
     Album album = albums.get(albumId);
     if (album == null) {
       throw new InvalidParentAlbumFound(albumId);
     }
     Image image =
         imageBuilderFactory
             .newImageBuilder()
             .withId(imageId)
             .build()
             .modify()
             .setSone(sone)
             .setCreationTime(creationTime)
             .setKey(key)
             .setTitle(title)
             .setDescription(description)
             .setWidth(width)
             .setHeight(height)
             .update();
     album.addImage(image);
     images.put(image.getId(), image);
   }
 }