Example usage for javax.print.attribute PrintRequestAttributeSet containsValue

List of usage examples for javax.print.attribute PrintRequestAttributeSet containsValue

Introduction

In this page you can find the example usage for javax.print.attribute PrintRequestAttributeSet containsValue.

Prototype

public boolean containsValue(Attribute attribute);

Source Link

Document

Returns true if this attribute set contains the given attribute value.

Usage

From source file:org.pentaho.reporting.engine.classic.extensions.modules.java14print.Java14PrintUtil.java

/**
 * This tests, whether the given attribute set defines the same page properties as the given JFreeReport object.
 * <p/>//from ww w. j  av a  2 s.co  m
 * While showing the print dialog, the user has the chance to alter the page format of the print job. When that
 * happens, we have to repaginate the whole report, which may render the users page range input invalid. In that case,
 * we will have to redisplay the dialog.
 *
 * @param attributes
 * @param report
 * @return
 */
public static int isValidConfiguration(final PrintRequestAttributeSet attributes, final MasterReport report) {
    final PrintRequestAttributeSet reportAttributes = copyConfiguration(null, report);
    // now, compare that minimal set with the given attribute collection.

    final Attribute[] printAttribs = reportAttributes.toArray();
    boolean invalidConfig = false;
    for (int i = 0; i < printAttribs.length; i++) {
        final Attribute attrib = printAttribs[i];
        if (attributes.containsValue(attrib) == false) {
            invalidConfig = true;
            break;
        }
    }

    if (invalidConfig == false) {
        return CONFIGURATION_VALID;
    }
    if (attributes.containsKey(PageRanges.class)) {
        return CONFIGURATION_SHOW_DIALOG;
    }
    return CONFIGURATION_REPAGINATE;
}