com.google.gdata.model.batch
Class BatchUtils

java.lang.Object
  extended by com.google.gdata.model.batch.BatchUtils

public class BatchUtils
extends java.lang.Object

New data model version of batch utils. These utilities can operate on both the old and the new data model, so should be used during the transition.


Method Summary
static java.lang.String getBatchId(IEntry entry)
          Gets the value of the tag <batch:id>.
static BatchOperationType getBatchOperationType(IEntry entry)
          Gets the batch operation type from the tag <batch:operation> in a IEntry.
static BatchOperationType getBatchOperationType(IFeed feed)
          Gets the batch operation type from the tag <batch:operation> in a BaseFeed.
static IBatchInterrupted getInterrupted(IEntry entry)
          Gets the value of the tag <batch:interrupted>.
static IBatchStatus getStatus(IEntry entry)
          Gets the value of the tag <batch:status>.
static boolean isFailure(IEntry entry)
          Checks whether a batch entry is an error report.
static boolean isSuccess(IEntry entry)
          Checks whether a batch entry is a success report.
static void setBatchId(IEntry entry, java.lang.String id)
          Sets the value of the tag <batch:id>.
static void setBatchOperationType(IEntry entry, BatchOperationType op)
          Sets the batch operation to execute in a IEntry.
static void setBatchOperationType(IFeed feed, BatchOperationType op)
          Sets the batch operation to execute in a BaseFeed.
static void throwIfInterrupted(IFeed ifeed)
          Throws a BatchInterrupted exception if any entry within the feed has a batch interrupted child element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBatchId

public static java.lang.String getBatchId(IEntry entry)
Gets the value of the tag <batch:id>.

Parameters:
entry - the entry to get the id from
Returns:
the batch id or null if it is not set

setBatchId

public static void setBatchId(IEntry entry,
                              java.lang.String id)
Sets the value of the tag <batch:id>.

Parameters:
entry - entry to get the id from
id - the batch id or null to remove it

getBatchOperationType

public static BatchOperationType getBatchOperationType(IEntry entry)
Gets the batch operation type from the tag <batch:operation> in a IEntry.

Parameters:
entry - the entry to get the operation type from
Returns:
the operation to execute or null if it's not set

getBatchOperationType

public static BatchOperationType getBatchOperationType(IFeed feed)
Gets the batch operation type from the tag <batch:operation> in a BaseFeed.

Parameters:
feed -
Returns:
the operation to execute or null if it's not set

setBatchOperationType

public static void setBatchOperationType(IEntry entry,
                                         BatchOperationType op)
Sets the batch operation to execute in a IEntry.

Parameters:
entry - the entry to set the operation type on
op - batch operation type or null to remove it

setBatchOperationType

public static void setBatchOperationType(IFeed feed,
                                         BatchOperationType op)
Sets the batch operation to execute in a BaseFeed.

Parameters:
feed -
op - batch operation type or null to remove it.

getInterrupted

public static IBatchInterrupted getInterrupted(IEntry entry)
Gets the value of the tag <batch:interrupted>.

Parameters:
entry -
Returns:
the object corresponding to the tag or null

getStatus

public static IBatchStatus getStatus(IEntry entry)
Gets the value of the tag <batch:status>.

Parameters:
entry -
Returns:
the object corresponding to the tag or null

isSuccess

public static boolean isSuccess(IEntry entry)
Checks whether a batch entry is a success report. This method is a shortcut for checking the code of the entry's BatchStatus object.

Parameters:
entry -
Returns:
true if the entry is a success report.
Throws:
java.lang.IllegalArgumentException - if the entry does not contain a BatchStatus object.

isFailure

public static boolean isFailure(IEntry entry)
Checks whether a batch entry is an error report. This method is a shortcut for checking the code of the entry's BatchStatus object. You'll want to call getStatus(IEntry) to get the error description and message when this method returns true.

Parameters:
entry -
Returns:
true if the entry is an error report.
Throws:
java.lang.IllegalArgumentException - if the entry does not contain a BatchStatus object.

throwIfInterrupted

public static void throwIfInterrupted(IFeed ifeed)
                               throws BatchInterruptedException
Throws a BatchInterrupted exception if any entry within the feed has a batch interrupted child element.

Parameters:
ifeed - batch response feed to check
Throws:
BatchInterruptedException - if batch interrupted entry is found.