public PrintServiceAttributeSet getAttributes() { PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet(); attrs.add(getPrinterName()); attrs.add(getPrinterIsAcceptingJobs()); PrinterState prnState = getPrinterState(); if (prnState != null) { attrs.add(prnState); } PrinterStateReasons prnStateReasons = getPrinterStateReasons(); if (prnStateReasons != null) { attrs.add(prnStateReasons); } attrs.add(getQueuedJobCount()); int caps = getPrinterCapabilities(); if ((caps & DEVCAP_COLOR) != 0) { attrs.add(ColorSupported.SUPPORTED); } else { attrs.add(ColorSupported.NOT_SUPPORTED); } return AttributeSetUtilities.unmodifiableView(attrs); }
@Override public <T extends PrintServiceAttribute>T getAttribute(Class<T> category){ if(category == null){ throw new NullPointerException("category"); } if(!(PrintServiceAttribute.class.isAssignableFrom(category))){ throw new IllegalArgumentException("The categhory '" + category + "' is not a valid PrintServiceAttribute"); } if(category == ColorSupported.class){ // works better than settings.get_SupportsColor(); if(settings.get_DefaultPageSettings().get_Color()){ return (T)ColorSupported.SUPPORTED; }else{ return (T)ColorSupported.NOT_SUPPORTED; } }else if(category == PrinterName.class){ return (T)getPrinterName(); } else { // QueuedJobCount and PrinterIsAcceptingJobs return (T)peer.getPrinterStatus(printer, category); } }
public <T extends PrintServiceAttribute> T getAttribute(Class<T> category) { if (category == null) { throw new NullPointerException("category"); } if (!(PrintServiceAttribute.class.isAssignableFrom(category))) { throw new IllegalArgumentException("Not a PrintServiceAttribute"); } if (category == ColorSupported.class) { @SuppressWarnings("unchecked") T tmp = (T)ColorSupported.SUPPORTED; return tmp; } else { return null; } }
public final void testUnmodifiableView() { AttributeSet aset = new HashAttributeSet(); aset = AttributeSetUtilities.unmodifiableView(aset); try { aset.add(ColorSupported.SUPPORTED); aset.addAll(aset); aset.clear(); aset.remove(ColorSupported.NOT_SUPPORTED); aset.remove(ColorSupported.class); fail("method doesn't throw UnmodifiableSetException if someone" + "try to modify attribute set"); } catch (Exception e) { //System.out.println("testUnmodifiableView - " + e.toString()); } }
public <T extends PrintServiceAttribute> T getAttribute(Class<T> category) { if (category == null) { throw new NullPointerException("category"); } if (!(PrintServiceAttribute.class.isAssignableFrom(category))) { throw new IllegalArgumentException("Not a PrintServiceAttribute"); } if (category == ColorSupported.class) { return (T)ColorSupported.SUPPORTED; } else { return null; } }
public <T extends PrintServiceAttribute> T getAttribute(Class<T> category) { if (category == null) { throw new NullPointerException("category"); } if (!(PrintServiceAttribute.class.isAssignableFrom(category))) { throw new IllegalArgumentException("Not a PrintServiceAttribute"); } if (category == ColorSupported.class) { int caps = getPrinterCapabilities(); if ((caps & DEVCAP_COLOR) != 0) { return (T)ColorSupported.SUPPORTED; } else { return (T)ColorSupported.NOT_SUPPORTED; } } else if (category == PrinterName.class) { return (T)getPrinterName(); } else if (category == PrinterState.class) { return (T)getPrinterState(); } else if (category == PrinterStateReasons.class) { return (T)getPrinterStateReasons(); } else if (category == QueuedJobCount.class) { return (T)getQueuedJobCount(); } else if (category == PrinterIsAcceptingJobs.class) { return (T)getPrinterIsAcceptingJobs(); } else { return null; } }
@Override public PrintServiceAttributeSet getAttributes(){ PrintServiceAttributeSet attrs = new HashPrintServiceAttributeSet(); attrs.add(getPrinterName()); PrinterIsAcceptingJobs acptJobs = getAttribute(PrinterIsAcceptingJobs.class); if(acptJobs != null){ attrs.add(acptJobs); } PrinterState prnState = getAttribute(PrinterState.class); if(prnState != null){ attrs.add(prnState); } PrinterStateReasons prnStateReasons = getAttribute(PrinterStateReasons.class); if(prnStateReasons != null){ attrs.add(prnStateReasons); } QueuedJobCount jobCount = getAttribute(QueuedJobCount.class); if(jobCount != null){ attrs.add(jobCount); } // TODO: Seems to be more accurate than settings.get_SupportsColor(), which doesn't work for CutePDF if(settings.get_DefaultPageSettings().get_Color()){ attrs.add(ColorSupported.SUPPORTED); }else{ attrs.add(ColorSupported.NOT_SUPPORTED); } return AttributeSetUtilities.unmodifiableView(attrs); }
@SuppressWarnings("unchecked") public <T extends PrintServiceAttribute> T getAttribute(Class<T> category) { if (category == null) { throw new NullPointerException("category"); } if (!(PrintServiceAttribute.class.isAssignableFrom(category))) { throw new IllegalArgumentException("Not a PrintServiceAttribute"); } if (category == ColorSupported.class) { int caps = getPrinterCapabilities(); if ((caps & DEVCAP_COLOR) != 0) { return (T)ColorSupported.SUPPORTED; } else { return (T)ColorSupported.NOT_SUPPORTED; } } else if (category == PrinterName.class) { return (T)getPrinterName(); } else if (category == PrinterState.class) { return (T)getPrinterState(); } else if (category == PrinterStateReasons.class) { return (T)getPrinterStateReasons(); } else if (category == QueuedJobCount.class) { return (T)getQueuedJobCount(); } else if (category == PrinterIsAcceptingJobs.class) { return (T)getPrinterIsAcceptingJobs(); } else { return null; } }