FileDocCategorySizeDatePackage
GDataEntityBuilder.javaAPI DocApache Lucene 2.1.05855Wed Feb 14 10:46:06 GMT 2007org.apache.lucene.gdata.server

GDataEntityBuilder

public class GDataEntityBuilder extends Object
{@link com.google.gdata.data.BaseFeed}, {@link com.google.gdata.data.BaseEntry} instances have to be build from a {@link java.io.Reader} instance as they come in from a client request or out of a storage.

To provide a generic builder class the {@link GDataEntityBuilder} requests the type of the feed / entry and the corresponding {@link com.google.gdata.data.ExtensionProfile} form the global {@link org.apache.lucene.gdata.server.registry.GDataServerRegistry} and builds the instances from the provided reader.

This build will not returne the abstract base classes.

author
Simon Willnauer

Fields Summary
Constructors Summary
Methods Summary
public static com.google.gdata.data.BaseEntrybuildEntry(GDataRequest request)
Builds a {@link BaseEntry} instance from the {@link Reader} provided by the {@link GDataRequest}

param
request - the request to build the instance from
return
- a BaseEntry instance
throws
IOException - if an I/O Exception occures on the provided reader
throws
ParseException - if the entry could not be parsed

        if (request == null)
            throw new IllegalArgumentException("request must not be null");
        ProvidedService config = request.getConfigurator();
        return buildEntry(request.getReader(), config);
    
public static com.google.gdata.data.BaseEntrybuildEntry(java.io.Reader reader, org.apache.lucene.gdata.server.registry.ProvidedService config)
Builds a {@link BaseFeed} instance from the {@link Reader} provided by the {@link GDataRequest}

param
reader - the reader to build the feed from
param
config - the instance config containing the extension profile to parse the resource
return
- a BaseFeed instance
throws
IOException - if an I/O Exception occures on the provided reader
throws
ParseException - if the entry could not be parsed

       
        BaseEntry e = createEntityInstance(config).createEntry();
        e.parseAtom(config.getExtensionProfile(), reader);
        return e;
    
public static com.google.gdata.data.BaseFeedbuildFeed(GDataRequest request)
Builds a {@link BaseFeed} instance from the {@link Reader} provided by the {@link GDataRequest}

param
request - the request to build the instance from
return
- a BaseFeed instance
throws
IOException - if an I/O Exception occures on the provided reader
throws
ParseException - if the feed could not be parsed

        if (request == null)
            throw new IllegalArgumentException("request must not be null");
        ProvidedService config = request.getConfigurator();
        return buildFeed(request.getReader(), config);
    
public static com.google.gdata.data.BaseFeedbuildFeed(java.io.Reader reader, org.apache.lucene.gdata.server.registry.ProvidedService config)
Builds a {@link BaseFeed} from the provided {@link Reader}

param
reader - the reader to build the feed from
param
config - the feed instance config containing the extension profile to parse the resource
return
- a BaseFeed instance
throws
IOException - if an I/O Exception occures on the provided reader
throws
ParseException - if the feed could not be parsed


        BaseFeed retVal = null;
        retVal = createEntityInstance(config);
        retVal.parseAtom(config.getExtensionProfile(), reader);
      
        return retVal;
    
private static com.google.gdata.data.BaseFeedcreateEntityInstance(org.apache.lucene.gdata.server.registry.ProvidedService config)

        if(config.getFeedType() == null)
            throw new IllegalArgumentException("feedtype is null in ProvidedService");
        
        BaseFeed retVal = null;
        try {
            retVal = (BaseFeed) config.getFeedType().newInstance();
        } catch (Exception e) {
            throw new EntityBuilderException("Can't instanciate Feed for feedType "+config.getFeedType().getName(),e);
        }
        return retVal;