if (printer == null) return null;
JSONObject options = new JSONObject();
-
PrinterAttributes printerAttrs = printer.getPrinterAttributes();
- Set<Paper> papers = printerAttrs.getSupportedPapers();
JSONArray papersArray = new JSONArray();
- for (Paper source : papers) {
+ for (Paper source : printerAttrs.getSupportedPapers()) {
papersArray.put(source.getName());
}
options.put("paper", papersArray);
+ options.put("defaultPaper",
+ printerAttrs.getDefaultPaper().getName());
- Set<PaperSource> paperSources =
- printerAttrs.getSupportedPaperSources();
JSONArray paperSourcesArray = new JSONArray();
- for (PaperSource source : paperSources) {
+ for (PaperSource source :
+ printerAttrs.getSupportedPaperSources()) {
paperSourcesArray.put(source.getName());
}
options.put("paperSource", papersArray);
+ options.put("defaultPaperSource",
+ printerAttrs.getDefaultPaperSource().getName());
-
- Set<Collation> collations = printerAttrs.getSupportedCollations();
JSONArray collationsArray = new JSONArray();
- for (Collation collation : collations) {
+ for (Collation collation :
+ printerAttrs.getSupportedCollations()) {
collationsArray.put(collation.toString());
}
options.put("collation", collationsArray);
+ options.put("defaultCollation",
+ printerAttrs.getDefaultCollation().toString());
- Set<PrintColor> colors = printerAttrs.getSupportedPrintColors();
JSONArray colorsArray = new JSONArray();
- for (PrintColor color : colors) {
+ for (PrintColor color :
+ printerAttrs.getSupportedPrintColors()) {
colorsArray.put(color.toString());
}
options.put("printColor", colorsArray);
+ options.put("defaultPrintColor",
+ printerAttrs.getDefaultPrintColor().toString());
- Set<PrintQuality> qualities = printerAttrs.getSupportedPrintQuality();
JSONArray qualityArray = new JSONArray();
- for (PrintQuality quality : qualities) {
+ for (PrintQuality quality :
+ printerAttrs.getSupportedPrintQuality()) {
qualityArray.put(quality.toString());
}
options.put("printQuality", qualityArray);
+ options.put("defaultPrintQuality",
+ printerAttrs.getDefaultPrintQuality().toString());
- Set<PrintSides> sides = printerAttrs.getSupportedPrintSides();
JSONArray sidesArray = new JSONArray();
- for (PrintSides side : sides) {
+ for (PrintSides side : printerAttrs.getSupportedPrintSides()) {
sidesArray.put(side.toString());
}
- options.put("printSides", qualityArray);
+ options.put("printSides", sidesArray);
+ options.put("defaultPrintSides",
+ printerAttrs.getDefaultPrintSides().toString());
- Set<PageOrientation> orients =
- printerAttrs.getSupportedPageOrientations();
JSONArray orientsArray = new JSONArray();
- for (PageOrientation orient : orients) {
+ for (PageOrientation orient :
+ printerAttrs.getSupportedPageOrientations()) {
orientsArray.put(orient.toString());
}
options.put("pageOrientation", orientsArray);
+ options.put("defaultPageOrientation",
+ printerAttrs.getDefaultPageOrientation().toString());
+
+ JSONArray marginsArray = new JSONArray();
+ for (Printer.MarginType margin : Printer.MarginType.values()) {
+ marginsArray.put(margin.toString());
+ }
+ options.put("marginType", marginsArray);
+ options.put("defaultMarginType", Printer.MarginType.DEFAULT);
+
+ options.put("supportsPageRanges", printerAttrs.supportsPageRanges());
+ options.put("defaultCopies", printerAttrs.getDefaultCopies());
return options;
}