Class PersonPageDataSerializer
- java.lang.Object
-
- romanemperorsscraper.scraping.people.PersonPageDataSerializer
-
public final class PersonPageDataSerializer extends java.lang.Object
Utility class providing methods for dynasties people' PersonPageData objects serialization.- Author:
- Matteo Collica, Radu Ionut Barbalata
- See Also:
PersonPageData
,PersonNameUrl
-
-
Constructor Summary
Constructors Modifier Constructor Description private
PersonPageDataSerializer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.ArrayList<PersonNameUrl>
deserializeArrayOfPersonNameUrl(org.json.simple.JSONObject serializedArrayOfPersonNameUrls)
Restore (and construct) an ArrayList of PersonNameUrl(s) from a JSONObject (its serialized form)static PersonNameUrl
deserializePersonNameUrl(org.json.simple.JSONObject serializedPersonNameUrl)
Restore (and construct) a PersonNameUrl from a JSONObject (its serialized form)static java.util.HashMap<java.lang.String,PersonPageData>
deserializePersonPageDataHashMap(org.json.simple.JSONObject serializedHashMap)
Given a JSONObject which represents the serialized form of an HashMap containing some PersonPageData instances by their Wikipedia page URL, reconstruct the corresponding PersonPageData objects and, once the deserialization is completed, return the original HashMapstatic java.lang.String
parseJsonString(java.lang.Object object)
Cast an Object to a Stringprivate static org.json.simple.JSONObject
serializeArrayOfPersonNameUrl(java.util.ArrayList<PersonNameUrl> arrayOfPersonNameUrls)
Create and return a serialized form of a given ArrayList of PersonNameUrl objectsprivate static org.json.simple.JSONObject
serializePersonNameUrl(PersonNameUrl personNameUrl)
Create and return a serialized form of a given PersonNameUrl objectstatic org.json.simple.JSONObject
serializePersonPageData(PersonPageData personPageData)
Create and return a serialized form of a given PersonPageData objectstatic org.json.simple.JSONObject
serializePersonPageDataHashMap(java.util.HashMap<java.lang.String,PersonPageData> urlPersonPageDataMatches)
Given an HashMap containing PersonPageData instances by URL, serialize it in a single JSONObject and then return it
-
-
-
Method Detail
-
serializePersonPageData
public static org.json.simple.JSONObject serializePersonPageData(PersonPageData personPageData)
Create and return a serialized form of a given PersonPageData object- Parameters:
personPageData
- the PersonPageData object to be serialized- Returns:
- the PersonPageData object serialized as a JSONObject
-
parseJsonString
public static java.lang.String parseJsonString(java.lang.Object object)
Cast an Object to a String- Parameters:
object
- the object to be casted as String- Returns:
- null if the Object is null, the Object casted as String otherwise
-
serializePersonNameUrl
private static org.json.simple.JSONObject serializePersonNameUrl(PersonNameUrl personNameUrl)
Create and return a serialized form of a given PersonNameUrl object- Parameters:
personNameUrl
- the PersonNameUrl object to be serialized- Returns:
- the PersonNameUrl object serialized as a JSONObject
-
deserializePersonNameUrl
public static PersonNameUrl deserializePersonNameUrl(org.json.simple.JSONObject serializedPersonNameUrl)
Restore (and construct) a PersonNameUrl from a JSONObject (its serialized form)- Parameters:
serializedPersonNameUrl
- the JSONObject to deserialize data from- Returns:
- null if the serialized PersonNameUrl is empty or null, the deserialized PersonNameUrl instance otherwise
-
serializeArrayOfPersonNameUrl
private static org.json.simple.JSONObject serializeArrayOfPersonNameUrl(java.util.ArrayList<PersonNameUrl> arrayOfPersonNameUrls)
Create and return a serialized form of a given ArrayList of PersonNameUrl objects- Parameters:
arrayOfPersonNameUrls
- an ArrayList of PersonNameUrl objects to be serialized- Returns:
- the ArrayList of PersonNameUrl(s) serialized as a JSONObject
-
deserializeArrayOfPersonNameUrl
public static java.util.ArrayList<PersonNameUrl> deserializeArrayOfPersonNameUrl(org.json.simple.JSONObject serializedArrayOfPersonNameUrls)
Restore (and construct) an ArrayList of PersonNameUrl(s) from a JSONObject (its serialized form)- Parameters:
serializedArrayOfPersonNameUrls
- the JSONObject to deserialize data from- Returns:
- null if the ArrayList of serialized PersonNameUrl(s) is empty or null, the deserialized ArrayList of PersonNameUrl instances otherwise
-
serializePersonPageDataHashMap
public static org.json.simple.JSONObject serializePersonPageDataHashMap(java.util.HashMap<java.lang.String,PersonPageData> urlPersonPageDataMatches)
Given an HashMap containing PersonPageData instances by URL, serialize it in a single JSONObject and then return it- Parameters:
urlPersonPageDataMatches
- the HashMap of PersonPageData instances to be serialized- Returns:
- a JSONObject containing the serialized PersonPageData instances, where the key for each PersonPageData is its Wikipedia page URL
-
deserializePersonPageDataHashMap
public static java.util.HashMap<java.lang.String,PersonPageData> deserializePersonPageDataHashMap(org.json.simple.JSONObject serializedHashMap)
Given a JSONObject which represents the serialized form of an HashMap containing some PersonPageData instances by their Wikipedia page URL, reconstruct the corresponding PersonPageData objects and, once the deserialization is completed, return the original HashMap- Parameters:
serializedHashMap
- the JSONObject to deserialize data from- Returns:
- the deserialized HashMap of PersonPageData instances by their Wikipedia page URL
-
-