* Parse the expiration date string into appropriate fields.
*/
private void parseDateString() throws BrokerException {
String dateString = props.getProperty(PROP_DATE_STRING);
if (dateString == null)
throw new BrokerException(br.getString(br.E_BAD_LICENSE_DATA));
if (dateString.startsWith(NONE_STRING)) {
// Do nothing.
}
else if (dateString.startsWith(TRY_STRING)) {
// this license contains the number of days to try
int oindex = dateString.indexOf(OPEN_BRACKET);
int cindex = dateString.indexOf(CLOSE_BRACKET);
int d = Integer.parseInt(
dateString.substring(oindex+1, cindex));
setDaysToTry(d);
} else if (dateString.startsWith(VALID_STRING)) {
// this license contains a date range
int oindex = dateString.indexOf(OPEN_BRACKET);
int dashindex = dateString.indexOf(DASH);
int cindex = dateString.indexOf(CLOSE_BRACKET);
if ((dashindex - oindex) > 1) {
// we have a start date
long start = Long.parseLong(
dateString.substring(oindex+1, dashindex));
setStartDate(new Date(start));
}
if ((cindex - dashindex) > 1) {
// we have an exipriation date
long end = Long.parseLong(
dateString.substring(dashindex+1, cindex));
setExpirationDate(new Date(end));
}
} else {
// bad format
throw new BrokerException(br.getString(br.E_BAD_LICENSE_DATA));
}
}