ImportIO Java Facilitator

Making ImportIO simpler with Java.

This project is maintained by thuzhen

Introduction

Facilitator is a project that aims to integrate ImportIO better in Java apps by caching and parsing data retrieved by ImportIO. This project is just a hobby and is not affiliated with ImportIO.

Features

Integration with POJOs

Facilitator provides an easy and quick way to get POJOs out of your data. Let's see how.

Create an IOClient's instance.

IOClient is a special subclass of ImportIO that provides all the tools to parse your data.

IOClient client = new IOClient("YOURUSERID", "YOURSECRETKEY");

Notes

Create a classic ImportIO Query.

Your query can be almost anything.

Get a POJO class ready to handle you data.

Mark the fields you want to fill with @Attribute("name") annotation with "name" being the column name of your data in ImportIO. Here's an example that could describe a product from a website such as Amazon.

class Product
{
  @Id
  protected long id;
  @Attribute("name")
  protected String name;
  @Attribute("image")
  protected String imageUrl;
  @Attribute("price")
  protected Money price;
  ...
  protected Integer someOtherField
  ...
}

Some special classes such as Date and Money are handled by Facilitator, which means if your field represent a date, its class could be either Date, Long (in which case it will correspond to the timestamp), or String (it will correspond to the date as a string). Here's a quick table of compatible types and classes:

Types Classes Value
Date java.util.Date
Long
String
-
timestamp
literal date
Money org.joda.money.Money
Double
String
-
Amount of money
Amount of money + currency sign

Notes

Use your IOClient to query the server

It will get you a list of POJO instances. You will have to tell the client which class it should generate (here, Product.class)

List<Product> products = client.populate(query, Product.class);

Notes

In-memory caching

Facilitator automatically cache all the queries you make (actually no more than 200 to save memory) with a TTL of one hour. Which means that if you call populate() again with the same query, it won't reload fresh data unless you force refresh (passing true a the third parameter) or the TTL has expired.

Customize

Facilitator has been built so you can extend it to automatically parse your data and fit it into POJOs. If you want to add your own parser, this is actually quite simple. Explanations coming soon.

Authors and Contributors