Example usage for javax.print.attribute PrintRequestAttributeSet toArray

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

Introduction

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

Prototype

public Attribute[] toArray();

Source Link

Document

Returns an array of the attributes contained in this set.

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/>//  w ww.ja v a 2s  . c  o 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;
}