private static ExtensionProfile getExtProfile(BaseEntry<?> entry, boolean isAdapting) { ExtensionProfile extProfile = null; extProfile = new ExtensionProfile(); ((BaseEntry<?>) entry).declareExtensions(extProfile); if (isAdapting) { extProfile.setAutoExtending(true); } return extProfile; }
/** * Generates the atom output for an entry using the given xml writer and * extension profile. */ public static void generateAtom(XmlWriter writer, IEntry entry, ExtensionProfile extProfile) throws IOException { if (entry instanceof BaseEntry) { ((BaseEntry<?>) entry).generateAtom(writer, extProfile); } else { } }
public Link addLink(String rel, String type, String href) { Link link = new Link(rel, type, href); addLink(link); return link; }
putAttributes(generator); generateAttributes(attrs, generator); generateStartElement(w, Namespaces.atomNs, "entry", attrs, nsDecls); w.simpleElement(getAtomPubNs(), "edited", null, state.edited.toString()); generateExtensions(w, extProfile);
if (result instanceof BaseEntry) { BaseEntry<?> entryResult = (BaseEntry<?>) result; entryResult.parseAtom(inProps.getExtensionProfile(), inputReader); if (resultClass == Entry.class) { BaseEntry<?> adaptedEntry = entryResult.getAdaptedEntry(); if (resultClass.isInstance(adaptedEntry)) { result = resultClass.cast(adaptedEntry);
nsDecls.addAll(extProfile.getNamespaceDecls()); generateStartElement(w, Namespaces.rssNs, "item", null, nsDecls); generateExtensions(w, extProfile);
@Override public void generateXml(XmlWriter xw, OutputProperties outProps, IAtom source) throws IOException { if (source instanceof IFeed) { IFeed feed = (IFeed) source; if (feed instanceof BaseFeed) { ((BaseFeed<?, ?>) feed).generateRss(xw, outProps.getExtensionProfile()); } else { throw new IllegalArgumentException( "Feed was not an instance of BaseFeed"); } } else if (source instanceof IEntry) { IEntry entry = (IEntry) source; if (entry instanceof BaseEntry) { ((BaseEntry<?>) entry).generateRss(xw, outProps.getExtensionProfile()); } else { throw new IllegalArgumentException( "Entry was not an instance of BaseEntry"); } } else { throw new IllegalStateException("Unexpected source type: " + source); } } }
adaptedFeed.getEntries().add(entry.getAdaptedEntry());
/** * Gets a list of entries of a particular kind. */ public <T extends BaseEntry> List<T> getEntries(Class<T> returnClass) { List<T> adaptedEntries = new ArrayList<T>(); for (BaseEntry<?> entry : getEntries()) { T adapted = entry.getAdaptor(returnClass); if (adapted != null) { adaptedEntries.add(adapted); } } return adaptedEntries; } }
/** * Locates and returns the most specific {@link Kind.Adaptor} BaseEntry * subtype for this entry. If none can be found for the current class, * {@code null} will be returned. * * @throws Kind.AdaptorException for subclasses to throw. */ public BaseEntry<?> getAdaptedEntry() throws Kind.AdaptorException { BaseEntry<?> adaptedEntry = null; // Find the BaseEntry adaptor instance that is most specific. for (Kind.Adaptor adaptor : getAdaptors()) { if (!(adaptor instanceof BaseEntry)) { continue; } // If first matching adaptor or a narrower subtype of the current one, // then use it. if (adaptedEntry == null || adaptedEntry.getClass().isAssignableFrom(adaptor.getClass())) { adaptedEntry = (BaseEntry<?>) adaptor; } } return adaptedEntry; } }
putAttributes(generator); generateAttributes(attrs, generator); generateStartElement(w, Namespaces.atomNs, "entry", attrs, nsDecls); w.simpleElement(getAtomPubNs(), "edited", null, state.edited.toString()); generateExtensions(w, extProfile);
if (result instanceof BaseEntry) { BaseEntry<?> entryResult = (BaseEntry<?>) result; entryResult.parseAtom(inProps.getExtensionProfile(), inputReader); if (resultClass == Entry.class) { BaseEntry<?> adaptedEntry = entryResult.getAdaptedEntry(); if (resultClass.isInstance(adaptedEntry)) { result = resultClass.cast(adaptedEntry);
nsDecls.addAll(extProfile.getNamespaceDecls()); generateStartElement(w, Namespaces.rssNs, "item", null, nsDecls); generateExtensions(w, extProfile);
@Override public void generateXml(XmlWriter xw, OutputProperties outProps, IAtom source) throws IOException { if (source instanceof IFeed) { IFeed feed = (IFeed) source; if (feed instanceof BaseFeed) { ((BaseFeed<?, ?>) feed).generateRss(xw, outProps.getExtensionProfile()); } else { throw new IllegalArgumentException( "Feed was not an instance of BaseFeed"); } } else if (source instanceof IEntry) { IEntry entry = (IEntry) source; if (entry instanceof BaseEntry) { ((BaseEntry<?>) entry).generateRss(xw, outProps.getExtensionProfile()); } else { throw new IllegalArgumentException( "Entry was not an instance of BaseEntry"); } } else { throw new IllegalStateException("Unexpected source type: " + source); } } }
adaptedFeed.getEntries().add(entry.getAdaptedEntry());
/** * Gets a list of entries of a particular kind. */ public <T extends BaseEntry> List<T> getEntries(Class<T> returnClass) { List<T> adaptedEntries = new ArrayList<T>(); for (BaseEntry<?> entry : getEntries()) { T adapted = entry.getAdaptor(returnClass); if (adapted != null) { adaptedEntries.add(adapted); } } return adaptedEntries; } }
/** * Locates and returns the most specific {@link Kind.Adaptor} BaseEntry * subtype for this entry. If none can be found for the current class, * {@code null} will be returned. * * @throws Kind.AdaptorException for subclasses to throw. */ public BaseEntry<?> getAdaptedEntry() throws Kind.AdaptorException { BaseEntry<?> adaptedEntry = null; // Find the BaseEntry adaptor instance that is most specific. for (Kind.Adaptor adaptor : getAdaptors()) { if (!(adaptor instanceof BaseEntry)) { continue; } // If first matching adaptor or a narrower subtype of the current one, // then use it. if (adaptedEntry == null || adaptedEntry.getClass().isAssignableFrom(adaptor.getClass())) { adaptedEntry = (BaseEntry<?>) adaptor; } } return adaptedEntry; } }
@Override public void declareExtensions(ExtensionProfile extProfile) { super.declareExtensions(extProfile); // When inviting/removing attendees we can control whether to send // them notifications or not. We re-purpose // SendEventNotificationsProperty for this task. extProfile.declare(CalendarEventEntry.class, SendEventNotificationsProperty.getDefaultDescription()); }
putAttributes(generator); generateAttributes(attrs, generator); generateStartElement(w, Namespaces.atomNs, "entry", attrs, nsDecls); w.simpleElement(getAtomPubNs(), "edited", null, state.edited.toString()); generateExtensions(w, extProfile);
/** * Generates the atom output for an entry using the given xml writer and * extension profile. */ public static void generateAtom(XmlWriter writer, IEntry entry, ExtensionProfile extProfile) throws IOException { if (entry instanceof BaseEntry) { ((BaseEntry<?>) entry).generateAtom(writer, extProfile); } else { } }