コード例 #1
0
 public LinkInfo getBestAcquisitionLink() {
   LinkInfo best = null;
   int bestPriority = 0;
   for (LinkInfo link : links) {
     // boolean isAcquisition = link.rel!=null && link.rel.indexOf("acquisition")>=0;
     int priority = link.getPriority();
     if (priority > 0 && priority > bestPriority) {
       if (link.getPriority() > 0 && (best == null || best.getPriority() < link.getPriority())) {
         best = link;
         bestPriority = priority;
       }
     }
   }
   return best;
 }
コード例 #2
0
    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
      super.startElement(uri, localName, qName, attributes);
      if (qName != null && qName.length() > 0) localName = qName;
      level++;
      L.d(tab() + "<" + localName + ">");
      currentAttributes = attributes;
      elements.push(localName);
      // String currentElement = elements.peek();
      if (!insideFeed && "feed".equals(localName)) {
        insideFeed = true;
      } else if ("entry".equals(localName)) {
        if (!insideFeed) {
          insideFeed = true;
          singleEntry = true;
        }
        insideEntry = true;
        entryInfo = new EntryInfo();
      } else if ("category".equals(localName)) {
        if (insideEntry) {
          String category = attributes.getValue("label");
          if (category != null) entryInfo.categories.add(category);
        }
      } else if ("id".equals(localName)) {

      } else if ("updated".equals(localName)) {

      } else if ("title".equals(localName)) {

      } else if ("link".equals(localName)) {
        LinkInfo link = new LinkInfo(url, attributes);
        if (link.isValid() && insideFeed) {
          L.d(tab() + link.toString());
          if (insideEntry) {
            if (link.type != null) {
              entryInfo.links.add(link);
              int priority = link.getPriority();
              if (link.type.startsWith("application/atom+xml")) {
                entryInfo.link = link;
              } else if (priority > 0
                  && (entryInfo.link == null || entryInfo.link.getPriority() < priority)) {
                entryInfo.link = link;
              }
            }
          } else {
            if ("self".equals(link.rel)) docInfo.selfLink = link;
            else if ("alternate".equals(link.rel)) docInfo.alternateLink = link;
          }
        }
      } else if ("author".equals(localName)) {
        authorInfo = new AuthorInfo();
      }
    }