Пример #1
0
 public boolean startElementHandler(
     String ns, String tag, ZLStringMap attributes, String bufferContent) {
   switch (myState) {
     case START:
       if (testTag(TAG_RSS, tag, ns, null)) {
         myState = RSS;
       }
       break;
     case RSS:
       if (testTag(TAG_CHANNEL, tag, ns, null)) {
         myState = CHANNEL;
       }
       break;
     case CHANNEL:
       if (testTag(TAG_TITLE, tag, ns, null)) {
         myState = C_TITLE;
       }
       if (testTag(TAG_LINK, tag, ns, null)) {
         myState = C_LINK;
       }
       if (testTag(TAG_ITEM, tag, ns, null)) {
         myItem = myFeedHandler.createEntry(attributes);
         myState = ITEM;
       }
       break;
     case ITEM:
       if (testTag(TAG_TITLE, tag, ns, null)) {
         myAuthor = new RSSAuthor(attributes);
         myState = TITLE;
       }
       if (testTag(TAG_LINK, tag, ns, null)) {
         myState = LINK;
       }
       if (testTag(TAG_DESCRIPTION, tag, ns, null)) {
         myState = DESCRIPTION;
       }
       if (testTag(TAG_CATEGORY, tag, ns, null)) {
         myState = CATEGORY;
       }
       if (testTag(TAG_GUID, tag, ns, null)) {
         myId = new ATOMId();
         myState = GUID;
       }
       if (testTag(TAG_PUBDATE, tag, ns, null)) {
         myState = PUBDATE;
       }
   }
   return false;
 }
Пример #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;
 }