Builder
class Builder
| kotlin.Any | |
| ↳ | 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.
Summary
| Public constructors | |
|---|---|
|
Creates a new instance. |
|
| Public methods | |
|---|---|
| PrinterCapabilitiesInfo.Builder |
addMediaSize(mediaSize: PrintAttributes.MediaSize, isDefault: Boolean)Adds a supported media size. |
| PrinterCapabilitiesInfo.Builder |
addResolution(resolution: PrintAttributes.Resolution, isDefault: Boolean)Adds a supported resolution. |
| PrinterCapabilitiesInfo |
build()Crates a new |
| PrinterCapabilitiesInfo.Builder |
setColorModes(colorModes: Int, defaultColorMode: Int)Sets the color modes. |
| PrinterCapabilitiesInfo.Builder |
setDuplexModes(duplexModes: Int, defaultDuplexMode: Int)Sets the duplex modes. |
| PrinterCapabilitiesInfo.Builder |
setMinMargins(margins: PrintAttributes.Margins)Sets the minimal margins. |
Public constructors
Builder
Builder(printerId: PrinterId)
Creates a new instance.
| Parameters | |
|---|---|
printerId |
PrinterId: The printer id. Cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
If the printer id is null. |
Public methods
addMediaSize
fun addMediaSize(
mediaSize: PrintAttributes.MediaSize,
isDefault: Boolean
): PrinterCapabilitiesInfo.Builder
Adds a supported media size.
Required: Yes
| Parameters | |
|---|---|
mediaSize |
PrintAttributes.MediaSize: A media size. This value cannot be null. |
isDefault |
Boolean: Whether this is the default. |
| Return | |
|---|---|
PrinterCapabilitiesInfo.Builder |
This builder. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
If set as default and there is already a default. |
addResolution
fun addResolution(
resolution: PrintAttributes.Resolution,
isDefault: Boolean
): PrinterCapabilitiesInfo.Builder
Adds a supported resolution.
Required: Yes
| Parameters | |
|---|---|
resolution |
PrintAttributes.Resolution: A resolution. This value cannot be null. |
isDefault |
Boolean: Whether this is the default. |
| Return | |
|---|---|
PrinterCapabilitiesInfo.Builder |
This builder. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
If set as default and there is already a default. |
build
fun build(): PrinterCapabilitiesInfo
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, android.print.PrintAttributes#DUPLEX_MODE_NONE will set as the only supported mode and also as the default duplex mode.
| Return | |
|---|---|
PrinterCapabilitiesInfo |
A new PrinterCapabilitiesInfo. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalStateException |
If a required attribute was not specified. |
setColorModes
fun setColorModes(
colorModes: Int,
defaultColorMode: Int
): PrinterCapabilitiesInfo.Builder
Sets the color modes.
Required: Yes
| Parameters | |
|---|---|
colorModes |
Int: The color mode bit mask. Value is either 0 or a combination of android.print.PrintAttributes#COLOR_MODE_MONOCHROME, and android.print.PrintAttributes#COLOR_MODE_COLOR |
defaultColorMode |
Int: The default color mode. Value is either 0 or a combination of android.print.PrintAttributes#COLOR_MODE_MONOCHROME, and android.print.PrintAttributes#COLOR_MODE_COLOR |
| Return | |
|---|---|
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. This value cannot benull. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
If color modes contains an invalid mode bit or if the default color mode is invalid. |
setDuplexModes
fun setDuplexModes(
duplexModes: Int,
defaultDuplexMode: Int
): PrinterCapabilitiesInfo.Builder
Sets the duplex modes.
Required: No
| Parameters | |
|---|---|
duplexModes |
Int: The duplex mode bit mask. Value is either 0 or a combination of android.print.PrintAttributes#DUPLEX_MODE_NONE, android.print.PrintAttributes#DUPLEX_MODE_LONG_EDGE, and android.print.PrintAttributes#DUPLEX_MODE_SHORT_EDGE |
defaultDuplexMode |
Int: The default duplex mode. Value is either 0 or a combination of android.print.PrintAttributes#DUPLEX_MODE_NONE, android.print.PrintAttributes#DUPLEX_MODE_LONG_EDGE, and android.print.PrintAttributes#DUPLEX_MODE_SHORT_EDGE |
| Return | |
|---|---|
PrinterCapabilitiesInfo.Builder |
This builder. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
If duplex modes contains an invalid mode bit or if the default duplex mode is invalid. |
setMinMargins
fun setMinMargins(margins: PrintAttributes.Margins): PrinterCapabilitiesInfo.Builder
Sets the minimal margins. These are the minimal margins the printer physically supports.
Required: Yes
| Parameters | |
|---|---|
margins |
PrintAttributes.Margins: The margins. This value cannot be null. |
| Return | |
|---|---|
PrinterCapabilitiesInfo.Builder |
This builder. This value cannot be null. |
| Exceptions | |
|---|---|
java.lang.IllegalArgumentException |
If margins are null. |