예제 #1
0
  private void parseTitle(String bufferContent) {
    String[] marks = {"~ by:", "By"};
    boolean found = false;

    for (int i = 0; i < marks.length; i++) {
      int foundIndex = bufferContent.indexOf(marks[i]);
      if (foundIndex >= 0) {
        if (myAuthor != null) {
          String title = bufferContent.substring(0, foundIndex);
          myItem.Title = title;
          String authorName = bufferContent.substring(foundIndex + marks[i].length());
          myAuthor.Name = authorName.trim();
          myItem.Authors.push(myAuthor);
          myAuthor = null;
        }
        found = true;
        break;
      }
    }

    if (!found) {
      myItem.Title = bufferContent;
    }
  }
예제 #2
0
 public boolean endElementHandler(String ns, String tag, String bufferContent) {
   switch (myState) {
     case START:
       break;
     case RSS:
       if (testTag(TAG_RSS, tag, ns, null)) {
         myState = START;
       }
       break;
     case CHANNEL:
       if (testTag(TAG_CHANNEL, tag, ns, null)) {
         myState = RSS;
       }
       break;
     case C_TITLE:
       if (testTag(TAG_TITLE, tag, ns, null)) {
         myState = CHANNEL;
       }
       break;
     case C_LINK:
       if (testTag(TAG_LINK, tag, ns, null)) {
         myState = CHANNEL;
       }
       break;
     case ITEM:
       if (testTag(TAG_ITEM, tag, ns, null)) {
         myFeedHandler.processFeedEntry(myItem);
         myState = CHANNEL;
       }
     case TITLE:
       if (testTag(TAG_TITLE, tag, ns, null)) {
         parseTitle(bufferContent);
         myState = ITEM;
       }
       break;
     case GUID:
       if (testTag(TAG_GUID, tag, ns, null)) {
         if (myId != null) {
           myId.Uri = bufferContent;
           myItem.Id = myId;
           myId = null;
         }
         myState = ITEM;
       }
       break;
     case DESCRIPTION:
       if (testTag(TAG_DESCRIPTION, tag, ns, null)) {
         myFormattedBuffer.reset(FormattedBuffer.Type.Html);
         myFormattedBuffer.appendText(makeFormat(bufferContent));
         myItem.Summary = myFormattedBuffer.getText();
         myState = ITEM;
       }
       break;
     case CATEGORY:
       if (testTag(TAG_CATEGORY, tag, ns, null)) {
         String[] tokens = bufferContent.split(", ");
         for (String str : tokens) {
           ZLStringMap source = new ZLStringMap();
           source.put(RSSCategory.LABEL, str);
           myCategory = new RSSCategory(source);
           if (myCategory != null) {
             myItem.Categories.push(myCategory);
           }
           myCategory = null;
         }
         myState = ITEM;
       }
       break;
     case PUBDATE:
       if (testTag(TAG_PUBDATE, tag, ns, null)) {
         myState = ITEM;
       }
       break;
     case LINK:
       if (testTag(TAG_LINK, tag, ns, null)) {
         myState = ITEM;
       }
       break;
   }
   return false;
 }