IniPrinterSection.java
package sidplay.ini;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import libsidplay.components.printer.PrinterConnection;
import libsidplay.components.printer.PrinterModel;
import libsidplay.config.IPrinterSection;
import sidplay.ini.converter.BeanToStringConverter;
import static libsidplay.config.IPrinterSection.PRINTER_SECTION_BUNDLE;
import static sidplay.ini.IniDefaults.*;
/**
* Printer section of the INI file.
*
* @author Ken Händel
*
*/
@Parameters(resourceBundle = PRINTER_SECTION_BUNDLE)
public class IniPrinterSection extends IniSection implements IPrinterSection {
private static final String SECTION_ID = "Printer";
protected IniPrinterSection(IniReader iniReader) {
super(iniReader);
}
/**
* Printer turned on?
*
* @return printer turned on?
*/
@Override
public final boolean isPrinterOn() {
return iniReader.getPropertyBool(SECTION_ID, "PrinterOn", DEFAULT_PRINTER_ON);
}
/**
* Turn the printer on.
*
* @param on printer turned on?
*/
@Override
@Parameter(names = {"--printerOn"}, arity = 1, descriptionKey = "PRINTER_ON", order = 80)
public final void setPrinterOn(final boolean on) {
iniReader.setProperty(SECTION_ID, "PrinterOn", on);
}
@Override
public final PrinterModel getPrinterModel() {
return iniReader.getPropertyEnum(SECTION_ID, "PrinterModel", DEFAULT_PRINTER_MODEL, PrinterModel.class);
}
@Override
@Parameter(names = {"--printerModel"}, descriptionKey = "PRINTER_MODEL", order = 81)
public final void setPrinterModel(PrinterModel model) {
iniReader.setProperty(SECTION_ID, "PrinterModel", model);
}
@Override
public final PrinterConnection getPrinterConnection() {
return iniReader.getPropertyEnum(SECTION_ID, "PrinterConnection", DEFAULT_PRINTER_CONNECTION, PrinterConnection.class);
}
@Override
@Parameter(names = {"--printerConnection"}, descriptionKey = "PRINTER_CONNECTION", order = 82)
public final void setPrinterConnection(PrinterConnection connection) {
iniReader.setProperty(SECTION_ID, "PrinterConnection", connection);
}
@Override
public final String toString() {
return BeanToStringConverter.toString(this);
}
}