Package de.umass.xml

Examples of de.umass.xml.DomElement


    Result result = Caller.getInstance()
        .call("radio.getPlaylist", session, "discovery", String.valueOf(discovery), "rtp", String.valueOf(rtp));
//    Result result = Caller.getInstance().call("radio.getPlaylist", session);
    if (!result.isSuccessful())
      return null;
    DomElement root = result.getContentElement();
    for (DomElement e : root.getChildren("link")) {
      if ("http://www.last.fm/expiry".equals(e.getAttribute("rel"))) {
        this.expiry = Integer.parseInt(e.getText());
        break;
      }
    }
View Full Code Here


    link.search = "1".equals(element.getChildText("isSearch"));
    link.icon = element.getChildText("supplierIcon");
    if (link.icon != null && link.icon.length() == 0)
      link.icon = null;
    if (element.hasChild("price")) {
      DomElement child = element.getChild("price");
      link.currency = child.getChildText("currency");
      link.price = Double.parseDouble(child.getChildText("amount"));
    }
    return link;
  }
View Full Code Here

    }
    MapUtilities.nullSafePut(params, "limit", limit);
    Result result = Caller.getInstance().call(method, apiKey, params);
    if (!result.isSuccessful())
      return null;
    DomElement element = result.getContentElement();
    Collection<DomElement> children = element.getChildren(target);
    Collection collection = new ArrayList(children.size());
    boolean targetArtist = "artist".equals(target);
    boolean targetTrack = "track".equals(target);
    boolean targetAlbum = "album".equals(target);
    for (DomElement domElement : children) {
      if (targetArtist)
        collection.add(ResponseBuilder.buildItem(domElement, Artist.class));
      if (targetTrack)
        collection.add(ResponseBuilder.buildItem(domElement, Track.class));
      if (targetAlbum)
        collection.add(ResponseBuilder.buildItem(domElement, Album.class));
    }
    long fromTime = 0;
    long toTime = 0;
    // workaround for geo.getMetroXXX methods, since they don't have from & to attributes if no dates were given upon calling
    if (element.hasAttribute("from")) {
      fromTime = 1000 * Long.parseLong(element.getAttribute("from"));
      toTime = 1000 * Long.parseLong(element.getAttribute("to"));
    }
    return new Chart<T>(new Date(fromTime), new Date(toTime), collection);
  }
View Full Code Here

   */
  static LinkedHashMap<String, String> getWeeklyChartList(String methodName, String paramName, String paramValue, String apiKey) {
    Result result = Caller.getInstance().call(methodName, apiKey, paramName, paramValue);
    if (!result.isSuccessful())
      return new LinkedHashMap<String, String>(0);
    DomElement element = result.getContentElement();
    LinkedHashMap<String, String> list = new LinkedHashMap<String, String>();
    for (DomElement domElement : element.getChildren("chart")) {
      list.put(domElement.getAttribute("from"), domElement.getAttribute("to"));
    }
    return list;
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  static Collection<Chart> getWeeklyChartListAsCharts(String sourceType, String source, String apiKey) {
    Result result = Caller.getInstance().call(sourceType + ".getWeeklyChartList", apiKey, sourceType, source);
    if (!result.isSuccessful())
      return Collections.emptyList();
    DomElement element = result.getContentElement();
    List<Chart> list = new ArrayList<Chart>();
    for (DomElement domElement : element.getChildren("chart")) {
      long fromTime = 1000 * Long.parseLong(domElement.getAttribute("from"));
      long toTime = 1000 * Long.parseLong(domElement.getAttribute("to"));
      list.add(new Chart(new Date(fromTime), new Date(toTime), null));
    }
    return list;
View Full Code Here

  }

  public DomElement getContentElement() {
    if (!isSuccessful())
      return null;
    return new DomElement(resultDocument.getDocumentElement()).getChild("*");
  }
 
View Full Code Here

   */
  public static Collection<String> getTags(String artist, String album, Session session) {
    Result result = Caller.getInstance().call("album.getTags", session, "artist", artist, "album", album);
    if (!result.isSuccessful())
      return Collections.emptyList();
    DomElement element = result.getContentElement();
    Collection<String> tags = new ArrayList<String>();
    for (DomElement domElement : element.getChildren("tag")) {
      tags.add(domElement.getChildText("name"));
    }
    return tags;
  }
View Full Code Here

   * @param apiKey A Last.fm API key.
   * @return a Collection of matches
   */
  public static Collection<Album> search(String album, String apiKey) {
    Result result = Caller.getInstance().call("album.search", apiKey, "album", album);
    DomElement matches = result.getContentElement().getChild("albummatches");
    Collection<DomElement> children = matches.getChildren("album");
    Collection<Album> albums = new ArrayList<Album>(children.size());
    for (DomElement element : children) {
      albums.add(FACTORY.createItemFromElement(element));
    }
    return albums;
View Full Code Here

    }
    params.put("country", country);
    Result result = Caller.getInstance().call("album.getBuylinks", apiKey, params);
    if (!result.isSuccessful())
      return Collections.emptyList();
    DomElement element = result.getContentElement();
    DomElement physicals = element.getChild("physicals");
    DomElement downloads = element.getChild("downloads");
    Collection<BuyLink> links = new ArrayList<BuyLink>();
    for (DomElement e : physicals.getChildren("affiliation")) {
      links.add(BuyLink.linkFromElement(BuyLink.StoreType.PHYSICAl, e));
    }
    for (DomElement e : downloads.getChildren("affiliation")) {
      links.add(BuyLink.linkFromElement(BuyLink.StoreType.DIGITAL, e));
    }
    return links;
  }
View Full Code Here

    p.title = e.getChildText("title");
    if (e.hasChild("size"))
      p.size = Integer.parseInt(e.getChildText("size"));
    p.creator = e.getChildText("creator");
    p.annotation = e.getChildText("annotation");
    DomElement tl = e.getChild("trackList");
    if (tl != null) {
      for (DomElement te : tl.getChildren("track")) {
        Track t = new Track(te.getChildText("title"), te.getChildText("identifier"),
            te.getChildText("creator"));
        t.album = te.getChildText("album");
        t.duration = Integer.parseInt(te.getChildText("duration")) / 1000;
        t.imageUrls.put(ImageSize.LARGE, te.getChildText("image"));
View Full Code Here

TOP

Related Classes of de.umass.xml.DomElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.