コード例 #1
0
  @Override
  public SessionInfo build(Node applicationNode) {
    boolean expired = false;
    Integer playsLeft = 30;
    Integer playsElapsed = 0;

    node = applicationNode;
    Node radioPermissionsNode = XMLUtil.findNamedElementNode(node, "radioPermission");

    Node userNode = XMLUtil.findNamedElementNode(radioPermissionsNode, "user");
    boolean radio = !XMLUtil.getChildContents(userNode, "radio").contentEquals("0");
    boolean freeTrial = !XMLUtil.getChildContents(userNode, "freetrial").contentEquals("0");

    Node trialNode = XMLUtil.findNamedElementNode(userNode, "trial");
    if (trialNode != null) {
      expired = !XMLUtil.getChildContents(trialNode, "expired").contentEquals("0");
      playsLeft = Integer.parseInt(XMLUtil.getChildContents(trialNode, "playsleft"));
      playsElapsed = Integer.parseInt(XMLUtil.getChildContents(trialNode, "playselapsed"));
    }

    return new SessionInfo(radio, freeTrial, expired, playsLeft, playsElapsed);
  }
コード例 #2
0
  @Override
  public RadioPlayList build(Node radioTracklistNode) {
    node = radioTracklistNode;

    String title = getText("title");
    String creator = getText("creator");
    String date = getText("date");
    String link = getText("link");
    String id = getText("id");
    boolean streamable = true;
    if (getText("streamable") != null && getText("streamable").contentEquals("0"))
      streamable = false;
    Node trackListNode = getChildNode("trackList");
    RadioTrack[] tracks = null;
    if (trackListNode != null) {
      List<Node> trackNodes = XMLUtil.findNamedElementNodes(trackListNode, "track");
      tracks = new RadioTrack[trackNodes.size()];
      int i = 0;
      for (Node trackNode : trackNodes) {
        tracks[i++] = trackBuilder.build(trackNode);
      }
    }
    return new RadioPlayList(title, creator, date, link, tracks, id, streamable);
  }