citysdk.tourism.client.parser
Class DataReader

java.lang.Object
  extended by citysdk.tourism.client.parser.DataReader

public class DataReader
extends java.lang.Object

Used as an aid to get data from a POI-based object. It abstract the parsing of data and gets the information needed specified by the application using a given set of terms or languages. In case a given language is not found, it defaults to en_GB.

Author:
Pedro Cruz

Constructor Summary
DataReader()
           
 
Method Summary
static java.util.Map<java.lang.String,java.util.Locale> getAvailableLangs(POI poi, Field field)
          Gets a mapping of all the available languages of a given field in the POI object.
static java.lang.String getCalendar(POI poi, Term term)
          Returns an iCalendar of the given term.
static java.util.List<java.lang.String> getCategories(POI poi, java.util.Locale lang)
          Gets the categories in a given language.
static java.lang.String getContacts(POI poi)
          Gets the contacts in vCard format
static java.lang.String getDescription(POI poi, java.util.Locale lang)
          Gets the description in a given language.
static java.util.List<ImageContent> getImagesUri(POI poi)
          Gets all the URI images of the given POI object.
static java.lang.String getLabel(POI poi, Term term, java.util.Locale lang)
          Gets the label with the given term in a given language.
static java.lang.String getLink(POI poi, Term term)
          Returns the link with a given term.
static java.util.List<GeometryContent> getLocationGeometry(POI poi, Term term)
          Gets a list of points of the POI object with the given term.
static java.util.List<LineContent> getLocationLine(POI poi, Term term)
          Gets a list of lines of the POI object with the given term.
static java.util.List<PointContent> getLocationPoint(POI poi, Term term)
          Gets a list of points of the POI object with the given term.
static java.util.List<PolygonContent> getLocationPolygon(POI poi, Term term)
          Gets a list of polygons of the POI object with the given term.
static java.lang.String getOccupation(POI poi)
          Gets the occupation in a given language.
static java.lang.String getPrice(POI poi, java.util.Locale lang)
          Gets the price in a given language.
static java.lang.String getRelationshipBase(POI poi, Term term)
          Gets the relationship base with a given term.
static java.lang.String getRelationshipId(POI poi, Term term)
          Gets the relationship id with a given term.
static java.util.List<java.lang.String> getTags(ListTag list, java.util.Locale lang)
          Gets the tags within the list of tags in a given language.
static java.util.List<ImageContent> getThumbnails(POI poi)
          Gets all the thumbnails in 64-base bytecode or URI
static java.lang.String getWaitingTime(POI poi)
          Gets the waiting time in a given language.
static void setDefaultLocale(java.util.Locale locale)
          Sets the default locale.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataReader

public DataReader()
Method Detail

setDefaultLocale

public static void setDefaultLocale(java.util.Locale locale)
Sets the default locale. If locale is null, it defaults to en_GB.

Parameters:
locale - the default locale.

getAvailableLangs

public static java.util.Map<java.lang.String,java.util.Locale> getAvailableLangs(POI poi,
                                                                                 Field field)
Gets a mapping of all the available languages of a given field in the POI object.

Parameters:
poi - the object to get the data.
field - the wanted field
Returns:
a mapping of language codes and the respective locales.

getLabel

public static java.lang.String getLabel(POI poi,
                                        Term term,
                                        java.util.Locale lang)
Gets the label with the given term in a given language.

Parameters:
poi - the object to get the data.
term - the term used.
lang - the wanted language.
Returns:
a String containing the following: the value of the label in the given language. If such language is not found it will return in default language and if the default language is not present it will return a DataContent containing null.

getDescription

public static java.lang.String getDescription(POI poi,
                                              java.util.Locale lang)
Gets the description in a given language.

Parameters:
poi - the object to get the data.
lang - the wanted language.
Returns:
a String containing the following: the value of the description in the desired language or in the default language if none found or null.

getCategories

public static java.util.List<java.lang.String> getCategories(POI poi,
                                                             java.util.Locale lang)
Gets the categories in a given language.

Parameters:
poi - the object to get the data.
lang - the wanted language.
Returns:
a list containing the following: the categories in the desired language if none found or empty.

getPrice

public static java.lang.String getPrice(POI poi,
                                        java.util.Locale lang)
Gets the price in a given language.

Parameters:
poi - the object to get the data.
lang - the wanted language.
Returns:
a String containing the following: the value of the price in the desired language or in the default language if it was not found or null if the default language is not present.

getWaitingTime

public static java.lang.String getWaitingTime(POI poi)
Gets the waiting time in a given language.

Parameters:
poi - the object to get the data.
Returns:
a String containing the waiting time (in seconds) or null.

getOccupation

public static java.lang.String getOccupation(POI poi)
Gets the occupation in a given language.

Parameters:
poi - the object to get the data.
Returns:
a String containing the occupation value (0 to 100) or null.

getThumbnails

public static java.util.List<ImageContent> getThumbnails(POI poi)
Gets all the thumbnails in 64-base bytecode or URI

Parameters:
poi - the object to get the data.
Returns:
a list of ImageContent where each element contains the following: the bytecode (base-64) or URI of the thumbnail, or an empty list if none found.

getLocationGeometry

public static java.util.List<GeometryContent> getLocationGeometry(POI poi,
                                                                  Term term)
Gets a list of points of the POI object with the given term.

Parameters:
poi - the object to get the data.
term - the term to be used.
Returns:
a list (of GeometryContent) containing all geometries with the given term or an empty list.

getLocationPoint

public static java.util.List<PointContent> getLocationPoint(POI poi,
                                                            Term term)
Gets a list of points of the POI object with the given term. It only checks the Point geometry.

Parameters:
poi - the object to get the data.
term - the term to be used.
Returns:
a list (of PointContent) containing all points with the given term or an empty list.

getLocationLine

public static java.util.List<LineContent> getLocationLine(POI poi,
                                                          Term term)
Gets a list of lines of the POI object with the given term. It only checks the Line geometry.

Parameters:
poi - the object to get the data.
term - the term to be used.
Returns:
a list (of LineContent ) containing all lines with the given term or an empty list.

getLocationPolygon

public static java.util.List<PolygonContent> getLocationPolygon(POI poi,
                                                                Term term)
Gets a list of polygons of the POI object with the given term. It only checks the Polygon geometry.

Parameters:
poi - the object to get the data.
term - the term to be used.
Returns:
a list (of PolygonContent) containing all polygons with the given term or an empty list.

getContacts

public static java.lang.String getContacts(POI poi)
Gets the contacts in vCard format

Parameters:
poi - the object to get the data.
Returns:
a String in vCard format containing the information or null if none were found.

getCalendar

public static java.lang.String getCalendar(POI poi,
                                           Term term)
Returns an iCalendar of the given term.

Parameters:
poi - the object to get the data.
term - the term to search for.
Returns:
a String in iCalendar format with the given term or null if none were found.

getImagesUri

public static java.util.List<ImageContent> getImagesUri(POI poi)
Gets all the URI images of the given POI object.

Parameters:
poi - the object to get the data.
Returns:
the list of URIs ( ImageContent) of the images or an empty list if none were found.

getRelationshipBase

public static java.lang.String getRelationshipBase(POI poi,
                                                   Term term)
Gets the relationship base with a given term.

Parameters:
poi - the object to get the data.
term - the term used.
Returns:
a String containing the relationship base with the given term or null if none was found.

getRelationshipId

public static java.lang.String getRelationshipId(POI poi,
                                                 Term term)
Gets the relationship id with a given term.

Parameters:
poi - the object to get the data.
term - the term used.
Returns:
a String containing the relationship id with the given term or null if none was found.

getLink

public static java.lang.String getLink(POI poi,
                                       Term term)
Returns the link with a given term.

Parameters:
poi - the object to get the data.
term - the term used
Returns:
a String containing a link or null if none found.

getTags

public static java.util.List<java.lang.String> getTags(ListTag list,
                                                       java.util.Locale lang)
Gets the tags within the list of tags in a given language.

Parameters:
list - the list of tags.
lang - the wanted language.
Returns:
a list of tags in the given language, or an empty list if none was found.