/* * Copyright 2010-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.amazonaws.services.comprehend.model; import java.io.Serializable; import com.amazonaws.AmazonWebServiceRequest; /** *

* Creates a new document classification request to analyze a single document in * real-time, using a previously created and trained custom model and an * endpoint. *

*

* You can input plain text or you can upload a single-page input document * (text, PDF, Word, or image). *

*

* If the system detects errors while processing a page in the input document, * the API response includes an entry in Errors that describes the * errors. *

*

* If the system detects a document-level error in your input document, the API * returns an InvalidRequestException error response. For details * about this exception, see * Errors in semi-structured documents in the Comprehend Developer Guide. *

*/ public class ClassifyDocumentRequest extends AmazonWebServiceRequest implements Serializable { /** *

* The document text to be analyzed. If you enter text using this parameter, * do not use the Bytes parameter. *

*

* Constraints:
* Length: 1 -
*/ private String text; /** *

* The Amazon Resource Number (ARN) of the endpoint. For information about * endpoints, see Managing endpoints. *

*

* Constraints:
* Length: - 256
* Pattern: * arn:aws(-[^:]+)?:comprehend:[a-zA-Z0-9-]*:[0-9]{12}:document * -classifier-endpoint/[a-zA-Z0-9](-*[a-zA-Z0-9])*
*/ private String endpointArn; /** *

* Use the Bytes parameter to input a text, PDF, Word or image * file. You can also use the Bytes parameter to input an * Amazon Textract DetectDocumentText or * AnalyzeDocument output file. *

*

* Provide the input document as a sequence of base64-encoded bytes. If your * code uses an Amazon Web Services SDK to classify documents, the SDK may * encode the document file bytes for you. *

*

* The maximum length of this field depends on the input document type. For * details, see * Inputs for real-time custom analysis in the Comprehend Developer * Guide. *

*

* If you use the Bytes parameter, do not use the * Text parameter. *

*

* Constraints:
* Length: 1 -
*/ private java.nio.ByteBuffer bytes; /** *

* Provides configuration parameters to override the default actions for * extracting text from PDF documents and image files. *

*/ private DocumentReaderConfig documentReaderConfig; /** *

* The document text to be analyzed. If you enter text using this parameter, * do not use the Bytes parameter. *

*

* Constraints:
* Length: 1 -
* * @return

* The document text to be analyzed. If you enter text using this * parameter, do not use the Bytes parameter. *

*/ public String getText() { return text; } /** *

* The document text to be analyzed. If you enter text using this parameter, * do not use the Bytes parameter. *

*

* Constraints:
* Length: 1 -
* * @param text

* The document text to be analyzed. If you enter text using this * parameter, do not use the Bytes parameter. *

*/ public void setText(String text) { this.text = text; } /** *

* The document text to be analyzed. If you enter text using this parameter, * do not use the Bytes parameter. *

*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Length: 1 -
* * @param text

* The document text to be analyzed. If you enter text using this * parameter, do not use the Bytes parameter. *

* @return A reference to this updated object so that method calls can be * chained together. */ public ClassifyDocumentRequest withText(String text) { this.text = text; return this; } /** *

* The Amazon Resource Number (ARN) of the endpoint. For information about * endpoints, see Managing endpoints. *

*

* Constraints:
* Length: - 256
* Pattern: * arn:aws(-[^:]+)?:comprehend:[a-zA-Z0-9-]*:[0-9]{12}:document * -classifier-endpoint/[a-zA-Z0-9](-*[a-zA-Z0-9])*
* * @return

* The Amazon Resource Number (ARN) of the endpoint. For information * about endpoints, see Managing endpoints. *

*/ public String getEndpointArn() { return endpointArn; } /** *

* The Amazon Resource Number (ARN) of the endpoint. For information about * endpoints, see Managing endpoints. *

*

* Constraints:
* Length: - 256
* Pattern: * arn:aws(-[^:]+)?:comprehend:[a-zA-Z0-9-]*:[0-9]{12}:document * -classifier-endpoint/[a-zA-Z0-9](-*[a-zA-Z0-9])*
* * @param endpointArn

* The Amazon Resource Number (ARN) of the endpoint. For * information about endpoints, see Managing endpoints. *

*/ public void setEndpointArn(String endpointArn) { this.endpointArn = endpointArn; } /** *

* The Amazon Resource Number (ARN) of the endpoint. For information about * endpoints, see Managing endpoints. *

*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Length: - 256
* Pattern: * arn:aws(-[^:]+)?:comprehend:[a-zA-Z0-9-]*:[0-9]{12}:document * -classifier-endpoint/[a-zA-Z0-9](-*[a-zA-Z0-9])*
* * @param endpointArn

* The Amazon Resource Number (ARN) of the endpoint. For * information about endpoints, see Managing endpoints. *

* @return A reference to this updated object so that method calls can be * chained together. */ public ClassifyDocumentRequest withEndpointArn(String endpointArn) { this.endpointArn = endpointArn; return this; } /** *

* Use the Bytes parameter to input a text, PDF, Word or image * file. You can also use the Bytes parameter to input an * Amazon Textract DetectDocumentText or * AnalyzeDocument output file. *

*

* Provide the input document as a sequence of base64-encoded bytes. If your * code uses an Amazon Web Services SDK to classify documents, the SDK may * encode the document file bytes for you. *

*

* The maximum length of this field depends on the input document type. For * details, see * Inputs for real-time custom analysis in the Comprehend Developer * Guide. *

*

* If you use the Bytes parameter, do not use the * Text parameter. *

*

* Constraints:
* Length: 1 -
* * @return

* Use the Bytes parameter to input a text, PDF, Word * or image file. You can also use the Bytes parameter * to input an Amazon Textract DetectDocumentText or * AnalyzeDocument output file. *

*

* Provide the input document as a sequence of base64-encoded bytes. * If your code uses an Amazon Web Services SDK to classify * documents, the SDK may encode the document file bytes for you. *

*

* The maximum length of this field depends on the input document * type. For details, see Inputs for real-time custom analysis in the Comprehend * Developer Guide. *

*

* If you use the Bytes parameter, do not use the * Text parameter. *

*/ public java.nio.ByteBuffer getBytes() { return bytes; } /** *

* Use the Bytes parameter to input a text, PDF, Word or image * file. You can also use the Bytes parameter to input an * Amazon Textract DetectDocumentText or * AnalyzeDocument output file. *

*

* Provide the input document as a sequence of base64-encoded bytes. If your * code uses an Amazon Web Services SDK to classify documents, the SDK may * encode the document file bytes for you. *

*

* The maximum length of this field depends on the input document type. For * details, see * Inputs for real-time custom analysis in the Comprehend Developer * Guide. *

*

* If you use the Bytes parameter, do not use the * Text parameter. *

*

* Constraints:
* Length: 1 -
* * @param bytes

* Use the Bytes parameter to input a text, PDF, * Word or image file. You can also use the Bytes * parameter to input an Amazon Textract * DetectDocumentText or * AnalyzeDocument output file. *

*

* Provide the input document as a sequence of base64-encoded * bytes. If your code uses an Amazon Web Services SDK to * classify documents, the SDK may encode the document file bytes * for you. *

*

* The maximum length of this field depends on the input document * type. For details, see Inputs for real-time custom analysis in the Comprehend * Developer Guide. *

*

* If you use the Bytes parameter, do not use the * Text parameter. *

*/ public void setBytes(java.nio.ByteBuffer bytes) { this.bytes = bytes; } /** *

* Use the Bytes parameter to input a text, PDF, Word or image * file. You can also use the Bytes parameter to input an * Amazon Textract DetectDocumentText or * AnalyzeDocument output file. *

*

* Provide the input document as a sequence of base64-encoded bytes. If your * code uses an Amazon Web Services SDK to classify documents, the SDK may * encode the document file bytes for you. *

*

* The maximum length of this field depends on the input document type. For * details, see * Inputs for real-time custom analysis in the Comprehend Developer * Guide. *

*

* If you use the Bytes parameter, do not use the * Text parameter. *

*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Length: 1 -
* * @param bytes

* Use the Bytes parameter to input a text, PDF, * Word or image file. You can also use the Bytes * parameter to input an Amazon Textract * DetectDocumentText or * AnalyzeDocument output file. *

*

* Provide the input document as a sequence of base64-encoded * bytes. If your code uses an Amazon Web Services SDK to * classify documents, the SDK may encode the document file bytes * for you. *

*

* The maximum length of this field depends on the input document * type. For details, see Inputs for real-time custom analysis in the Comprehend * Developer Guide. *

*

* If you use the Bytes parameter, do not use the * Text parameter. *

* @return A reference to this updated object so that method calls can be * chained together. */ public ClassifyDocumentRequest withBytes(java.nio.ByteBuffer bytes) { this.bytes = bytes; return this; } /** *

* Provides configuration parameters to override the default actions for * extracting text from PDF documents and image files. *

* * @return

* Provides configuration parameters to override the default actions * for extracting text from PDF documents and image files. *

*/ public DocumentReaderConfig getDocumentReaderConfig() { return documentReaderConfig; } /** *

* Provides configuration parameters to override the default actions for * extracting text from PDF documents and image files. *

* * @param documentReaderConfig

* Provides configuration parameters to override the default * actions for extracting text from PDF documents and image * files. *

*/ public void setDocumentReaderConfig(DocumentReaderConfig documentReaderConfig) { this.documentReaderConfig = documentReaderConfig; } /** *

* Provides configuration parameters to override the default actions for * extracting text from PDF documents and image files. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param documentReaderConfig

* Provides configuration parameters to override the default * actions for extracting text from PDF documents and image * files. *

* @return A reference to this updated object so that method calls can be * chained together. */ public ClassifyDocumentRequest withDocumentReaderConfig( DocumentReaderConfig documentReaderConfig) { this.documentReaderConfig = documentReaderConfig; return this; } /** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getText() != null) sb.append("Text: " + getText() + ","); if (getEndpointArn() != null) sb.append("EndpointArn: " + getEndpointArn() + ","); if (getBytes() != null) sb.append("Bytes: " + getBytes() + ","); if (getDocumentReaderConfig() != null) sb.append("DocumentReaderConfig: " + getDocumentReaderConfig()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getText() == null) ? 0 : getText().hashCode()); hashCode = prime * hashCode + ((getEndpointArn() == null) ? 0 : getEndpointArn().hashCode()); hashCode = prime * hashCode + ((getBytes() == null) ? 0 : getBytes().hashCode()); hashCode = prime * hashCode + ((getDocumentReaderConfig() == null) ? 0 : getDocumentReaderConfig().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ClassifyDocumentRequest == false) return false; ClassifyDocumentRequest other = (ClassifyDocumentRequest) obj; if (other.getText() == null ^ this.getText() == null) return false; if (other.getText() != null && other.getText().equals(this.getText()) == false) return false; if (other.getEndpointArn() == null ^ this.getEndpointArn() == null) return false; if (other.getEndpointArn() != null && other.getEndpointArn().equals(this.getEndpointArn()) == false) return false; if (other.getBytes() == null ^ this.getBytes() == null) return false; if (other.getBytes() != null && other.getBytes().equals(this.getBytes()) == false) return false; if (other.getDocumentReaderConfig() == null ^ this.getDocumentReaderConfig() == null) return false; if (other.getDocumentReaderConfig() != null && other.getDocumentReaderConfig().equals(this.getDocumentReaderConfig()) == false) return false; return true; } }