Package org.dlese.dpc.oai
Class OAIUtils
java.lang.Object
org.dlese.dpc.oai.OAIUtils
Contains utility methods used in OAI.
- Version:
- $Id: OAIUtils.java,v 1.11 2009/03/20 23:33:53 jweather Exp $
- Author:
- John Weatherley
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringDecode an identifier or resumption token.static StringEncode an identifier or resumption token.static final DategetDateFromDatestamp(String datestamp) Converts an ISO8601 UTC datestamp String of the form yyyy-MM-ddTHH:mm:ssZ or the short form yyyy-MM-dd to a Java Date.static final DategetDateFromDatestamp(String datestamp, long increment) Converts an ISO8601 UTC datastamp String of the form yyyy-MM-ddTHH:mm:ssZ or the short form yyyy-MM-dd to a Java Date.static final StringgetDatestampFromDate(Date date) Gets an ISO8601 UTC datestamp string of the form yyyy-MM-ddTHH:mm:ssZ from a Date.static StringgetHarvestedDirBaseURLPath(String basePath, String baseURL) Creates an appropriate directory path where harvested file(s) are saved similar to wget paths based on the URI.static StringgetHarvestedDirPath(String basePath, String setname, String prefix, String baseURL) Creates an appropriate directory path where harvested file(s) are saved based on the baseURL, format and set.static final longgetLongFromDatestamp(String datestamp) Converts an ISO8601 UTC datastamp String of the form yyyy-MM-ddTHH:mm:ssZ to a long.static final longgetLongFromDatestamp(String datestamp, long increment) Converts an ISO8601 UTC datastamp String of the form yyyy-MM-ddTHH:mm:ssZ to a long.
-
Constructor Details
-
OAIUtils
public OAIUtils()
-
-
Method Details
-
getDatestampFromDate
Gets an ISO8601 UTC datestamp string of the form yyyy-MM-ddTHH:mm:ssZ from a Date.- Parameters:
date- The Date- Returns:
- The corresponding datestamp String in UTC timezone
- See Also:
-
getDateFromDatestamp
Converts an ISO8601 UTC datestamp String of the form yyyy-MM-ddTHH:mm:ssZ or the short form yyyy-MM-dd to a Java Date. See ISO8601 and OAI date info for more info. If the short form yyyy-MM-dd is given, this method adds the String t01:00:00z to it to produce an ISO8601 compliant date time.- Parameters:
datestamp- A datestamp in UTC format.- Returns:
- The dateFromDatestamp value
- Throws:
ParseException- If unable to interpret the datestamp.
-
getDateFromDatestamp
public static final Date getDateFromDatestamp(String datestamp, long increment) throws ParseException Converts an ISO8601 UTC datastamp String of the form yyyy-MM-ddTHH:mm:ssZ or the short form yyyy-MM-dd to a Java Date. See ISO8601 and OAI date info for more info. If the short form yyyy-MM-dd is given, this method adds the String t01:00:00z to it to produce an ISO8601 compliant date time.- Parameters:
datestamp- A datestamp in UTC format.increment- Number of seconds to increment the date, positive or negative, or 0 to leave unchanged.- Returns:
- The dateFromDatestamp value
- Throws:
ParseException- If unable to interpret the datestamp.
-
getLongFromDatestamp
Converts an ISO8601 UTC datastamp String of the form yyyy-MM-ddTHH:mm:ssZ to a long. See ISO8601 and OAI date info for more info.- Parameters:
datestamp- A datestamp in UTC format.- Returns:
- The longFromDatestamp value
- Throws:
ParseException- If unable to interpret the datestamp.
-
getLongFromDatestamp
public static final long getLongFromDatestamp(String datestamp, long increment) throws ParseException Converts an ISO8601 UTC datastamp String of the form yyyy-MM-ddTHH:mm:ssZ to a long. See ISO8601 and OAI date info for more info.- Parameters:
datestamp- A datestamp in UTC format.increment- Number of seconds to increment the date, positive or negative, or 0 to leave unchanged.- Returns:
- The longFromDatestamp value
- Throws:
ParseException- If unable to interpret the datestamp.
-
getHarvestedDirBaseURLPath
Creates an appropriate directory path where harvested file(s) are saved similar to wget paths based on the URI.- Parameters:
basePath- The base output directory.baseURL- The baseURL of the OAI data provider.- Returns:
- The path where the harvested files are saved.
-
getHarvestedDirPath
public static String getHarvestedDirPath(String basePath, String setname, String prefix, String baseURL) Creates an appropriate directory path where harvested file(s) are saved based on the baseURL, format and set. The set name is encoded for file system compliance.- Parameters:
basePath- The base output directory.setname- The OAI setSpec harvested, or null if none.prefix- The metadataPrefix (format) harvested.baseURL- The baseURL of the OAI data provider.- Returns:
- The path where the harvested files are saved.
-
encode
Encode an identifier or resumption token. Can also be used to encode chars for use in file names.See section 3.1.1.3 in http://www.openarchives.org/OAI/2.0/openarchivesprotocol.htm
- Parameters:
msg- A String to encode.- Returns:
- Encoded String
- Throws:
Exception- If error
-
decode
Decode an identifier or resumption token.See section 3.1.1.3 in http://www.openarchives.org/OAI/2.0/openarchivesprotocol.htm
- Parameters:
msg- Message to decode- Returns:
- Decoded String
- Throws:
Exception- If unable to decode.
-