Skip to content

JohnBrainard/gravatar-java-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gravatar Java API

The Gravatar Java API is a simple wrapper around the Gravatar image and profile URLs. The goal is to implement a complete Java API then add J2EE support.

Features

  • Simple Java API access to Gravatar features
  • Supports multiple ratings parameters
  • Native Java object access to Gravatar profile data

Planned Features

  • JSP Tags
  • Grails plugin

Sample Usage

Generate Gravatar Image URL

GravatarImageURL gravatarURL = new GravatarImageURL("test@test.com");

gravatarURL.setDefaultImage(GravatarDefaultImage.RandomMonster);
gravatarURL.setSize(100);

String toString = gravatarURL.toString();

Retrieve Image as Byte Array

try {
	gravatarURL.getBytes() // Throws IOException
} catch (IOException ex) {
	// Handle exception...
}

Want profile info as native Java Objects?

The following example loads the profile JSON and parses it using the Gson parser, all of which is transparent to you. You can just as easily use PCContactLoader.getLoader().loadContact(Reader) to load from a JSON source outside of Gravatar.

GravatarProfileURL profile = new GravatarProfileURL("test@test.com");

PCContact contact = profile.getContact();

In order to run the above code, ensure that the Gson library is on your classpath. To keep the Gravatar Java API ligthweight, the maven dependency for the Gson library is required only at compile time so that you're not forced to load a library you don't need if all you care to do is generate URLs or parse the JSON or XML data yourself.

About

Gravatar Java API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages