com.pras
Class SpreadSheetFactory

java.lang.Object
  extended by com.pras.SpreadSheetFactory

public class SpreadSheetFactory
extends java.lang.Object

It is a SpreadSheet Generator Class. It accepts Gmail User ID and PassWord to generate Authentication Token.
It uses 2 Google APIs-
SpreadSheet Create/Delete - Google Document API
WorkSheet Create/Delete, Record Add - Google SpreadSheet API

Author:
Prasanta Paul

Field Summary
static java.lang.String authToken
           
 
Method Summary
 void addSharePermission(SpreadSheet sp, Collaborator[] collaborators)
          Share a SpreadSheet with a given list of Collaborators.
 void changeSharePermission(Collaborator c, java.lang.String role)
          Change Share permission for a particular ACL entry
 void createSpreadSheet(java.lang.String spName)
          Create SpreadSheet with the given name
 void deleteSpreadSheet(java.lang.String resID)
          Delete a SpreadSheet
 void flushMe()
          Deallocate SpreadSheetFactory instance
 java.util.ArrayList<Collaborator> getAllCollaborators(SpreadSheet sp)
          Get list of all Collaborators to whom this SpreadSheet is shared
 java.util.ArrayList<SpreadSheet> getAllSpreadSheets()
          Get All stored SpreadSheets from Server
 java.util.ArrayList<SpreadSheet> getAllSpreadSheets(boolean doRefresh)
          Get All stored SpreadSheets either from Server or Local Cache
 java.util.ArrayList<SpreadSheet> getAllSpreadSheets(boolean doRefresh, java.lang.String title, boolean isTitleExact)
          Get All stored SpreadSheets either from Server or Local Cache
static SpreadSheetFactory getInstance()
          This will return an existing SpreadSheetFactory instance or null
Note: Make sure you have previously called getInstance(String userName, String password)
static SpreadSheetFactory getInstance(Authenticator authenticator)
          This will create SpreadSheetFactory Instance using your custom Authenticatior.
static SpreadSheetFactory getInstance(java.lang.String email, java.lang.String password)
          This will create SpreadSheetFactory Instance with valid User ID (e.g.
 java.util.ArrayList<SpreadSheet> getSpreadSheet(java.lang.String title, boolean isTitleExact)
          Get list of SpreadSheet with matching title.
 void removeSharePermission(Collaborator c)
          Remove Share access of a selected user.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

authToken

public static java.lang.String authToken
Method Detail

getInstance

public static SpreadSheetFactory getInstance()
This will return an existing SpreadSheetFactory instance or null
Note: Make sure you have previously called getInstance(String userName, String password)

Returns:

getInstance

public static SpreadSheetFactory getInstance(java.lang.String email,
                                             java.lang.String password)
This will create SpreadSheetFactory Instance with valid User ID (e.g. abc@gmail.com) and password

Parameters:
userName - Gmail account id e.g. abc@gmail.com
password - Gmail account password
Returns:

getInstance

public static SpreadSheetFactory getInstance(Authenticator authenticator)
This will create SpreadSheetFactory Instance using your custom Authenticatior. Use this if you want to use your custom Authenticator e.g. in Android you can use AccountManager to create a custom Authenticator.

Parameters:
authenticator - Your Custom Authenticator.
Returns:

flushMe

public void flushMe()
Deallocate SpreadSheetFactory instance


createSpreadSheet

public void createSpreadSheet(java.lang.String spName)
Create SpreadSheet with the given name

Parameters:
spName - SpreadSheet name

deleteSpreadSheet

public void deleteSpreadSheet(java.lang.String resID)
Delete a SpreadSheet

Parameters:
resID - Resource ID of the SpreadSheet you want to Delete

getSpreadSheet

public java.util.ArrayList<SpreadSheet> getSpreadSheet(java.lang.String title,
                                                       boolean isTitleExact)
Get list of SpreadSheet with matching title. It will do Synch with Server

Parameters:
title - SpreadSheet title
isTitleExact - Whether title string should be an exact match
Returns:

getAllSpreadSheets

public java.util.ArrayList<SpreadSheet> getAllSpreadSheets()
Get All stored SpreadSheets from Server

Returns:

getAllSpreadSheets

public java.util.ArrayList<SpreadSheet> getAllSpreadSheets(boolean doRefresh)
Get All stored SpreadSheets either from Server or Local Cache

Parameters:
doRefresh - Do you want to Synch with Server ?
Returns:
List of Entry. Each Entry represents a SpreadSheet

getAllSpreadSheets

public java.util.ArrayList<SpreadSheet> getAllSpreadSheets(boolean doRefresh,
                                                           java.lang.String title,
                                                           boolean isTitleExact)
Get All stored SpreadSheets either from Server or Local Cache

Parameters:
doRefresh -
title - SpreadSheet title. null means all SpreadSheets. No need to do URL encode.
isTitleExact - Whether title string should be an exact match
Returns:

addSharePermission

public void addSharePermission(SpreadSheet sp,
                               Collaborator[] collaborators)
Share a SpreadSheet with a given list of Collaborators. NOTE: You need not to mention editLink of Collaborator

Parameters:
sp - The SpreadSheet you want to share
collaborators - List of Collaborators with whim you want to share this.

getAllCollaborators

public java.util.ArrayList<Collaborator> getAllCollaborators(SpreadSheet sp)
Get list of all Collaborators to whom this SpreadSheet is shared

Parameters:
sp - SpreadSheet
Returns:

changeSharePermission

public void changeSharePermission(Collaborator c,
                                  java.lang.String role)
Change Share permission for a particular ACL entry

Parameters:
c - Collaborator instance stored in SpreadSheet. It should have a valid EditLink URL
role - {owner, writer, reader}

removeSharePermission

public void removeSharePermission(Collaborator c)
Remove Share access of a selected user.

Parameters:
c - Collaborator Instance. It should have the Edit Link.