public void removePrintJobAttributeListener( PrintJobAttributeListener listener) { synchronized (this) { if (listener == null || attrListeners == null ) { return; } int index = attrListeners.indexOf(listener); if (index == -1) { return; } else { attrListeners.remove(index); listenedAttributeSets.remove(index); if (attrListeners.isEmpty()) { attrListeners = null; listenedAttributeSets = null; } } } }
@Override public void removePrintJobAttributeListener(PrintJobAttributeListener listener){ synchronized(this){ if(listener == null || attrListeners == null){ return; } int index = attrListeners.indexOf(listener); if(index == -1){ return; }else{ attrListeners.remove(index); listenedAttributeSets.remove(index); if(attrListeners.isEmpty()){ attrListeners = null; listenedAttributeSets = null; } } } }
void notifyAttrListeners(final PrintJobAttribute... attrs) { final PrintJobAttributeSet attrSet = new HashPrintJobAttributeSet(attrs); final PrintJobAttributeEvent event = new PrintJobAttributeEvent(this, attrSet); for (PrintJobAttribute attr : attrs) { final Class<? extends Attribute> cat = attr.getCategory(); for (Map.Entry<PrintJobAttributeListener, PrintJobAttributeSet> e : attrListeners .entrySet()) { if ((e.getValue() == null) || (e.getValue().containsKey(cat))) { e.getKey().attributeUpdate(event); } } } }