com.wselwood.mpcreader.modifiers.YearOfObservationModifier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mpc-reader Show documentation
Show all versions of mpc-reader Show documentation
A Reader for minor planet center data files.
package com.wselwood.mpcreader.modifiers;
import com.wselwood.mpcreader.InvalidDataException;
import com.wselwood.mpcreader.columns.Container;
/**
* Created by wselwood on 03/05/14.
*/
public class YearOfObservationModifier implements Modifier {
public YearOfObservationModifier(Container num, Container input, Container firstYear, Container lastYear) {
this.num = num;
this.input = input;
this.firstYear = firstYear;
this.lastYear = lastYear;
}
@Override
public void process() throws InvalidDataException {
if(num.get() > 1) {
firstYear.set(Integer.parseInt(input.get().substring(0, 4)));
lastYear.set(Integer.parseInt(input.get().substring(5, 9)));
}
else {
firstYear.set(-1);
lastYear.set(-1);
}
}
private final Container num;
private final Container input;
private final Container firstYear;
private final Container lastYear;
}