예제 #1
0
  public boolean startElementHandler(
      final String ns, final String tag, final ZLStringMap attributes, final String bufferContent) {
    boolean interruptReading = false;
    switch (myState) {
      case START:
        if (ns == XMLNamespaces.Atom && tag == TAG_FEED) {
          myFeedHandler.processFeedStart();
          myFeed = myFeedHandler.createFeed(attributes);
          myState = FEED;
          myFeedMetadataProcessed = false;
        }
        break;
      case FEED:
        if (ns == XMLNamespaces.Atom) {
          if (tag == TAG_AUTHOR) {
            myAuthor = new ATOMAuthor(attributes);
            myState = F_AUTHOR;
          } else if (tag == TAG_ID) {
            myId = new ATOMId(attributes);
            myState = F_ID;
          } else if (tag == TAG_ICON) {
            myIcon = new ATOMIcon(attributes);
            myState = F_ICON;
          } else if (tag == TAG_LINK) {
            myLink = myFeedHandler.createLink(attributes); // TODO
            myState = F_LINK;
          } else if (tag == TAG_CATEGORY) {
            myCategory = new ATOMCategory(attributes);
            myState = F_CATEGORY;
          } else if (tag == TAG_TITLE) {
            // myTitle = new ATOMTitle(attributes); // TODO:implement ATOMTextConstruct & ATOMTitle
            setFormattingType(attributes.getValue("type"));
            myState = F_TITLE;
          } else if (tag == TAG_SUBTITLE) {
            // mySubtitle = new ATOMTitle(attributes); // TODO:implement ATOMTextConstruct &
            // ATOMSubtitle
            setFormattingType(attributes.getValue("type"));
            myState = F_SUBTITLE;
          } else if (tag == TAG_UPDATED) {
            myUpdated = new ATOMUpdated(attributes);
            myState = F_UPDATED;
          } else if (tag == TAG_ENTRY) {
            myEntry = myFeedHandler.createEntry(attributes);
            myState = F_ENTRY;
            // Process feed metadata just before first feed entry
            if (myFeed != null && !myFeedMetadataProcessed) {
              interruptReading = myFeedHandler.processFeedMetadata(myFeed, true);
              myFeedMetadataProcessed = true;
            }
          }
        }
        break;
      case F_ENTRY:
        if (ns == XMLNamespaces.Atom) {
          if (tag == TAG_AUTHOR) {
            myAuthor = new ATOMAuthor(attributes);
            myState = FE_AUTHOR;
          } else if (tag == TAG_ID) {
            myId = new ATOMId(attributes);
            myState = FE_ID;
          } else if (tag == TAG_CATEGORY) {
            myCategory = new ATOMCategory(attributes);
            myState = FE_CATEGORY;
          } else if (tag == TAG_LINK) {
            myLink = myFeedHandler.createLink(attributes); // TODO
            myState = FE_LINK;
          } else if (tag == TAG_PUBLISHED) {
            myPublished = new ATOMPublished(attributes);
            myState = FE_PUBLISHED;
          } else if (tag == TAG_SUMMARY) {
            // mySummary = new ATOMSummary(attributes); // TODO:implement ATOMTextConstruct &
            // ATOMSummary
            setFormattingType(attributes.getValue("type"));
            myState = FE_SUMMARY;
          } else if (tag == TAG_CONTENT) {
            // myConent = new ATOMContent(attributes); // TODO:implement ATOMContent
            setFormattingType(attributes.getValue("type"));
            myState = FE_CONTENT;
          } else if (tag == TAG_TITLE) {
            // myTitle = new ATOMTitle(attributes); // TODO:implement ATOMTextConstruct & ATOMTitle
            setFormattingType(attributes.getValue("type"));
            myState = FE_TITLE;
          } else if (tag == TAG_UPDATED) {
            myUpdated = new ATOMUpdated(attributes);
            myState = FE_UPDATED;
          }
        }
        break;
      case F_AUTHOR:
        if (ns == XMLNamespaces.Atom) {
          if (tag == TAG_NAME) {
            myState = FA_NAME;
          } else if (tag == TAG_URI) {
            myState = FA_URI;
          } else if (tag == TAG_EMAIL) {
            myState = FA_EMAIL;
          }
        }
        break;
      case FE_AUTHOR:
        if (ns == XMLNamespaces.Atom) {
          if (tag == TAG_NAME) {
            myState = FEA_NAME;
          } else if (tag == TAG_URI) {
            myState = FEA_URI;
          } else if (tag == TAG_EMAIL) {
            myState = FEA_EMAIL;
          }
        }
        break;
      case FE_CONTENT:
      case FE_SUMMARY:
      case FE_TITLE:
      case F_TITLE:
      case F_SUBTITLE:
        myFormattedBuffer.appendText(bufferContent);
        myFormattedBuffer.appendStartTag(tag, attributes);
        break;
      default:
        break;
    }

    return interruptReading;
  }