to top
Android APIs
public static final class

PrinterCapabilitiesInfo.Builder

extends Object
java.lang.Object
   ↳ android.print.PrinterCapabilitiesInfo.Builder

Class Overview

Builder for creating of a PrinterCapabilitiesInfo. This class is responsible to enforce that all required attributes have at least one default value. In other words, this class creates only well-formed PrinterCapabilitiesInfos.

Look at the individual methods for a reference whether a property is required or if it is optional.

Summary

Public Constructors
PrinterCapabilitiesInfo.Builder(PrinterId printerId)
Creates a new instance.
Public Methods
PrinterCapabilitiesInfo.Builder addMediaSize(PrintAttributes.MediaSize mediaSize, boolean isDefault)
Adds a supported media size.
PrinterCapabilitiesInfo.Builder addResolution(PrintAttributes.Resolution resolution, boolean isDefault)
Adds a supported resolution.
PrinterCapabilitiesInfo build()
Crates a new PrinterCapabilitiesInfo enforcing that all required properties have been specified.
PrinterCapabilitiesInfo.Builder setColorModes(int colorModes, int defaultColorMode)
Sets the color modes.
PrinterCapabilitiesInfo.Builder setMinMargins(PrintAttributes.Margins margins)
Sets the minimal margins.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public PrinterCapabilitiesInfo.Builder (PrinterId printerId)

Added in API level 19

Creates a new instance.

Parameters
printerId The printer id. Cannot be null.
Throws
IllegalArgumentException If the printer id is null.

Public Methods

public PrinterCapabilitiesInfo.Builder addMediaSize (PrintAttributes.MediaSize mediaSize, boolean isDefault)

Added in API level 19

Adds a supported media size.

Required: Yes

Parameters
mediaSize A media size.
isDefault Whether this is the default.
Returns
  • This builder.
Throws
IllegalArgumentException If set as default and there is already a default.

public PrinterCapabilitiesInfo.Builder addResolution (PrintAttributes.Resolution resolution, boolean isDefault)

Added in API level 19

Adds a supported resolution.

Required: Yes

Parameters
resolution A resolution.
isDefault Whether this is the default.
Returns
  • This builder.
Throws
IllegalArgumentException If set as default and there is already a default.

public PrinterCapabilitiesInfo build ()

Added in API level 19

Crates a new PrinterCapabilitiesInfo enforcing that all required properties have been specified. See individual methods in this class for reference about required attributes.

Returns
Throws
IllegalStateException If a required attribute was not specified.

public PrinterCapabilitiesInfo.Builder setColorModes (int colorModes, int defaultColorMode)

Added in API level 19

Sets the color modes.

Required: Yes

Parameters
colorModes The color mode bit mask.
defaultColorMode The default color mode.
Returns
  • This builder.
Throws
IllegalArgumentException If color modes contains an invalid mode bit or if the default color mode is invalid.

public PrinterCapabilitiesInfo.Builder setMinMargins (PrintAttributes.Margins margins)

Added in API level 19

Sets the minimal margins. These are the minimal margins the printer physically supports.

Required: Yes

Parameters
margins The margins.
Returns
  • This builder.
Throws
IllegalArgumentException If margins are null.