Here you can find the source of getSetting(PrintService service, PrintRequestAttributeSet set, Class extends Attribute> type, boolean tryDefaultIfNull)
Parameter | Description |
---|---|
service | The PrintService to use. |
set | The PrintRequestAttributeSet to use. |
type | The setting type to extract. |
tryDefaultIfNull | Whether to ask for the default if no value is present in the set. |
null
if neither the set or the service has a value for it.
public static Attribute getSetting(PrintService service, PrintRequestAttributeSet set, Class<? extends Attribute> type, boolean tryDefaultIfNull)
//package com.java2s; /*/*from www . j a v a2 s .c o m*/ * Copyright (c) 1998-2017 by Richard A. Wilkes. All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public * License, version 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This Source Code Form is "Incompatible With Secondary Licenses", as * defined by the Mozilla Public License, version 2.0. */ import javax.print.PrintService; import javax.print.attribute.Attribute; import javax.print.attribute.PrintRequestAttributeSet; public class Main { /** * Extracts a setting from the specified {@link PrintRequestAttributeSet} or looks up a default * value from the specified {@link PrintService} if the set doesn't contain it. * * @param service The {@link PrintService} to use. * @param set The {@link PrintRequestAttributeSet} to use. * @param type The setting type to extract. * @param tryDefaultIfNull Whether to ask for the default if no value is present in the set. * @return The value for the setting, or <code>null</code> if neither the set or the service has * a value for it. */ public static Attribute getSetting(PrintService service, PrintRequestAttributeSet set, Class<? extends Attribute> type, boolean tryDefaultIfNull) { Attribute attribute = set.get(type); if (tryDefaultIfNull && attribute == null && service != null) { attribute = (Attribute) service.getDefaultAttributeValue(type); } return attribute; } }