
// InternetArchive.java 
// Andrew Davison, ad@coe.psu.ac.th, July 2023

/* DTO (Data Transfer Object) classes used by 
   Google GSON to map the JSON responses from the
   Internet Archive advanced search to Java objects.
     https://archive.org/advancedsearch.php


   Based on code generated by
   https://json2csharp.com/code-converters/json-to-pojo
   when supplied with JSON output ffrom several searches
*/


import java.util.*;

import com.google.gson.annotations.*;



import java.util.*;


class InternetArchive
{
  ResponseHeader responseHeader;
  Response response;
}


class ResponseHeader
{
  int status;
  int qTime;
  Params params;
}


class Params
{
  String query;
  String qin;
  String fields;
  String wt;
  String sort;
  String rows;
  int start;
}


class Response
{
  int numFound;
  int start;
  ArrayList<Doc> docs;
}


class Doc
/* this doesn't include all the possible Doc fields,
   only the ones requested in the fl[] parameters in
   the URL query
*/
{
  String identifier;
  String title;
  int year;

  // these vars can be string or a list of strings
  Object publisher;
  Object creator;  
  Object subject;   
  Object description; 
  Object format;
  

  // ensure that a string list is always returned

  public ArrayList<String> getPublisher() 
  {  return HTTPUtils.getStringList(publisher);  }

  public ArrayList<String> getCreator() 
  {  return HTTPUtils.getStringList(creator);  }

  public ArrayList<String> getSubject() 
  {  return HTTPUtils.getStringList(subject);  }

  public ArrayList<String> getDescription() 
  {  return HTTPUtils.getStringList(description);  }

  public ArrayList<String> getFormat() 
  {  return HTTPUtils.getStringList(format);  }


}  // end of Doc class



