/** * Get the metadata elements of the specified type. * * @param want find this metadata type * @return List of InvMetadata objects. List may be empty but not null. */ public java.util.List<InvMetadata> getMetadata(thredds.catalog.MetadataType want) { List<InvMetadata> result = new ArrayList<InvMetadata>(); for (InvMetadata m : getMetadata()) { MetadataType mtype = MetadataType.getType(m.getMetadataType()); if (mtype == want) result.add(m); } return result; }
public boolean endElementHandler(String ns, String tag, String bufferContent) { boolean interruptReading = false; switch (myState) { case START: break; case FEED: if (ns == XMLNamespaces.Atom && tag == TAG_FEED) { if (myFeed != null) { interruptReading = myFeedHandler.processFeedMetadata(myFeed, false); } myFeed = null; myFeedHandler.processFeedEnd(); myState = START; } break; case F_ENTRY: if (ns == XMLNamespaces.Atom && tag == TAG_ENTRY) { if (myEntry != null) { interruptReading = myFeedHandler.processFeedEntry(myEntry); } myEntry = null; myState = FEED; } break; case F_ID: if (ns == XMLNamespaces.Atom && tag == TAG_ID) { // FIXME:uri can be lost:buffer will be truncated, if there are extension tags inside the // <id> tag if (bufferContent != null && myFeed != null) { myId.Uri = bufferContent; myFeed.Id = myId; } myId = null; myState = FEED; } break; case F_ICON: if (ns == XMLNamespaces.Atom && tag == TAG_ICON) { // FIXME:uri can be lost:buffer will be truncated, if there are extension tags inside the // <id> tag if (bufferContent != null && myFeed != null) { myIcon.Uri = bufferContent; myFeed.Icon = myIcon; } myIcon = null; myState = FEED; } break; case F_LINK: if (ns == XMLNamespaces.Atom && tag == TAG_LINK) { if (myFeed != null) { myFeed.Links.add(myLink); } myLink = null; myState = FEED; } break; case F_CATEGORY: if (ns == XMLNamespaces.Atom && tag == TAG_CATEGORY) { if (myFeed != null) { myFeed.Categories.add(myCategory); } myCategory = null; myState = FEED; } break; case F_TITLE: myFormattedBuffer.appendText(bufferContent); if (ns == XMLNamespaces.Atom && tag == TAG_TITLE) { // TODO:implement ATOMTextConstruct & ATOMTitle final CharSequence title = myFormattedBuffer.getText(); if (myFeed != null) { myFeed.Title = title; } myState = FEED; } else { myFormattedBuffer.appendEndTag(tag); } break; case F_SUBTITLE: myFormattedBuffer.appendText(bufferContent); if (ns == XMLNamespaces.Atom && tag == TAG_SUBTITLE) { // TODO:implement ATOMTextConstruct & ATOMSubtitle final CharSequence subtitle = myFormattedBuffer.getText(); if (myFeed != null) { myFeed.Subtitle = subtitle; } myState = FEED; } else { myFormattedBuffer.appendEndTag(tag); } break; case F_UPDATED: if (ns == XMLNamespaces.Atom && tag == TAG_UPDATED) { // FIXME:uri can be lost:buffer will be truncated, if there are extension tags inside the // <id> tag if (ATOMDateConstruct.parse(bufferContent, myUpdated) && myFeed != null) { myFeed.Updated = myUpdated; } myUpdated = null; myState = FEED; } break; case F_AUTHOR: if (ns == XMLNamespaces.Atom && tag == TAG_AUTHOR) { if (myFeed != null && myAuthor.Name != null) { myFeed.Authors.add(myAuthor); } myAuthor = null; myState = FEED; } break; case FA_NAME: if (ns == XMLNamespaces.Atom && tag == TAG_NAME) { myAuthor.Name = bufferContent; myState = F_AUTHOR; } break; case FEA_NAME: if (ns == XMLNamespaces.Atom && tag == TAG_NAME) { myAuthor.Name = bufferContent; myState = FE_AUTHOR; } break; case FA_URI: if (ns == XMLNamespaces.Atom && tag == TAG_URI) { myAuthor.Uri = bufferContent; myState = F_AUTHOR; } break; case FEA_URI: if (ns == XMLNamespaces.Atom && tag == TAG_URI) { myAuthor.Uri = bufferContent; myState = FE_AUTHOR; } break; case FA_EMAIL: if (ns == XMLNamespaces.Atom && tag == TAG_EMAIL) { myAuthor.Email = bufferContent; myState = F_AUTHOR; } break; case FEA_EMAIL: if (ns == XMLNamespaces.Atom && tag == TAG_EMAIL) { myAuthor.Email = bufferContent; myState = FE_AUTHOR; } break; case FE_AUTHOR: if (ns == XMLNamespaces.Atom && tag == TAG_AUTHOR) { if (myAuthor.Name != null) { myEntry.Authors.add(myAuthor); } myAuthor = null; myState = F_ENTRY; } break; case FE_ID: if (ns == XMLNamespaces.Atom && tag == TAG_ID) { // FIXME:uri can be lost:buffer will be truncated, if there are extension tags inside the // <id> tag if (bufferContent != null) { myId.Uri = bufferContent; myEntry.Id = myId; } myId = null; myState = F_ENTRY; } break; case FE_CATEGORY: if (ns == XMLNamespaces.Atom && tag == TAG_CATEGORY) { myEntry.Categories.add(myCategory); myCategory = null; myState = F_ENTRY; } break; case FE_LINK: if (ns == XMLNamespaces.Atom && tag == TAG_LINK) { myEntry.Links.add(myLink); myLink = null; myState = F_ENTRY; } break; case FE_PUBLISHED: if (ns == XMLNamespaces.Atom && tag == TAG_PUBLISHED) { // FIXME:uri can be lost:buffer will be truncated, if there are extension tags inside the // <id> tag if (ATOMDateConstruct.parse(bufferContent, myPublished)) { myEntry.Published = myPublished; } myPublished = null; myState = F_ENTRY; } break; case FE_SUMMARY: myFormattedBuffer.appendText(bufferContent); if (ns == XMLNamespaces.Atom && tag == TAG_SUMMARY) { // TODO:implement ATOMTextConstruct & ATOMSummary myEntry.Summary = myFormattedBuffer.getText(); myState = F_ENTRY; } else { myFormattedBuffer.appendEndTag(tag); } break; case FE_CONTENT: myFormattedBuffer.appendText(bufferContent); if (ns == XMLNamespaces.Atom && tag == TAG_CONTENT) { // TODO:implement ATOMContent myEntry.Content = myFormattedBuffer.getText(); myState = F_ENTRY; } else { myFormattedBuffer.appendEndTag(tag); } break; case FE_TITLE: myFormattedBuffer.appendText(bufferContent); if (ns == XMLNamespaces.Atom && tag == TAG_TITLE) { // TODO:implement ATOMTextConstruct & ATOMTitle myEntry.Title = myFormattedBuffer.getText(); myState = F_ENTRY; } else { myFormattedBuffer.appendEndTag(tag); } break; case FE_UPDATED: if (ns == XMLNamespaces.Atom && tag == TAG_UPDATED) { // FIXME:uri can be lost:buffer will be truncated, if there are extension tags inside the // <id> tag try { if (ATOMDateConstruct.parse(bufferContent, myUpdated)) { myEntry.Updated = myUpdated; } } catch (Exception e) { // this ATOMDateConstruct.parse() throws OOB exception time to time } myUpdated = null; myState = F_ENTRY; } break; } return interruptReading; }