public final class

MetadataContext

extends Object
implements Comparable<T>
java.lang.Object
   ↳ com.google.gdata.model.MetadataContext

Class Overview

A context that metadata is operating under. Currently this contains the alt format, projection and version of the current request. Immutable.

This class also contains static initializers for the transforms required by each of our alt formats, which guarantees they will be loaded. We may want to put them somewhere else, but we need to move the constants for the contexts along with them.

Summary

Fields
public static final MetadataContext ATOM The ATOM metadata context.
public static final MetadataContext RSS The RSS metadata context.
private final AltFormat altFormat
private final String projection
private final Version version
Public Methods
int compareTo(MetadataContext other)
Compare two context objects to order them.
boolean equals(Object obj)
Checks that the other object is a metadata context with the same alt type and version.
static MetadataContext forAlt(AltFormat format)
Creates a new immutable metadata context with just an alt format.
static MetadataContext forContext(AltFormat format, String projection, Version version)
Creates a new immutable metadata context.
static MetadataContext forProjection(String projection)
Creates a new immutable metadata context with just projection.
static MetadataContext forVersion(Version version)
Constructs a new immutable metadata context with just version.
AltFormat getAltFormat()
The alt format the context represents.
String getProjection()
The projection the context represents.
Version getVersion()
The version the context represents.
int hashCode()
The hashCode for a context is just the hashcode of its parts.
boolean matches(MetadataContext other)
Returns true if this context is a match for the given context.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.Comparable

Fields

public static final MetadataContext ATOM

The ATOM metadata context.

public static final MetadataContext RSS

The RSS metadata context.

private final AltFormat altFormat

private final String projection

private final Version version

Public Methods

public int compareTo (MetadataContext other)

Compare two context objects to order them. A null value for any field is treated as a low value. Otherwise we use the normal string comparison. If the given context object is null a NullPointerException will be thrown.

Parameters
other

public boolean equals (Object obj)

Checks that the other object is a metadata context with the same alt type and version.

Parameters
obj

public static MetadataContext forAlt (AltFormat format)

Creates a new immutable metadata context with just an alt format. The format must not be null or this will throw a null pointer exception.

Parameters
format The alt format for the context, not null.
Returns
  • a metadata context for the alt format.

public static MetadataContext forContext (AltFormat format, String projection, Version version)

Creates a new immutable metadata context. If version, projection and alt type are all null this method will return null, which is the default context.

Parameters
format The alt format of the context.
projection The projection for the context.
version The version of the context.
Returns
  • an immutable metadata context with the given alt type, projection and version, or null if all parameters are null.

public static MetadataContext forProjection (String projection)

Creates a new immutable metadata context with just projection. If the projection is null this will return null, which is the default context.

Parameters
projection The projection of the context.
Returns
  • an immutable metadata context with the given projection, or null if the projection was null.

public static MetadataContext forVersion (Version version)

Constructs a new immutable metadata context with just version. If version is null this will return null, which is the default context.

Parameters
version The version of the context.
Returns
  • an immutable metadata context with the given version, or null if the version was null.

public AltFormat getAltFormat ()

The alt format the context represents.

Returns
  • the alt format or null if the context doesn't have an alt format.

public String getProjection ()

The projection the context represents.

Returns
  • the projection or null if the context doesn't have a projection.

public Version getVersion ()

The version the context represents.

Returns
  • the version or null if no version exists in this context.

public int hashCode ()

The hashCode for a context is just the hashcode of its parts.

public boolean matches (MetadataContext other)

Returns true if this context is a match for the given context. A context is a match for another context if it is a subset of that context. Null properties are ignored, but any properties that are set must match the same property on the other context.

Parameters
other

public String toString ()