📄 serverbasefeed.java
字号:
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.lucene.gdata.data;import java.io.IOException;import java.io.InputStream;import java.io.Reader;import java.util.Collection;import java.util.List;import java.util.Set;import org.apache.lucene.gdata.server.registry.ProvidedService;import com.google.gdata.client.Service;import com.google.gdata.data.BaseEntry;import com.google.gdata.data.BaseFeed;import com.google.gdata.data.Category;import com.google.gdata.data.DateTime;import com.google.gdata.data.Extension;import com.google.gdata.data.ExtensionProfile;import com.google.gdata.data.Feed;import com.google.gdata.data.Generator;import com.google.gdata.data.Link;import com.google.gdata.data.Person;import com.google.gdata.data.TextConstruct;import com.google.gdata.util.ParseException;import com.google.gdata.util.ServiceException;import com.google.gdata.util.XmlBlob;import com.google.gdata.util.common.xml.XmlWriter;/** * The GData-Server uses the GDATA-Client API for an interal representation of * entries. These entities have dynamic elements like Links being generated * using the requested URL.<br/> Some components of the server also need * additional infomation like the service type * {@link org.apache.lucene.gdata.server.registry.ProvidedService} of the feed. * All these information are * encapsulated in the ServerBaseFeed decoration a concrete subl class of <tt>BaseFeed</tt>. The type of the * {@link com.google.gdata.data.BaseEntry} contained it this feed will be passed to the ServerBaseFeed * at creation time via the constructor. To retrieve the original entry call * {@link ServerBaseFeed#getFeed()} returns a * {@link com.google.gdata.data.BaseFeed} instance which can be casted into the * actual type. To use the ServerBaseEntry for generation a provided format like * RSS/ATOM the corresponding {@link com.google.gdata.data.ExtensionProfile} has * to be provided to the generation method. * * @author Simon Willnauer * */public class ServerBaseFeed { private String serviceType; private ProvidedService serviceConfig; private GDataAccount account; private BaseFeed feed; /** * @return Returns the account. */ public GDataAccount getAccount() { return this.account; } /** * @param account The account to set. */ public void setAccount(GDataAccount account) { this.account = account; } /** * Creates a new ServerBaseFeed and decorates a basic instance of {@link Feed} */ @SuppressWarnings("unchecked") public ServerBaseFeed() { this.feed = new Feed(); } /** * @param feed - the feed to decorate * */ @SuppressWarnings("unchecked") public ServerBaseFeed(BaseFeed feed) { this.feed = feed; } /** * @return Returns the feed. */ public BaseFeed getFeed() { return this.feed; } /** * @param feed The feed to set. */ public void setFeed(BaseFeed feed) { this.feed = feed; } /** * @see com.google.gdata.data.BaseFeed#declareExtensions(com.google.gdata.data.ExtensionProfile) */ public void declareExtensions(ExtensionProfile extProfile) { this.feed.declareExtensions(extProfile); } /** * @param link - * a link added to the link list of the feed */ @SuppressWarnings("unchecked") public void addLink(final Link link) { this.feed.getLinks().add(link); } /** * @param collection - * a collection of <code>Link</code> instance to be added to * the feeds link list */ public void addLinks(final Collection<Link> collection) { this.feed.getLinks().addAll(collection); } /** * @return - the name of the service related of the feed represented by this * ServerBaseFeed */ public String getServiceType() { return this.serviceType; } /** * @param serviceType - * the name of the service related of the feed represented by * this ServerBaseFeed */ public void setServiceType(String serviceType) { this.serviceType = serviceType; } /** * @return - the provided service */ public ProvidedService getServiceConfig() { return this.serviceConfig; } /** * @param serviceConfig - - * the provided service */ public void setServiceConfig(ProvidedService serviceConfig) { this.serviceConfig = serviceConfig; if (serviceConfig != null) this.serviceType = this.serviceConfig.getName(); } /** * @param person - * adds an author to the feed */ public void addAuthor(final Person person) { this.feed.getAuthors().add(person); } /** * @see com.google.gdata.data.BaseFeed#createEntry() */ public BaseEntry createEntry() { return this.feed.createEntry(); } /** * @see com.google.gdata.data.BaseFeed#generateAtom(com.google.gdata.util.common.xml.XmlWriter, com.google.gdata.data.ExtensionProfile) */ public void generateAtom(XmlWriter arg0, ExtensionProfile arg1) throws IOException { this.feed.generateAtom(arg0, arg1); } /** * @see com.google.gdata.data.BaseFeed#generateAtomColl(com.google.gdata.util.common.xml.XmlWriter) */ public void generateAtomColl(XmlWriter arg0) throws IOException { this.feed.generateAtomColl(arg0); } /** * @see com.google.gdata.data.BaseFeed#generateRss(com.google.gdata.util.common.xml.XmlWriter, com.google.gdata.data.ExtensionProfile) */ public void generateRss(XmlWriter arg0, ExtensionProfile arg1) throws IOException { this.feed.generateRss(arg0, arg1); } /** * @see com.google.gdata.data.BaseFeed#getCanPost() */ public boolean getCanPost() { return this.feed.getCanPost(); } /** * @see com.google.gdata.data.BaseFeed#getEntries() */ public List getEntries() { return this.feed.getEntries(); } /** * @see com.google.gdata.data.BaseFeed#getEntryPostLink() */ public Link getEntryPostLink() { return this.feed.getEntryPostLink(); } /** * @see com.google.gdata.data.BaseFeed#getItemsPerPage() */ public int getItemsPerPage() { return this.feed.getItemsPerPage(); } /** * @see com.google.gdata.data.BaseFeed#getSelf() */ public BaseFeed getSelf() throws IOException, ServiceException { return this.feed.getSelf(); } /** * @see com.google.gdata.data.BaseFeed#getSelfLink() */ public Link getSelfLink() { return this.feed.getSelfLink(); } /** * @see com.google.gdata.data.BaseFeed#getService() */ public Service getService() { return this.feed.getService(); } /** * @see com.google.gdata.data.BaseFeed#getStartIndex() */ public int getStartIndex() { return this.feed.getStartIndex(); } /** * @see com.google.gdata.data.BaseFeed#getTotalResults() */ public int getTotalResults() { return this.feed.getTotalResults(); } /** * @see com.google.gdata.data.BaseFeed#insert(E) */ public BaseEntry insert(BaseEntry arg0) throws ServiceException, IOException { return this.feed.insert(arg0); } /** * @see com.google.gdata.data.BaseFeed#parseAtom(com.google.gdata.data.ExtensionProfile, java.io.InputStream) */ public void parseAtom(ExtensionProfile arg0, InputStream arg1) throws IOException, ParseException { this.feed.parseAtom(arg0, arg1); } /** * @see com.google.gdata.data.BaseFeed#parseAtom(com.google.gdata.data.ExtensionProfile, java.io.Reader) */ public void parseAtom(ExtensionProfile arg0, Reader arg1) throws IOException, ParseException { this.feed.parseAtom(arg0, arg1); } /** * @see com.google.gdata.data.BaseFeed#setCanPost(boolean) */ public void setCanPost(boolean arg0) { this.feed.setCanPost(arg0); } /** * @see com.google.gdata.data.BaseFeed#setItemsPerPage(int)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -