コード例 #1
0
ファイル: Album.java プロジェクト: Tobiaswk/ophelia
 static Album albumFromElement(DomElement element, String artistName) {
   if (element == null) return null;
   Album album = new Album(null, null, artistName);
   MusicEntry.loadStandardInfo(album, element);
   if (element.hasChild("id")) {
     album.id = element.getChildText("id");
   }
   if (element.hasChild("artist")) {
     album.artist = element.getChild("artist").getChildText("name");
     if (album.artist == null) album.artist = element.getChildText("artist");
   }
   if (element.hasChild("releasedate")) {
     try {
       album.releaseDate = RELEASE_DATE_FORMAT.parse(element.getChildText("releasedate"));
     } catch (ParseException e) {
       // uh oh
     }
   }
   if (element.hasChild("toptags")) {
     for (DomElement o : element.getChild("toptags").getChildren("tag")) {
       album.tags.add(o.getChildText("name"));
     }
   }
   return album;
 }
コード例 #2
0
ファイル: Image.java プロジェクト: vohoangan123456/mirlastfm
 static Image imageFromElement(DomElement e) {
   Image i = new Image();
   i.title = e.getChildText("title");
   i.url = e.getChildText("url");
   i.format = e.getChildText("format");
   try {
     i.dateAdded = DATE_ADDED_FORMAT.parse(e.getChildText("dateadded"));
   } catch (ParseException e1) {
     e1.printStackTrace();
   }
   DomElement owner = e.getChild("owner");
   if (owner != null) i.owner = owner.getChildText("name");
   DomElement votes = e.getChild("votes");
   if (votes != null) {
     i.thumbsUp = Integer.parseInt(votes.getChildText("thumbsup"));
     i.thumbsDown = Integer.parseInt(votes.getChildText("thumbsdown"));
   }
   DomElement sizes = e.getChild("sizes");
   for (DomElement image : sizes.getChildren("size")) {
     // code copied from ImageHolder.loadImages
     String attribute = image.getAttribute("name");
     ImageSize size;
     if (attribute == null)
       size = ImageSize.MEDIUM; // workaround for image responses without size attr.
     else size = ImageSize.valueOf(attribute.toUpperCase(Locale.ENGLISH));
     i.imageUrls.put(size, image.getText());
   }
   return i;
 }