public
static
final
class
PrinterCapabilitiesInfo.Builder
extends Object
| java.lang.Object | |
| ↳ | android.print.PrinterCapabilitiesInfo.Builder |
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.
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.Builder
|
setColorModes(int colorModes, int defaultColorMode)
Sets the color modes. |
PrinterCapabilitiesInfo.Builder
|
setDuplexModes(int duplexModes, int defaultDuplexMode)
Sets the duplex modes. |
PrinterCapabilitiesInfo.Builder
|
setMinMargins(PrintAttributes.Margins margins)
Sets the minimal margins. |
Inherited methods | |
|---|---|
java.lang.Object
| |
PrinterCapabilitiesInfo.Builder (PrinterId printerId)
Creates a new instance.
| Parameters | |
|---|---|
printerId |
PrinterId:
The printer id. Cannot be null. |
| Throws | |
|---|---|
IllegalArgumentException |
If the printer id is null.
|
PrinterCapabilitiesInfo.Builder addMediaSize (PrintAttributes.MediaSize mediaSize, boolean isDefault)
Adds a supported media size.
Required: Yes
| Parameters | |
|---|---|
mediaSize |
PrintAttributes.MediaSize:
A media size. |
isDefault |
boolean:
Whether this is the default. |
| Returns | |
|---|---|
PrinterCapabilitiesInfo.Builder |
This builder. |
| Throws | |
|---|---|
IllegalArgumentException |
If set as default and there is already a default. |
See also:
PrinterCapabilitiesInfo.Builder addResolution (PrintAttributes.Resolution resolution, boolean isDefault)
Adds a supported resolution.
Required: Yes
| Parameters | |
|---|---|
resolution |
PrintAttributes.Resolution:
A resolution. |
isDefault |
boolean:
Whether this is the default. |
| Returns | |
|---|---|
PrinterCapabilitiesInfo.Builder |
This builder. |
| Throws | |
|---|---|
IllegalArgumentException |
If set as default and there is already a default. |
See also:
PrinterCapabilitiesInfo build ()
Crates a new PrinterCapabilitiesInfo enforcing that all
required properties have been specified. See individual methods
in this class for reference about required attributes.
Note: If you do not add supported duplex modes,
DUPLEX_MODE_NONE will set
as the only supported mode and also as the default duplex mode.
| Returns | |
|---|---|
PrinterCapabilitiesInfo |
A new PrinterCapabilitiesInfo. |
| Throws | |
|---|---|
IllegalStateException |
If a required attribute was not specified. |
PrinterCapabilitiesInfo.Builder setColorModes (int colorModes, int defaultColorMode)
Sets the color modes.
Required: Yes
| Parameters | |
|---|---|
colorModes |
int:
The color mode bit mask. |
defaultColorMode |
int:
The default color mode. |
| Returns | |
|---|---|
PrinterCapabilitiesInfo.Builder |
This builder.
Note: On platform version 19 (Kitkat) specifying only PrintAttributes#COLOR_MODE_MONOCHROME leads to a print spooler crash. Hence, you should declare either both color modes or PrintAttributes#COLOR_MODE_COLOR. |
| Throws | |
|---|---|
IllegalArgumentException |
If color modes contains an invalid mode bit or if the default color mode is invalid. |
See also:
PrinterCapabilitiesInfo.Builder setDuplexModes (int duplexModes, int defaultDuplexMode)
Sets the duplex modes.
Required: No
| Parameters | |
|---|---|
duplexModes |
int:
The duplex mode bit mask. |
defaultDuplexMode |
int:
The default duplex mode. |
| Returns | |
|---|---|
PrinterCapabilitiesInfo.Builder |
This builder. |
| Throws | |
|---|---|
IllegalArgumentException |
If duplex modes contains an invalid mode bit or if the default duplex mode is invalid. |
PrinterCapabilitiesInfo.Builder setMinMargins (PrintAttributes.Margins margins)
Sets the minimal margins. These are the minimal margins the printer physically supports.
Required: Yes
| Parameters | |
|---|---|
margins |
PrintAttributes.Margins:
The margins. |
| Returns | |
|---|---|
PrinterCapabilitiesInfo.Builder |
This builder. |
| Throws | |
|---|---|
IllegalArgumentException |
If margins are null. |
See also: