@Test public void testIsValidConfiguration() { PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); MasterReport report = mockReport( PageFormat.LANDSCAPE ); int result = Java14PrintUtil.isValidConfiguration( attributes, report ); assertThat( result, is( equalTo( Java14PrintUtil.CONFIGURATION_REPAGINATE ) ) ); attributes.add( new PageRanges( 1 ) ); result = Java14PrintUtil.isValidConfiguration( attributes, report ); assertThat( result, is( equalTo( Java14PrintUtil.CONFIGURATION_SHOW_DIALOG ) ) ); attributes = Java14PrintUtil.copyConfiguration( null, report ); result = Java14PrintUtil.isValidConfiguration( attributes, report ); assertThat( result, is( equalTo( Java14PrintUtil.CONFIGURATION_VALID ) ) ); }
public static int isValidConfiguration( final PrintRequestAttributeSet attributes, final MasterReport report ) { final PrintRequestAttributeSet reportAttributes = copyConfiguration( null, report ); 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; }
Java14PrintUtil { public static int isValidConfiguration( final PrintRequestAttributeSet attributes, final MasterReport report ) { final PrintRequestAttributeSet reportAttributes = copyConfiguration( null, report ); 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; } }
Java14PrintUtil { public static int isValidConfiguration( final PrintRequestAttributeSet attributes, final MasterReport report ) { final PrintRequestAttributeSet reportAttributes = copyConfiguration( null, report ); 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; } private  Java14PrintUtil(); }
Java14PrintUtil { public static int isValidConfiguration( final PrintRequestAttributeSet attributes, final MasterReport report ) { final PrintRequestAttributeSet reportAttributes = copyConfiguration( null, report ); 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; } private  Java14PrintUtil(); static int isValidConfiguration( final PrintRequestAttributeSet attributes, final MasterReport report ); static PrintRequestAttributeSet copyConfiguration( PrintRequestAttributeSet attributes,
      final MasterReport report ); static PrintRequestAttributeSet copyAuxillaryAttributes( PrintRequestAttributeSet attributes,
      final MasterReport report ); static PageFormat extractPageFormat( final PrintRequestAttributeSet attributeSet ); static void printDirectly( final MasterReport report, PrintService printService ); static boolean print( final MasterReport report ); static boolean print( final MasterReport report, final ReportProgressListener progressListener ); }
Java14PrintUtil { public static int isValidConfiguration( final PrintRequestAttributeSet attributes, final MasterReport report ) { final PrintRequestAttributeSet reportAttributes = copyConfiguration( null, report ); 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; } private  Java14PrintUtil(); static int isValidConfiguration( final PrintRequestAttributeSet attributes, final MasterReport report ); static PrintRequestAttributeSet copyConfiguration( PrintRequestAttributeSet attributes,
      final MasterReport report ); static PrintRequestAttributeSet copyAuxillaryAttributes( PrintRequestAttributeSet attributes,
      final MasterReport report ); static PageFormat extractPageFormat( final PrintRequestAttributeSet attributeSet ); static void printDirectly( final MasterReport report, PrintService printService ); static boolean print( final MasterReport report ); static boolean print( final MasterReport report, final ReportProgressListener progressListener ); static final int CONFIGURATION_VALID; static final int CONFIGURATION_REPAGINATE; static final int CONFIGURATION_SHOW_DIALOG; }