From fe2ed1807ed95f8deed502b2d04d79b9e8a13f20 Mon Sep 17 00:00:00 2001 From: Maverick Studer Date: Mon, 7 Oct 2024 12:28:10 +0200 Subject: [PATCH] RED-9123: Improve performance of re-analysis (Spike) --- .../build.gradle.kts | 1 + .../api/data/redaction/DocumentData.java | 25 +- .../api/data/redaction/DocumentPage.java | 1 + .../api/data/redaction/DocumentPageProto.java | 1816 ++++++++++ .../data/redaction/DocumentPositionData.java | 1 + .../redaction/DocumentPositionDataProto.java | 3086 +++++++++++++++++ .../api/data/redaction/DocumentStructure.java | 1 + .../redaction/DocumentStructureProto.java | 799 +++++ .../redaction/DocumentStructureWrapper.java | 126 + .../api/data/redaction/DocumentTextData.java | 1 + .../data/redaction/DocumentTextDataProto.java | 2424 +++++++++++++ .../api/data/redaction/EntryDataProto.java | 2977 ++++++++++++++++ .../api/data/redaction/LayoutEngine.java | 1 + .../api/data/redaction/LayoutEngineProto.java | 193 ++ .../internal/api/data/redaction/NodeType.java | 1 + .../api/data/redaction/NodeTypeProto.java | 274 ++ .../src/main/resources/DocumentPage.proto | 21 + .../main/resources/DocumentPositionData.proto | 25 + .../main/resources/DocumentStructure.proto | 8 + .../src/main/resources/DocumentTextData.proto | 29 + .../src/main/resources/EntryData.proto | 27 + .../src/main/resources/LayoutEngine.proto | 7 + .../src/main/resources/NodeType.proto | 14 + .../build.gradle.kts | 7 +- .../processor/LayoutParsingPipeline.java | 2 +- .../LayoutParsingStorageService.java | 34 +- .../processor/model/AbstractPageBlock.java | 2 +- .../processor/model/graph/DocumentTree.java | 2 +- .../graph/nodes/AbstractSemanticNode.java | 2 +- .../processor/model/graph/nodes/Document.java | 2 +- .../processor/model/graph/nodes/Footer.java | 2 +- .../processor/model/graph/nodes/Header.java | 2 +- .../processor/model/graph/nodes/Headline.java | 2 +- .../processor/model/graph/nodes/Image.java | 2 +- .../model/graph/nodes/Paragraph.java | 2 +- .../processor/model/graph/nodes/Section.java | 3 +- .../model/graph/nodes/SemanticNode.java | 4 +- .../model/graph/nodes/SuperSection.java | 2 +- .../processor/model/graph/nodes/Table.java | 4 +- .../model/graph/nodes/TableCell.java | 2 +- .../graph/textblock/AtomicTextBlock.java | 21 +- .../BlockificationPostprocessingService.java | 2 +- .../services/mapper/DocumentDataMapper.java | 137 +- .../services/mapper/DocumentGraphMapper.java | 64 +- .../services/mapper/PropertiesMapper.java | 85 +- .../mapper/TaasDocumentDataMapper.java | 2 +- .../utils/PdfVisualisationUtility.java | 3 +- .../processor/utils/ProtobufUtil.java | 42 + .../processor/visualization/LayoutGrid.java | 4 +- .../build.gradle.kts | 5 +- .../graph/DocumentGraphJsonWritingTest.java | 2 +- .../graph/DocumentGraphMappingTest.java | 39 +- .../services/RulingCleaningServiceTest.java | 13 +- .../server/utils/visualizations/PdfDraw.java | 3 +- 54 files changed, 12164 insertions(+), 192 deletions(-) create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPageProto.java create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPositionDataProto.java create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentStructureProto.java create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentStructureWrapper.java create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentTextDataProto.java create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/EntryDataProto.java create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/LayoutEngineProto.java create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/NodeTypeProto.java create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentPage.proto create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentPositionData.proto create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentStructure.proto create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentTextData.proto create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/resources/EntryData.proto create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/resources/LayoutEngine.proto create mode 100644 layoutparser-service/layoutparser-service-internal-api/src/main/resources/NodeType.proto create mode 100644 layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/utils/ProtobufUtil.java diff --git a/layoutparser-service/layoutparser-service-internal-api/build.gradle.kts b/layoutparser-service/layoutparser-service-internal-api/build.gradle.kts index 024695b..d31934a 100644 --- a/layoutparser-service/layoutparser-service-internal-api/build.gradle.kts +++ b/layoutparser-service/layoutparser-service-internal-api/build.gradle.kts @@ -7,4 +7,5 @@ description = "layoutparser-service-internal-api" dependencies { implementation("io.swagger.core.v3:swagger-annotations:2.2.15") + implementation("com.google.protobuf:protobuf-java-util:4.27.1") } diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentData.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentData.java index 036fb12..8131ae4 100644 --- a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentData.java +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentData.java @@ -2,6 +2,11 @@ package com.knecon.fforesight.service.layoutparser.internal.api.data.redaction; import java.io.Serializable; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPageProto.AllDocumentPages; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPositionDataProto.AllDocumentPositionData; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructureProto.DocumentStructure; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentTextDataProto.AllDocumentTextData; + import io.swagger.v3.oas.annotations.media.Schema; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -13,16 +18,26 @@ import lombok.experimental.FieldDefaults; @Builder @AllArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) -@Schema(description = "Object containing the complete document layout parsing information. It is split into 4 categories, structure, text, positions and pages: " + "The document tree structure of SemanticNodes such as Section, Paragraph, Headline, etc. " + "The text, which is stored as separate blocks of data. " + "The text positions, which are also stored as separate blocks. The Blocks are equal to the text blocks in length and order. " + "The page information.") +@Schema(description = "Object containing the complete document layout parsing information. It is split into 4 categories, structure, text, positions and pages: " + + "The document tree structure of SemanticNodes such as Section, Paragraph, Headline, etc. " + + "The text, which is stored as separate blocks of data. " + + "The text positions, which are also stored as separate blocks. The Blocks are equal to the text blocks in length and order. " + + "The page information.") public class DocumentData implements Serializable { @Schema(description = "Contains information about the document's pages.") - DocumentPage[] documentPages; + AllDocumentPages documentPages; @Schema(description = "Contains information about the document's text.") - DocumentTextData[] documentTextData; + AllDocumentTextData documentTextData; @Schema(description = "Contains information about the document's text positions.") - DocumentPositionData[] documentPositions; + AllDocumentPositionData documentPositions; @Schema(description = "Contains information about the document's semantic structure.") - DocumentStructure documentStructure; + DocumentStructureWrapper documentStructureWrapper; + + + public DocumentStructure getDocumentStructure() { + + return documentStructureWrapper.getDocumentStructure(); + } } diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPage.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPage.java index 97703cd..f104118 100644 --- a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPage.java +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPage.java @@ -10,6 +10,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.FieldDefaults; +@Deprecated @Data @Builder @NoArgsConstructor diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPageProto.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPageProto.java new file mode 100644 index 0000000..58f2e1d --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPageProto.java @@ -0,0 +1,1816 @@ +package com.knecon.fforesight.service.layoutparser.internal.api.data.redaction; + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: DocumentPage.proto +// Protobuf Java Version: 4.27.1 +@SuppressWarnings("all") +public final class DocumentPageProto { + + private DocumentPageProto() {} + + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", DocumentPageProto.class.getName()); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) { + + } + + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + + public interface AllDocumentPagesOrBuilder extends + // @@protoc_insertion_point(interface_extends:AllDocumentPages) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .DocumentPage documentPages = 1; + */ + java.util.List getDocumentPagesList(); + + + /** + * repeated .DocumentPage documentPages = 1; + */ + DocumentPageProto.DocumentPage getDocumentPages(int index); + + + /** + * repeated .DocumentPage documentPages = 1; + */ + int getDocumentPagesCount(); + + + /** + * repeated .DocumentPage documentPages = 1; + */ + java.util.List getDocumentPagesOrBuilderList(); + + + /** + * repeated .DocumentPage documentPages = 1; + */ + DocumentPageProto.DocumentPageOrBuilder getDocumentPagesOrBuilder(int index); + + } + + /** + * Protobuf type {@code AllDocumentPages} + */ + public static final class AllDocumentPages extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:AllDocumentPages) + AllDocumentPagesOrBuilder { + + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", AllDocumentPages.class.getName()); + } + + // Use AllDocumentPages.newBuilder() to construct. + private AllDocumentPages(com.google.protobuf.GeneratedMessage.Builder builder) { + + super(builder); + } + + + private AllDocumentPages() { + + documentPages_ = java.util.Collections.emptyList(); + } + + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentPageProto.internal_static_AllDocumentPages_descriptor; + } + + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentPageProto.internal_static_AllDocumentPages_fieldAccessorTable.ensureFieldAccessorsInitialized(DocumentPageProto.AllDocumentPages.class, + DocumentPageProto.AllDocumentPages.Builder.class); + } + + + public static final int DOCUMENTPAGES_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private java.util.List documentPages_; + + + /** + * repeated .DocumentPage documentPages = 1; + */ + @java.lang.Override + public java.util.List getDocumentPagesList() { + + return documentPages_; + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + @java.lang.Override + public java.util.List getDocumentPagesOrBuilderList() { + + return documentPages_; + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + @java.lang.Override + public int getDocumentPagesCount() { + + return documentPages_.size(); + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + @java.lang.Override + public DocumentPageProto.DocumentPage getDocumentPages(int index) { + + return documentPages_.get(index); + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + @java.lang.Override + public DocumentPageProto.DocumentPageOrBuilder getDocumentPagesOrBuilder(int index) { + + return documentPages_.get(index); + } + + + private byte memoizedIsInitialized = -1; + + + @java.lang.Override + public final boolean isInitialized() { + + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) { + return true; + } + if (isInitialized == 0) { + return false; + } + + memoizedIsInitialized = 1; + return true; + } + + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + + for (int i = 0; i < documentPages_.size(); i++) { + output.writeMessage(1, documentPages_.get(i)); + } + getUnknownFields().writeTo(output); + } + + + @java.lang.Override + public int getSerializedSize() { + + int size = memoizedSize; + if (size != -1) { + return size; + } + + size = 0; + for (int i = 0; i < documentPages_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, documentPages_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof DocumentPageProto.AllDocumentPages)) { + return super.equals(obj); + } + DocumentPageProto.AllDocumentPages other = (DocumentPageProto.AllDocumentPages) obj; + + if (!getDocumentPagesList().equals(other.getDocumentPagesList())) { + return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) { + return false; + } + return true; + } + + + @java.lang.Override + public int hashCode() { + + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getDocumentPagesCount() > 0) { + hash = (37 * hash) + DOCUMENTPAGES_FIELD_NUMBER; + hash = (53 * hash) + getDocumentPagesList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + + public static DocumentPageProto.AllDocumentPages parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentPageProto.AllDocumentPages parseFrom(java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentPageProto.AllDocumentPages parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentPageProto.AllDocumentPages parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentPageProto.AllDocumentPages parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentPageProto.AllDocumentPages parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentPageProto.AllDocumentPages parseFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static DocumentPageProto.AllDocumentPages parseFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + public static DocumentPageProto.AllDocumentPages parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + + public static DocumentPageProto.AllDocumentPages parseDelimitedFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + + public static DocumentPageProto.AllDocumentPages parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static DocumentPageProto.AllDocumentPages parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + @java.lang.Override + public Builder newBuilderForType() {return newBuilder();} + + + public static Builder newBuilder() { + + return DEFAULT_INSTANCE.toBuilder(); + } + + + public static Builder newBuilder(DocumentPageProto.AllDocumentPages prototype) { + + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + + @java.lang.Override + public Builder toBuilder() { + + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + + Builder builder = new Builder(parent); + return builder; + } + + + /** + * Protobuf type {@code AllDocumentPages} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:AllDocumentPages) + DocumentPageProto.AllDocumentPagesOrBuilder { + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentPageProto.internal_static_AllDocumentPages_descriptor; + } + + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentPageProto.internal_static_AllDocumentPages_fieldAccessorTable.ensureFieldAccessorsInitialized(DocumentPageProto.AllDocumentPages.class, + DocumentPageProto.AllDocumentPages.Builder.class); + } + + + // Construct using DocumentPageOuterClass.AllDocumentPages.newBuilder() + private Builder() { + + } + + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + + super(parent); + + } + + + @java.lang.Override + public Builder clear() { + + super.clear(); + bitField0_ = 0; + if (documentPagesBuilder_ == null) { + documentPages_ = java.util.Collections.emptyList(); + } else { + documentPages_ = null; + documentPagesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + + return DocumentPageProto.internal_static_AllDocumentPages_descriptor; + } + + + @java.lang.Override + public DocumentPageProto.AllDocumentPages getDefaultInstanceForType() { + + return DocumentPageProto.AllDocumentPages.getDefaultInstance(); + } + + + @java.lang.Override + public DocumentPageProto.AllDocumentPages build() { + + DocumentPageProto.AllDocumentPages result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + + @java.lang.Override + public DocumentPageProto.AllDocumentPages buildPartial() { + + DocumentPageProto.AllDocumentPages result = new DocumentPageProto.AllDocumentPages(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + + private void buildPartialRepeatedFields(DocumentPageProto.AllDocumentPages result) { + + if (documentPagesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + documentPages_ = java.util.Collections.unmodifiableList(documentPages_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.documentPages_ = documentPages_; + } else { + result.documentPages_ = documentPagesBuilder_.build(); + } + } + + + private void buildPartial0(DocumentPageProto.AllDocumentPages result) { + + int from_bitField0_ = bitField0_; + } + + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + + if (other instanceof DocumentPageProto.AllDocumentPages) { + return mergeFrom((DocumentPageProto.AllDocumentPages) other); + } else { + super.mergeFrom(other); + return this; + } + } + + + public Builder mergeFrom(DocumentPageProto.AllDocumentPages other) { + + if (other == DocumentPageProto.AllDocumentPages.getDefaultInstance()) { + return this; + } + if (documentPagesBuilder_ == null) { + if (!other.documentPages_.isEmpty()) { + if (documentPages_.isEmpty()) { + documentPages_ = other.documentPages_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureDocumentPagesIsMutable(); + documentPages_.addAll(other.documentPages_); + } + onChanged(); + } + } else { + if (!other.documentPages_.isEmpty()) { + if (documentPagesBuilder_.isEmpty()) { + documentPagesBuilder_.dispose(); + documentPagesBuilder_ = null; + documentPages_ = other.documentPages_; + bitField0_ = (bitField0_ & ~0x00000001); + documentPagesBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getDocumentPagesFieldBuilder() : null; + } else { + documentPagesBuilder_.addAllMessages(other.documentPages_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + + @java.lang.Override + public final boolean isInitialized() { + + return true; + } + + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + DocumentPageProto.DocumentPage m = input.readMessage(DocumentPageProto.DocumentPage.parser(), extensionRegistry); + if (documentPagesBuilder_ == null) { + ensureDocumentPagesIsMutable(); + documentPages_.add(m); + } else { + documentPagesBuilder_.addMessage(m); + } + break; + } // case 10 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + + private int bitField0_; + + private java.util.List documentPages_ = java.util.Collections.emptyList(); + + + private void ensureDocumentPagesIsMutable() { + + if (!((bitField0_ & 0x00000001) != 0)) { + documentPages_ = new java.util.ArrayList(documentPages_); + bitField0_ |= 0x00000001; + } + } + + + private com.google.protobuf.RepeatedFieldBuilder documentPagesBuilder_; + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public java.util.List getDocumentPagesList() { + + if (documentPagesBuilder_ == null) { + return java.util.Collections.unmodifiableList(documentPages_); + } else { + return documentPagesBuilder_.getMessageList(); + } + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public int getDocumentPagesCount() { + + if (documentPagesBuilder_ == null) { + return documentPages_.size(); + } else { + return documentPagesBuilder_.getCount(); + } + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public DocumentPageProto.DocumentPage getDocumentPages(int index) { + + if (documentPagesBuilder_ == null) { + return documentPages_.get(index); + } else { + return documentPagesBuilder_.getMessage(index); + } + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public Builder setDocumentPages(int index, DocumentPageProto.DocumentPage value) { + + if (documentPagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentPagesIsMutable(); + documentPages_.set(index, value); + onChanged(); + } else { + documentPagesBuilder_.setMessage(index, value); + } + return this; + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public Builder setDocumentPages(int index, DocumentPageProto.DocumentPage.Builder builderForValue) { + + if (documentPagesBuilder_ == null) { + ensureDocumentPagesIsMutable(); + documentPages_.set(index, builderForValue.build()); + onChanged(); + } else { + documentPagesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public Builder addDocumentPages(DocumentPageProto.DocumentPage value) { + + if (documentPagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentPagesIsMutable(); + documentPages_.add(value); + onChanged(); + } else { + documentPagesBuilder_.addMessage(value); + } + return this; + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public Builder addDocumentPages(int index, DocumentPageProto.DocumentPage value) { + + if (documentPagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentPagesIsMutable(); + documentPages_.add(index, value); + onChanged(); + } else { + documentPagesBuilder_.addMessage(index, value); + } + return this; + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public Builder addDocumentPages(DocumentPageProto.DocumentPage.Builder builderForValue) { + + if (documentPagesBuilder_ == null) { + ensureDocumentPagesIsMutable(); + documentPages_.add(builderForValue.build()); + onChanged(); + } else { + documentPagesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public Builder addDocumentPages(int index, DocumentPageProto.DocumentPage.Builder builderForValue) { + + if (documentPagesBuilder_ == null) { + ensureDocumentPagesIsMutable(); + documentPages_.add(index, builderForValue.build()); + onChanged(); + } else { + documentPagesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public Builder addAllDocumentPages(java.lang.Iterable values) { + + if (documentPagesBuilder_ == null) { + ensureDocumentPagesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, documentPages_); + onChanged(); + } else { + documentPagesBuilder_.addAllMessages(values); + } + return this; + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public Builder clearDocumentPages() { + + if (documentPagesBuilder_ == null) { + documentPages_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + documentPagesBuilder_.clear(); + } + return this; + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public Builder removeDocumentPages(int index) { + + if (documentPagesBuilder_ == null) { + ensureDocumentPagesIsMutable(); + documentPages_.remove(index); + onChanged(); + } else { + documentPagesBuilder_.remove(index); + } + return this; + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public DocumentPageProto.DocumentPage.Builder getDocumentPagesBuilder(int index) { + + return getDocumentPagesFieldBuilder().getBuilder(index); + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public DocumentPageProto.DocumentPageOrBuilder getDocumentPagesOrBuilder(int index) { + + if (documentPagesBuilder_ == null) { + return documentPages_.get(index); + } else { + return documentPagesBuilder_.getMessageOrBuilder(index); + } + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public java.util.List getDocumentPagesOrBuilderList() { + + if (documentPagesBuilder_ != null) { + return documentPagesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(documentPages_); + } + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public DocumentPageProto.DocumentPage.Builder addDocumentPagesBuilder() { + + return getDocumentPagesFieldBuilder().addBuilder(DocumentPageProto.DocumentPage.getDefaultInstance()); + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public DocumentPageProto.DocumentPage.Builder addDocumentPagesBuilder(int index) { + + return getDocumentPagesFieldBuilder().addBuilder(index, DocumentPageProto.DocumentPage.getDefaultInstance()); + } + + + /** + * repeated .DocumentPage documentPages = 1; + */ + public java.util.List getDocumentPagesBuilderList() { + + return getDocumentPagesFieldBuilder().getBuilderList(); + } + + + private com.google.protobuf.RepeatedFieldBuilder getDocumentPagesFieldBuilder() { + + if (documentPagesBuilder_ == null) { + documentPagesBuilder_ = new com.google.protobuf.RepeatedFieldBuilder( + documentPages_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + documentPages_ = null; + } + return documentPagesBuilder_; + } + + // @@protoc_insertion_point(builder_scope:AllDocumentPages) + } + + // @@protoc_insertion_point(class_scope:AllDocumentPages) + private static final DocumentPageProto.AllDocumentPages DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new DocumentPageProto.AllDocumentPages(); + } + + public static DocumentPageProto.AllDocumentPages getDefaultInstance() { + + return DEFAULT_INSTANCE; + } + + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public AllDocumentPages parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + + public static com.google.protobuf.Parser parser() { + + return PARSER; + } + + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + + return PARSER; + } + + + @java.lang.Override + public DocumentPageProto.AllDocumentPages getDefaultInstanceForType() { + + return DEFAULT_INSTANCE; + } + + } + + public interface DocumentPageOrBuilder extends + // @@protoc_insertion_point(interface_extends:DocumentPage) + com.google.protobuf.MessageOrBuilder { + + /** + *
+         * The page number, starting with 1.
+         * 
+ * + * int32 number = 1; + * + * @return The number. + */ + int getNumber(); + + + /** + *
+         * The page height in PDF user units.
+         * 
+ * + * int32 height = 2; + * + * @return The height. + */ + int getHeight(); + + + /** + *
+         * The page width in PDF user units.
+         * 
+ * + * int32 width = 3; + * + * @return The width. + */ + int getWidth(); + + + /** + *
+         * The page rotation as specified by the PDF.
+         * 
+ * + * int32 rotation = 4; + * + * @return The rotation. + */ + int getRotation(); + + } + + /** + * Protobuf type {@code DocumentPage} + */ + public static final class DocumentPage extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:DocumentPage) + DocumentPageOrBuilder { + + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", DocumentPage.class.getName()); + } + + // Use DocumentPage.newBuilder() to construct. + private DocumentPage(com.google.protobuf.GeneratedMessage.Builder builder) { + + super(builder); + } + + + private DocumentPage() { + + } + + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentPageProto.internal_static_DocumentPage_descriptor; + } + + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentPageProto.internal_static_DocumentPage_fieldAccessorTable.ensureFieldAccessorsInitialized(DocumentPageProto.DocumentPage.class, + DocumentPageProto.DocumentPage.Builder.class); + } + + + public static final int NUMBER_FIELD_NUMBER = 1; + private int number_ = 0; + + + /** + *
+         * The page number, starting with 1.
+         * 
+ * + * int32 number = 1; + * + * @return The number. + */ + @java.lang.Override + public int getNumber() { + + return number_; + } + + + public static final int HEIGHT_FIELD_NUMBER = 2; + private int height_ = 0; + + + /** + *
+         * The page height in PDF user units.
+         * 
+ * + * int32 height = 2; + * + * @return The height. + */ + @java.lang.Override + public int getHeight() { + + return height_; + } + + + public static final int WIDTH_FIELD_NUMBER = 3; + private int width_ = 0; + + + /** + *
+         * The page width in PDF user units.
+         * 
+ * + * int32 width = 3; + * + * @return The width. + */ + @java.lang.Override + public int getWidth() { + + return width_; + } + + + public static final int ROTATION_FIELD_NUMBER = 4; + private int rotation_ = 0; + + + /** + *
+         * The page rotation as specified by the PDF.
+         * 
+ * + * int32 rotation = 4; + * + * @return The rotation. + */ + @java.lang.Override + public int getRotation() { + + return rotation_; + } + + + private byte memoizedIsInitialized = -1; + + + @java.lang.Override + public final boolean isInitialized() { + + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) { + return true; + } + if (isInitialized == 0) { + return false; + } + + memoizedIsInitialized = 1; + return true; + } + + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + + if (number_ != 0) { + output.writeInt32(1, number_); + } + if (height_ != 0) { + output.writeInt32(2, height_); + } + if (width_ != 0) { + output.writeInt32(3, width_); + } + if (rotation_ != 0) { + output.writeInt32(4, rotation_); + } + getUnknownFields().writeTo(output); + } + + + @java.lang.Override + public int getSerializedSize() { + + int size = memoizedSize; + if (size != -1) { + return size; + } + + size = 0; + if (number_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(1, number_); + } + if (height_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, height_); + } + if (width_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(3, width_); + } + if (rotation_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(4, rotation_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof DocumentPageProto.DocumentPage)) { + return super.equals(obj); + } + DocumentPageProto.DocumentPage other = (DocumentPageProto.DocumentPage) obj; + + if (getNumber() != other.getNumber()) { + return false; + } + if (getHeight() != other.getHeight()) { + return false; + } + if (getWidth() != other.getWidth()) { + return false; + } + if (getRotation() != other.getRotation()) { + return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) { + return false; + } + return true; + } + + + @java.lang.Override + public int hashCode() { + + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NUMBER_FIELD_NUMBER; + hash = (53 * hash) + getNumber(); + hash = (37 * hash) + HEIGHT_FIELD_NUMBER; + hash = (53 * hash) + getHeight(); + hash = (37 * hash) + WIDTH_FIELD_NUMBER; + hash = (53 * hash) + getWidth(); + hash = (37 * hash) + ROTATION_FIELD_NUMBER; + hash = (53 * hash) + getRotation(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + + public static DocumentPageProto.DocumentPage parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentPageProto.DocumentPage parseFrom(java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentPageProto.DocumentPage parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentPageProto.DocumentPage parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentPageProto.DocumentPage parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentPageProto.DocumentPage parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentPageProto.DocumentPage parseFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static DocumentPageProto.DocumentPage parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + public static DocumentPageProto.DocumentPage parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + + public static DocumentPageProto.DocumentPage parseDelimitedFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + + public static DocumentPageProto.DocumentPage parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static DocumentPageProto.DocumentPage parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + @java.lang.Override + public Builder newBuilderForType() {return newBuilder();} + + + public static Builder newBuilder() { + + return DEFAULT_INSTANCE.toBuilder(); + } + + + public static Builder newBuilder(DocumentPageProto.DocumentPage prototype) { + + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + + @java.lang.Override + public Builder toBuilder() { + + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + + Builder builder = new Builder(parent); + return builder; + } + + + /** + * Protobuf type {@code DocumentPage} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:DocumentPage) + DocumentPageProto.DocumentPageOrBuilder { + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentPageProto.internal_static_DocumentPage_descriptor; + } + + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentPageProto.internal_static_DocumentPage_fieldAccessorTable.ensureFieldAccessorsInitialized(DocumentPageProto.DocumentPage.class, + DocumentPageProto.DocumentPage.Builder.class); + } + + + // Construct using DocumentPageOuterClass.DocumentPage.newBuilder() + private Builder() { + + } + + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + + super(parent); + + } + + + @java.lang.Override + public Builder clear() { + + super.clear(); + bitField0_ = 0; + number_ = 0; + height_ = 0; + width_ = 0; + rotation_ = 0; + return this; + } + + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + + return DocumentPageProto.internal_static_DocumentPage_descriptor; + } + + + @java.lang.Override + public DocumentPageProto.DocumentPage getDefaultInstanceForType() { + + return DocumentPageProto.DocumentPage.getDefaultInstance(); + } + + + @java.lang.Override + public DocumentPageProto.DocumentPage build() { + + DocumentPageProto.DocumentPage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + + @java.lang.Override + public DocumentPageProto.DocumentPage buildPartial() { + + DocumentPageProto.DocumentPage result = new DocumentPageProto.DocumentPage(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + + private void buildPartial0(DocumentPageProto.DocumentPage result) { + + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.number_ = number_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.height_ = height_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.width_ = width_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.rotation_ = rotation_; + } + } + + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + + if (other instanceof DocumentPageProto.DocumentPage) { + return mergeFrom((DocumentPageProto.DocumentPage) other); + } else { + super.mergeFrom(other); + return this; + } + } + + + public Builder mergeFrom(DocumentPageProto.DocumentPage other) { + + if (other == DocumentPageProto.DocumentPage.getDefaultInstance()) { + return this; + } + if (other.getNumber() != 0) { + setNumber(other.getNumber()); + } + if (other.getHeight() != 0) { + setHeight(other.getHeight()); + } + if (other.getWidth() != 0) { + setWidth(other.getWidth()); + } + if (other.getRotation() != 0) { + setRotation(other.getRotation()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + + @java.lang.Override + public final boolean isInitialized() { + + return true; + } + + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + number_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 16: { + height_ = input.readInt32(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 24: { + width_ = input.readInt32(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 32: { + rotation_ = input.readInt32(); + bitField0_ |= 0x00000008; + break; + } // case 32 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + + private int bitField0_; + + private int number_; + + + /** + *
+             * The page number, starting with 1.
+             * 
+ * + * int32 number = 1; + * + * @return The number. + */ + @java.lang.Override + public int getNumber() { + + return number_; + } + + + /** + *
+             * The page number, starting with 1.
+             * 
+ * + * int32 number = 1; + * + * @param value The number to set. + * @return This builder for chaining. + */ + public Builder setNumber(int value) { + + number_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + + /** + *
+             * The page number, starting with 1.
+             * 
+ * + * int32 number = 1; + * + * @return This builder for chaining. + */ + public Builder clearNumber() { + + bitField0_ = (bitField0_ & ~0x00000001); + number_ = 0; + onChanged(); + return this; + } + + + private int height_; + + + /** + *
+             * The page height in PDF user units.
+             * 
+ * + * int32 height = 2; + * + * @return The height. + */ + @java.lang.Override + public int getHeight() { + + return height_; + } + + + /** + *
+             * The page height in PDF user units.
+             * 
+ * + * int32 height = 2; + * + * @param value The height to set. + * @return This builder for chaining. + */ + public Builder setHeight(int value) { + + height_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + + /** + *
+             * The page height in PDF user units.
+             * 
+ * + * int32 height = 2; + * + * @return This builder for chaining. + */ + public Builder clearHeight() { + + bitField0_ = (bitField0_ & ~0x00000002); + height_ = 0; + onChanged(); + return this; + } + + + private int width_; + + + /** + *
+             * The page width in PDF user units.
+             * 
+ * + * int32 width = 3; + * + * @return The width. + */ + @java.lang.Override + public int getWidth() { + + return width_; + } + + + /** + *
+             * The page width in PDF user units.
+             * 
+ * + * int32 width = 3; + * + * @param value The width to set. + * @return This builder for chaining. + */ + public Builder setWidth(int value) { + + width_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + + /** + *
+             * The page width in PDF user units.
+             * 
+ * + * int32 width = 3; + * + * @return This builder for chaining. + */ + public Builder clearWidth() { + + bitField0_ = (bitField0_ & ~0x00000004); + width_ = 0; + onChanged(); + return this; + } + + + private int rotation_; + + + /** + *
+             * The page rotation as specified by the PDF.
+             * 
+ * + * int32 rotation = 4; + * + * @return The rotation. + */ + @java.lang.Override + public int getRotation() { + + return rotation_; + } + + + /** + *
+             * The page rotation as specified by the PDF.
+             * 
+ * + * int32 rotation = 4; + * + * @param value The rotation to set. + * @return This builder for chaining. + */ + public Builder setRotation(int value) { + + rotation_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + + /** + *
+             * The page rotation as specified by the PDF.
+             * 
+ * + * int32 rotation = 4; + * + * @return This builder for chaining. + */ + public Builder clearRotation() { + + bitField0_ = (bitField0_ & ~0x00000008); + rotation_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:DocumentPage) + } + + // @@protoc_insertion_point(class_scope:DocumentPage) + private static final DocumentPageProto.DocumentPage DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new DocumentPageProto.DocumentPage(); + } + + public static DocumentPageProto.DocumentPage getDefaultInstance() { + + return DEFAULT_INSTANCE; + } + + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DocumentPage parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + + public static com.google.protobuf.Parser parser() { + + return PARSER; + } + + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + + return PARSER; + } + + + @java.lang.Override + public DocumentPageProto.DocumentPage getDefaultInstanceForType() { + + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor internal_static_AllDocumentPages_descriptor; + private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_AllDocumentPages_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_DocumentPage_descriptor; + private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_DocumentPage_fieldAccessorTable; + + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + + return descriptor; + } + + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = {"\n\022DocumentPage.proto\"8\n\020AllDocumentPages" + + "\022$\n\rdocumentPages\030\001 \003(\0132\r.DocumentPage\"O" + + "\n\014DocumentPage\022\016\n\006number\030\001 \001(\005\022\016\n\006height" + + "\030\002 \001(\005\022\r\n\005width\030\003 \001(\005\022\020\n\010rotation\030\004 \001(\005b" + + "\006proto3"}; + descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[]{}); + internal_static_AllDocumentPages_descriptor = getDescriptor().getMessageTypes() + .get(0); + internal_static_AllDocumentPages_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_AllDocumentPages_descriptor, + new java.lang.String[]{"DocumentPages",}); + internal_static_DocumentPage_descriptor = getDescriptor().getMessageTypes() + .get(1); + internal_static_DocumentPage_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_DocumentPage_descriptor, + new java.lang.String[]{"Number", "Height", "Width", "Rotation",}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPositionData.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPositionData.java index 4114575..0a1f315 100644 --- a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPositionData.java +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPositionData.java @@ -10,6 +10,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.FieldDefaults; +@Deprecated @Data @Builder @NoArgsConstructor diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPositionDataProto.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPositionDataProto.java new file mode 100644 index 0000000..890afd1 --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentPositionDataProto.java @@ -0,0 +1,3086 @@ +package com.knecon.fforesight.service.layoutparser.internal.api.data.redaction; + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: DocumentPositionData.proto +// Protobuf Java Version: 4.27.1 +@SuppressWarnings("all") +public final class DocumentPositionDataProto { + + private DocumentPositionDataProto() {} + + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", DocumentPositionDataProto.class.getName()); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) { + + } + + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + + public interface AllDocumentPositionDataOrBuilder extends + // @@protoc_insertion_point(interface_extends:AllDocumentPositionData) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + java.util.List getDocumentPositionDataList(); + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + DocumentPositionData getDocumentPositionData(int index); + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + int getDocumentPositionDataCount(); + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + java.util.List getDocumentPositionDataOrBuilderList(); + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + DocumentPositionDataOrBuilder getDocumentPositionDataOrBuilder(int index); + + } + + /** + * Protobuf type {@code AllDocumentPositionData} + */ + public static final class AllDocumentPositionData extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:AllDocumentPositionData) + AllDocumentPositionDataOrBuilder { + + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", AllDocumentPositionData.class.getName()); + } + + // Use AllDocumentPositionData.newBuilder() to construct. + private AllDocumentPositionData(com.google.protobuf.GeneratedMessage.Builder builder) { + + super(builder); + } + + + private AllDocumentPositionData() { + + documentPositionData_ = java.util.Collections.emptyList(); + } + + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentPositionDataProto.internal_static_AllDocumentPositionData_descriptor; + } + + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentPositionDataProto.internal_static_AllDocumentPositionData_fieldAccessorTable.ensureFieldAccessorsInitialized(AllDocumentPositionData.class, + AllDocumentPositionData.Builder.class); + } + + + public static final int DOCUMENTPOSITIONDATA_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private java.util.List documentPositionData_; + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + @java.lang.Override + public java.util.List getDocumentPositionDataList() { + + return documentPositionData_; + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + @java.lang.Override + public java.util.List getDocumentPositionDataOrBuilderList() { + + return documentPositionData_; + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + @java.lang.Override + public int getDocumentPositionDataCount() { + + return documentPositionData_.size(); + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + @java.lang.Override + public DocumentPositionData getDocumentPositionData(int index) { + + return documentPositionData_.get(index); + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + @java.lang.Override + public DocumentPositionDataOrBuilder getDocumentPositionDataOrBuilder(int index) { + + return documentPositionData_.get(index); + } + + + private byte memoizedIsInitialized = -1; + + + @java.lang.Override + public final boolean isInitialized() { + + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) { + return true; + } + if (isInitialized == 0) { + return false; + } + + memoizedIsInitialized = 1; + return true; + } + + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + + for (int i = 0; i < documentPositionData_.size(); i++) { + output.writeMessage(1, documentPositionData_.get(i)); + } + getUnknownFields().writeTo(output); + } + + + @java.lang.Override + public int getSerializedSize() { + + int size = memoizedSize; + if (size != -1) { + return size; + } + + size = 0; + for (int i = 0; i < documentPositionData_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, documentPositionData_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof AllDocumentPositionData)) { + return super.equals(obj); + } + AllDocumentPositionData other = (AllDocumentPositionData) obj; + + if (!getDocumentPositionDataList().equals(other.getDocumentPositionDataList())) { + return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) { + return false; + } + return true; + } + + + @java.lang.Override + public int hashCode() { + + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getDocumentPositionDataCount() > 0) { + hash = (37 * hash) + DOCUMENTPOSITIONDATA_FIELD_NUMBER; + hash = (53 * hash) + getDocumentPositionDataList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + + public static AllDocumentPositionData parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static AllDocumentPositionData parseFrom(java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static AllDocumentPositionData parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static AllDocumentPositionData parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static AllDocumentPositionData parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static AllDocumentPositionData parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static AllDocumentPositionData parseFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static AllDocumentPositionData parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + public static AllDocumentPositionData parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + + public static AllDocumentPositionData parseDelimitedFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + + public static AllDocumentPositionData parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static AllDocumentPositionData parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + @java.lang.Override + public Builder newBuilderForType() {return newBuilder();} + + + public static Builder newBuilder() { + + return DEFAULT_INSTANCE.toBuilder(); + } + + + public static Builder newBuilder(AllDocumentPositionData prototype) { + + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + + @java.lang.Override + public Builder toBuilder() { + + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + + Builder builder = new Builder(parent); + return builder; + } + + + /** + * Protobuf type {@code AllDocumentPositionData} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:AllDocumentPositionData) + AllDocumentPositionDataOrBuilder { + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentPositionDataProto.internal_static_AllDocumentPositionData_descriptor; + } + + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentPositionDataProto.internal_static_AllDocumentPositionData_fieldAccessorTable.ensureFieldAccessorsInitialized(AllDocumentPositionData.class, + AllDocumentPositionData.Builder.class); + } + + + // Construct using AllDocumentPositionData.newBuilder() + private Builder() { + + } + + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + + super(parent); + + } + + + @java.lang.Override + public Builder clear() { + + super.clear(); + bitField0_ = 0; + if (documentPositionDataBuilder_ == null) { + documentPositionData_ = java.util.Collections.emptyList(); + } else { + documentPositionData_ = null; + documentPositionDataBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + + return DocumentPositionDataProto.internal_static_AllDocumentPositionData_descriptor; + } + + + @java.lang.Override + public AllDocumentPositionData getDefaultInstanceForType() { + + return AllDocumentPositionData.getDefaultInstance(); + } + + + @java.lang.Override + public AllDocumentPositionData build() { + + AllDocumentPositionData result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + + @java.lang.Override + public AllDocumentPositionData buildPartial() { + + AllDocumentPositionData result = new AllDocumentPositionData(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + + private void buildPartialRepeatedFields(AllDocumentPositionData result) { + + if (documentPositionDataBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + documentPositionData_ = java.util.Collections.unmodifiableList(documentPositionData_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.documentPositionData_ = documentPositionData_; + } else { + result.documentPositionData_ = documentPositionDataBuilder_.build(); + } + } + + + private void buildPartial0(AllDocumentPositionData result) { + + int from_bitField0_ = bitField0_; + } + + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + + if (other instanceof AllDocumentPositionData) { + return mergeFrom((AllDocumentPositionData) other); + } else { + super.mergeFrom(other); + return this; + } + } + + + public Builder mergeFrom(AllDocumentPositionData other) { + + if (other == AllDocumentPositionData.getDefaultInstance()) { + return this; + } + if (documentPositionDataBuilder_ == null) { + if (!other.documentPositionData_.isEmpty()) { + if (documentPositionData_.isEmpty()) { + documentPositionData_ = other.documentPositionData_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureDocumentPositionDataIsMutable(); + documentPositionData_.addAll(other.documentPositionData_); + } + onChanged(); + } + } else { + if (!other.documentPositionData_.isEmpty()) { + if (documentPositionDataBuilder_.isEmpty()) { + documentPositionDataBuilder_.dispose(); + documentPositionDataBuilder_ = null; + documentPositionData_ = other.documentPositionData_; + bitField0_ = (bitField0_ & ~0x00000001); + documentPositionDataBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getDocumentPositionDataFieldBuilder() : null; + } else { + documentPositionDataBuilder_.addAllMessages(other.documentPositionData_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + + @java.lang.Override + public final boolean isInitialized() { + + return true; + } + + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + DocumentPositionData m = input.readMessage(DocumentPositionData.parser(), extensionRegistry); + if (documentPositionDataBuilder_ == null) { + ensureDocumentPositionDataIsMutable(); + documentPositionData_.add(m); + } else { + documentPositionDataBuilder_.addMessage(m); + } + break; + } // case 10 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + + private int bitField0_; + + private java.util.List documentPositionData_ = java.util.Collections.emptyList(); + + + private void ensureDocumentPositionDataIsMutable() { + + if (!((bitField0_ & 0x00000001) != 0)) { + documentPositionData_ = new java.util.ArrayList(documentPositionData_); + bitField0_ |= 0x00000001; + } + } + + + private com.google.protobuf.RepeatedFieldBuilder documentPositionDataBuilder_; + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public java.util.List getDocumentPositionDataList() { + + if (documentPositionDataBuilder_ == null) { + return java.util.Collections.unmodifiableList(documentPositionData_); + } else { + return documentPositionDataBuilder_.getMessageList(); + } + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public int getDocumentPositionDataCount() { + + if (documentPositionDataBuilder_ == null) { + return documentPositionData_.size(); + } else { + return documentPositionDataBuilder_.getCount(); + } + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public DocumentPositionData getDocumentPositionData(int index) { + + if (documentPositionDataBuilder_ == null) { + return documentPositionData_.get(index); + } else { + return documentPositionDataBuilder_.getMessage(index); + } + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public Builder setDocumentPositionData(int index, DocumentPositionData value) { + + if (documentPositionDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentPositionDataIsMutable(); + documentPositionData_.set(index, value); + onChanged(); + } else { + documentPositionDataBuilder_.setMessage(index, value); + } + return this; + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public Builder setDocumentPositionData(int index, DocumentPositionData.Builder builderForValue) { + + if (documentPositionDataBuilder_ == null) { + ensureDocumentPositionDataIsMutable(); + documentPositionData_.set(index, builderForValue.build()); + onChanged(); + } else { + documentPositionDataBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public Builder addDocumentPositionData(DocumentPositionData value) { + + if (documentPositionDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentPositionDataIsMutable(); + documentPositionData_.add(value); + onChanged(); + } else { + documentPositionDataBuilder_.addMessage(value); + } + return this; + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public Builder addDocumentPositionData(int index, DocumentPositionData value) { + + if (documentPositionDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentPositionDataIsMutable(); + documentPositionData_.add(index, value); + onChanged(); + } else { + documentPositionDataBuilder_.addMessage(index, value); + } + return this; + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public Builder addDocumentPositionData(DocumentPositionData.Builder builderForValue) { + + if (documentPositionDataBuilder_ == null) { + ensureDocumentPositionDataIsMutable(); + documentPositionData_.add(builderForValue.build()); + onChanged(); + } else { + documentPositionDataBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public Builder addDocumentPositionData(int index, DocumentPositionData.Builder builderForValue) { + + if (documentPositionDataBuilder_ == null) { + ensureDocumentPositionDataIsMutable(); + documentPositionData_.add(index, builderForValue.build()); + onChanged(); + } else { + documentPositionDataBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public Builder addAllDocumentPositionData(java.lang.Iterable values) { + + if (documentPositionDataBuilder_ == null) { + ensureDocumentPositionDataIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, documentPositionData_); + onChanged(); + } else { + documentPositionDataBuilder_.addAllMessages(values); + } + return this; + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public Builder clearDocumentPositionData() { + + if (documentPositionDataBuilder_ == null) { + documentPositionData_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + documentPositionDataBuilder_.clear(); + } + return this; + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public Builder removeDocumentPositionData(int index) { + + if (documentPositionDataBuilder_ == null) { + ensureDocumentPositionDataIsMutable(); + documentPositionData_.remove(index); + onChanged(); + } else { + documentPositionDataBuilder_.remove(index); + } + return this; + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public DocumentPositionData.Builder getDocumentPositionDataBuilder(int index) { + + return getDocumentPositionDataFieldBuilder().getBuilder(index); + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public DocumentPositionDataOrBuilder getDocumentPositionDataOrBuilder(int index) { + + if (documentPositionDataBuilder_ == null) { + return documentPositionData_.get(index); + } else { + return documentPositionDataBuilder_.getMessageOrBuilder(index); + } + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public java.util.List getDocumentPositionDataOrBuilderList() { + + if (documentPositionDataBuilder_ != null) { + return documentPositionDataBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(documentPositionData_); + } + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public DocumentPositionData.Builder addDocumentPositionDataBuilder() { + + return getDocumentPositionDataFieldBuilder().addBuilder(DocumentPositionData.getDefaultInstance()); + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public DocumentPositionData.Builder addDocumentPositionDataBuilder(int index) { + + return getDocumentPositionDataFieldBuilder().addBuilder(index, DocumentPositionData.getDefaultInstance()); + } + + + /** + * repeated .DocumentPositionData documentPositionData = 1; + */ + public java.util.List getDocumentPositionDataBuilderList() { + + return getDocumentPositionDataFieldBuilder().getBuilderList(); + } + + + private com.google.protobuf.RepeatedFieldBuilder getDocumentPositionDataFieldBuilder() { + + if (documentPositionDataBuilder_ == null) { + documentPositionDataBuilder_ = new com.google.protobuf.RepeatedFieldBuilder( + documentPositionData_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + documentPositionData_ = null; + } + return documentPositionDataBuilder_; + } + + // @@protoc_insertion_point(builder_scope:AllDocumentPositionData) + } + + // @@protoc_insertion_point(class_scope:AllDocumentPositionData) + private static final AllDocumentPositionData DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new AllDocumentPositionData(); + } + + public static AllDocumentPositionData getDefaultInstance() { + + return DEFAULT_INSTANCE; + } + + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public AllDocumentPositionData parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + + public static com.google.protobuf.Parser parser() { + + return PARSER; + } + + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + + return PARSER; + } + + + @java.lang.Override + public AllDocumentPositionData getDefaultInstanceForType() { + + return DEFAULT_INSTANCE; + } + + } + + public interface DocumentPositionDataOrBuilder extends + // @@protoc_insertion_point(interface_extends:DocumentPositionData) + com.google.protobuf.MessageOrBuilder { + + /** + *
+         * Identifier of the text block.
+         * 
+ * + * int64 id = 1; + * + * @return The id. + */ + long getId(); + + + /** + *
+         * For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate.
+         * This is required due to the text and position coordinates not being equal.
+         * 
+ * + * repeated int32 stringIdxToPositionIdx = 2; + * + * @return A list containing the stringIdxToPositionIdx. + */ + java.util.List getStringIdxToPositionIdxList(); + + + /** + *
+         * For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate.
+         * This is required due to the text and position coordinates not being equal.
+         * 
+ * + * repeated int32 stringIdxToPositionIdx = 2; + * + * @return The count of stringIdxToPositionIdx. + */ + int getStringIdxToPositionIdxCount(); + + + /** + *
+         * For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate.
+         * This is required due to the text and position coordinates not being equal.
+         * 
+ * + * repeated int32 stringIdxToPositionIdx = 2; + * + * @param index The index of the element to return. + * @return The stringIdxToPositionIdx at the given index. + */ + int getStringIdxToPositionIdx(int index); + + + /** + *
+         * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+         * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+         * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+         * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + java.util.List getPositionsList(); + + + /** + *
+         * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+         * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+         * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+         * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + DocumentPositionData.Position getPositions(int index); + + + /** + *
+         * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+         * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+         * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+         * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + int getPositionsCount(); + + + /** + *
+         * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+         * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+         * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+         * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + java.util.List getPositionsOrBuilderList(); + + + /** + *
+         * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+         * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+         * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+         * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + DocumentPositionData.PositionOrBuilder getPositionsOrBuilder(int index); + + } + + /** + * Protobuf type {@code DocumentPositionData} + */ + public static final class DocumentPositionData extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:DocumentPositionData) + DocumentPositionDataOrBuilder { + + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", DocumentPositionData.class.getName()); + } + + // Use DocumentPositionData.newBuilder() to construct. + private DocumentPositionData(com.google.protobuf.GeneratedMessage.Builder builder) { + + super(builder); + } + + + private DocumentPositionData() { + + stringIdxToPositionIdx_ = emptyIntList(); + positions_ = java.util.Collections.emptyList(); + } + + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentPositionDataProto.internal_static_DocumentPositionData_descriptor; + } + + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentPositionDataProto.internal_static_DocumentPositionData_fieldAccessorTable.ensureFieldAccessorsInitialized(DocumentPositionData.class, + DocumentPositionData.Builder.class); + } + + + public interface PositionOrBuilder extends + // @@protoc_insertion_point(interface_extends:DocumentPositionData.Position) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated float value = 1; + * + * @return A list containing the value. + */ + java.util.List getValueList(); + + + /** + * repeated float value = 1; + * + * @return The count of value. + */ + int getValueCount(); + + + /** + * repeated float value = 1; + * + * @param index The index of the element to return. + * @return The value at the given index. + */ + float getValue(int index); + + } + + /** + *
+         * Definition of a BoundingBox that contains x, y, width, and height.
+         * 
+ *

+ * Protobuf type {@code DocumentPositionData.Position} + */ + public static final class Position extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:DocumentPositionData.Position) + PositionOrBuilder { + + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", Position.class.getName()); + } + + // Use Position.newBuilder() to construct. + private Position(com.google.protobuf.GeneratedMessage.Builder builder) { + + super(builder); + } + + + private Position() { + + value_ = emptyFloatList(); + } + + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentPositionDataProto.internal_static_DocumentPositionData_Position_descriptor; + } + + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentPositionDataProto.internal_static_DocumentPositionData_Position_fieldAccessorTable.ensureFieldAccessorsInitialized(DocumentPositionData.Position.class, + DocumentPositionData.Position.Builder.class); + } + + + public static final int VALUE_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private com.google.protobuf.Internal.FloatList value_ = emptyFloatList(); + + + /** + * repeated float value = 1; + * + * @return A list containing the value. + */ + @java.lang.Override + public java.util.List getValueList() { + + return value_; + } + + + /** + * repeated float value = 1; + * + * @return The count of value. + */ + public int getValueCount() { + + return value_.size(); + } + + + /** + * repeated float value = 1; + * + * @param index The index of the element to return. + * @return The value at the given index. + */ + public float getValue(int index) { + + return value_.getFloat(index); + } + + + private int valueMemoizedSerializedSize = -1; + + private byte memoizedIsInitialized = -1; + + + @java.lang.Override + public final boolean isInitialized() { + + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) { + return true; + } + if (isInitialized == 0) { + return false; + } + + memoizedIsInitialized = 1; + return true; + } + + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + + getSerializedSize(); + if (getValueList().size() > 0) { + output.writeUInt32NoTag(10); + output.writeUInt32NoTag(valueMemoizedSerializedSize); + } + for (int i = 0; i < value_.size(); i++) { + output.writeFloatNoTag(value_.getFloat(i)); + } + getUnknownFields().writeTo(output); + } + + + @java.lang.Override + public int getSerializedSize() { + + int size = memoizedSize; + if (size != -1) { + return size; + } + + size = 0; + { + int dataSize = 0; + dataSize = 4 * getValueList().size(); + size += dataSize; + if (!getValueList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize); + } + valueMemoizedSerializedSize = dataSize; + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof DocumentPositionData.Position)) { + return super.equals(obj); + } + DocumentPositionData.Position other = (DocumentPositionData.Position) obj; + + if (!getValueList().equals(other.getValueList())) { + return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) { + return false; + } + return true; + } + + + @java.lang.Override + public int hashCode() { + + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getValueCount() > 0) { + hash = (37 * hash) + VALUE_FIELD_NUMBER; + hash = (53 * hash) + getValueList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + + public static DocumentPositionData.Position parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentPositionData.Position parseFrom(java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentPositionData.Position parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentPositionData.Position parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentPositionData.Position parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentPositionData.Position parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentPositionData.Position parseFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static DocumentPositionData.Position parseFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + public static DocumentPositionData.Position parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + + public static DocumentPositionData.Position parseDelimitedFrom(java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + + public static DocumentPositionData.Position parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static DocumentPositionData.Position parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + @java.lang.Override + public Builder newBuilderForType() {return newBuilder();} + + + public static Builder newBuilder() { + + return DEFAULT_INSTANCE.toBuilder(); + } + + + public static Builder newBuilder(DocumentPositionData.Position prototype) { + + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + + @java.lang.Override + public Builder toBuilder() { + + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + + Builder builder = new Builder(parent); + return builder; + } + + + /** + *

+             * Definition of a BoundingBox that contains x, y, width, and height.
+             * 
+ *

+ * Protobuf type {@code DocumentPositionData.Position} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:DocumentPositionData.Position) + DocumentPositionData.PositionOrBuilder { + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentPositionDataProto.internal_static_DocumentPositionData_Position_descriptor; + } + + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentPositionDataProto.internal_static_DocumentPositionData_Position_fieldAccessorTable.ensureFieldAccessorsInitialized(DocumentPositionData.Position.class, + DocumentPositionData.Position.Builder.class); + } + + + // Construct using DocumentPositionData.Position.newBuilder() + private Builder() { + + } + + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + + super(parent); + + } + + + @java.lang.Override + public Builder clear() { + + super.clear(); + bitField0_ = 0; + value_ = emptyFloatList(); + return this; + } + + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + + return DocumentPositionDataProto.internal_static_DocumentPositionData_Position_descriptor; + } + + + @java.lang.Override + public DocumentPositionData.Position getDefaultInstanceForType() { + + return DocumentPositionData.Position.getDefaultInstance(); + } + + + @java.lang.Override + public DocumentPositionData.Position build() { + + DocumentPositionData.Position result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + + @java.lang.Override + public DocumentPositionData.Position buildPartial() { + + DocumentPositionData.Position result = new DocumentPositionData.Position(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + + private void buildPartial0(DocumentPositionData.Position result) { + + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + value_.makeImmutable(); + result.value_ = value_; + } + } + + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + + if (other instanceof DocumentPositionData.Position) { + return mergeFrom((DocumentPositionData.Position) other); + } else { + super.mergeFrom(other); + return this; + } + } + + + public Builder mergeFrom(DocumentPositionData.Position other) { + + if (other == DocumentPositionData.Position.getDefaultInstance()) { + return this; + } + if (!other.value_.isEmpty()) { + if (value_.isEmpty()) { + value_ = other.value_; + value_.makeImmutable(); + bitField0_ |= 0x00000001; + } else { + ensureValueIsMutable(); + value_.addAll(other.value_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + + @java.lang.Override + public final boolean isInitialized() { + + return true; + } + + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 13: { + float v = input.readFloat(); + ensureValueIsMutable(); + value_.addFloat(v); + break; + } // case 13 + case 10: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + int alloc = length > 4096 ? 4096 : length; + ensureValueIsMutable(alloc / 4); + while (input.getBytesUntilLimit() > 0) { + value_.addFloat(input.readFloat()); + } + input.popLimit(limit); + break; + } // case 10 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + + private int bitField0_; + + private com.google.protobuf.Internal.FloatList value_ = emptyFloatList(); + + + private void ensureValueIsMutable() { + + if (!value_.isModifiable()) { + value_ = makeMutableCopy(value_); + } + bitField0_ |= 0x00000001; + } + + + private void ensureValueIsMutable(int capacity) { + + if (!value_.isModifiable()) { + value_ = makeMutableCopy(value_, capacity); + } + bitField0_ |= 0x00000001; + } + + + /** + * repeated float value = 1; + * + * @return A list containing the value. + */ + public java.util.List getValueList() { + + value_.makeImmutable(); + return value_; + } + + + /** + * repeated float value = 1; + * + * @return The count of value. + */ + public int getValueCount() { + + return value_.size(); + } + + + /** + * repeated float value = 1; + * + * @param index The index of the element to return. + * @return The value at the given index. + */ + public float getValue(int index) { + + return value_.getFloat(index); + } + + + /** + * repeated float value = 1; + * + * @param index The index to set the value at. + * @param value The value to set. + * @return This builder for chaining. + */ + public Builder setValue(int index, float value) { + + ensureValueIsMutable(); + value_.setFloat(index, value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + + /** + * repeated float value = 1; + * + * @param value The value to add. + * @return This builder for chaining. + */ + public Builder addValue(float value) { + + ensureValueIsMutable(); + value_.addFloat(value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + + /** + * repeated float value = 1; + * + * @param values The value to add. + * @return This builder for chaining. + */ + public Builder addAllValue(java.lang.Iterable values) { + + ensureValueIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, value_); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + + /** + * repeated float value = 1; + * + * @return This builder for chaining. + */ + public Builder clearValue() { + + value_ = emptyFloatList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:DocumentPositionData.Position) + } + + // @@protoc_insertion_point(class_scope:DocumentPositionData.Position) + private static final DocumentPositionData.Position DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new DocumentPositionData.Position(); + } + + public static DocumentPositionData.Position getDefaultInstance() { + + return DEFAULT_INSTANCE; + } + + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Position parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + + public static com.google.protobuf.Parser parser() { + + return PARSER; + } + + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + + return PARSER; + } + + + @java.lang.Override + public DocumentPositionData.Position getDefaultInstanceForType() { + + return DEFAULT_INSTANCE; + } + + } + + public static final int ID_FIELD_NUMBER = 1; + private long id_ = 0L; + + + /** + *

+         * Identifier of the text block.
+         * 
+ * + * int64 id = 1; + * + * @return The id. + */ + @java.lang.Override + public long getId() { + + return id_; + } + + + public static final int STRINGIDXTOPOSITIONIDX_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private com.google.protobuf.Internal.IntList stringIdxToPositionIdx_ = emptyIntList(); + + + /** + *
+         * For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate.
+         * This is required due to the text and position coordinates not being equal.
+         * 
+ * + * repeated int32 stringIdxToPositionIdx = 2; + * + * @return A list containing the stringIdxToPositionIdx. + */ + @java.lang.Override + public java.util.List getStringIdxToPositionIdxList() { + + return stringIdxToPositionIdx_; + } + + + /** + *
+         * For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate.
+         * This is required due to the text and position coordinates not being equal.
+         * 
+ * + * repeated int32 stringIdxToPositionIdx = 2; + * + * @return The count of stringIdxToPositionIdx. + */ + public int getStringIdxToPositionIdxCount() { + + return stringIdxToPositionIdx_.size(); + } + + + /** + *
+         * For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate.
+         * This is required due to the text and position coordinates not being equal.
+         * 
+ * + * repeated int32 stringIdxToPositionIdx = 2; + * + * @param index The index of the element to return. + * @return The stringIdxToPositionIdx at the given index. + */ + public int getStringIdxToPositionIdx(int index) { + + return stringIdxToPositionIdx_.getInt(index); + } + + + private int stringIdxToPositionIdxMemoizedSerializedSize = -1; + + public static final int POSITIONS_FIELD_NUMBER = 3; + @SuppressWarnings("serial") + private java.util.List positions_; + + + /** + *
+         * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+         * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+         * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+         * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + @java.lang.Override + public java.util.List getPositionsList() { + + return positions_; + } + + + /** + *
+         * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+         * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+         * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+         * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + @java.lang.Override + public java.util.List getPositionsOrBuilderList() { + + return positions_; + } + + + /** + *
+         * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+         * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+         * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+         * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + @java.lang.Override + public int getPositionsCount() { + + return positions_.size(); + } + + + /** + *
+         * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+         * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+         * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+         * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + @java.lang.Override + public DocumentPositionData.Position getPositions(int index) { + + return positions_.get(index); + } + + + /** + *
+         * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+         * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+         * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+         * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + @java.lang.Override + public DocumentPositionData.PositionOrBuilder getPositionsOrBuilder(int index) { + + return positions_.get(index); + } + + + private byte memoizedIsInitialized = -1; + + + @java.lang.Override + public final boolean isInitialized() { + + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) { + return true; + } + if (isInitialized == 0) { + return false; + } + + memoizedIsInitialized = 1; + return true; + } + + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + + getSerializedSize(); + if (id_ != 0L) { + output.writeInt64(1, id_); + } + if (getStringIdxToPositionIdxList().size() > 0) { + output.writeUInt32NoTag(18); + output.writeUInt32NoTag(stringIdxToPositionIdxMemoizedSerializedSize); + } + for (int i = 0; i < stringIdxToPositionIdx_.size(); i++) { + output.writeInt32NoTag(stringIdxToPositionIdx_.getInt(i)); + } + for (int i = 0; i < positions_.size(); i++) { + output.writeMessage(3, positions_.get(i)); + } + getUnknownFields().writeTo(output); + } + + + @java.lang.Override + public int getSerializedSize() { + + int size = memoizedSize; + if (size != -1) { + return size; + } + + size = 0; + if (id_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, id_); + } + { + int dataSize = 0; + for (int i = 0; i < stringIdxToPositionIdx_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(stringIdxToPositionIdx_.getInt(i)); + } + size += dataSize; + if (!getStringIdxToPositionIdxList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize); + } + stringIdxToPositionIdxMemoizedSerializedSize = dataSize; + } + for (int i = 0; i < positions_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, positions_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof DocumentPositionData)) { + return super.equals(obj); + } + DocumentPositionData other = (DocumentPositionData) obj; + + if (getId() != other.getId()) { + return false; + } + if (!getStringIdxToPositionIdxList().equals(other.getStringIdxToPositionIdxList())) { + return false; + } + if (!getPositionsList().equals(other.getPositionsList())) { + return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) { + return false; + } + return true; + } + + + @java.lang.Override + public int hashCode() { + + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getId()); + if (getStringIdxToPositionIdxCount() > 0) { + hash = (37 * hash) + STRINGIDXTOPOSITIONIDX_FIELD_NUMBER; + hash = (53 * hash) + getStringIdxToPositionIdxList().hashCode(); + } + if (getPositionsCount() > 0) { + hash = (37 * hash) + POSITIONS_FIELD_NUMBER; + hash = (53 * hash) + getPositionsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + + public static DocumentPositionData parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentPositionData parseFrom(java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentPositionData parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentPositionData parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentPositionData parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentPositionData parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentPositionData parseFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static DocumentPositionData parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + public static DocumentPositionData parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + + public static DocumentPositionData parseDelimitedFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + + public static DocumentPositionData parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static DocumentPositionData parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + @java.lang.Override + public Builder newBuilderForType() {return newBuilder();} + + + public static Builder newBuilder() { + + return DEFAULT_INSTANCE.toBuilder(); + } + + + public static Builder newBuilder(DocumentPositionData prototype) { + + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + + @java.lang.Override + public Builder toBuilder() { + + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + + Builder builder = new Builder(parent); + return builder; + } + + + /** + * Protobuf type {@code DocumentPositionData} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:DocumentPositionData) + DocumentPositionDataOrBuilder { + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentPositionDataProto.internal_static_DocumentPositionData_descriptor; + } + + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentPositionDataProto.internal_static_DocumentPositionData_fieldAccessorTable.ensureFieldAccessorsInitialized(DocumentPositionData.class, + DocumentPositionData.Builder.class); + } + + + // Construct using DocumentPositionData.newBuilder() + private Builder() { + + } + + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + + super(parent); + + } + + + @java.lang.Override + public Builder clear() { + + super.clear(); + bitField0_ = 0; + id_ = 0L; + stringIdxToPositionIdx_ = emptyIntList(); + if (positionsBuilder_ == null) { + positions_ = java.util.Collections.emptyList(); + } else { + positions_ = null; + positionsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + + return DocumentPositionDataProto.internal_static_DocumentPositionData_descriptor; + } + + + @java.lang.Override + public DocumentPositionData getDefaultInstanceForType() { + + return DocumentPositionData.getDefaultInstance(); + } + + + @java.lang.Override + public DocumentPositionData build() { + + DocumentPositionData result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + + @java.lang.Override + public DocumentPositionData buildPartial() { + + DocumentPositionData result = new DocumentPositionData(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + + private void buildPartialRepeatedFields(DocumentPositionData result) { + + if (positionsBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0)) { + positions_ = java.util.Collections.unmodifiableList(positions_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.positions_ = positions_; + } else { + result.positions_ = positionsBuilder_.build(); + } + } + + + private void buildPartial0(DocumentPositionData result) { + + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.id_ = id_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + stringIdxToPositionIdx_.makeImmutable(); + result.stringIdxToPositionIdx_ = stringIdxToPositionIdx_; + } + } + + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + + if (other instanceof DocumentPositionData) { + return mergeFrom((DocumentPositionData) other); + } else { + super.mergeFrom(other); + return this; + } + } + + + public Builder mergeFrom(DocumentPositionData other) { + + if (other == DocumentPositionData.getDefaultInstance()) { + return this; + } + if (other.getId() != 0L) { + setId(other.getId()); + } + if (!other.stringIdxToPositionIdx_.isEmpty()) { + if (stringIdxToPositionIdx_.isEmpty()) { + stringIdxToPositionIdx_ = other.stringIdxToPositionIdx_; + stringIdxToPositionIdx_.makeImmutable(); + bitField0_ |= 0x00000002; + } else { + ensureStringIdxToPositionIdxIsMutable(); + stringIdxToPositionIdx_.addAll(other.stringIdxToPositionIdx_); + } + onChanged(); + } + if (positionsBuilder_ == null) { + if (!other.positions_.isEmpty()) { + if (positions_.isEmpty()) { + positions_ = other.positions_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensurePositionsIsMutable(); + positions_.addAll(other.positions_); + } + onChanged(); + } + } else { + if (!other.positions_.isEmpty()) { + if (positionsBuilder_.isEmpty()) { + positionsBuilder_.dispose(); + positionsBuilder_ = null; + positions_ = other.positions_; + bitField0_ = (bitField0_ & ~0x00000004); + positionsBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getPositionsFieldBuilder() : null; + } else { + positionsBuilder_.addAllMessages(other.positions_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + + @java.lang.Override + public final boolean isInitialized() { + + return true; + } + + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + id_ = input.readInt64(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 16: { + int v = input.readInt32(); + ensureStringIdxToPositionIdxIsMutable(); + stringIdxToPositionIdx_.addInt(v); + break; + } // case 16 + case 18: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + ensureStringIdxToPositionIdxIsMutable(); + while (input.getBytesUntilLimit() > 0) { + stringIdxToPositionIdx_.addInt(input.readInt32()); + } + input.popLimit(limit); + break; + } // case 18 + case 26: { + DocumentPositionData.Position m = input.readMessage(DocumentPositionData.Position.parser(), extensionRegistry); + if (positionsBuilder_ == null) { + ensurePositionsIsMutable(); + positions_.add(m); + } else { + positionsBuilder_.addMessage(m); + } + break; + } // case 26 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + + private int bitField0_; + + private long id_; + + + /** + *
+             * Identifier of the text block.
+             * 
+ * + * int64 id = 1; + * + * @return The id. + */ + @java.lang.Override + public long getId() { + + return id_; + } + + + /** + *
+             * Identifier of the text block.
+             * 
+ * + * int64 id = 1; + * + * @param value The id to set. + * @return This builder for chaining. + */ + public Builder setId(long value) { + + id_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + + /** + *
+             * Identifier of the text block.
+             * 
+ * + * int64 id = 1; + * + * @return This builder for chaining. + */ + public Builder clearId() { + + bitField0_ = (bitField0_ & ~0x00000001); + id_ = 0L; + onChanged(); + return this; + } + + + private com.google.protobuf.Internal.IntList stringIdxToPositionIdx_ = emptyIntList(); + + + private void ensureStringIdxToPositionIdxIsMutable() { + + if (!stringIdxToPositionIdx_.isModifiable()) { + stringIdxToPositionIdx_ = makeMutableCopy(stringIdxToPositionIdx_); + } + bitField0_ |= 0x00000002; + } + + + /** + *
+             * For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate.
+             * This is required due to the text and position coordinates not being equal.
+             * 
+ * + * repeated int32 stringIdxToPositionIdx = 2; + * + * @return A list containing the stringIdxToPositionIdx. + */ + public java.util.List getStringIdxToPositionIdxList() { + + stringIdxToPositionIdx_.makeImmutable(); + return stringIdxToPositionIdx_; + } + + + /** + *
+             * For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate.
+             * This is required due to the text and position coordinates not being equal.
+             * 
+ * + * repeated int32 stringIdxToPositionIdx = 2; + * + * @return The count of stringIdxToPositionIdx. + */ + public int getStringIdxToPositionIdxCount() { + + return stringIdxToPositionIdx_.size(); + } + + + /** + *
+             * For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate.
+             * This is required due to the text and position coordinates not being equal.
+             * 
+ * + * repeated int32 stringIdxToPositionIdx = 2; + * + * @param index The index of the element to return. + * @return The stringIdxToPositionIdx at the given index. + */ + public int getStringIdxToPositionIdx(int index) { + + return stringIdxToPositionIdx_.getInt(index); + } + + + /** + *
+             * For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate.
+             * This is required due to the text and position coordinates not being equal.
+             * 
+ * + * repeated int32 stringIdxToPositionIdx = 2; + * + * @param index The index to set the value at. + * @param value The stringIdxToPositionIdx to set. + * @return This builder for chaining. + */ + public Builder setStringIdxToPositionIdx(int index, int value) { + + ensureStringIdxToPositionIdxIsMutable(); + stringIdxToPositionIdx_.setInt(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + + /** + *
+             * For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate.
+             * This is required due to the text and position coordinates not being equal.
+             * 
+ * + * repeated int32 stringIdxToPositionIdx = 2; + * + * @param value The stringIdxToPositionIdx to add. + * @return This builder for chaining. + */ + public Builder addStringIdxToPositionIdx(int value) { + + ensureStringIdxToPositionIdxIsMutable(); + stringIdxToPositionIdx_.addInt(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + + /** + *
+             * For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate.
+             * This is required due to the text and position coordinates not being equal.
+             * 
+ * + * repeated int32 stringIdxToPositionIdx = 2; + * + * @param values The stringIdxToPositionIdx to add. + * @return This builder for chaining. + */ + public Builder addAllStringIdxToPositionIdx(java.lang.Iterable values) { + + ensureStringIdxToPositionIdxIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, stringIdxToPositionIdx_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + + /** + *
+             * For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate.
+             * This is required due to the text and position coordinates not being equal.
+             * 
+ * + * repeated int32 stringIdxToPositionIdx = 2; + * + * @return This builder for chaining. + */ + public Builder clearStringIdxToPositionIdx() { + + stringIdxToPositionIdx_ = emptyIntList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + + private java.util.List positions_ = java.util.Collections.emptyList(); + + + private void ensurePositionsIsMutable() { + + if (!((bitField0_ & 0x00000004) != 0)) { + positions_ = new java.util.ArrayList(positions_); + bitField0_ |= 0x00000004; + } + } + + + private com.google.protobuf.RepeatedFieldBuilder positionsBuilder_; + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public java.util.List getPositionsList() { + + if (positionsBuilder_ == null) { + return java.util.Collections.unmodifiableList(positions_); + } else { + return positionsBuilder_.getMessageList(); + } + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public int getPositionsCount() { + + if (positionsBuilder_ == null) { + return positions_.size(); + } else { + return positionsBuilder_.getCount(); + } + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public DocumentPositionData.Position getPositions(int index) { + + if (positionsBuilder_ == null) { + return positions_.get(index); + } else { + return positionsBuilder_.getMessage(index); + } + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public Builder setPositions(int index, DocumentPositionData.Position value) { + + if (positionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePositionsIsMutable(); + positions_.set(index, value); + onChanged(); + } else { + positionsBuilder_.setMessage(index, value); + } + return this; + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public Builder setPositions(int index, DocumentPositionData.Position.Builder builderForValue) { + + if (positionsBuilder_ == null) { + ensurePositionsIsMutable(); + positions_.set(index, builderForValue.build()); + onChanged(); + } else { + positionsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public Builder addPositions(DocumentPositionData.Position value) { + + if (positionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePositionsIsMutable(); + positions_.add(value); + onChanged(); + } else { + positionsBuilder_.addMessage(value); + } + return this; + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public Builder addPositions(int index, DocumentPositionData.Position value) { + + if (positionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePositionsIsMutable(); + positions_.add(index, value); + onChanged(); + } else { + positionsBuilder_.addMessage(index, value); + } + return this; + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public Builder addPositions(DocumentPositionData.Position.Builder builderForValue) { + + if (positionsBuilder_ == null) { + ensurePositionsIsMutable(); + positions_.add(builderForValue.build()); + onChanged(); + } else { + positionsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public Builder addPositions(int index, DocumentPositionData.Position.Builder builderForValue) { + + if (positionsBuilder_ == null) { + ensurePositionsIsMutable(); + positions_.add(index, builderForValue.build()); + onChanged(); + } else { + positionsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public Builder addAllPositions(java.lang.Iterable values) { + + if (positionsBuilder_ == null) { + ensurePositionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, positions_); + onChanged(); + } else { + positionsBuilder_.addAllMessages(values); + } + return this; + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public Builder clearPositions() { + + if (positionsBuilder_ == null) { + positions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + positionsBuilder_.clear(); + } + return this; + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public Builder removePositions(int index) { + + if (positionsBuilder_ == null) { + ensurePositionsIsMutable(); + positions_.remove(index); + onChanged(); + } else { + positionsBuilder_.remove(index); + } + return this; + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public DocumentPositionData.Position.Builder getPositionsBuilder(int index) { + + return getPositionsFieldBuilder().getBuilder(index); + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public DocumentPositionData.PositionOrBuilder getPositionsOrBuilder(int index) { + + if (positionsBuilder_ == null) { + return positions_.get(index); + } else { + return positionsBuilder_.getMessageOrBuilder(index); + } + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public java.util.List getPositionsOrBuilderList() { + + if (positionsBuilder_ != null) { + return positionsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(positions_); + } + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public DocumentPositionData.Position.Builder addPositionsBuilder() { + + return getPositionsFieldBuilder().addBuilder(DocumentPositionData.Position.getDefaultInstance()); + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public DocumentPositionData.Position.Builder addPositionsBuilder(int index) { + + return getPositionsFieldBuilder().addBuilder(index, DocumentPositionData.Position.getDefaultInstance()); + } + + + /** + *
+             * The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block.
+             * The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner.
+             * In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates.
+             * 
+ * + * repeated .DocumentPositionData.Position positions = 3; + */ + public java.util.List getPositionsBuilderList() { + + return getPositionsFieldBuilder().getBuilderList(); + } + + + private com.google.protobuf.RepeatedFieldBuilder getPositionsFieldBuilder() { + + if (positionsBuilder_ == null) { + positionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilder( + positions_, + ((bitField0_ & 0x00000004) != 0), + getParentForChildren(), + isClean()); + positions_ = null; + } + return positionsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:DocumentPositionData) + } + + // @@protoc_insertion_point(class_scope:DocumentPositionData) + private static final DocumentPositionData DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new DocumentPositionData(); + } + + public static DocumentPositionData getDefaultInstance() { + + return DEFAULT_INSTANCE; + } + + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DocumentPositionData parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + + public static com.google.protobuf.Parser parser() { + + return PARSER; + } + + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + + return PARSER; + } + + + @java.lang.Override + public DocumentPositionData getDefaultInstanceForType() { + + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor internal_static_AllDocumentPositionData_descriptor; + private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_AllDocumentPositionData_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_DocumentPositionData_descriptor; + private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_DocumentPositionData_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_DocumentPositionData_Position_descriptor; + private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_DocumentPositionData_Position_fieldAccessorTable; + + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + + return descriptor; + } + + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = {"\n\032DocumentPositionData.proto\"N\n\027AllDocum" + + "entPositionData\0223\n\024documentPositionData\030" + + "\001 \003(\0132\025.DocumentPositionData\"\220\001\n\024Documen" + + "tPositionData\022\n\n\002id\030\001 \001(\003\022\036\n\026stringIdxTo" + + "PositionIdx\030\002 \003(\005\0221\n\tpositions\030\003 \003(\0132\036.D" + + "ocumentPositionData.Position\032\031\n\010Position" + + "\022\r\n\005value\030\001 \003(\002b\006proto3"}; + descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[]{}); + internal_static_AllDocumentPositionData_descriptor = getDescriptor().getMessageTypes() + .get(0); + internal_static_AllDocumentPositionData_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_AllDocumentPositionData_descriptor, + new java.lang.String[]{"DocumentPositionData",}); + internal_static_DocumentPositionData_descriptor = getDescriptor().getMessageTypes() + .get(1); + internal_static_DocumentPositionData_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_DocumentPositionData_descriptor, + new java.lang.String[]{"Id", "StringIdxToPositionIdx", "Positions",}); + internal_static_DocumentPositionData_Position_descriptor = internal_static_DocumentPositionData_descriptor.getNestedTypes() + .get(0); + internal_static_DocumentPositionData_Position_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_DocumentPositionData_Position_descriptor, + new java.lang.String[]{"Value",}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentStructure.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentStructure.java index c7a8499..4bf9558 100644 --- a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentStructure.java +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentStructure.java @@ -16,6 +16,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.FieldDefaults; +@Deprecated @Data @Builder @NoArgsConstructor diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentStructureProto.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentStructureProto.java new file mode 100644 index 0000000..d99d5db --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentStructureProto.java @@ -0,0 +1,799 @@ +package com.knecon.fforesight.service.layoutparser.internal.api.data.redaction; + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: DocumentStructure.proto +// Protobuf Java Version: 4.27.1 +@SuppressWarnings("all") +public final class DocumentStructureProto { + + private DocumentStructureProto() {} + + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", DocumentStructureProto.class.getName()); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) { + + } + + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + + public interface DocumentStructureOrBuilder extends + // @@protoc_insertion_point(interface_extends:DocumentStructure) + com.google.protobuf.MessageOrBuilder { + + /** + *
+         * The root EntryData represents the Document.
+         * 
+ * + * .EntryData root = 1; + * + * @return Whether the root field is set. + */ + boolean hasRoot(); + + + /** + *
+         * The root EntryData represents the Document.
+         * 
+ * + * .EntryData root = 1; + * + * @return The root. + */ + EntryDataProto.EntryData getRoot(); + + + /** + *
+         * The root EntryData represents the Document.
+         * 
+ * + * .EntryData root = 1; + */ + EntryDataProto.EntryDataOrBuilder getRootOrBuilder(); + + } + + /** + * Protobuf type {@code DocumentStructure} + */ + public static final class DocumentStructure extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:DocumentStructure) + DocumentStructureOrBuilder { + + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", DocumentStructure.class.getName()); + } + + // Use DocumentStructure.newBuilder() to construct. + private DocumentStructure(com.google.protobuf.GeneratedMessage.Builder builder) { + + super(builder); + } + + + private DocumentStructure() { + + } + + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentStructureProto.internal_static_DocumentStructure_descriptor; + } + + + @Override + protected FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentStructureProto.internal_static_DocumentStructure_fieldAccessorTable.ensureFieldAccessorsInitialized(DocumentStructure.class, Builder.class); + } + + + private int bitField0_; + public static final int ROOT_FIELD_NUMBER = 1; + private EntryDataProto.EntryData root_; + + + /** + *
+         * The root EntryData represents the Document.
+         * 
+ * + * .EntryData root = 1; + * + * @return Whether the root field is set. + */ + @Override + public boolean hasRoot() { + + return ((bitField0_ & 0x00000001) != 0); + } + + + /** + *
+         * The root EntryData represents the Document.
+         * 
+ * + * .EntryData root = 1; + * + * @return The root. + */ + @Override + public EntryDataProto.EntryData getRoot() { + + return root_ == null ? EntryDataProto.EntryData.getDefaultInstance() : root_; + } + + + /** + *
+         * The root EntryData represents the Document.
+         * 
+ * + * .EntryData root = 1; + */ + @Override + public EntryDataProto.EntryDataOrBuilder getRootOrBuilder() { + + return root_ == null ? EntryDataProto.EntryData.getDefaultInstance() : root_; + } + + + private byte memoizedIsInitialized = -1; + + + @Override + public final boolean isInitialized() { + + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) { + return true; + } + if (isInitialized == 0) { + return false; + } + + memoizedIsInitialized = 1; + return true; + } + + + @Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getRoot()); + } + getUnknownFields().writeTo(output); + } + + + @Override + public int getSerializedSize() { + + int size = memoizedSize; + if (size != -1) { + return size; + } + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getRoot()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + + @Override + public boolean equals(final Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof DocumentStructure)) { + return super.equals(obj); + } + DocumentStructure other = (DocumentStructure) obj; + + if (hasRoot() != other.hasRoot()) { + return false; + } + if (hasRoot()) { + if (!getRoot().equals(other.getRoot())) { + return false; + } + } + if (!getUnknownFields().equals(other.getUnknownFields())) { + return false; + } + return true; + } + + + @Override + public int hashCode() { + + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasRoot()) { + hash = (37 * hash) + ROOT_FIELD_NUMBER; + hash = (53 * hash) + getRoot().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + + public static DocumentStructure parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentStructure parseFrom(java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentStructure parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentStructure parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentStructure parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentStructure parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentStructure parseFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static DocumentStructure parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + public static DocumentStructure parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + + public static DocumentStructure parseDelimitedFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + + public static DocumentStructure parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static DocumentStructure parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + @Override + public Builder newBuilderForType() {return newBuilder();} + + + public static Builder newBuilder() { + + return DEFAULT_INSTANCE.toBuilder(); + } + + + public static Builder newBuilder(DocumentStructure prototype) { + + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + + @Override + public Builder toBuilder() { + + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + + @Override + protected Builder newBuilderForType(BuilderParent parent) { + + Builder builder = new Builder(parent); + return builder; + } + + + /** + * Protobuf type {@code DocumentStructure} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:DocumentStructure) + DocumentStructureOrBuilder { + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentStructureProto.internal_static_DocumentStructure_descriptor; + } + + + @Override + protected FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentStructureProto.internal_static_DocumentStructure_fieldAccessorTable.ensureFieldAccessorsInitialized(DocumentStructure.class, Builder.class); + } + + + // Construct using DocumentStructureOuterClass.DocumentStructure.newBuilder() + private Builder() { + + maybeForceBuilderInitialization(); + } + + + private Builder(BuilderParent parent) { + + super(parent); + maybeForceBuilderInitialization(); + } + + + private void maybeForceBuilderInitialization() { + + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getRootFieldBuilder(); + } + } + + + @Override + public Builder clear() { + + super.clear(); + bitField0_ = 0; + root_ = null; + if (rootBuilder_ != null) { + rootBuilder_.dispose(); + rootBuilder_ = null; + } + return this; + } + + + @Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + + return DocumentStructureProto.internal_static_DocumentStructure_descriptor; + } + + + @Override + public DocumentStructure getDefaultInstanceForType() { + + return DocumentStructure.getDefaultInstance(); + } + + + @Override + public DocumentStructure build() { + + DocumentStructure result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + + @Override + public DocumentStructure buildPartial() { + + DocumentStructure result = new DocumentStructure(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + + private void buildPartial0(DocumentStructure result) { + + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.root_ = rootBuilder_ == null ? root_ : rootBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + + @Override + public Builder mergeFrom(com.google.protobuf.Message other) { + + if (other instanceof DocumentStructure) { + return mergeFrom((DocumentStructure) other); + } else { + super.mergeFrom(other); + return this; + } + } + + + public Builder mergeFrom(DocumentStructure other) { + + if (other == DocumentStructure.getDefaultInstance()) { + return this; + } + if (other.hasRoot()) { + mergeRoot(other.getRoot()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + + @Override + public final boolean isInitialized() { + + return true; + } + + + @Override + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + if (extensionRegistry == null) { + throw new NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + input.readMessage(getRootFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + + private int bitField0_; + + private EntryDataProto.EntryData root_; + private com.google.protobuf.SingleFieldBuilder rootBuilder_; + + + /** + *
+             * The root EntryData represents the Document.
+             * 
+ * + * .EntryData root = 1; + * + * @return Whether the root field is set. + */ + public boolean hasRoot() { + + return ((bitField0_ & 0x00000001) != 0); + } + + + /** + *
+             * The root EntryData represents the Document.
+             * 
+ * + * .EntryData root = 1; + * + * @return The root. + */ + public EntryDataProto.EntryData getRoot() { + + if (rootBuilder_ == null) { + return root_ == null ? EntryDataProto.EntryData.getDefaultInstance() : root_; + } else { + return rootBuilder_.getMessage(); + } + } + + + /** + *
+             * The root EntryData represents the Document.
+             * 
+ * + * .EntryData root = 1; + */ + public Builder setRoot(EntryDataProto.EntryData value) { + + if (rootBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + root_ = value; + } else { + rootBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + + /** + *
+             * The root EntryData represents the Document.
+             * 
+ * + * .EntryData root = 1; + */ + public Builder setRoot(EntryDataProto.EntryData.Builder builderForValue) { + + if (rootBuilder_ == null) { + root_ = builderForValue.build(); + } else { + rootBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + + /** + *
+             * The root EntryData represents the Document.
+             * 
+ * + * .EntryData root = 1; + */ + public Builder mergeRoot(EntryDataProto.EntryData value) { + + if (rootBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) && root_ != null && root_ != EntryDataProto.EntryData.getDefaultInstance()) { + getRootBuilder().mergeFrom(value); + } else { + root_ = value; + } + } else { + rootBuilder_.mergeFrom(value); + } + if (root_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + + /** + *
+             * The root EntryData represents the Document.
+             * 
+ * + * .EntryData root = 1; + */ + public Builder clearRoot() { + + bitField0_ = (bitField0_ & ~0x00000001); + root_ = null; + if (rootBuilder_ != null) { + rootBuilder_.dispose(); + rootBuilder_ = null; + } + onChanged(); + return this; + } + + + /** + *
+             * The root EntryData represents the Document.
+             * 
+ * + * .EntryData root = 1; + */ + public EntryDataProto.EntryData.Builder getRootBuilder() { + + bitField0_ |= 0x00000001; + onChanged(); + return getRootFieldBuilder().getBuilder(); + } + + + /** + *
+             * The root EntryData represents the Document.
+             * 
+ * + * .EntryData root = 1; + */ + public EntryDataProto.EntryDataOrBuilder getRootOrBuilder() { + + if (rootBuilder_ != null) { + return rootBuilder_.getMessageOrBuilder(); + } else { + return root_ == null ? EntryDataProto.EntryData.getDefaultInstance() : root_; + } + } + + + /** + *
+             * The root EntryData represents the Document.
+             * 
+ * + * .EntryData root = 1; + */ + private com.google.protobuf.SingleFieldBuilder getRootFieldBuilder() { + + if (rootBuilder_ == null) { + rootBuilder_ = new com.google.protobuf.SingleFieldBuilder(getRoot(), + getParentForChildren(), + isClean()); + root_ = null; + } + return rootBuilder_; + } + + // @@protoc_insertion_point(builder_scope:DocumentStructure) + } + + // @@protoc_insertion_point(class_scope:DocumentStructure) + private static final DocumentStructure DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new DocumentStructure(); + } + + public static DocumentStructure getDefaultInstance() { + + return DEFAULT_INSTANCE; + } + + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + @Override + public DocumentStructure parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + + public static com.google.protobuf.Parser parser() { + + return PARSER; + } + + + @Override + public com.google.protobuf.Parser getParserForType() { + + return PARSER; + } + + + @Override + public DocumentStructure getDefaultInstanceForType() { + + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor internal_static_DocumentStructure_descriptor; + private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_DocumentStructure_fieldAccessorTable; + + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + + return descriptor; + } + + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + String[] descriptorData = {"\n\027DocumentStructure.proto\032\017EntryData.pro" + + "to\"-\n\021DocumentStructure\022\030\n\004root\030\001 \001(\0132\n." + + "EntryDatab\006proto3"}; + descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{EntryDataProto.getDescriptor(),}); + internal_static_DocumentStructure_descriptor = getDescriptor().getMessageTypes() + .get(0); + internal_static_DocumentStructure_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_DocumentStructure_descriptor, + new String[]{"Root",}); + descriptor.resolveAllFeaturesImmutable(); + EntryDataProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentStructureWrapper.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentStructureWrapper.java new file mode 100644 index 0000000..79a3ad3 --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentStructureWrapper.java @@ -0,0 +1,126 @@ +package com.knecon.fforesight.service.layoutparser.internal.api.data.redaction; + +import static com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructureProto.DocumentStructure; + +import java.awt.geom.Rectangle2D; +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.EntryDataProto.EntryData; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class DocumentStructureWrapper implements Serializable { + + private final DocumentStructure documentStructure; + + + @Schema(description = "Object containing the extra field names, a table has in its properties field.") + public static class TableProperties implements Serializable { + + public static final String NUMBER_OF_ROWS = "numberOfRows"; + public static final String NUMBER_OF_COLS = "numberOfCols"; + + } + + @Schema(description = "Object containing the extra field names, an Image has in its properties field.") + public static class ImageProperties implements Serializable { + + public static final String TRANSPARENT = "transparent"; + public static final String IMAGE_TYPE = "imageType"; + public static final String POSITION = "position"; + public static final String ID = "id"; + + public static final String REPRESENTATION_HASH = "representationHash"; + + } + + @Schema(description = "Object containing the extra field names, a table cell has in its properties field.") + public static class TableCellProperties implements Serializable { + + public static final String B_BOX = "bBox"; + public static final String ROW = "row"; + public static final String COL = "col"; + public static final String HEADER = "header"; + + } + + @Schema(description = "Object containing the extra field names, a duplicate paragraph has in its properties field.") + public static class DuplicateParagraphProperties implements Serializable { + + public static final String UNSORTED_TEXTBLOCK_ID = "utbid"; + + } + + public static final String RECTANGLE_DELIMITER = ";"; + + + public static Rectangle2D parseRectangle2D(String bBox) { + + List floats = Arrays.stream(bBox.split(RECTANGLE_DELIMITER)) + .map(Float::parseFloat) + .toList(); + return new Rectangle2D.Float(floats.get(0), floats.get(1), floats.get(2), floats.get(3)); + } + + + public static double[] parseRepresentationVector(String representationHash) { + + String[] stringArray = representationHash.split("[,\\s]+"); + double[] doubleArray = new double[stringArray.length]; + for (int i = 0; i < stringArray.length; i++) { + doubleArray[i] = Double.parseDouble(stringArray[i]); + } + + return doubleArray; + } + + + public EntryData get(List tocId) { + + if (tocId.isEmpty()) { + return documentStructure.getRoot(); + } + EntryData entry = documentStructure.getRoot().getChildrenList() + .get(tocId.get(0)); + for (int id : tocId.subList(1, tocId.size())) { + entry = entry.getChildrenList() + .get(id); + } + return entry; + } + + + public Stream streamAllEntries() { + + return Stream.concat(Stream.of(documentStructure.getRoot()), + documentStructure.getRoot().getChildrenList() + .stream()) + .flatMap(DocumentStructureWrapper::flatten); + } + + + public String toString() { + + return String.join("\n", + streamAllEntries().map(EntryData::toString) + .toList()); + } + + + private static Stream flatten(EntryData entry) { + + return Stream.concat(Stream.of(entry), + entry.getChildrenList() + .stream() + .flatMap(DocumentStructureWrapper::flatten)); + } + +} diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentTextData.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentTextData.java index ac26445..3b13eb3 100644 --- a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentTextData.java +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentTextData.java @@ -10,6 +10,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.FieldDefaults; +@Deprecated @Data @Builder @NoArgsConstructor diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentTextDataProto.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentTextDataProto.java new file mode 100644 index 0000000..0f36219 --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/DocumentTextDataProto.java @@ -0,0 +1,2424 @@ +package com.knecon.fforesight.service.layoutparser.internal.api.data.redaction; + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: DocumentTextData.proto +// Protobuf Java Version: 4.27.1 +@SuppressWarnings("all") +public final class DocumentTextDataProto { + + private DocumentTextDataProto() {} + + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", DocumentTextDataProto.class.getName()); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) { + + } + + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + + public interface AllDocumentTextDataOrBuilder extends + // @@protoc_insertion_point(interface_extends:AllDocumentTextData) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + java.util.List getDocumentTextDataList(); + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + DocumentTextData getDocumentTextData(int index); + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + int getDocumentTextDataCount(); + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + java.util.List getDocumentTextDataOrBuilderList(); + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + DocumentTextDataOrBuilder getDocumentTextDataOrBuilder(int index); + + } + + /** + * Protobuf type {@code AllDocumentTextData} + */ + public static final class AllDocumentTextData extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:AllDocumentTextData) + AllDocumentTextDataOrBuilder { + + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", AllDocumentTextData.class.getName()); + } + + // Use AllDocumentTextData.newBuilder() to construct. + private AllDocumentTextData(com.google.protobuf.GeneratedMessage.Builder builder) { + + super(builder); + } + + + private AllDocumentTextData() { + + documentTextData_ = java.util.Collections.emptyList(); + } + + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentTextDataProto.internal_static_AllDocumentTextData_descriptor; + } + + + @Override + protected FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentTextDataProto.internal_static_AllDocumentTextData_fieldAccessorTable.ensureFieldAccessorsInitialized(AllDocumentTextData.class, Builder.class); + } + + + public static final int DOCUMENTTEXTDATA_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private java.util.List documentTextData_; + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + @Override + public java.util.List getDocumentTextDataList() { + + return documentTextData_; + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + @Override + public java.util.List getDocumentTextDataOrBuilderList() { + + return documentTextData_; + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + @Override + public int getDocumentTextDataCount() { + + return documentTextData_.size(); + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + @Override + public DocumentTextData getDocumentTextData(int index) { + + return documentTextData_.get(index); + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + @Override + public DocumentTextDataOrBuilder getDocumentTextDataOrBuilder(int index) { + + return documentTextData_.get(index); + } + + + private byte memoizedIsInitialized = -1; + + + @Override + public final boolean isInitialized() { + + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) { + return true; + } + if (isInitialized == 0) { + return false; + } + + memoizedIsInitialized = 1; + return true; + } + + + @Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + + for (int i = 0; i < documentTextData_.size(); i++) { + output.writeMessage(1, documentTextData_.get(i)); + } + getUnknownFields().writeTo(output); + } + + + @Override + public int getSerializedSize() { + + int size = memoizedSize; + if (size != -1) { + return size; + } + + size = 0; + for (int i = 0; i < documentTextData_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, documentTextData_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + + @Override + public boolean equals(final Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof AllDocumentTextData)) { + return super.equals(obj); + } + AllDocumentTextData other = (AllDocumentTextData) obj; + + if (!getDocumentTextDataList().equals(other.getDocumentTextDataList())) { + return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) { + return false; + } + return true; + } + + + @Override + public int hashCode() { + + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getDocumentTextDataCount() > 0) { + hash = (37 * hash) + DOCUMENTTEXTDATA_FIELD_NUMBER; + hash = (53 * hash) + getDocumentTextDataList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + + public static AllDocumentTextData parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static AllDocumentTextData parseFrom(java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static AllDocumentTextData parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static AllDocumentTextData parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static AllDocumentTextData parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static AllDocumentTextData parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static AllDocumentTextData parseFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static AllDocumentTextData parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + public static AllDocumentTextData parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + + public static AllDocumentTextData parseDelimitedFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + + public static AllDocumentTextData parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static AllDocumentTextData parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + @Override + public Builder newBuilderForType() {return newBuilder();} + + + public static Builder newBuilder() { + + return DEFAULT_INSTANCE.toBuilder(); + } + + + public static Builder newBuilder(AllDocumentTextData prototype) { + + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + + @Override + public Builder toBuilder() { + + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + + @Override + protected Builder newBuilderForType(BuilderParent parent) { + + Builder builder = new Builder(parent); + return builder; + } + + + /** + * Protobuf type {@code AllDocumentTextData} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:AllDocumentTextData) + AllDocumentTextDataOrBuilder { + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentTextDataProto.internal_static_AllDocumentTextData_descriptor; + } + + + @Override + protected FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentTextDataProto.internal_static_AllDocumentTextData_fieldAccessorTable.ensureFieldAccessorsInitialized(AllDocumentTextData.class, Builder.class); + } + + + // Construct using DocumentTextDataOuterClass.AllDocumentTextData.newBuilder() + private Builder() { + + } + + + private Builder(BuilderParent parent) { + + super(parent); + + } + + + @Override + public Builder clear() { + + super.clear(); + bitField0_ = 0; + if (documentTextDataBuilder_ == null) { + documentTextData_ = java.util.Collections.emptyList(); + } else { + documentTextData_ = null; + documentTextDataBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + + @Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + + return DocumentTextDataProto.internal_static_AllDocumentTextData_descriptor; + } + + + @Override + public AllDocumentTextData getDefaultInstanceForType() { + + return AllDocumentTextData.getDefaultInstance(); + } + + + @Override + public AllDocumentTextData build() { + + AllDocumentTextData result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + + @Override + public AllDocumentTextData buildPartial() { + + AllDocumentTextData result = new AllDocumentTextData(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + + private void buildPartialRepeatedFields(AllDocumentTextData result) { + + if (documentTextDataBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + documentTextData_ = java.util.Collections.unmodifiableList(documentTextData_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.documentTextData_ = documentTextData_; + } else { + result.documentTextData_ = documentTextDataBuilder_.build(); + } + } + + + private void buildPartial0(AllDocumentTextData result) { + + int from_bitField0_ = bitField0_; + } + + + @Override + public Builder mergeFrom(com.google.protobuf.Message other) { + + if (other instanceof AllDocumentTextData) { + return mergeFrom((AllDocumentTextData) other); + } else { + super.mergeFrom(other); + return this; + } + } + + + public Builder mergeFrom(AllDocumentTextData other) { + + if (other == AllDocumentTextData.getDefaultInstance()) { + return this; + } + if (documentTextDataBuilder_ == null) { + if (!other.documentTextData_.isEmpty()) { + if (documentTextData_.isEmpty()) { + documentTextData_ = other.documentTextData_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureDocumentTextDataIsMutable(); + documentTextData_.addAll(other.documentTextData_); + } + onChanged(); + } + } else { + if (!other.documentTextData_.isEmpty()) { + if (documentTextDataBuilder_.isEmpty()) { + documentTextDataBuilder_.dispose(); + documentTextDataBuilder_ = null; + documentTextData_ = other.documentTextData_; + bitField0_ = (bitField0_ & ~0x00000001); + documentTextDataBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getDocumentTextDataFieldBuilder() : null; + } else { + documentTextDataBuilder_.addAllMessages(other.documentTextData_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + + @Override + public final boolean isInitialized() { + + return true; + } + + + @Override + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + if (extensionRegistry == null) { + throw new NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + DocumentTextData m = input.readMessage(DocumentTextData.parser(), extensionRegistry); + if (documentTextDataBuilder_ == null) { + ensureDocumentTextDataIsMutable(); + documentTextData_.add(m); + } else { + documentTextDataBuilder_.addMessage(m); + } + break; + } // case 10 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + + private int bitField0_; + + private java.util.List documentTextData_ = java.util.Collections.emptyList(); + + + private void ensureDocumentTextDataIsMutable() { + + if (!((bitField0_ & 0x00000001) != 0)) { + documentTextData_ = new java.util.ArrayList(documentTextData_); + bitField0_ |= 0x00000001; + } + } + + + private com.google.protobuf.RepeatedFieldBuilder documentTextDataBuilder_; + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public java.util.List getDocumentTextDataList() { + + if (documentTextDataBuilder_ == null) { + return java.util.Collections.unmodifiableList(documentTextData_); + } else { + return documentTextDataBuilder_.getMessageList(); + } + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public int getDocumentTextDataCount() { + + if (documentTextDataBuilder_ == null) { + return documentTextData_.size(); + } else { + return documentTextDataBuilder_.getCount(); + } + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public DocumentTextData getDocumentTextData(int index) { + + if (documentTextDataBuilder_ == null) { + return documentTextData_.get(index); + } else { + return documentTextDataBuilder_.getMessage(index); + } + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public Builder setDocumentTextData(int index, DocumentTextData value) { + + if (documentTextDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentTextDataIsMutable(); + documentTextData_.set(index, value); + onChanged(); + } else { + documentTextDataBuilder_.setMessage(index, value); + } + return this; + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public Builder setDocumentTextData(int index, DocumentTextData.Builder builderForValue) { + + if (documentTextDataBuilder_ == null) { + ensureDocumentTextDataIsMutable(); + documentTextData_.set(index, builderForValue.build()); + onChanged(); + } else { + documentTextDataBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public Builder addDocumentTextData(DocumentTextData value) { + + if (documentTextDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentTextDataIsMutable(); + documentTextData_.add(value); + onChanged(); + } else { + documentTextDataBuilder_.addMessage(value); + } + return this; + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public Builder addDocumentTextData(int index, DocumentTextData value) { + + if (documentTextDataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentTextDataIsMutable(); + documentTextData_.add(index, value); + onChanged(); + } else { + documentTextDataBuilder_.addMessage(index, value); + } + return this; + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public Builder addDocumentTextData(DocumentTextData.Builder builderForValue) { + + if (documentTextDataBuilder_ == null) { + ensureDocumentTextDataIsMutable(); + documentTextData_.add(builderForValue.build()); + onChanged(); + } else { + documentTextDataBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public Builder addDocumentTextData(int index, DocumentTextData.Builder builderForValue) { + + if (documentTextDataBuilder_ == null) { + ensureDocumentTextDataIsMutable(); + documentTextData_.add(index, builderForValue.build()); + onChanged(); + } else { + documentTextDataBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public Builder addAllDocumentTextData(Iterable values) { + + if (documentTextDataBuilder_ == null) { + ensureDocumentTextDataIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, documentTextData_); + onChanged(); + } else { + documentTextDataBuilder_.addAllMessages(values); + } + return this; + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public Builder clearDocumentTextData() { + + if (documentTextDataBuilder_ == null) { + documentTextData_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + documentTextDataBuilder_.clear(); + } + return this; + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public Builder removeDocumentTextData(int index) { + + if (documentTextDataBuilder_ == null) { + ensureDocumentTextDataIsMutable(); + documentTextData_.remove(index); + onChanged(); + } else { + documentTextDataBuilder_.remove(index); + } + return this; + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public DocumentTextData.Builder getDocumentTextDataBuilder(int index) { + + return getDocumentTextDataFieldBuilder().getBuilder(index); + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public DocumentTextDataOrBuilder getDocumentTextDataOrBuilder(int index) { + + if (documentTextDataBuilder_ == null) { + return documentTextData_.get(index); + } else { + return documentTextDataBuilder_.getMessageOrBuilder(index); + } + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public java.util.List getDocumentTextDataOrBuilderList() { + + if (documentTextDataBuilder_ != null) { + return documentTextDataBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(documentTextData_); + } + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public DocumentTextData.Builder addDocumentTextDataBuilder() { + + return getDocumentTextDataFieldBuilder().addBuilder(DocumentTextData.getDefaultInstance()); + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public DocumentTextData.Builder addDocumentTextDataBuilder(int index) { + + return getDocumentTextDataFieldBuilder().addBuilder(index, DocumentTextData.getDefaultInstance()); + } + + + /** + * repeated .DocumentTextData documentTextData = 1; + */ + public java.util.List getDocumentTextDataBuilderList() { + + return getDocumentTextDataFieldBuilder().getBuilderList(); + } + + + private com.google.protobuf.RepeatedFieldBuilder getDocumentTextDataFieldBuilder() { + + if (documentTextDataBuilder_ == null) { + documentTextDataBuilder_ = new com.google.protobuf.RepeatedFieldBuilder(documentTextData_, + ((bitField0_ + & 0x00000001) + != 0), + getParentForChildren(), + isClean()); + documentTextData_ = null; + } + return documentTextDataBuilder_; + } + + // @@protoc_insertion_point(builder_scope:AllDocumentTextData) + } + + // @@protoc_insertion_point(class_scope:AllDocumentTextData) + private static final AllDocumentTextData DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new AllDocumentTextData(); + } + + public static AllDocumentTextData getDefaultInstance() { + + return DEFAULT_INSTANCE; + } + + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + @Override + public AllDocumentTextData parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + + public static com.google.protobuf.Parser parser() { + + return PARSER; + } + + + @Override + public com.google.protobuf.Parser getParserForType() { + + return PARSER; + } + + + @Override + public AllDocumentTextData getDefaultInstanceForType() { + + return DEFAULT_INSTANCE; + } + + } + + public interface DocumentTextDataOrBuilder extends + // @@protoc_insertion_point(interface_extends:DocumentTextData) + com.google.protobuf.MessageOrBuilder { + + /** + *
+         * Identifier of the text block.
+         * 
+ * + * int64 id = 1; + * + * @return The id. + */ + long getId(); + + + /** + *
+         * The page the text block occurs on.
+         * 
+ * + * int64 page = 2; + * + * @return The page. + */ + long getPage(); + + + /** + *
+         * The text of the text block.
+         * 
+ * + * string searchText = 3; + * + * @return The searchText. + */ + String getSearchText(); + + + /** + *
+         * The text of the text block.
+         * 
+ * + * string searchText = 3; + * + * @return The bytes for searchText. + */ + com.google.protobuf.ByteString getSearchTextBytes(); + + + /** + *
+         * Each text block is assigned a number on a page, starting from 0.
+         * 
+ * + * int32 numberOnPage = 4; + * + * @return The numberOnPage. + */ + int getNumberOnPage(); + + + /** + *
+         * The text blocks are ordered, this number represents the start of the text block as a string offset.
+         * 
+ * + * int32 start = 5; + * + * @return The start. + */ + int getStart(); + + + /** + *
+         * The text blocks are ordered, this number represents the end of the text block as a string offset.
+         * 
+ * + * int32 end = 6; + * + * @return The end. + */ + int getEnd(); + + + /** + *
+         * The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak.
+         * 
+ * + * repeated int32 lineBreaks = 7; + * + * @return A list containing the lineBreaks. + */ + java.util.List getLineBreaksList(); + + + /** + *
+         * The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak.
+         * 
+ * + * repeated int32 lineBreaks = 7; + * + * @return The count of lineBreaks. + */ + int getLineBreaksCount(); + + + /** + *
+         * The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak.
+         * 
+ * + * repeated int32 lineBreaks = 7; + * + * @param index The index of the element to return. + * @return The lineBreaks at the given index. + */ + int getLineBreaks(int index); + + } + + /** + * Protobuf type {@code DocumentTextData} + */ + public static final class DocumentTextData extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:DocumentTextData) + DocumentTextDataOrBuilder { + + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", DocumentTextData.class.getName()); + } + + // Use DocumentTextData.newBuilder() to construct. + private DocumentTextData(com.google.protobuf.GeneratedMessage.Builder builder) { + + super(builder); + } + + + private DocumentTextData() { + + searchText_ = ""; + lineBreaks_ = emptyIntList(); + } + + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentTextDataProto.internal_static_DocumentTextData_descriptor; + } + + + @Override + protected FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentTextDataProto.internal_static_DocumentTextData_fieldAccessorTable.ensureFieldAccessorsInitialized(DocumentTextData.class, Builder.class); + } + + + public static final int ID_FIELD_NUMBER = 1; + private long id_ = 0L; + + + /** + *
+         * Identifier of the text block.
+         * 
+ * + * int64 id = 1; + * + * @return The id. + */ + @Override + public long getId() { + + return id_; + } + + + public static final int PAGE_FIELD_NUMBER = 2; + private long page_ = 0L; + + + /** + *
+         * The page the text block occurs on.
+         * 
+ * + * int64 page = 2; + * + * @return The page. + */ + @Override + public long getPage() { + + return page_; + } + + + public static final int SEARCHTEXT_FIELD_NUMBER = 3; + @SuppressWarnings("serial") + private volatile Object searchText_ = ""; + + + /** + *
+         * The text of the text block.
+         * 
+ * + * string searchText = 3; + * + * @return The searchText. + */ + @Override + public String getSearchText() { + + Object ref = searchText_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + searchText_ = s; + return s; + } + } + + + /** + *
+         * The text of the text block.
+         * 
+ * + * string searchText = 3; + * + * @return The bytes for searchText. + */ + @Override + public com.google.protobuf.ByteString getSearchTextBytes() { + + Object ref = searchText_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); + searchText_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + + public static final int NUMBERONPAGE_FIELD_NUMBER = 4; + private int numberOnPage_ = 0; + + + /** + *
+         * Each text block is assigned a number on a page, starting from 0.
+         * 
+ * + * int32 numberOnPage = 4; + * + * @return The numberOnPage. + */ + @Override + public int getNumberOnPage() { + + return numberOnPage_; + } + + + public static final int START_FIELD_NUMBER = 5; + private int start_ = 0; + + + /** + *
+         * The text blocks are ordered, this number represents the start of the text block as a string offset.
+         * 
+ * + * int32 start = 5; + * + * @return The start. + */ + @Override + public int getStart() { + + return start_; + } + + + public static final int END_FIELD_NUMBER = 6; + private int end_ = 0; + + + /** + *
+         * The text blocks are ordered, this number represents the end of the text block as a string offset.
+         * 
+ * + * int32 end = 6; + * + * @return The end. + */ + @Override + public int getEnd() { + + return end_; + } + + + public static final int LINEBREAKS_FIELD_NUMBER = 7; + @SuppressWarnings("serial") + private com.google.protobuf.Internal.IntList lineBreaks_ = emptyIntList(); + + + /** + *
+         * The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak.
+         * 
+ * + * repeated int32 lineBreaks = 7; + * + * @return A list containing the lineBreaks. + */ + @Override + public java.util.List getLineBreaksList() { + + return lineBreaks_; + } + + + /** + *
+         * The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak.
+         * 
+ * + * repeated int32 lineBreaks = 7; + * + * @return The count of lineBreaks. + */ + public int getLineBreaksCount() { + + return lineBreaks_.size(); + } + + + /** + *
+         * The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak.
+         * 
+ * + * repeated int32 lineBreaks = 7; + * + * @param index The index of the element to return. + * @return The lineBreaks at the given index. + */ + public int getLineBreaks(int index) { + + return lineBreaks_.getInt(index); + } + + + private int lineBreaksMemoizedSerializedSize = -1; + + private byte memoizedIsInitialized = -1; + + + @Override + public final boolean isInitialized() { + + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) { + return true; + } + if (isInitialized == 0) { + return false; + } + + memoizedIsInitialized = 1; + return true; + } + + + @Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + + getSerializedSize(); + if (id_ != 0L) { + output.writeInt64(1, id_); + } + if (page_ != 0L) { + output.writeInt64(2, page_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(searchText_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, searchText_); + } + if (numberOnPage_ != 0) { + output.writeInt32(4, numberOnPage_); + } + if (start_ != 0) { + output.writeInt32(5, start_); + } + if (end_ != 0) { + output.writeInt32(6, end_); + } + if (getLineBreaksList().size() > 0) { + output.writeUInt32NoTag(58); + output.writeUInt32NoTag(lineBreaksMemoizedSerializedSize); + } + for (int i = 0; i < lineBreaks_.size(); i++) { + output.writeInt32NoTag(lineBreaks_.getInt(i)); + } + getUnknownFields().writeTo(output); + } + + + @Override + public int getSerializedSize() { + + int size = memoizedSize; + if (size != -1) { + return size; + } + + size = 0; + if (id_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, id_); + } + if (page_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(2, page_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(searchText_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, searchText_); + } + if (numberOnPage_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(4, numberOnPage_); + } + if (start_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(5, start_); + } + if (end_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(6, end_); + } + { + int dataSize = 0; + for (int i = 0; i < lineBreaks_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(lineBreaks_.getInt(i)); + } + size += dataSize; + if (!getLineBreaksList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize); + } + lineBreaksMemoizedSerializedSize = dataSize; + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + + @Override + public boolean equals(final Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof DocumentTextData)) { + return super.equals(obj); + } + DocumentTextData other = (DocumentTextData) obj; + + if (getId() != other.getId()) { + return false; + } + if (getPage() != other.getPage()) { + return false; + } + if (!getSearchText().equals(other.getSearchText())) { + return false; + } + if (getNumberOnPage() != other.getNumberOnPage()) { + return false; + } + if (getStart() != other.getStart()) { + return false; + } + if (getEnd() != other.getEnd()) { + return false; + } + if (!getLineBreaksList().equals(other.getLineBreaksList())) { + return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) { + return false; + } + return true; + } + + + @Override + public int hashCode() { + + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getId()); + hash = (37 * hash) + PAGE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getPage()); + hash = (37 * hash) + SEARCHTEXT_FIELD_NUMBER; + hash = (53 * hash) + getSearchText().hashCode(); + hash = (37 * hash) + NUMBERONPAGE_FIELD_NUMBER; + hash = (53 * hash) + getNumberOnPage(); + hash = (37 * hash) + START_FIELD_NUMBER; + hash = (53 * hash) + getStart(); + hash = (37 * hash) + END_FIELD_NUMBER; + hash = (53 * hash) + getEnd(); + if (getLineBreaksCount() > 0) { + hash = (37 * hash) + LINEBREAKS_FIELD_NUMBER; + hash = (53 * hash) + getLineBreaksList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + + public static DocumentTextData parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentTextData parseFrom(java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentTextData parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentTextData parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentTextData parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static DocumentTextData parseFrom(byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static DocumentTextData parseFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static DocumentTextData parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + public static DocumentTextData parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + + public static DocumentTextData parseDelimitedFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + + public static DocumentTextData parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static DocumentTextData parseFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + @Override + public Builder newBuilderForType() {return newBuilder();} + + + public static Builder newBuilder() { + + return DEFAULT_INSTANCE.toBuilder(); + } + + + public static Builder newBuilder(DocumentTextData prototype) { + + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + + @Override + public Builder toBuilder() { + + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + + @Override + protected Builder newBuilderForType(BuilderParent parent) { + + Builder builder = new Builder(parent); + return builder; + } + + + /** + * Protobuf type {@code DocumentTextData} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:DocumentTextData) + DocumentTextDataOrBuilder { + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return DocumentTextDataProto.internal_static_DocumentTextData_descriptor; + } + + + @Override + protected FieldAccessorTable internalGetFieldAccessorTable() { + + return DocumentTextDataProto.internal_static_DocumentTextData_fieldAccessorTable.ensureFieldAccessorsInitialized(DocumentTextData.class, Builder.class); + } + + + // Construct using DocumentTextDataOuterClass.DocumentTextData.newBuilder() + private Builder() { + + } + + + private Builder(BuilderParent parent) { + + super(parent); + + } + + + @Override + public Builder clear() { + + super.clear(); + bitField0_ = 0; + id_ = 0L; + page_ = 0L; + searchText_ = ""; + numberOnPage_ = 0; + start_ = 0; + end_ = 0; + lineBreaks_ = emptyIntList(); + return this; + } + + + @Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + + return DocumentTextDataProto.internal_static_DocumentTextData_descriptor; + } + + + @Override + public DocumentTextData getDefaultInstanceForType() { + + return DocumentTextData.getDefaultInstance(); + } + + + @Override + public DocumentTextData build() { + + DocumentTextData result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + + @Override + public DocumentTextData buildPartial() { + + DocumentTextData result = new DocumentTextData(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + + private void buildPartial0(DocumentTextData result) { + + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.id_ = id_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.page_ = page_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.searchText_ = searchText_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.numberOnPage_ = numberOnPage_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.start_ = start_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.end_ = end_; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + lineBreaks_.makeImmutable(); + result.lineBreaks_ = lineBreaks_; + } + } + + + @Override + public Builder mergeFrom(com.google.protobuf.Message other) { + + if (other instanceof DocumentTextData) { + return mergeFrom((DocumentTextData) other); + } else { + super.mergeFrom(other); + return this; + } + } + + + public Builder mergeFrom(DocumentTextData other) { + + if (other == DocumentTextData.getDefaultInstance()) { + return this; + } + if (other.getId() != 0L) { + setId(other.getId()); + } + if (other.getPage() != 0L) { + setPage(other.getPage()); + } + if (!other.getSearchText().isEmpty()) { + searchText_ = other.searchText_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (other.getNumberOnPage() != 0) { + setNumberOnPage(other.getNumberOnPage()); + } + if (other.getStart() != 0) { + setStart(other.getStart()); + } + if (other.getEnd() != 0) { + setEnd(other.getEnd()); + } + if (!other.lineBreaks_.isEmpty()) { + if (lineBreaks_.isEmpty()) { + lineBreaks_ = other.lineBreaks_; + lineBreaks_.makeImmutable(); + bitField0_ |= 0x00000040; + } else { + ensureLineBreaksIsMutable(); + lineBreaks_.addAll(other.lineBreaks_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + + @Override + public final boolean isInitialized() { + + return true; + } + + + @Override + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + if (extensionRegistry == null) { + throw new NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + id_ = input.readInt64(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 16: { + page_ = input.readInt64(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 26: { + searchText_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 32: { + numberOnPage_ = input.readInt32(); + bitField0_ |= 0x00000008; + break; + } // case 32 + case 40: { + start_ = input.readInt32(); + bitField0_ |= 0x00000010; + break; + } // case 40 + case 48: { + end_ = input.readInt32(); + bitField0_ |= 0x00000020; + break; + } // case 48 + case 56: { + int v = input.readInt32(); + ensureLineBreaksIsMutable(); + lineBreaks_.addInt(v); + break; + } // case 56 + case 58: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + ensureLineBreaksIsMutable(); + while (input.getBytesUntilLimit() > 0) { + lineBreaks_.addInt(input.readInt32()); + } + input.popLimit(limit); + break; + } // case 58 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + + private int bitField0_; + + private long id_; + + + /** + *
+             * Identifier of the text block.
+             * 
+ * + * int64 id = 1; + * + * @return The id. + */ + @Override + public long getId() { + + return id_; + } + + + /** + *
+             * Identifier of the text block.
+             * 
+ * + * int64 id = 1; + * + * @param value The id to set. + * @return This builder for chaining. + */ + public Builder setId(long value) { + + id_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + + /** + *
+             * Identifier of the text block.
+             * 
+ * + * int64 id = 1; + * + * @return This builder for chaining. + */ + public Builder clearId() { + + bitField0_ = (bitField0_ & ~0x00000001); + id_ = 0L; + onChanged(); + return this; + } + + + private long page_; + + + /** + *
+             * The page the text block occurs on.
+             * 
+ * + * int64 page = 2; + * + * @return The page. + */ + @Override + public long getPage() { + + return page_; + } + + + /** + *
+             * The page the text block occurs on.
+             * 
+ * + * int64 page = 2; + * + * @param value The page to set. + * @return This builder for chaining. + */ + public Builder setPage(long value) { + + page_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + + /** + *
+             * The page the text block occurs on.
+             * 
+ * + * int64 page = 2; + * + * @return This builder for chaining. + */ + public Builder clearPage() { + + bitField0_ = (bitField0_ & ~0x00000002); + page_ = 0L; + onChanged(); + return this; + } + + + private Object searchText_ = ""; + + + /** + *
+             * The text of the text block.
+             * 
+ * + * string searchText = 3; + * + * @return The searchText. + */ + public String getSearchText() { + + Object ref = searchText_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + searchText_ = s; + return s; + } else { + return (String) ref; + } + } + + + /** + *
+             * The text of the text block.
+             * 
+ * + * string searchText = 3; + * + * @return The bytes for searchText. + */ + public com.google.protobuf.ByteString getSearchTextBytes() { + + Object ref = searchText_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((String) ref); + searchText_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + + /** + *
+             * The text of the text block.
+             * 
+ * + * string searchText = 3; + * + * @param value The searchText to set. + * @return This builder for chaining. + */ + public Builder setSearchText(String value) { + + if (value == null) { + throw new NullPointerException(); + } + searchText_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + + /** + *
+             * The text of the text block.
+             * 
+ * + * string searchText = 3; + * + * @return This builder for chaining. + */ + public Builder clearSearchText() { + + searchText_ = getDefaultInstance().getSearchText(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + + /** + *
+             * The text of the text block.
+             * 
+ * + * string searchText = 3; + * + * @param value The bytes for searchText to set. + * @return This builder for chaining. + */ + public Builder setSearchTextBytes(com.google.protobuf.ByteString value) { + + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + searchText_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + + private int numberOnPage_; + + + /** + *
+             * Each text block is assigned a number on a page, starting from 0.
+             * 
+ * + * int32 numberOnPage = 4; + * + * @return The numberOnPage. + */ + @Override + public int getNumberOnPage() { + + return numberOnPage_; + } + + + /** + *
+             * Each text block is assigned a number on a page, starting from 0.
+             * 
+ * + * int32 numberOnPage = 4; + * + * @param value The numberOnPage to set. + * @return This builder for chaining. + */ + public Builder setNumberOnPage(int value) { + + numberOnPage_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + + /** + *
+             * Each text block is assigned a number on a page, starting from 0.
+             * 
+ * + * int32 numberOnPage = 4; + * + * @return This builder for chaining. + */ + public Builder clearNumberOnPage() { + + bitField0_ = (bitField0_ & ~0x00000008); + numberOnPage_ = 0; + onChanged(); + return this; + } + + + private int start_; + + + /** + *
+             * The text blocks are ordered, this number represents the start of the text block as a string offset.
+             * 
+ * + * int32 start = 5; + * + * @return The start. + */ + @Override + public int getStart() { + + return start_; + } + + + /** + *
+             * The text blocks are ordered, this number represents the start of the text block as a string offset.
+             * 
+ * + * int32 start = 5; + * + * @param value The start to set. + * @return This builder for chaining. + */ + public Builder setStart(int value) { + + start_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + + /** + *
+             * The text blocks are ordered, this number represents the start of the text block as a string offset.
+             * 
+ * + * int32 start = 5; + * + * @return This builder for chaining. + */ + public Builder clearStart() { + + bitField0_ = (bitField0_ & ~0x00000010); + start_ = 0; + onChanged(); + return this; + } + + + private int end_; + + + /** + *
+             * The text blocks are ordered, this number represents the end of the text block as a string offset.
+             * 
+ * + * int32 end = 6; + * + * @return The end. + */ + @Override + public int getEnd() { + + return end_; + } + + + /** + *
+             * The text blocks are ordered, this number represents the end of the text block as a string offset.
+             * 
+ * + * int32 end = 6; + * + * @param value The end to set. + * @return This builder for chaining. + */ + public Builder setEnd(int value) { + + end_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + + /** + *
+             * The text blocks are ordered, this number represents the end of the text block as a string offset.
+             * 
+ * + * int32 end = 6; + * + * @return This builder for chaining. + */ + public Builder clearEnd() { + + bitField0_ = (bitField0_ & ~0x00000020); + end_ = 0; + onChanged(); + return this; + } + + + private com.google.protobuf.Internal.IntList lineBreaks_ = emptyIntList(); + + + private void ensureLineBreaksIsMutable() { + + if (!lineBreaks_.isModifiable()) { + lineBreaks_ = makeMutableCopy(lineBreaks_); + } + bitField0_ |= 0x00000040; + } + + + /** + *
+             * The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak.
+             * 
+ * + * repeated int32 lineBreaks = 7; + * + * @return A list containing the lineBreaks. + */ + public java.util.List getLineBreaksList() { + + lineBreaks_.makeImmutable(); + return lineBreaks_; + } + + + /** + *
+             * The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak.
+             * 
+ * + * repeated int32 lineBreaks = 7; + * + * @return The count of lineBreaks. + */ + public int getLineBreaksCount() { + + return lineBreaks_.size(); + } + + + /** + *
+             * The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak.
+             * 
+ * + * repeated int32 lineBreaks = 7; + * + * @param index The index of the element to return. + * @return The lineBreaks at the given index. + */ + public int getLineBreaks(int index) { + + return lineBreaks_.getInt(index); + } + + + /** + *
+             * The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak.
+             * 
+ * + * repeated int32 lineBreaks = 7; + * + * @param index The index to set the value at. + * @param value The lineBreaks to set. + * @return This builder for chaining. + */ + public Builder setLineBreaks(int index, int value) { + + ensureLineBreaksIsMutable(); + lineBreaks_.setInt(index, value); + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + + /** + *
+             * The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak.
+             * 
+ * + * repeated int32 lineBreaks = 7; + * + * @param value The lineBreaks to add. + * @return This builder for chaining. + */ + public Builder addLineBreaks(int value) { + + ensureLineBreaksIsMutable(); + lineBreaks_.addInt(value); + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + + /** + *
+             * The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak.
+             * 
+ * + * repeated int32 lineBreaks = 7; + * + * @param values The lineBreaks to add. + * @return This builder for chaining. + */ + public Builder addAllLineBreaks(Iterable values) { + + ensureLineBreaksIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, lineBreaks_); + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + + /** + *
+             * The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak.
+             * 
+ * + * repeated int32 lineBreaks = 7; + * + * @return This builder for chaining. + */ + public Builder clearLineBreaks() { + + lineBreaks_ = emptyIntList(); + bitField0_ = (bitField0_ & ~0x00000040); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:DocumentTextData) + } + + // @@protoc_insertion_point(class_scope:DocumentTextData) + private static final DocumentTextData DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new DocumentTextData(); + } + + public static DocumentTextData getDefaultInstance() { + + return DEFAULT_INSTANCE; + } + + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + @Override + public DocumentTextData parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + + public static com.google.protobuf.Parser parser() { + + return PARSER; + } + + + @Override + public com.google.protobuf.Parser getParserForType() { + + return PARSER; + } + + + @Override + public DocumentTextData getDefaultInstanceForType() { + + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor internal_static_AllDocumentTextData_descriptor; + private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_AllDocumentTextData_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_DocumentTextData_descriptor; + private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_DocumentTextData_fieldAccessorTable; + + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + + return descriptor; + } + + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + String[] descriptorData = {"\n\026DocumentTextData.proto\"B\n\023AllDocumentT" + + "extData\022+\n\020documentTextData\030\001 \003(\0132\021.Docu" + + "mentTextData\"\206\001\n\020DocumentTextData\022\n\n\002id\030" + + "\001 \001(\003\022\014\n\004page\030\002 \001(\003\022\022\n\nsearchText\030\003 \001(\t\022" + + "\024\n\014numberOnPage\030\004 \001(\005\022\r\n\005start\030\005 \001(\005\022\013\n\003" + + "end\030\006 \001(\005\022\022\n\nlineBreaks\030\007 \003(\005b\006proto3"}; + descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[]{}); + internal_static_AllDocumentTextData_descriptor = getDescriptor().getMessageTypes() + .get(0); + internal_static_AllDocumentTextData_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_AllDocumentTextData_descriptor, + new String[]{"DocumentTextData",}); + internal_static_DocumentTextData_descriptor = getDescriptor().getMessageTypes() + .get(1); + internal_static_DocumentTextData_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_DocumentTextData_descriptor, + new String[]{"Id", "Page", "SearchText", "NumberOnPage", "Start", "End", "LineBreaks",}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/EntryDataProto.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/EntryDataProto.java new file mode 100644 index 0000000..f7fabe2 --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/EntryDataProto.java @@ -0,0 +1,2977 @@ +package com.knecon.fforesight.service.layoutparser.internal.api.data.redaction; + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: EntryData.proto +// Protobuf Java Version: 4.27.1 +@SuppressWarnings("all") +public final class EntryDataProto { + + private EntryDataProto() {} + + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", EntryDataProto.class.getName()); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) { + + } + + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + + public interface EntryDataOrBuilder extends + // @@protoc_insertion_point(interface_extends:EntryData) + com.google.protobuf.MessageOrBuilder { + + /** + *
+         * Type of the semantic node.
+         * 
+ * + * .NodeType type = 1; + * + * @return The enum numeric value on the wire for type. + */ + int getTypeValue(); + + + /** + *
+         * Type of the semantic node.
+         * 
+ * + * .NodeType type = 1; + * + * @return The type. + */ + NodeTypeProto.NodeType getType(); + + + /** + *
+         * Specifies the position in the parsed tree structure.
+         * 
+ * + * repeated int32 treeId = 2; + * + * @return A list containing the treeId. + */ + java.util.List getTreeIdList(); + + + /** + *
+         * Specifies the position in the parsed tree structure.
+         * 
+ * + * repeated int32 treeId = 2; + * + * @return The count of treeId. + */ + int getTreeIdCount(); + + + /** + *
+         * Specifies the position in the parsed tree structure.
+         * 
+ * + * repeated int32 treeId = 2; + * + * @param index The index of the element to return. + * @return The treeId at the given index. + */ + int getTreeId(int index); + + + /** + *
+         * Specifies the text block IDs associated with this semantic node.
+         * 
+ * + * repeated int64 atomicBlockIds = 3; + * + * @return A list containing the atomicBlockIds. + */ + java.util.List getAtomicBlockIdsList(); + + + /** + *
+         * Specifies the text block IDs associated with this semantic node.
+         * 
+ * + * repeated int64 atomicBlockIds = 3; + * + * @return The count of atomicBlockIds. + */ + int getAtomicBlockIdsCount(); + + + /** + *
+         * Specifies the text block IDs associated with this semantic node.
+         * 
+ * + * repeated int64 atomicBlockIds = 3; + * + * @param index The index of the element to return. + * @return The atomicBlockIds at the given index. + */ + long getAtomicBlockIds(int index); + + + /** + *
+         * Specifies the pages this semantic node appears on.
+         * 
+ * + * repeated int64 pageNumbers = 4; + * + * @return A list containing the pageNumbers. + */ + java.util.List getPageNumbersList(); + + + /** + *
+         * Specifies the pages this semantic node appears on.
+         * 
+ * + * repeated int64 pageNumbers = 4; + * + * @return The count of pageNumbers. + */ + int getPageNumbersCount(); + + + /** + *
+         * Specifies the pages this semantic node appears on.
+         * 
+ * + * repeated int64 pageNumbers = 4; + * + * @param index The index of the element to return. + * @return The pageNumbers at the given index. + */ + long getPageNumbers(int index); + + + /** + *
+         * Some semantic nodes have additional information, this information is stored in this Map.
+         * 
+ * + * map<string, string> properties = 5; + */ + int getPropertiesCount(); + + + /** + *
+         * Some semantic nodes have additional information, this information is stored in this Map.
+         * 
+ * + * map<string, string> properties = 5; + */ + boolean containsProperties(String key); + + + /** + * Use {@link #getPropertiesMap()} instead. + */ + @Deprecated + java.util.Map getProperties(); + + + /** + *
+         * Some semantic nodes have additional information, this information is stored in this Map.
+         * 
+ * + * map<string, string> properties = 5; + */ + java.util.Map getPropertiesMap(); + + + /** + *
+         * Some semantic nodes have additional information, this information is stored in this Map.
+         * 
+ * + * map<string, string> properties = 5; + */ + /* nullable */ + String getPropertiesOrDefault(String key, + /* nullable */ + String defaultValue); + + + /** + *
+         * Some semantic nodes have additional information, this information is stored in this Map.
+         * 
+ * + * map<string, string> properties = 5; + */ + String getPropertiesOrThrow(String key); + + + /** + *
+         * All child Entries of this Entry.
+         * 
+ * + * repeated .EntryData children = 6; + */ + java.util.List getChildrenList(); + + + /** + *
+         * All child Entries of this Entry.
+         * 
+ * + * repeated .EntryData children = 6; + */ + EntryData getChildren(int index); + + + /** + *
+         * All child Entries of this Entry.
+         * 
+ * + * repeated .EntryData children = 6; + */ + int getChildrenCount(); + + + /** + *
+         * All child Entries of this Entry.
+         * 
+ * + * repeated .EntryData children = 6; + */ + java.util.List getChildrenOrBuilderList(); + + + /** + *
+         * All child Entries of this Entry.
+         * 
+ * + * repeated .EntryData children = 6; + */ + EntryDataOrBuilder getChildrenOrBuilder(int index); + + + /** + *
+         * Describes the origin of the semantic node.
+         * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @return A list containing the engines. + */ + java.util.List getEnginesList(); + + + /** + *
+         * Describes the origin of the semantic node.
+         * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @return The count of engines. + */ + int getEnginesCount(); + + + /** + *
+         * Describes the origin of the semantic node.
+         * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @param index The index of the element to return. + * @return The engines at the given index. + */ + LayoutEngineProto.LayoutEngine getEngines(int index); + + + /** + *
+         * Describes the origin of the semantic node.
+         * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @return A list containing the enum numeric values on the wire for engines. + */ + java.util.List getEnginesValueList(); + + + /** + *
+         * Describes the origin of the semantic node.
+         * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @param index The index of the value to return. + * @return The enum numeric value on the wire of engines at the given index. + */ + int getEnginesValue(int index); + + } + + /** + * Protobuf type {@code EntryData} + */ + public static class EntryData extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:EntryData) + EntryDataOrBuilder { + + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", EntryData.class.getName()); + } + + // Use EntryData.newBuilder() to construct. + private EntryData(com.google.protobuf.GeneratedMessage.Builder builder) { + + super(builder); + } + + + private EntryData() { + + type_ = 0; + treeId_ = emptyIntList(); + atomicBlockIds_ = emptyLongList(); + pageNumbers_ = emptyLongList(); + children_ = java.util.Collections.emptyList(); + engines_ = java.util.Collections.emptyList(); + } + + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return EntryDataProto.internal_static_EntryData_descriptor; + } + + + @SuppressWarnings({"rawtypes"}) + @Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection(int number) { + + switch (number) { + case 5: + return internalGetProperties(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + + @Override + protected FieldAccessorTable internalGetFieldAccessorTable() { + + return EntryDataProto.internal_static_EntryData_fieldAccessorTable.ensureFieldAccessorsInitialized(EntryData.class, Builder.class); + } + + + public static final int TYPE_FIELD_NUMBER = 1; + private int type_ = 0; + + + /** + *
+         * Type of the semantic node.
+         * 
+ * + * .NodeType type = 1; + * + * @return The enum numeric value on the wire for type. + */ + @Override + public int getTypeValue() { + + return type_; + } + + + /** + *
+         * Type of the semantic node.
+         * 
+ * + * .NodeType type = 1; + * + * @return The type. + */ + @Override + public NodeTypeProto.NodeType getType() { + + NodeTypeProto.NodeType result = NodeTypeProto.NodeType.forNumber(type_); + return result == null ? NodeTypeProto.NodeType.UNRECOGNIZED : result; + } + + + public static final int TREEID_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private com.google.protobuf.Internal.IntList treeId_ = emptyIntList(); + + + /** + *
+         * Specifies the position in the parsed tree structure.
+         * 
+ * + * repeated int32 treeId = 2; + * + * @return A list containing the treeId. + */ + @Override + public java.util.List getTreeIdList() { + + return treeId_; + } + + + /** + *
+         * Specifies the position in the parsed tree structure.
+         * 
+ * + * repeated int32 treeId = 2; + * + * @return The count of treeId. + */ + public int getTreeIdCount() { + + return treeId_.size(); + } + + + /** + *
+         * Specifies the position in the parsed tree structure.
+         * 
+ * + * repeated int32 treeId = 2; + * + * @param index The index of the element to return. + * @return The treeId at the given index. + */ + public int getTreeId(int index) { + + return treeId_.getInt(index); + } + + + private int treeIdMemoizedSerializedSize = -1; + + public static final int ATOMICBLOCKIDS_FIELD_NUMBER = 3; + @SuppressWarnings("serial") + private com.google.protobuf.Internal.LongList atomicBlockIds_ = emptyLongList(); + + + /** + *
+         * Specifies the text block IDs associated with this semantic node.
+         * 
+ * + * repeated int64 atomicBlockIds = 3; + * + * @return A list containing the atomicBlockIds. + */ + @Override + public java.util.List getAtomicBlockIdsList() { + + return atomicBlockIds_; + } + + + /** + *
+         * Specifies the text block IDs associated with this semantic node.
+         * 
+ * + * repeated int64 atomicBlockIds = 3; + * + * @return The count of atomicBlockIds. + */ + public int getAtomicBlockIdsCount() { + + return atomicBlockIds_.size(); + } + + + /** + *
+         * Specifies the text block IDs associated with this semantic node.
+         * 
+ * + * repeated int64 atomicBlockIds = 3; + * + * @param index The index of the element to return. + * @return The atomicBlockIds at the given index. + */ + public long getAtomicBlockIds(int index) { + + return atomicBlockIds_.getLong(index); + } + + + private int atomicBlockIdsMemoizedSerializedSize = -1; + + public static final int PAGENUMBERS_FIELD_NUMBER = 4; + @SuppressWarnings("serial") + private com.google.protobuf.Internal.LongList pageNumbers_ = emptyLongList(); + + + /** + *
+         * Specifies the pages this semantic node appears on.
+         * 
+ * + * repeated int64 pageNumbers = 4; + * + * @return A list containing the pageNumbers. + */ + @Override + public java.util.List getPageNumbersList() { + + return pageNumbers_; + } + + + /** + *
+         * Specifies the pages this semantic node appears on.
+         * 
+ * + * repeated int64 pageNumbers = 4; + * + * @return The count of pageNumbers. + */ + public int getPageNumbersCount() { + + return pageNumbers_.size(); + } + + + /** + *
+         * Specifies the pages this semantic node appears on.
+         * 
+ * + * repeated int64 pageNumbers = 4; + * + * @param index The index of the element to return. + * @return The pageNumbers at the given index. + */ + public long getPageNumbers(int index) { + + return pageNumbers_.getLong(index); + } + + + private int pageNumbersMemoizedSerializedSize = -1; + + public static final int PROPERTIES_FIELD_NUMBER = 5; + + private static final class PropertiesDefaultEntryHolder { + + static final com.google.protobuf.MapEntry defaultEntry = com.google.protobuf.MapEntry.newDefaultInstance(EntryDataProto.internal_static_EntryData_PropertiesEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField properties_; + + + private com.google.protobuf.MapField internalGetProperties() { + + if (properties_ == null) { + return com.google.protobuf.MapField.emptyMapField(PropertiesDefaultEntryHolder.defaultEntry); + } + return properties_; + } + + + public int getPropertiesCount() { + + return internalGetProperties().getMap().size(); + } + + + /** + *
+         * Some semantic nodes have additional information, this information is stored in this Map.
+         * 
+ * + * map<string, string> properties = 5; + */ + @Override + public boolean containsProperties(String key) { + + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetProperties().getMap().containsKey(key); + } + + + /** + * Use {@link #getPropertiesMap()} instead. + */ + @Override + @Deprecated + public java.util.Map getProperties() { + + return getPropertiesMap(); + } + + + /** + *
+         * Some semantic nodes have additional information, this information is stored in this Map.
+         * 
+ * + * map<string, string> properties = 5; + */ + @Override + public java.util.Map getPropertiesMap() { + + return internalGetProperties().getMap(); + } + + + /** + *
+         * Some semantic nodes have additional information, this information is stored in this Map.
+         * 
+ * + * map<string, string> properties = 5; + */ + @Override + public /* nullable */ + String getPropertiesOrDefault(String key, + /* nullable */ + String defaultValue) { + + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetProperties().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + + /** + *
+         * Some semantic nodes have additional information, this information is stored in this Map.
+         * 
+ * + * map<string, string> properties = 5; + */ + @Override + public String getPropertiesOrThrow(String key) { + + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetProperties().getMap(); + if (!map.containsKey(key)) { + throw new IllegalArgumentException(); + } + return map.get(key); + } + + + public static final int CHILDREN_FIELD_NUMBER = 6; + @SuppressWarnings("serial") + private java.util.List children_; + + + /** + *
+         * All child Entries of this Entry.
+         * 
+ * + * repeated .EntryData children = 6; + */ + @Override + public java.util.List getChildrenList() { + + return children_; + } + + + /** + *
+         * All child Entries of this Entry.
+         * 
+ * + * repeated .EntryData children = 6; + */ + @Override + public java.util.List getChildrenOrBuilderList() { + + return children_; + } + + + /** + *
+         * All child Entries of this Entry.
+         * 
+ * + * repeated .EntryData children = 6; + */ + @Override + public int getChildrenCount() { + + return children_.size(); + } + + + /** + *
+         * All child Entries of this Entry.
+         * 
+ * + * repeated .EntryData children = 6; + */ + @Override + public EntryData getChildren(int index) { + + return children_.get(index); + } + + + /** + *
+         * All child Entries of this Entry.
+         * 
+ * + * repeated .EntryData children = 6; + */ + @Override + public EntryDataOrBuilder getChildrenOrBuilder(int index) { + + return children_.get(index); + } + + + public static final int ENGINES_FIELD_NUMBER = 7; + @SuppressWarnings("serial") + private java.util.List engines_; + private static final com.google.protobuf.Internal.ListAdapter.Converter engines_converter_ = new com.google.protobuf.Internal.ListAdapter.Converter() { + public LayoutEngineProto.LayoutEngine convert(Integer from) { + + LayoutEngineProto.LayoutEngine result = LayoutEngineProto.LayoutEngine.forNumber(from); + return result == null ? LayoutEngineProto.LayoutEngine.UNRECOGNIZED : result; + } + }; + + + /** + *
+         * Describes the origin of the semantic node.
+         * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @return A list containing the engines. + */ + @Override + public java.util.List getEnginesList() { + + return new com.google.protobuf.Internal.ListAdapter(engines_, engines_converter_); + } + + + /** + *
+         * Describes the origin of the semantic node.
+         * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @return The count of engines. + */ + @Override + public int getEnginesCount() { + + return engines_.size(); + } + + + /** + *
+         * Describes the origin of the semantic node.
+         * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @param index The index of the element to return. + * @return The engines at the given index. + */ + @Override + public LayoutEngineProto.LayoutEngine getEngines(int index) { + + return engines_converter_.convert(engines_.get(index)); + } + + + /** + *
+         * Describes the origin of the semantic node.
+         * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @return A list containing the enum numeric values on the wire for engines. + */ + @Override + public java.util.List getEnginesValueList() { + + return engines_; + } + + + /** + *
+         * Describes the origin of the semantic node.
+         * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @param index The index of the value to return. + * @return The enum numeric value on the wire of engines at the given index. + */ + @Override + public int getEnginesValue(int index) { + + return engines_.get(index); + } + + + private int enginesMemoizedSerializedSize; + + private byte memoizedIsInitialized = -1; + + + @Override + public final boolean isInitialized() { + + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) { + return true; + } + if (isInitialized == 0) { + return false; + } + + memoizedIsInitialized = 1; + return true; + } + + + @Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + + getSerializedSize(); + if (type_ != NodeTypeProto.NodeType.DOCUMENT.getNumber()) { + output.writeEnum(1, type_); + } + if (getTreeIdList().size() > 0) { + output.writeUInt32NoTag(18); + output.writeUInt32NoTag(treeIdMemoizedSerializedSize); + } + for (int i = 0; i < treeId_.size(); i++) { + output.writeInt32NoTag(treeId_.getInt(i)); + } + if (getAtomicBlockIdsList().size() > 0) { + output.writeUInt32NoTag(26); + output.writeUInt32NoTag(atomicBlockIdsMemoizedSerializedSize); + } + for (int i = 0; i < atomicBlockIds_.size(); i++) { + output.writeInt64NoTag(atomicBlockIds_.getLong(i)); + } + if (getPageNumbersList().size() > 0) { + output.writeUInt32NoTag(34); + output.writeUInt32NoTag(pageNumbersMemoizedSerializedSize); + } + for (int i = 0; i < pageNumbers_.size(); i++) { + output.writeInt64NoTag(pageNumbers_.getLong(i)); + } + com.google.protobuf.GeneratedMessage.serializeStringMapTo(output, internalGetProperties(), PropertiesDefaultEntryHolder.defaultEntry, 5); + for (int i = 0; i < children_.size(); i++) { + output.writeMessage(6, children_.get(i)); + } + if (getEnginesList().size() > 0) { + output.writeUInt32NoTag(58); + output.writeUInt32NoTag(enginesMemoizedSerializedSize); + } + for (int i = 0; i < engines_.size(); i++) { + output.writeEnumNoTag(engines_.get(i)); + } + getUnknownFields().writeTo(output); + } + + + @Override + public int getSerializedSize() { + + int size = memoizedSize; + if (size != -1) { + return size; + } + + size = 0; + if (type_ != NodeTypeProto.NodeType.DOCUMENT.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, type_); + } + { + int dataSize = 0; + for (int i = 0; i < treeId_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(treeId_.getInt(i)); + } + size += dataSize; + if (!getTreeIdList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize); + } + treeIdMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + for (int i = 0; i < atomicBlockIds_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream.computeInt64SizeNoTag(atomicBlockIds_.getLong(i)); + } + size += dataSize; + if (!getAtomicBlockIdsList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize); + } + atomicBlockIdsMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + for (int i = 0; i < pageNumbers_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream.computeInt64SizeNoTag(pageNumbers_.getLong(i)); + } + size += dataSize; + if (!getPageNumbersList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize); + } + pageNumbersMemoizedSerializedSize = dataSize; + } + for (java.util.Map.Entry entry : internalGetProperties().getMap().entrySet()) { + com.google.protobuf.MapEntry properties__ = PropertiesDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, properties__); + } + for (int i = 0; i < children_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, children_.get(i)); + } + { + int dataSize = 0; + for (int i = 0; i < engines_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream.computeEnumSizeNoTag(engines_.get(i)); + } + size += dataSize; + if (!getEnginesList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(dataSize); + } + enginesMemoizedSerializedSize = dataSize; + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + + @Override + public boolean equals(final Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof EntryData)) { + return super.equals(obj); + } + EntryData other = (EntryData) obj; + + if (type_ != other.type_) { + return false; + } + if (!getTreeIdList().equals(other.getTreeIdList())) { + return false; + } + if (!getAtomicBlockIdsList().equals(other.getAtomicBlockIdsList())) { + return false; + } + if (!getPageNumbersList().equals(other.getPageNumbersList())) { + return false; + } + if (!internalGetProperties().equals(other.internalGetProperties())) { + return false; + } + if (!getChildrenList().equals(other.getChildrenList())) { + return false; + } + if (!engines_.equals(other.engines_)) { + return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) { + return false; + } + return true; + } + + + @Override + public int hashCode() { + + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + if (getTreeIdCount() > 0) { + hash = (37 * hash) + TREEID_FIELD_NUMBER; + hash = (53 * hash) + getTreeIdList().hashCode(); + } + if (getAtomicBlockIdsCount() > 0) { + hash = (37 * hash) + ATOMICBLOCKIDS_FIELD_NUMBER; + hash = (53 * hash) + getAtomicBlockIdsList().hashCode(); + } + if (getPageNumbersCount() > 0) { + hash = (37 * hash) + PAGENUMBERS_FIELD_NUMBER; + hash = (53 * hash) + getPageNumbersList().hashCode(); + } + if (!internalGetProperties().getMap().isEmpty()) { + hash = (37 * hash) + PROPERTIES_FIELD_NUMBER; + hash = (53 * hash) + internalGetProperties().hashCode(); + } + if (getChildrenCount() > 0) { + hash = (37 * hash) + CHILDREN_FIELD_NUMBER; + hash = (53 * hash) + getChildrenList().hashCode(); + } + if (getEnginesCount() > 0) { + hash = (37 * hash) + ENGINES_FIELD_NUMBER; + hash = (53 * hash) + engines_.hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + + public static EntryData parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static EntryData parseFrom(java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static EntryData parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static EntryData parseFrom(com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static EntryData parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data); + } + + + public static EntryData parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + return PARSER.parseFrom(data, extensionRegistry); + } + + + public static EntryData parseFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static EntryData parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + public static EntryData parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + + public static EntryData parseDelimitedFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + + public static EntryData parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + + public static EntryData parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + + @Override + public Builder newBuilderForType() {return newBuilder();} + + + public static Builder newBuilder() { + + return DEFAULT_INSTANCE.toBuilder(); + } + + + public static Builder newBuilder(EntryData prototype) { + + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + + @Override + public Builder toBuilder() { + + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + + @Override + protected Builder newBuilderForType(BuilderParent parent) { + + Builder builder = new Builder(parent); + return builder; + } + + + /** + * Protobuf type {@code EntryData} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:EntryData) + EntryDataOrBuilder { + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + + return EntryDataProto.internal_static_EntryData_descriptor; + } + + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection(int number) { + + switch (number) { + case 5: + return internalGetProperties(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection(int number) { + + switch (number) { + case 5: + return internalGetMutableProperties(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + + @Override + protected FieldAccessorTable internalGetFieldAccessorTable() { + + return EntryDataProto.internal_static_EntryData_fieldAccessorTable.ensureFieldAccessorsInitialized(EntryData.class, Builder.class); + } + + + // Construct using EntryDataOuterClass.EntryData.newBuilder() + private Builder() { + + } + + + private Builder(BuilderParent parent) { + + super(parent); + + } + + + @Override + public Builder clear() { + + super.clear(); + bitField0_ = 0; + type_ = 0; + treeId_ = emptyIntList(); + atomicBlockIds_ = emptyLongList(); + pageNumbers_ = emptyLongList(); + internalGetMutableProperties().clear(); + if (childrenBuilder_ == null) { + children_ = java.util.Collections.emptyList(); + } else { + children_ = null; + childrenBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000020); + engines_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + return this; + } + + + @Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + + return EntryDataProto.internal_static_EntryData_descriptor; + } + + + @Override + public EntryData getDefaultInstanceForType() { + + return EntryData.getDefaultInstance(); + } + + + @Override + public EntryData build() { + + EntryData result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + + @Override + public EntryData buildPartial() { + + EntryData result = new EntryData(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + + private void buildPartialRepeatedFields(EntryData result) { + + if (childrenBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0)) { + children_ = java.util.Collections.unmodifiableList(children_); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.children_ = children_; + } else { + result.children_ = childrenBuilder_.build(); + } + if (((bitField0_ & 0x00000040) != 0)) { + engines_ = java.util.Collections.unmodifiableList(engines_); + bitField0_ = (bitField0_ & ~0x00000040); + } + result.engines_ = engines_; + } + + + private void buildPartial0(EntryData result) { + + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.type_ = type_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + treeId_.makeImmutable(); + result.treeId_ = treeId_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + atomicBlockIds_.makeImmutable(); + result.atomicBlockIds_ = atomicBlockIds_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + pageNumbers_.makeImmutable(); + result.pageNumbers_ = pageNumbers_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.properties_ = internalGetProperties(); + result.properties_.makeImmutable(); + } + } + + + @Override + public Builder mergeFrom(com.google.protobuf.Message other) { + + if (other instanceof EntryData) { + return mergeFrom((EntryData) other); + } else { + super.mergeFrom(other); + return this; + } + } + + + public Builder mergeFrom(EntryData other) { + + if (other == EntryData.getDefaultInstance()) { + return this; + } + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + if (!other.treeId_.isEmpty()) { + if (treeId_.isEmpty()) { + treeId_ = other.treeId_; + treeId_.makeImmutable(); + bitField0_ |= 0x00000002; + } else { + ensureTreeIdIsMutable(); + treeId_.addAll(other.treeId_); + } + onChanged(); + } + if (!other.atomicBlockIds_.isEmpty()) { + if (atomicBlockIds_.isEmpty()) { + atomicBlockIds_ = other.atomicBlockIds_; + atomicBlockIds_.makeImmutable(); + bitField0_ |= 0x00000004; + } else { + ensureAtomicBlockIdsIsMutable(); + atomicBlockIds_.addAll(other.atomicBlockIds_); + } + onChanged(); + } + if (!other.pageNumbers_.isEmpty()) { + if (pageNumbers_.isEmpty()) { + pageNumbers_ = other.pageNumbers_; + pageNumbers_.makeImmutable(); + bitField0_ |= 0x00000008; + } else { + ensurePageNumbersIsMutable(); + pageNumbers_.addAll(other.pageNumbers_); + } + onChanged(); + } + internalGetMutableProperties().mergeFrom(other.internalGetProperties()); + bitField0_ |= 0x00000010; + if (childrenBuilder_ == null) { + if (!other.children_.isEmpty()) { + if (children_.isEmpty()) { + children_ = other.children_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensureChildrenIsMutable(); + children_.addAll(other.children_); + } + onChanged(); + } + } else { + if (!other.children_.isEmpty()) { + if (childrenBuilder_.isEmpty()) { + childrenBuilder_.dispose(); + childrenBuilder_ = null; + children_ = other.children_; + bitField0_ = (bitField0_ & ~0x00000020); + childrenBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getChildrenFieldBuilder() : null; + } else { + childrenBuilder_.addAllMessages(other.children_); + } + } + } + if (!other.engines_.isEmpty()) { + if (engines_.isEmpty()) { + engines_ = other.engines_; + bitField0_ = (bitField0_ & ~0x00000040); + } else { + ensureEnginesIsMutable(); + engines_.addAll(other.engines_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + + @Override + public final boolean isInitialized() { + + return true; + } + + + @Override + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + + if (extensionRegistry == null) { + throw new NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + type_ = input.readEnum(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 16: { + int v = input.readInt32(); + ensureTreeIdIsMutable(); + treeId_.addInt(v); + break; + } // case 16 + case 18: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + ensureTreeIdIsMutable(); + while (input.getBytesUntilLimit() > 0) { + treeId_.addInt(input.readInt32()); + } + input.popLimit(limit); + break; + } // case 18 + case 24: { + long v = input.readInt64(); + ensureAtomicBlockIdsIsMutable(); + atomicBlockIds_.addLong(v); + break; + } // case 24 + case 26: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + ensureAtomicBlockIdsIsMutable(); + while (input.getBytesUntilLimit() > 0) { + atomicBlockIds_.addLong(input.readInt64()); + } + input.popLimit(limit); + break; + } // case 26 + case 32: { + long v = input.readInt64(); + ensurePageNumbersIsMutable(); + pageNumbers_.addLong(v); + break; + } // case 32 + case 34: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + ensurePageNumbersIsMutable(); + while (input.getBytesUntilLimit() > 0) { + pageNumbers_.addLong(input.readInt64()); + } + input.popLimit(limit); + break; + } // case 34 + case 42: { + com.google.protobuf.MapEntry properties__ = input.readMessage(PropertiesDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableProperties().getMutableMap().put(properties__.getKey(), properties__.getValue()); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: { + EntryData m = input.readMessage(EntryData.parser(), extensionRegistry); + if (childrenBuilder_ == null) { + ensureChildrenIsMutable(); + children_.add(m); + } else { + childrenBuilder_.addMessage(m); + } + break; + } // case 50 + case 56: { + int tmpRaw = input.readEnum(); + ensureEnginesIsMutable(); + engines_.add(tmpRaw); + break; + } // case 56 + case 58: { + int length = input.readRawVarint32(); + int oldLimit = input.pushLimit(length); + while (input.getBytesUntilLimit() > 0) { + int tmpRaw = input.readEnum(); + ensureEnginesIsMutable(); + engines_.add(tmpRaw); + } + input.popLimit(oldLimit); + break; + } // case 58 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + + private int bitField0_; + + private int type_ = 0; + + + /** + *
+             * Type of the semantic node.
+             * 
+ * + * .NodeType type = 1; + * + * @return The enum numeric value on the wire for type. + */ + @Override + public int getTypeValue() { + + return type_; + } + + + /** + *
+             * Type of the semantic node.
+             * 
+ * + * .NodeType type = 1; + * + * @param value The enum numeric value on the wire for type to set. + * @return This builder for chaining. + */ + public Builder setTypeValue(int value) { + + type_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + + /** + *
+             * Type of the semantic node.
+             * 
+ * + * .NodeType type = 1; + * + * @return The type. + */ + @Override + public NodeTypeProto.NodeType getType() { + + NodeTypeProto.NodeType result = NodeTypeProto.NodeType.forNumber(type_); + return result == null ? NodeTypeProto.NodeType.UNRECOGNIZED : result; + } + + + /** + *
+             * Type of the semantic node.
+             * 
+ * + * .NodeType type = 1; + * + * @param value The type to set. + * @return This builder for chaining. + */ + public Builder setType(NodeTypeProto.NodeType value) { + + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + type_ = value.getNumber(); + onChanged(); + return this; + } + + + /** + *
+             * Type of the semantic node.
+             * 
+ * + * .NodeType type = 1; + * + * @return This builder for chaining. + */ + public Builder clearType() { + + bitField0_ = (bitField0_ & ~0x00000001); + type_ = 0; + onChanged(); + return this; + } + + + private com.google.protobuf.Internal.IntList treeId_ = emptyIntList(); + + + private void ensureTreeIdIsMutable() { + + if (!treeId_.isModifiable()) { + treeId_ = makeMutableCopy(treeId_); + } + bitField0_ |= 0x00000002; + } + + + /** + *
+             * Specifies the position in the parsed tree structure.
+             * 
+ * + * repeated int32 treeId = 2; + * + * @return A list containing the treeId. + */ + public java.util.List getTreeIdList() { + + treeId_.makeImmutable(); + return treeId_; + } + + + /** + *
+             * Specifies the position in the parsed tree structure.
+             * 
+ * + * repeated int32 treeId = 2; + * + * @return The count of treeId. + */ + public int getTreeIdCount() { + + return treeId_.size(); + } + + + /** + *
+             * Specifies the position in the parsed tree structure.
+             * 
+ * + * repeated int32 treeId = 2; + * + * @param index The index of the element to return. + * @return The treeId at the given index. + */ + public int getTreeId(int index) { + + return treeId_.getInt(index); + } + + + /** + *
+             * Specifies the position in the parsed tree structure.
+             * 
+ * + * repeated int32 treeId = 2; + * + * @param index The index to set the value at. + * @param value The treeId to set. + * @return This builder for chaining. + */ + public Builder setTreeId(int index, int value) { + + ensureTreeIdIsMutable(); + treeId_.setInt(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + + /** + *
+             * Specifies the position in the parsed tree structure.
+             * 
+ * + * repeated int32 treeId = 2; + * + * @param value The treeId to add. + * @return This builder for chaining. + */ + public Builder addTreeId(int value) { + + ensureTreeIdIsMutable(); + treeId_.addInt(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + + /** + *
+             * Specifies the position in the parsed tree structure.
+             * 
+ * + * repeated int32 treeId = 2; + * + * @param values The treeId to add. + * @return This builder for chaining. + */ + public Builder addAllTreeId(Iterable values) { + + ensureTreeIdIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, treeId_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + + /** + *
+             * Specifies the position in the parsed tree structure.
+             * 
+ * + * repeated int32 treeId = 2; + * + * @return This builder for chaining. + */ + public Builder clearTreeId() { + + treeId_ = emptyIntList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + + private com.google.protobuf.Internal.LongList atomicBlockIds_ = emptyLongList(); + + + private void ensureAtomicBlockIdsIsMutable() { + + if (!atomicBlockIds_.isModifiable()) { + atomicBlockIds_ = makeMutableCopy(atomicBlockIds_); + } + bitField0_ |= 0x00000004; + } + + + /** + *
+             * Specifies the text block IDs associated with this semantic node.
+             * 
+ * + * repeated int64 atomicBlockIds = 3; + * + * @return A list containing the atomicBlockIds. + */ + public java.util.List getAtomicBlockIdsList() { + + atomicBlockIds_.makeImmutable(); + return atomicBlockIds_; + } + + + /** + *
+             * Specifies the text block IDs associated with this semantic node.
+             * 
+ * + * repeated int64 atomicBlockIds = 3; + * + * @return The count of atomicBlockIds. + */ + public int getAtomicBlockIdsCount() { + + return atomicBlockIds_.size(); + } + + + /** + *
+             * Specifies the text block IDs associated with this semantic node.
+             * 
+ * + * repeated int64 atomicBlockIds = 3; + * + * @param index The index of the element to return. + * @return The atomicBlockIds at the given index. + */ + public long getAtomicBlockIds(int index) { + + return atomicBlockIds_.getLong(index); + } + + + /** + *
+             * Specifies the text block IDs associated with this semantic node.
+             * 
+ * + * repeated int64 atomicBlockIds = 3; + * + * @param index The index to set the value at. + * @param value The atomicBlockIds to set. + * @return This builder for chaining. + */ + public Builder setAtomicBlockIds(int index, long value) { + + ensureAtomicBlockIdsIsMutable(); + atomicBlockIds_.setLong(index, value); + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + + /** + *
+             * Specifies the text block IDs associated with this semantic node.
+             * 
+ * + * repeated int64 atomicBlockIds = 3; + * + * @param value The atomicBlockIds to add. + * @return This builder for chaining. + */ + public Builder addAtomicBlockIds(long value) { + + ensureAtomicBlockIdsIsMutable(); + atomicBlockIds_.addLong(value); + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + + /** + *
+             * Specifies the text block IDs associated with this semantic node.
+             * 
+ * + * repeated int64 atomicBlockIds = 3; + * + * @param values The atomicBlockIds to add. + * @return This builder for chaining. + */ + public Builder addAllAtomicBlockIds(Iterable values) { + + ensureAtomicBlockIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, atomicBlockIds_); + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + + /** + *
+             * Specifies the text block IDs associated with this semantic node.
+             * 
+ * + * repeated int64 atomicBlockIds = 3; + * + * @return This builder for chaining. + */ + public Builder clearAtomicBlockIds() { + + atomicBlockIds_ = emptyLongList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + + private com.google.protobuf.Internal.LongList pageNumbers_ = emptyLongList(); + + + private void ensurePageNumbersIsMutable() { + + if (!pageNumbers_.isModifiable()) { + pageNumbers_ = makeMutableCopy(pageNumbers_); + } + bitField0_ |= 0x00000008; + } + + + /** + *
+             * Specifies the pages this semantic node appears on.
+             * 
+ * + * repeated int64 pageNumbers = 4; + * + * @return A list containing the pageNumbers. + */ + public java.util.List getPageNumbersList() { + + pageNumbers_.makeImmutable(); + return pageNumbers_; + } + + + /** + *
+             * Specifies the pages this semantic node appears on.
+             * 
+ * + * repeated int64 pageNumbers = 4; + * + * @return The count of pageNumbers. + */ + public int getPageNumbersCount() { + + return pageNumbers_.size(); + } + + + /** + *
+             * Specifies the pages this semantic node appears on.
+             * 
+ * + * repeated int64 pageNumbers = 4; + * + * @param index The index of the element to return. + * @return The pageNumbers at the given index. + */ + public long getPageNumbers(int index) { + + return pageNumbers_.getLong(index); + } + + + /** + *
+             * Specifies the pages this semantic node appears on.
+             * 
+ * + * repeated int64 pageNumbers = 4; + * + * @param index The index to set the value at. + * @param value The pageNumbers to set. + * @return This builder for chaining. + */ + public Builder setPageNumbers(int index, long value) { + + ensurePageNumbersIsMutable(); + pageNumbers_.setLong(index, value); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + + /** + *
+             * Specifies the pages this semantic node appears on.
+             * 
+ * + * repeated int64 pageNumbers = 4; + * + * @param value The pageNumbers to add. + * @return This builder for chaining. + */ + public Builder addPageNumbers(long value) { + + ensurePageNumbersIsMutable(); + pageNumbers_.addLong(value); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + + /** + *
+             * Specifies the pages this semantic node appears on.
+             * 
+ * + * repeated int64 pageNumbers = 4; + * + * @param values The pageNumbers to add. + * @return This builder for chaining. + */ + public Builder addAllPageNumbers(Iterable values) { + + ensurePageNumbersIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, pageNumbers_); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + + /** + *
+             * Specifies the pages this semantic node appears on.
+             * 
+ * + * repeated int64 pageNumbers = 4; + * + * @return This builder for chaining. + */ + public Builder clearPageNumbers() { + + pageNumbers_ = emptyLongList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + + + private com.google.protobuf.MapField properties_; + + + private com.google.protobuf.MapField internalGetProperties() { + + if (properties_ == null) { + return com.google.protobuf.MapField.emptyMapField(PropertiesDefaultEntryHolder.defaultEntry); + } + return properties_; + } + + + private com.google.protobuf.MapField internalGetMutableProperties() { + + if (properties_ == null) { + properties_ = com.google.protobuf.MapField.newMapField(PropertiesDefaultEntryHolder.defaultEntry); + } + if (!properties_.isMutable()) { + properties_ = properties_.copy(); + } + bitField0_ |= 0x00000010; + onChanged(); + return properties_; + } + + + public int getPropertiesCount() { + + return internalGetProperties().getMap().size(); + } + + + /** + *
+             * Some semantic nodes have additional information, this information is stored in this Map.
+             * 
+ * + * map<string, string> properties = 5; + */ + @Override + public boolean containsProperties(String key) { + + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetProperties().getMap().containsKey(key); + } + + + /** + * Use {@link #getPropertiesMap()} instead. + */ + @Override + @Deprecated + public java.util.Map getProperties() { + + return getPropertiesMap(); + } + + + /** + *
+             * Some semantic nodes have additional information, this information is stored in this Map.
+             * 
+ * + * map<string, string> properties = 5; + */ + @Override + public java.util.Map getPropertiesMap() { + + return internalGetProperties().getMap(); + } + + + /** + *
+             * Some semantic nodes have additional information, this information is stored in this Map.
+             * 
+ * + * map<string, string> properties = 5; + */ + @Override + public /* nullable */ + String getPropertiesOrDefault(String key, + /* nullable */ + String defaultValue) { + + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetProperties().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + + /** + *
+             * Some semantic nodes have additional information, this information is stored in this Map.
+             * 
+ * + * map<string, string> properties = 5; + */ + @Override + public String getPropertiesOrThrow(String key) { + + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetProperties().getMap(); + if (!map.containsKey(key)) { + throw new IllegalArgumentException(); + } + return map.get(key); + } + + + public Builder clearProperties() { + + bitField0_ = (bitField0_ & ~0x00000010); + internalGetMutableProperties().getMutableMap().clear(); + return this; + } + + + /** + *
+             * Some semantic nodes have additional information, this information is stored in this Map.
+             * 
+ * + * map<string, string> properties = 5; + */ + public Builder removeProperties(String key) { + + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableProperties().getMutableMap().remove(key); + return this; + } + + + /** + * Use alternate mutation accessors instead. + */ + @Deprecated + public java.util.Map getMutableProperties() { + + bitField0_ |= 0x00000010; + return internalGetMutableProperties().getMutableMap(); + } + + + /** + *
+             * Some semantic nodes have additional information, this information is stored in this Map.
+             * 
+ * + * map<string, string> properties = 5; + */ + public Builder putProperties(String key, String value) { + + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableProperties().getMutableMap().put(key, value); + bitField0_ |= 0x00000010; + return this; + } + + + /** + *
+             * Some semantic nodes have additional information, this information is stored in this Map.
+             * 
+ * + * map<string, string> properties = 5; + */ + public Builder putAllProperties(java.util.Map values) { + + internalGetMutableProperties().getMutableMap().putAll(values); + bitField0_ |= 0x00000010; + return this; + } + + + private java.util.List children_ = java.util.Collections.emptyList(); + + + private void ensureChildrenIsMutable() { + + if (!((bitField0_ & 0x00000020) != 0)) { + children_ = new java.util.ArrayList(children_); + bitField0_ |= 0x00000020; + } + } + + + private com.google.protobuf.RepeatedFieldBuilder childrenBuilder_; + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public java.util.List getChildrenList() { + + if (childrenBuilder_ == null) { + return java.util.Collections.unmodifiableList(children_); + } else { + return childrenBuilder_.getMessageList(); + } + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public int getChildrenCount() { + + if (childrenBuilder_ == null) { + return children_.size(); + } else { + return childrenBuilder_.getCount(); + } + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public EntryData getChildren(int index) { + + if (childrenBuilder_ == null) { + return children_.get(index); + } else { + return childrenBuilder_.getMessage(index); + } + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public Builder setChildren(int index, EntryData value) { + + if (childrenBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureChildrenIsMutable(); + children_.set(index, value); + onChanged(); + } else { + childrenBuilder_.setMessage(index, value); + } + return this; + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public Builder setChildren(int index, Builder builderForValue) { + + if (childrenBuilder_ == null) { + ensureChildrenIsMutable(); + children_.set(index, builderForValue.build()); + onChanged(); + } else { + childrenBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public Builder addChildren(EntryData value) { + + if (childrenBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureChildrenIsMutable(); + children_.add(value); + onChanged(); + } else { + childrenBuilder_.addMessage(value); + } + return this; + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public Builder addChildren(int index, EntryData value) { + + if (childrenBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureChildrenIsMutable(); + children_.add(index, value); + onChanged(); + } else { + childrenBuilder_.addMessage(index, value); + } + return this; + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public Builder addChildren(Builder builderForValue) { + + if (childrenBuilder_ == null) { + ensureChildrenIsMutable(); + children_.add(builderForValue.build()); + onChanged(); + } else { + childrenBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public Builder addChildren(int index, Builder builderForValue) { + + if (childrenBuilder_ == null) { + ensureChildrenIsMutable(); + children_.add(index, builderForValue.build()); + onChanged(); + } else { + childrenBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public Builder addAllChildren(Iterable values) { + + if (childrenBuilder_ == null) { + ensureChildrenIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, children_); + onChanged(); + } else { + childrenBuilder_.addAllMessages(values); + } + return this; + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public Builder clearChildren() { + + if (childrenBuilder_ == null) { + children_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + } else { + childrenBuilder_.clear(); + } + return this; + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public Builder removeChildren(int index) { + + if (childrenBuilder_ == null) { + ensureChildrenIsMutable(); + children_.remove(index); + onChanged(); + } else { + childrenBuilder_.remove(index); + } + return this; + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public Builder getChildrenBuilder(int index) { + + return getChildrenFieldBuilder().getBuilder(index); + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public EntryDataOrBuilder getChildrenOrBuilder(int index) { + + if (childrenBuilder_ == null) { + return children_.get(index); + } else { + return childrenBuilder_.getMessageOrBuilder(index); + } + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public java.util.List getChildrenOrBuilderList() { + + if (childrenBuilder_ != null) { + return childrenBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(children_); + } + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public Builder addChildrenBuilder() { + + return getChildrenFieldBuilder().addBuilder(EntryData.getDefaultInstance()); + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public Builder addChildrenBuilder(int index) { + + return getChildrenFieldBuilder().addBuilder(index, EntryData.getDefaultInstance()); + } + + + /** + *
+             * All child Entries of this Entry.
+             * 
+ * + * repeated .EntryData children = 6; + */ + public java.util.List getChildrenBuilderList() { + + return getChildrenFieldBuilder().getBuilderList(); + } + + + private com.google.protobuf.RepeatedFieldBuilder getChildrenFieldBuilder() { + + if (childrenBuilder_ == null) { + childrenBuilder_ = new com.google.protobuf.RepeatedFieldBuilder(children_, + ((bitField0_ & 0x00000020) != 0), + getParentForChildren(), + isClean()); + children_ = null; + } + return childrenBuilder_; + } + + + private java.util.List engines_ = java.util.Collections.emptyList(); + + + private void ensureEnginesIsMutable() { + + if (!((bitField0_ & 0x00000040) != 0)) { + engines_ = new java.util.ArrayList(engines_); + bitField0_ |= 0x00000040; + } + } + + + /** + *
+             * Describes the origin of the semantic node.
+             * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @return A list containing the engines. + */ + public java.util.List getEnginesList() { + + return new com.google.protobuf.Internal.ListAdapter(engines_, engines_converter_); + } + + + /** + *
+             * Describes the origin of the semantic node.
+             * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @return The count of engines. + */ + public int getEnginesCount() { + + return engines_.size(); + } + + + /** + *
+             * Describes the origin of the semantic node.
+             * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @param index The index of the element to return. + * @return The engines at the given index. + */ + public LayoutEngineProto.LayoutEngine getEngines(int index) { + + return engines_converter_.convert(engines_.get(index)); + } + + + /** + *
+             * Describes the origin of the semantic node.
+             * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @param index The index to set the value at. + * @param value The engines to set. + * @return This builder for chaining. + */ + public Builder setEngines(int index, LayoutEngineProto.LayoutEngine value) { + + if (value == null) { + throw new NullPointerException(); + } + ensureEnginesIsMutable(); + engines_.set(index, value.getNumber()); + onChanged(); + return this; + } + + + /** + *
+             * Describes the origin of the semantic node.
+             * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @param value The engines to add. + * @return This builder for chaining. + */ + public Builder addEngines(LayoutEngineProto.LayoutEngine value) { + + if (value == null) { + throw new NullPointerException(); + } + ensureEnginesIsMutable(); + engines_.add(value.getNumber()); + onChanged(); + return this; + } + + + /** + *
+             * Describes the origin of the semantic node.
+             * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @param values The engines to add. + * @return This builder for chaining. + */ + public Builder addAllEngines(Iterable values) { + + ensureEnginesIsMutable(); + for (LayoutEngineProto.LayoutEngine value : values) { + engines_.add(value.getNumber()); + } + onChanged(); + return this; + } + + + /** + *
+             * Describes the origin of the semantic node.
+             * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @return This builder for chaining. + */ + public Builder clearEngines() { + + engines_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + onChanged(); + return this; + } + + + /** + *
+             * Describes the origin of the semantic node.
+             * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @return A list containing the enum numeric values on the wire for engines. + */ + public java.util.List getEnginesValueList() { + + return java.util.Collections.unmodifiableList(engines_); + } + + + /** + *
+             * Describes the origin of the semantic node.
+             * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @param index The index of the value to return. + * @return The enum numeric value on the wire of engines at the given index. + */ + public int getEnginesValue(int index) { + + return engines_.get(index); + } + + + /** + *
+             * Describes the origin of the semantic node.
+             * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @param index The index to set the value at. + * @param value The enum numeric value on the wire for engines to set. + * @return This builder for chaining. + */ + public Builder setEnginesValue(int index, int value) { + + ensureEnginesIsMutable(); + engines_.set(index, value); + onChanged(); + return this; + } + + + /** + *
+             * Describes the origin of the semantic node.
+             * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @param value The enum numeric value on the wire for engines to add. + * @return This builder for chaining. + */ + public Builder addEnginesValue(int value) { + + ensureEnginesIsMutable(); + engines_.add(value); + onChanged(); + return this; + } + + + /** + *
+             * Describes the origin of the semantic node.
+             * 
+ * + * repeated .LayoutEngine engines = 7; + * + * @param values The enum numeric values on the wire for engines to add. + * @return This builder for chaining. + */ + public Builder addAllEnginesValue(Iterable values) { + + ensureEnginesIsMutable(); + for (int value : values) { + engines_.add(value); + } + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:EntryData) + } + + // @@protoc_insertion_point(class_scope:EntryData) + private static final EntryData DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new EntryData(); + } + + public static EntryData getDefaultInstance() { + + return DEFAULT_INSTANCE; + } + + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + @Override + public EntryData parsePartialFrom(com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + + public static com.google.protobuf.Parser parser() { + + return PARSER; + } + + + @Override + public com.google.protobuf.Parser getParserForType() { + + return PARSER; + } + + + @Override + public EntryData getDefaultInstanceForType() { + + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor internal_static_EntryData_descriptor; + private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_EntryData_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_EntryData_PropertiesEntry_descriptor; + private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_EntryData_PropertiesEntry_fieldAccessorTable; + + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + + return descriptor; + } + + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + String[] descriptorData = {"\n\017EntryData.proto\032\022LayoutEngine.proto\032\016N" + + "odeType.proto\"\202\002\n\tEntryData\022\027\n\004type\030\001 \001(" + + "\0162\t.NodeType\022\016\n\006treeId\030\002 \003(\005\022\026\n\016atomicBl" + + "ockIds\030\003 \003(\003\022\023\n\013pageNumbers\030\004 \003(\003\022.\n\npro" + + "perties\030\005 \003(\0132\032.EntryData.PropertiesEntr" + + "y\022\034\n\010children\030\006 \003(\0132\n.EntryData\022\036\n\007engin" + + "es\030\007 \003(\0162\r.LayoutEngine\0321\n\017PropertiesEnt" + + "ry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001b\006prot" + + "o3"}; + descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[]{LayoutEngineProto.getDescriptor(), NodeTypeProto.getDescriptor(),}); + internal_static_EntryData_descriptor = getDescriptor().getMessageTypes() + .get(0); + internal_static_EntryData_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_EntryData_descriptor, + new String[]{"Type", "TreeId", "AtomicBlockIds", "PageNumbers", "Properties", "Children", "Engines",}); + internal_static_EntryData_PropertiesEntry_descriptor = internal_static_EntryData_descriptor.getNestedTypes() + .get(0); + internal_static_EntryData_PropertiesEntry_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_EntryData_PropertiesEntry_descriptor, + new String[]{"Key", "Value",}); + descriptor.resolveAllFeaturesImmutable(); + LayoutEngineProto.getDescriptor(); + NodeTypeProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/LayoutEngine.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/LayoutEngine.java index 03b7f00..a6e8c03 100644 --- a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/LayoutEngine.java +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/LayoutEngine.java @@ -1,5 +1,6 @@ package com.knecon.fforesight.service.layoutparser.internal.api.data.redaction; +@Deprecated public enum LayoutEngine { ALGORITHM, AI, diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/LayoutEngineProto.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/LayoutEngineProto.java new file mode 100644 index 0000000..5407056 --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/LayoutEngineProto.java @@ -0,0 +1,193 @@ +package com.knecon.fforesight.service.layoutparser.internal.api.data.redaction; + +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: LayoutEngine.proto +// Protobuf Java Version: 4.27.1 +@SuppressWarnings("all") +public final class LayoutEngineProto { + + private LayoutEngineProto() {} + + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", LayoutEngineProto.class.getName()); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) { + + } + + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + + /** + * Protobuf enum {@code LayoutEngine} + */ + public enum LayoutEngine implements com.google.protobuf.ProtocolMessageEnum { + /** + * ALGORITHM = 0; + */ + ALGORITHM(0), + /** + * AI = 1; + */ + AI(1), + /** + * OUTLINE = 2; + */ + OUTLINE(2), + UNRECOGNIZED(-1), + ; + + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", LayoutEngine.class.getName()); + } + + /** + * ALGORITHM = 0; + */ + public static final int ALGORITHM_VALUE = 0; + /** + * AI = 1; + */ + public static final int AI_VALUE = 1; + /** + * OUTLINE = 2; + */ + public static final int OUTLINE_VALUE = 2; + + + public final int getNumber() { + + if (this == UNRECOGNIZED) { + throw new IllegalArgumentException("Can't get the number of an unknown enum value."); + } + return value; + } + + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @Deprecated + public static LayoutEngine valueOf(int value) { + + return forNumber(value); + } + + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static LayoutEngine forNumber(int value) { + + switch (value) { + case 0: + return ALGORITHM; + case 1: + return AI; + case 2: + return OUTLINE; + default: + return null; + } + } + + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + + return internalValueMap; + } + + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = new com.google.protobuf.Internal.EnumLiteMap() { + public LayoutEngine findValueByNumber(int number) { + + return LayoutEngine.forNumber(number); + } + }; + + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + + if (this == UNRECOGNIZED) { + throw new IllegalStateException("Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues() + .get(ordinal()); + } + + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + + return getDescriptor(); + } + + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + + return LayoutEngineProto.getDescriptor().getEnumTypes() + .get(0); + } + + + private static final LayoutEngine[] VALUES = values(); + + + public static LayoutEngine valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + + if (desc.getType() != getDescriptor()) { + throw new IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + + private final int value; + + + private LayoutEngine(int value) { + + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:LayoutEngine) + } + + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + + return descriptor; + } + + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + String[] descriptorData = {"\n\022LayoutEngine.proto*2\n\014LayoutEngine\022\r\n\t" + "ALGORITHM\020\000\022\006\n\002AI\020\001\022\013\n\007OUTLINE\020\002b\006proto3"}; + descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[]{}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/NodeType.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/NodeType.java index e446fb0..cc1df4d 100644 --- a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/NodeType.java +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/NodeType.java @@ -3,6 +3,7 @@ package com.knecon.fforesight.service.layoutparser.internal.api.data.redaction; import java.io.Serializable; import java.util.Locale; +@Deprecated public enum NodeType implements Serializable { DOCUMENT, SECTION, diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/NodeTypeProto.java b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/NodeTypeProto.java new file mode 100644 index 0000000..21a20cc --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/java/com/knecon/fforesight/service/layoutparser/internal/api/data/redaction/NodeTypeProto.java @@ -0,0 +1,274 @@ +package com.knecon.fforesight.service.layoutparser.internal.api.data.redaction; + +import java.util.Locale; +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: NodeType.proto +// Protobuf Java Version: 4.27.1 +@SuppressWarnings("all") +public final class NodeTypeProto { + + private NodeTypeProto() {} + + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", NodeTypeProto.class.getName()); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) { + + } + + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + + /** + * Protobuf enum {@code NodeType} + */ + public enum NodeType implements com.google.protobuf.ProtocolMessageEnum { + /** + * DOCUMENT = 0; + */ + DOCUMENT(0), + /** + * SECTION = 1; + */ + SECTION(1), + /** + * SUPER_SECTION = 2; + */ + SUPER_SECTION(2), + /** + * HEADLINE = 3; + */ + HEADLINE(3), + /** + * PARAGRAPH = 4; + */ + PARAGRAPH(4), + /** + * TABLE = 5; + */ + TABLE(5), + /** + * TABLE_CELL = 6; + */ + TABLE_CELL(6), + /** + * IMAGE = 7; + */ + IMAGE(7), + /** + * HEADER = 8; + */ + HEADER(8), + /** + * FOOTER = 9; + */ + FOOTER(9), + UNRECOGNIZED(-1), + ; + + + public String toString() { + + return this.name().charAt(0) + this.name().substring(1).toLowerCase(Locale.ROOT); + } + + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion(com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 27, + /* patch= */ 1, + /* suffix= */ "", NodeType.class.getName()); + } + + /** + * DOCUMENT = 0; + */ + public static final int DOCUMENT_VALUE = 0; + /** + * SECTION = 1; + */ + public static final int SECTION_VALUE = 1; + /** + * SUPER_SECTION = 2; + */ + public static final int SUPER_SECTION_VALUE = 2; + /** + * HEADLINE = 3; + */ + public static final int HEADLINE_VALUE = 3; + /** + * PARAGRAPH = 4; + */ + public static final int PARAGRAPH_VALUE = 4; + /** + * TABLE = 5; + */ + public static final int TABLE_VALUE = 5; + /** + * TABLE_CELL = 6; + */ + public static final int TABLE_CELL_VALUE = 6; + /** + * IMAGE = 7; + */ + public static final int IMAGE_VALUE = 7; + /** + * HEADER = 8; + */ + public static final int HEADER_VALUE = 8; + /** + * FOOTER = 9; + */ + public static final int FOOTER_VALUE = 9; + + + public final int getNumber() { + + if (this == UNRECOGNIZED) { + throw new IllegalArgumentException("Can't get the number of an unknown enum value."); + } + return value; + } + + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @Deprecated + public static NodeType valueOf(int value) { + + return forNumber(value); + } + + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static NodeType forNumber(int value) { + + switch (value) { + case 0: + return DOCUMENT; + case 1: + return SECTION; + case 2: + return SUPER_SECTION; + case 3: + return HEADLINE; + case 4: + return PARAGRAPH; + case 5: + return TABLE; + case 6: + return TABLE_CELL; + case 7: + return IMAGE; + case 8: + return HEADER; + case 9: + return FOOTER; + default: + return null; + } + } + + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + + return internalValueMap; + } + + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = new com.google.protobuf.Internal.EnumLiteMap() { + public NodeType findValueByNumber(int number) { + + return NodeType.forNumber(number); + } + }; + + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + + if (this == UNRECOGNIZED) { + throw new IllegalStateException("Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues() + .get(ordinal()); + } + + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + + return getDescriptor(); + } + + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + + return NodeTypeProto.getDescriptor().getEnumTypes() + .get(0); + } + + + private static final NodeType[] VALUES = values(); + + + public static NodeType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + + if (desc.getType() != getDescriptor()) { + throw new IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + + private final int value; + + + private NodeType(int value) { + + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:NodeType) + } + + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + + return descriptor; + } + + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + String[] descriptorData = {"\n\016NodeType.proto*\223\001\n\010NodeType\022\014\n\010DOCUMEN" + + "T\020\000\022\013\n\007SECTION\020\001\022\021\n\rSUPER_SECTION\020\002\022\014\n\010H" + + "EADLINE\020\003\022\r\n\tPARAGRAPH\020\004\022\t\n\005TABLE\020\005\022\016\n\nT" + + "ABLE_CELL\020\006\022\t\n\005IMAGE\020\007\022\n\n\006HEADER\020\010\022\n\n\006FO" + + "OTER\020\tb\006proto3"}; + descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[]{}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentPage.proto b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentPage.proto new file mode 100644 index 0000000..a3d518b --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentPage.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +message AllDocumentPages { + + repeated DocumentPage documentPages = 1; +} + +message DocumentPage { + // The page number, starting with 1. + int32 number = 1; + + // The page height in PDF user units. + int32 height = 2; + + // The page width in PDF user units. + int32 width = 3; + + // The page rotation as specified by the PDF. + int32 rotation = 4; +} + diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentPositionData.proto b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentPositionData.proto new file mode 100644 index 0000000..5353924 --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentPositionData.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +message AllDocumentPositionData { + + repeated DocumentPositionData documentPositionData = 1; +} + +message DocumentPositionData { + // Identifier of the text block. + int64 id = 1; + + // For each string coordinate in the search text of the text block, the array contains an entry relating the string coordinate to the position coordinate. + // This is required due to the text and position coordinates not being equal. + repeated int32 stringIdxToPositionIdx = 2; + + // The bounding box for each glyph as a rectangle. This matrix is of size (n,4), where n is the number of glyphs in the text block. + // The second dimension specifies the rectangle with the value x, y, width, height, with x, y specifying the lower left corner. + // In order to access this information, the stringIdxToPositionIdx array must be used to transform the coordinates. + repeated Position positions = 3; + + // Definition of a BoundingBox that contains x, y, width, and height. + message Position { + repeated float value = 1; + } +} diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentStructure.proto b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentStructure.proto new file mode 100644 index 0000000..fc7aea6 --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentStructure.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; + +import "EntryData.proto"; + +message DocumentStructure { + // The root EntryData represents the Document. + EntryData root = 1; +} diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentTextData.proto b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentTextData.proto new file mode 100644 index 0000000..9f187ce --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/DocumentTextData.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +message AllDocumentTextData { + + repeated DocumentTextData documentTextData = 1; +} + +message DocumentTextData { + // Identifier of the text block. + int64 id = 1; + + // The page the text block occurs on. + int64 page = 2; + + // The text of the text block. + string searchText = 3; + + // Each text block is assigned a number on a page, starting from 0. + int32 numberOnPage = 4; + + // The text blocks are ordered, this number represents the start of the text block as a string offset. + int32 start = 5; + + // The text blocks are ordered, this number represents the end of the text block as a string offset. + int32 end = 6; + + // The line breaks in the text of this semantic node in string offsets. They are exclusive end. At the end of each semantic node there is an implicit linebreak. + repeated int32 lineBreaks = 7; +} diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/resources/EntryData.proto b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/EntryData.proto new file mode 100644 index 0000000..09e7851 --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/EntryData.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; + +import "LayoutEngine.proto"; +import "NodeType.proto"; + +message EntryData { + // Type of the semantic node. + NodeType type = 1; + + // Specifies the position in the parsed tree structure. + repeated int32 treeId = 2; + + // Specifies the text block IDs associated with this semantic node. + repeated int64 atomicBlockIds = 3; + + // Specifies the pages this semantic node appears on. + repeated int64 pageNumbers = 4; + + // Some semantic nodes have additional information, this information is stored in this Map. + map properties = 5; + + // All child Entries of this Entry. + repeated EntryData children = 6; + + // Describes the origin of the semantic node. + repeated LayoutEngine engines = 7; +} diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/resources/LayoutEngine.proto b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/LayoutEngine.proto new file mode 100644 index 0000000..584da56 --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/LayoutEngine.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +enum LayoutEngine { + ALGORITHM = 0; + AI = 1; + OUTLINE = 2; +} diff --git a/layoutparser-service/layoutparser-service-internal-api/src/main/resources/NodeType.proto b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/NodeType.proto new file mode 100644 index 0000000..6cf9172 --- /dev/null +++ b/layoutparser-service/layoutparser-service-internal-api/src/main/resources/NodeType.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +enum NodeType { + DOCUMENT = 0; + SECTION = 1; + SUPER_SECTION = 2; + HEADLINE = 3; + PARAGRAPH = 4; + TABLE = 5; + TABLE_CELL = 6; + IMAGE = 7; + HEADER = 8; + FOOTER = 9; +} diff --git a/layoutparser-service/layoutparser-service-processor/build.gradle.kts b/layoutparser-service/layoutparser-service-processor/build.gradle.kts index adcc49f..c397e3b 100644 --- a/layoutparser-service/layoutparser-service-processor/build.gradle.kts +++ b/layoutparser-service/layoutparser-service-processor/build.gradle.kts @@ -16,8 +16,10 @@ dependencies { exclude("org.springframework.boot", "spring-boot-starter-security") exclude("org.springframework.boot", "spring-boot-starter-validation") } - implementation("com.knecon.fforesight:tenant-commons:0.30.0") - implementation("com.iqser.red.commons:storage-commons:2.45.0") + implementation("com.knecon.fforesight:tenant-commons:0.30.0") { + exclude("com.iqser.red.commons", "storage-commons") + } + implementation("com.iqser.red.commons:storage-commons:2.50.0") implementation("org.apache.pdfbox:pdfbox:${pdfBoxVersion}") implementation("org.apache.pdfbox:pdfbox-tools:${pdfBoxVersion}") @@ -34,4 +36,5 @@ dependencies { implementation("com.pdftron:PDFNet:10.11.0") implementation("org.apache.commons:commons-text:1.12.0") + implementation("com.google.protobuf:protobuf-java-util:4.27.1") } diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/LayoutParsingPipeline.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/LayoutParsingPipeline.java index e803c3b..13c52fb 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/LayoutParsingPipeline.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/LayoutParsingPipeline.java @@ -20,7 +20,7 @@ import org.apache.pdfbox.pdmodel.common.PDRectangle; import org.apache.pdfbox.pdmodel.documentinterchange.markedcontent.PDMarkedContent; import org.springframework.stereotype.Service; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.internal.api.queue.LayoutParsingFinishedEvent; import com.knecon.fforesight.service.layoutparser.internal.api.queue.LayoutParsingRequest; import com.knecon.fforesight.service.layoutparser.internal.api.queue.LayoutParsingType; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/LayoutParsingStorageService.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/LayoutParsingStorageService.java index 9a4e1ae..a84fccc 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/LayoutParsingStorageService.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/LayoutParsingStorageService.java @@ -11,7 +11,9 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Service; import com.fasterxml.jackson.databind.ObjectMapper; @@ -39,6 +41,8 @@ public class LayoutParsingStorageService { private final StorageService storageService; private final ObjectMapper objectMapper; + private final TaskExecutor taskExecutor; + @Observed(name = "LayoutParsingStorageService", contextualName = "get-origin-file") public File getOriginFile(String storageId) throws IOException { @@ -100,13 +104,35 @@ public class LayoutParsingStorageService { } + @SneakyThrows @Observed(name = "LayoutParsingStorageService", contextualName = "store-document-data") public void storeDocumentData(LayoutParsingRequest layoutParsingRequest, DocumentData documentData) { - storageService.storeJSONObject(TenantContext.getTenantId(), layoutParsingRequest.structureFileStorageId(), documentData.getDocumentStructure()); - storageService.storeJSONObject(TenantContext.getTenantId(), layoutParsingRequest.textBlockFileStorageId(), documentData.getDocumentTextData()); - storageService.storeJSONObject(TenantContext.getTenantId(), layoutParsingRequest.positionBlockFileStorageId(), documentData.getDocumentPositions()); - storageService.storeJSONObject(TenantContext.getTenantId(), layoutParsingRequest.pageFileStorageId(), documentData.getDocumentPages()); + Runnable storeDocumentStructureRunnable = () -> storageService.storeProtoObject(TenantContext.getTenantId(), + layoutParsingRequest.structureFileStorageId(), + documentData.getDocumentStructure()); + + CompletableFuture storeDocumentStructureFuture = CompletableFuture.runAsync(storeDocumentStructureRunnable, taskExecutor); + + Runnable storeDocumentTextDataRunnable = () -> storageService.storeProtoObject(TenantContext.getTenantId(), + layoutParsingRequest.textBlockFileStorageId(), + documentData.getDocumentTextData()); + + CompletableFuture storeDocumentTextDataFuture = CompletableFuture.runAsync(storeDocumentTextDataRunnable, taskExecutor); + + Runnable storeDocumentPositionsRunnable = () -> storageService.storeProtoObject(TenantContext.getTenantId(), + layoutParsingRequest.positionBlockFileStorageId(), + documentData.getDocumentPositions()); + + CompletableFuture storeDocumentPositionsFuture = CompletableFuture.runAsync(storeDocumentPositionsRunnable, taskExecutor); + + Runnable storeDocumentPagesRunnable = () -> storageService.storeProtoObject(TenantContext.getTenantId(), + layoutParsingRequest.pageFileStorageId(), + documentData.getDocumentPages()); + + CompletableFuture storeDocumentPagesFuture = CompletableFuture.runAsync(storeDocumentPagesRunnable, taskExecutor); + + CompletableFuture.allOf(storeDocumentStructureFuture, storeDocumentTextDataFuture, storeDocumentPositionsFuture, storeDocumentPagesFuture).join(); } diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/AbstractPageBlock.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/AbstractPageBlock.java index e7a58b1..54a1cb1 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/AbstractPageBlock.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/AbstractPageBlock.java @@ -4,7 +4,7 @@ import java.util.HashSet; import java.util.Set; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngine; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine; import com.knecon.fforesight.service.layoutparser.processor.docstrum.model.BoundingBox; import com.knecon.fforesight.service.layoutparser.processor.model.text.TextPageBlock; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/DocumentTree.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/DocumentTree.java index b5329bc..9552b8f 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/DocumentTree.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/DocumentTree.java @@ -8,7 +8,7 @@ import java.util.LinkedList; import java.util.List; import java.util.stream.Stream; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Document; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.GenericSemanticNode; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.SemanticNode; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/AbstractSemanticNode.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/AbstractSemanticNode.java index 3f9e051..52be80d 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/AbstractSemanticNode.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/AbstractSemanticNode.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngine; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine; import com.knecon.fforesight.service.layoutparser.processor.model.graph.DocumentTree; import com.knecon.fforesight.service.layoutparser.processor.model.graph.entity.TextEntity; import com.knecon.fforesight.service.layoutparser.processor.model.graph.textblock.TextBlock; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Document.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Document.java index 7139969..7d4f86d 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Document.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Document.java @@ -9,7 +9,7 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.DocumentTree; import com.knecon.fforesight.service.layoutparser.processor.model.graph.NodeVisitor; import com.knecon.fforesight.service.layoutparser.processor.model.graph.textblock.TextBlock; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Footer.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Footer.java index de4c73a..64a3e68 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Footer.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Footer.java @@ -1,6 +1,6 @@ package com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.NodeVisitor; import com.knecon.fforesight.service.layoutparser.processor.model.graph.textblock.TextBlock; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Header.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Header.java index e01bdbc..cad4e80 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Header.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Header.java @@ -1,6 +1,6 @@ package com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.NodeVisitor; import com.knecon.fforesight.service.layoutparser.processor.model.graph.textblock.TextBlock; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Headline.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Headline.java index fe669df..369174c 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Headline.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Headline.java @@ -1,6 +1,6 @@ package com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.NodeVisitor; import com.knecon.fforesight.service.layoutparser.processor.model.graph.textblock.TextBlock; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Image.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Image.java index 13afcf3..df28ea6 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Image.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Image.java @@ -6,7 +6,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.NodeVisitor; import com.knecon.fforesight.service.layoutparser.processor.model.graph.textblock.TextBlock; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Paragraph.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Paragraph.java index 288ab54..23c5711 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Paragraph.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Paragraph.java @@ -1,6 +1,6 @@ package com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.NodeVisitor; import com.knecon.fforesight.service.layoutparser.processor.model.graph.textblock.TextBlock; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Section.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Section.java index b02c814..46ee9cd 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Section.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Section.java @@ -1,6 +1,7 @@ package com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; + +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.NodeVisitor; import lombok.AccessLevel; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/SemanticNode.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/SemanticNode.java index 98103bf..a873722 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/SemanticNode.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/SemanticNode.java @@ -12,8 +12,8 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngine; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.DocumentTree; import com.knecon.fforesight.service.layoutparser.processor.model.graph.TextRange; import com.knecon.fforesight.service.layoutparser.processor.model.graph.entity.EntityType; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/SuperSection.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/SuperSection.java index 662afe3..6a8c974 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/SuperSection.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/SuperSection.java @@ -1,6 +1,6 @@ package com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.NodeVisitor; import lombok.AccessLevel; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Table.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Table.java index 82d8539..66b0ef7 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Table.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/Table.java @@ -12,8 +12,8 @@ import java.util.Set; import java.util.stream.IntStream; import java.util.stream.Stream; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngine; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.DocumentTree; import com.knecon.fforesight.service.layoutparser.processor.model.graph.NodeVisitor; import com.knecon.fforesight.service.layoutparser.processor.model.graph.entity.TextEntity; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/TableCell.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/TableCell.java index f6ba77b..1d8d4a8 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/TableCell.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/nodes/TableCell.java @@ -4,7 +4,7 @@ import java.awt.geom.Rectangle2D; import java.util.HashMap; import java.util.Map; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.NodeVisitor; import com.knecon.fforesight.service.layoutparser.processor.model.graph.textblock.TextBlock; import com.knecon.fforesight.service.layoutparser.processor.model.graph.textblock.TextBlockCollector; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/textblock/AtomicTextBlock.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/textblock/AtomicTextBlock.java index 6da9330..b9d7d12 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/textblock/AtomicTextBlock.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/model/graph/textblock/AtomicTextBlock.java @@ -1,5 +1,6 @@ package com.knecon.fforesight.service.layoutparser.processor.model.graph.textblock; +import static com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentTextDataProto.DocumentTextData; import static java.lang.String.format; import java.awt.geom.Rectangle2D; @@ -13,8 +14,8 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPositionData; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentTextData; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPositionDataProto.DocumentPositionData; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPositionDataProto.DocumentPositionData.Position; import com.knecon.fforesight.service.layoutparser.processor.model.graph.TextRange; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Page; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.SemanticNode; @@ -153,11 +154,9 @@ public class AtomicTextBlock implements TextBlock { .page(page) .textRange(new TextRange(documentTextData.getStart(), documentTextData.getEnd())) .searchText(documentTextData.getSearchText()) - .lineBreaks(Arrays.stream(documentTextData.getLineBreaks()).boxed() - .toList()) - .stringIdxToPositionIdx(Arrays.stream(documentPositionData.getStringIdxToPositionIdx()).boxed() - .toList()) - .positions(toRectangle2DList(documentPositionData.getPositions())) + .lineBreaks(documentTextData.getLineBreaksList()) + .stringIdxToPositionIdx(documentPositionData.getStringIdxToPositionIdxList()) + .positions(toRectangle2DList(documentPositionData.getPositionsList())) .parent(parent) .build(); } @@ -171,6 +170,14 @@ public class AtomicTextBlock implements TextBlock { } + private static List toRectangle2DList(List positions) { + + return positions.stream() + .map(pos -> (Rectangle2D) new Rectangle2D.Float(pos.getValue(0), pos.getValue(1), pos.getValue(2), pos.getValue(3))) + .toList(); + } + + public CharSequence getLine(int lineNumber) { if (lineNumber >= numberOfLines() || lineNumber < 0) { diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/blockification/BlockificationPostprocessingService.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/blockification/BlockificationPostprocessingService.java index 1be4489..2d4e700 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/blockification/BlockificationPostprocessingService.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/blockification/BlockificationPostprocessingService.java @@ -11,7 +11,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.similarity.LevenshteinDistance; import org.springframework.stereotype.Service; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngine; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine; import com.knecon.fforesight.service.layoutparser.processor.model.ClassificationPage; import com.knecon.fforesight.service.layoutparser.processor.model.PageBlockType; import com.knecon.fforesight.service.layoutparser.processor.model.SectionIdentifier; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/DocumentDataMapper.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/DocumentDataMapper.java index 3a0a076..561655d 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/DocumentDataMapper.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/DocumentDataMapper.java @@ -1,6 +1,10 @@ package com.knecon.fforesight.service.layoutparser.processor.services.mapper; +import static com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentTextDataProto.AllDocumentTextData; +import static com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentTextDataProto.DocumentTextData; + import java.awt.geom.Rectangle2D; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -9,11 +13,15 @@ import java.util.Set; import java.util.stream.Collectors; import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentData; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPage; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPositionData; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructure; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentTextData; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngine; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPageProto.AllDocumentPages; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPageProto.DocumentPage; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPositionDataProto.AllDocumentPositionData; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPositionDataProto.DocumentPositionData; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPositionDataProto.DocumentPositionData.Position; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructureProto.DocumentStructure; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructureWrapper; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.EntryDataProto.EntryData; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine; import com.knecon.fforesight.service.layoutparser.processor.model.graph.DocumentTree; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Document; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.DuplicatedParagraph; @@ -32,44 +40,57 @@ public class DocumentDataMapper { public DocumentData toDocumentData(Document document) { List documentTextData = document.streamTerminalTextBlocksInOrder() - .flatMap(textBlock -> textBlock.getAtomicTextBlocks().stream()) + .flatMap(textBlock -> textBlock.getAtomicTextBlocks() + .stream()) .distinct() .map(DocumentDataMapper::toAtomicTextBlockData) .toList(); + AllDocumentTextData allDocumentTextData = AllDocumentTextData.newBuilder().addAllDocumentTextData(documentTextData).build(); + List atomicPositionBlockData = document.streamTerminalTextBlocksInOrder() - .flatMap(textBlock -> textBlock.getAtomicTextBlocks().stream()) + .flatMap(textBlock -> textBlock.getAtomicTextBlocks() + .stream()) .distinct() .map(DocumentDataMapper::toAtomicPositionBlockData) .toList(); - Set nonEmptyTextBlocks = documentTextData.stream().mapToLong(DocumentTextData::getId).boxed().collect(Collectors.toSet()); + AllDocumentPositionData allDocumentPositionData = AllDocumentPositionData.newBuilder().addAllDocumentPositionData(atomicPositionBlockData).build(); - List documentPageData = document.getPages().stream().map(DocumentDataMapper::toPageData).toList(); - DocumentStructure tableOfContentsData = toDocumentTreeData(document.getDocumentTree()); + Set nonEmptyTextBlocks = documentTextData.stream() + .mapToLong(DocumentTextData::getId).boxed() + .collect(Collectors.toSet()); + + List documentPageData = document.getPages() + .stream() + .map(DocumentDataMapper::toPageData) + .toList(); + + AllDocumentPages allDocumentPages = AllDocumentPages.newBuilder().addAllDocumentPages(documentPageData).build(); + DocumentStructureWrapper tableOfContentsData = toDocumentTreeData(document.getDocumentTree()); return DocumentData.builder() - .documentTextData(documentTextData.toArray(new DocumentTextData[0])) - .documentPositions(atomicPositionBlockData.toArray(new DocumentPositionData[0])) - .documentPages(documentPageData.toArray(new DocumentPage[0])) - .documentStructure(tableOfContentsData) + .documentTextData(allDocumentTextData) + .documentPositions(allDocumentPositionData) + .documentPages(allDocumentPages) + .documentStructureWrapper(tableOfContentsData) .build(); } - private DocumentStructure toDocumentTreeData(DocumentTree documentTree) { + private DocumentStructureWrapper toDocumentTreeData(DocumentTree documentTree) { - return new DocumentStructure(toEntryData(documentTree.getRoot())); + return new DocumentStructureWrapper(DocumentStructure.newBuilder().setRoot(toEntryData(documentTree.getRoot())).build()); } - private DocumentStructure.EntryData toEntryData(DocumentTree.Entry entry) { + private EntryData toEntryData(DocumentTree.Entry entry) { - Long[] atomicTextBlocks; + List atomicTextBlocks; if (entry.getNode().isLeaf()) { atomicTextBlocks = toAtomicTextBlockIds(entry.getNode().getLeafTextBlock()); } else { - atomicTextBlocks = new Long[]{}; + atomicTextBlocks = new ArrayList<>(); } Map properties = switch (entry.getType()) { @@ -81,77 +102,81 @@ public class DocumentDataMapper { default -> new HashMap<>(); }; - DocumentStructure.EntryData.EntryDataBuilder documentBuilder = DocumentStructure.EntryData.builder() - .treeId(toPrimitiveIntArray(entry.getTreeId())) - .children(entry.getChildren().stream().map(DocumentDataMapper::toEntryData).toList()) - .type(entry.getType()) - .atomicBlockIds(atomicTextBlocks) - .pageNumbers(entry.getNode().getPages().stream().map(Page::getNumber).map(Integer::longValue).toArray(Long[]::new)) - .properties(properties); + var documentBuilder = EntryData.newBuilder() + .addAllTreeId(entry.getTreeId()) + .addAllChildren(entry.getChildren() + .stream() + .map(DocumentDataMapper::toEntryData) + .toList()) + .setType(entry.getType()) + .addAllAtomicBlockIds(atomicTextBlocks) + .addAllPageNumbers(entry.getNode().getPages() + .stream() + .map(Page::getNumber) + .map(Integer::longValue) + .toList()) + .putAllProperties(properties); if (entry.getNode() != null) { - documentBuilder.engines(entry.getNode().getEngines()); + documentBuilder.addAllEngines(entry.getNode().getEngines()); } else { - documentBuilder.engines(new HashSet<>(Set.of(LayoutEngine.ALGORITHM))); + documentBuilder.addAllEngines(new HashSet<>(Set.of(LayoutEngine.ALGORITHM))); } return documentBuilder.build(); } - private Long[] toAtomicTextBlockIds(TextBlock textBlock) { + private List toAtomicTextBlockIds(TextBlock textBlock) { - return textBlock.getAtomicTextBlocks().stream().map(AtomicTextBlock::getId).toArray(Long[]::new); + return textBlock.getAtomicTextBlocks() + .stream() + .map(AtomicTextBlock::getId) + .toList(); } private DocumentPage toPageData(Page p) { - return DocumentPage.builder().rotation(p.getRotation()).height(p.getHeight()).width(p.getWidth()).number(p.getNumber()).build(); + return DocumentPage.newBuilder().setRotation(p.getRotation()).setHeight(p.getHeight()).setWidth(p.getWidth()).setNumber(p.getNumber()).build(); } private DocumentTextData toAtomicTextBlockData(AtomicTextBlock atomicTextBlock) { - return DocumentTextData.builder() - .id(atomicTextBlock.getId()) - .page(atomicTextBlock.getPage().getNumber().longValue()) - .searchText(atomicTextBlock.getSearchText()) - .numberOnPage(atomicTextBlock.getNumberOnPage()) - .start(atomicTextBlock.getTextRange().start()) - .end(atomicTextBlock.getTextRange().end()) - .lineBreaks(toPrimitiveIntArray(atomicTextBlock.getLineBreaks())) + return DocumentTextData.newBuilder() + .setId(atomicTextBlock.getId()) + .setPage(atomicTextBlock.getPage().getNumber().longValue()) + .setSearchText(atomicTextBlock.getSearchText()) + .setNumberOnPage(atomicTextBlock.getNumberOnPage()) + .setStart(atomicTextBlock.getTextRange().start()) + .setEnd(atomicTextBlock.getTextRange().end()) + .addAllLineBreaks(atomicTextBlock.getLineBreaks()) .build(); } private DocumentPositionData toAtomicPositionBlockData(AtomicTextBlock atomicTextBlock) { - return DocumentPositionData.builder() - .id(atomicTextBlock.getId()) - .positions(toPrimitiveFloatMatrix(atomicTextBlock.getPositions())) - .stringIdxToPositionIdx(toPrimitiveIntArray(atomicTextBlock.getStringIdxToPositionIdx())) + return DocumentPositionData.newBuilder() + .setId(atomicTextBlock.getId()) + .addAllPositions(toPositions(atomicTextBlock.getPositions())) + .addAllStringIdxToPositionIdx(atomicTextBlock.getStringIdxToPositionIdx()) .build(); } - private static float[][] toPrimitiveFloatMatrix(List positions) { + private static List toPositions(List rects) { - float[][] positionMatrix = new float[positions.size()][]; - for (int i = 0; i < positions.size(); i++) { - positionMatrix[i] = toArray(positions.get(i)); + List positions = new ArrayList<>(); + for (Rectangle2D rect : rects) { + positions.add(toPosition(rect)); } - return positionMatrix; + return positions; } - private static float[] toArray(Rectangle2D positions) { + private static Position toPosition(Rectangle2D rect) { - return new float[]{(float) positions.getMinX(), (float) positions.getMinY(), (float) positions.getWidth(), (float) positions.getHeight()}; - } - - - private int[] toPrimitiveIntArray(List list) { - - return list.stream().mapToInt(Integer::intValue).toArray(); + return Position.newBuilder().addValue((float) rect.getMinX()).addValue((float) rect.getMinY()).addValue((float) rect.getWidth()).addValue((float) rect.getHeight()).build(); } } diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/DocumentGraphMapper.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/DocumentGraphMapper.java index d0db608..bd09579 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/DocumentGraphMapper.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/DocumentGraphMapper.java @@ -8,10 +8,10 @@ import java.util.Map; import java.util.NoSuchElementException; import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentData; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPage; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPositionData; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructure; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentTextData; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPageProto.DocumentPage; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPositionDataProto.AllDocumentPositionData; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentTextDataProto.AllDocumentTextData; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.EntryDataProto.EntryData; import com.knecon.fforesight.service.layoutparser.processor.model.graph.DocumentTree; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Document; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.DuplicatedParagraph; @@ -41,27 +41,29 @@ public class DocumentGraphMapper { DocumentTree documentTree = new DocumentTree(document); Context context = new Context(documentData, documentTree); - context.pages.addAll(Arrays.stream(documentData.getDocumentPages()) + context.pages.addAll(documentData.getDocumentPages().getDocumentPagesList() + .stream() .map(DocumentGraphMapper::buildPage) .toList()); - context.documentTree.getRoot().getChildren().addAll(buildEntries(documentData.getDocumentStructure().getRoot().getChildren(), context)); + context.documentTree.getRoot().getChildren().addAll(buildEntries(documentData.getDocumentStructure().getRoot().getChildrenList(), context)); document.setDocumentTree(context.documentTree); document.setPages(new HashSet<>(context.pages)); - document.setNumberOfPages(documentData.getDocumentPages().length); + document.setNumberOfPages(documentData.getDocumentPages().getDocumentPagesCount()); document.setTextBlock(document.getTextBlock()); return document; } - private List buildEntries(List entries, Context context) { + private List buildEntries(List entries, Context context) { List newEntries = new LinkedList<>(); - for (DocumentStructure.EntryData entryData : entries) { + for (EntryData entryData : entries) { - List pages = Arrays.stream(entryData.getPageNumbers()) + List pages = entryData.getPageNumbersList() + .stream() .map(pageNumber -> getPage(pageNumber, context)) .toList(); @@ -74,12 +76,12 @@ public class DocumentGraphMapper { case FOOTER -> buildFooter(context); case TABLE -> buildTable(context, entryData.getProperties()); case TABLE_CELL -> buildTableCell(context, entryData.getProperties()); - case IMAGE -> buildImage(context, entryData.getProperties(), entryData.getPageNumbers()); + case IMAGE -> buildImage(context, entryData.getProperties(), entryData.getPageNumbersList()); default -> throw new UnsupportedOperationException("Not yet implemented for type " + entryData.getType()); }; - if (entryData.getAtomicBlockIds().length > 0) { - TextBlock textBlock = toTextBlock(entryData.getAtomicBlockIds(), context, node); + if (entryData.getAtomicBlockIdsCount() > 0) { + TextBlock textBlock = toTextBlock(entryData.getAtomicBlockIdsList(), context, node); node.setLeafTextBlock(textBlock); switch (entryData.getType()) { case HEADER -> pages.forEach(page -> page.setHeader((Header) node)); @@ -89,11 +91,10 @@ public class DocumentGraphMapper { .forEach(atb -> atb.getPage().getTextBlocksOnPage().add(atb)); } } - List treeId = Arrays.stream(entryData.getTreeId()).boxed() - .toList(); + List treeId = entryData.getTreeIdList(); node.setTreeId(treeId); - newEntries.add(DocumentTree.Entry.builder().treeId(treeId).children(buildEntries(entryData.getChildren(), context)).node(node).build()); + newEntries.add(DocumentTree.Entry.builder().treeId(treeId).children(buildEntries(entryData.getChildrenList(), context)).node(node).build()); } return newEntries; } @@ -105,10 +106,10 @@ public class DocumentGraphMapper { } - private Image buildImage(Context context, Map properties, Long[] pageNumbers) { + private Image buildImage(Context context, Map properties, List pageNumbers) { - assert pageNumbers.length == 1; - Page page = getPage(pageNumbers[0], context); + assert pageNumbers.size() == 1; + Page page = getPage(pageNumbers.get(0), context); var builder = Image.builder(); PropertiesMapper.parseImageProperties(properties, builder); return builder.documentTree(context.documentTree).page(page).build(); @@ -161,7 +162,7 @@ public class DocumentGraphMapper { DuplicatedParagraph duplicatedParagraph = DuplicatedParagraph.builder().documentTree(context.documentTree).build(); - Long[] unsortedTextblockIds = PropertiesMapper.getUnsortedTextblockIds(properties); + var unsortedTextblockIds = PropertiesMapper.getUnsortedTextblockIds(properties); duplicatedParagraph.setUnsortedLeafTextBlock(toTextBlock(unsortedTextblockIds, context, duplicatedParagraph)); return duplicatedParagraph; @@ -171,9 +172,9 @@ public class DocumentGraphMapper { } - private TextBlock toTextBlock(Long[] atomicTextBlockIds, Context context, SemanticNode parent) { + private TextBlock toTextBlock(List atomicTextBlockIds, Context context, SemanticNode parent) { - return Arrays.stream(atomicTextBlockIds) + return atomicTextBlockIds.stream() .map(atomicTextBlockId -> getAtomicTextBlock(context, parent, atomicTextBlockId)) .collect(new TextBlockCollector()); } @@ -181,10 +182,13 @@ public class DocumentGraphMapper { private AtomicTextBlock getAtomicTextBlock(Context context, SemanticNode parent, Long atomicTextBlockId) { - return AtomicTextBlock.fromAtomicTextBlockData(context.documentTextDataBlockData.get(Math.toIntExact(atomicTextBlockId)), - context.atomicPositionBlockData.get(Math.toIntExact(atomicTextBlockId)), + return AtomicTextBlock.fromAtomicTextBlockData(context.documentTextDataBlockData.getDocumentTextDataList() + .get(Math.toIntExact(atomicTextBlockId)), + context.atomicPositionBlockData.getDocumentPositionDataList() + .get(Math.toIntExact(atomicTextBlockId)), parent, - getPage(context.documentTextDataBlockData.get(Math.toIntExact(atomicTextBlockId)).getPage(), context)); + getPage(context.documentTextDataBlockData.getDocumentTextDataList() + .get(Math.toIntExact(atomicTextBlockId)).getPage(), context)); } @@ -207,18 +211,16 @@ public class DocumentGraphMapper { private final DocumentTree documentTree; private final List pages; - private final List documentTextDataBlockData; - private final List atomicPositionBlockData; + private final AllDocumentTextData documentTextDataBlockData; + private final AllDocumentPositionData atomicPositionBlockData; Context(DocumentData documentData, DocumentTree documentTree) { this.documentTree = documentTree; this.pages = new LinkedList<>(); - this.documentTextDataBlockData = Arrays.stream(documentData.getDocumentTextData()) - .toList(); - this.atomicPositionBlockData = Arrays.stream(documentData.getDocumentPositions()) - .toList(); + this.documentTextDataBlockData = documentData.getDocumentTextData(); + this.atomicPositionBlockData = documentData.getDocumentPositions(); } diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/PropertiesMapper.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/PropertiesMapper.java index 453838a..65587d2 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/PropertiesMapper.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/PropertiesMapper.java @@ -3,10 +3,11 @@ package com.knecon.fforesight.service.layoutparser.processor.services.mapper; import java.awt.geom.Rectangle2D; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Locale; import java.util.Map; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructure; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructureWrapper; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.DuplicatedParagraph; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Image; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.ImageType; @@ -20,11 +21,11 @@ public class PropertiesMapper { public static Map buildImageProperties(Image image) { Map properties = new HashMap<>(); - properties.put(DocumentStructure.ImageProperties.IMAGE_TYPE, image.getImageType().toString()); - properties.put(DocumentStructure.ImageProperties.TRANSPARENT, String.valueOf(image.isTransparent())); - properties.put(DocumentStructure.ImageProperties.POSITION, toString(image.getPosition())); - properties.put(DocumentStructure.ImageProperties.ID, image.getId()); - properties.put(DocumentStructure.ImageProperties.REPRESENTATION_HASH, image.getRepresentationHash()); + properties.put(DocumentStructureWrapper.ImageProperties.IMAGE_TYPE, image.getImageType().toString()); + properties.put(DocumentStructureWrapper.ImageProperties.TRANSPARENT, String.valueOf(image.isTransparent())); + properties.put(DocumentStructureWrapper.ImageProperties.POSITION, toString(image.getPosition())); + properties.put(DocumentStructureWrapper.ImageProperties.ID, image.getId()); + properties.put(DocumentStructureWrapper.ImageProperties.REPRESENTATION_HASH, image.getRepresentationHash()); return properties; } @@ -32,15 +33,19 @@ public class PropertiesMapper { public static Map buildTableCellProperties(TableCell tableCell) { Map properties = new HashMap<>(); - properties.put(DocumentStructure.TableCellProperties.ROW, String.valueOf(tableCell.getRow())); - properties.put(DocumentStructure.TableCellProperties.COL, String.valueOf(tableCell.getCol())); - properties.put(DocumentStructure.TableCellProperties.HEADER, String.valueOf(tableCell.isHeader())); + properties.put(DocumentStructureWrapper.TableCellProperties.ROW, String.valueOf(tableCell.getRow())); + properties.put(DocumentStructureWrapper.TableCellProperties.COL, String.valueOf(tableCell.getCol())); + properties.put(DocumentStructureWrapper.TableCellProperties.HEADER, String.valueOf(tableCell.isHeader())); if (tableCell.getPages().size() > 1 || tableCell.getBBox().keySet().size() > 1) { throw new IllegalArgumentException("TableCell can only occur on a single page!"); } - String bBoxString = toString(tableCell.getBBox().get(tableCell.getPages().stream().findFirst().get())); - properties.put(DocumentStructure.TableCellProperties.B_BOX, bBoxString); + String bBoxString = toString(tableCell.getBBox() + .get(tableCell.getPages() + .stream() + .findFirst() + .get())); + properties.put(DocumentStructureWrapper.TableCellProperties.B_BOX, bBoxString); return properties; } @@ -49,59 +54,62 @@ public class PropertiesMapper { public static Map buildTableProperties(Table table) { Map properties = new HashMap<>(); - properties.put(DocumentStructure.TableProperties.NUMBER_OF_ROWS, String.valueOf(table.getNumberOfRows())); - properties.put(DocumentStructure.TableProperties.NUMBER_OF_COLS, String.valueOf(table.getNumberOfCols())); + properties.put(DocumentStructureWrapper.TableProperties.NUMBER_OF_ROWS, String.valueOf(table.getNumberOfRows())); + properties.put(DocumentStructureWrapper.TableProperties.NUMBER_OF_COLS, String.valueOf(table.getNumberOfCols())); return properties; } public static void parseImageProperties(Map properties, Image.ImageBuilder builder) { - builder.imageType(parseImageType(properties.get(DocumentStructure.ImageProperties.IMAGE_TYPE))); - builder.transparent(Boolean.parseBoolean(properties.get(DocumentStructure.ImageProperties.TRANSPARENT))); - builder.position(DocumentStructure.parseRectangle2D(properties.get(DocumentStructure.ImageProperties.POSITION))); + builder.imageType(parseImageType(properties.get(DocumentStructureWrapper.ImageProperties.IMAGE_TYPE))); + builder.transparent(Boolean.parseBoolean(properties.get(DocumentStructureWrapper.ImageProperties.TRANSPARENT))); + builder.position(DocumentStructureWrapper.parseRectangle2D(properties.get(DocumentStructureWrapper.ImageProperties.POSITION))); } public static void parseTableCellProperties(Map properties, TableCell.TableCellBuilder builder) { - builder.row(Integer.parseInt(properties.get(DocumentStructure.TableCellProperties.ROW))); - builder.col(Integer.parseInt(properties.get(DocumentStructure.TableCellProperties.COL))); - builder.header(Boolean.parseBoolean(properties.get(DocumentStructure.TableCellProperties.HEADER))); - builder.bBox(DocumentStructure.parseRectangle2D(properties.get(DocumentStructure.TableCellProperties.B_BOX))); + builder.row(Integer.parseInt(properties.get(DocumentStructureWrapper.TableCellProperties.ROW))); + builder.col(Integer.parseInt(properties.get(DocumentStructureWrapper.TableCellProperties.COL))); + builder.header(Boolean.parseBoolean(properties.get(DocumentStructureWrapper.TableCellProperties.HEADER))); + builder.bBox(DocumentStructureWrapper.parseRectangle2D(properties.get(DocumentStructureWrapper.TableCellProperties.B_BOX))); } public static void parseTableProperties(Map properties, Table.TableBuilder builder) { - builder.numberOfRows(Integer.parseInt(properties.get(DocumentStructure.TableProperties.NUMBER_OF_ROWS))); - builder.numberOfCols(Integer.parseInt(properties.get(DocumentStructure.TableProperties.NUMBER_OF_COLS))); + builder.numberOfRows(Integer.parseInt(properties.get(DocumentStructureWrapper.TableProperties.NUMBER_OF_ROWS))); + builder.numberOfCols(Integer.parseInt(properties.get(DocumentStructureWrapper.TableProperties.NUMBER_OF_COLS))); } public static Map buildDuplicateParagraphProperties(DuplicatedParagraph duplicatedParagraph) { Map properties = new HashMap<>(); - properties.put(DocumentStructure.DuplicateParagraphProperties.UNSORTED_TEXTBLOCK_ID, Arrays.toString(toAtomicTextBlockIds(duplicatedParagraph.getUnsortedLeafTextBlock()))); + properties.put(DocumentStructureWrapper.DuplicateParagraphProperties.UNSORTED_TEXTBLOCK_ID, + Arrays.toString(toAtomicTextBlockIds(duplicatedParagraph.getUnsortedLeafTextBlock()))); return properties; } public static boolean isDuplicateParagraph(Map properties) { - return properties.containsKey(DocumentStructure.DuplicateParagraphProperties.UNSORTED_TEXTBLOCK_ID); + return properties.containsKey(DocumentStructureWrapper.DuplicateParagraphProperties.UNSORTED_TEXTBLOCK_ID); } - public static Long[] getUnsortedTextblockIds(Map properties) { + public static List getUnsortedTextblockIds(Map properties) { - return toLongArray(properties.get(DocumentStructure.DuplicateParagraphProperties.UNSORTED_TEXTBLOCK_ID)); + return toLongList(properties.get(DocumentStructureWrapper.DuplicateParagraphProperties.UNSORTED_TEXTBLOCK_ID)); } - public static Long[] toLongArray(String ids) { + public static List toLongList(String ids) { - return Arrays.stream(ids.substring(1, ids.length() - 1).trim().split(",")).map(Long::valueOf).toArray(Long[]::new); + return Arrays.stream(ids.substring(1, ids.length() - 1).trim().split(",")) + .map(Long::valueOf) + .toList(); } @@ -120,20 +128,23 @@ public class PropertiesMapper { public static String toString(Rectangle2D rectangle2D) { return String.format(Locale.US, - "%f%s%f%s%f%s%f", - rectangle2D.getX(), - DocumentStructure.RECTANGLE_DELIMITER, - rectangle2D.getY(), - DocumentStructure.RECTANGLE_DELIMITER, - rectangle2D.getWidth(), - DocumentStructure.RECTANGLE_DELIMITER, - rectangle2D.getHeight()); + "%f%s%f%s%f%s%f", + rectangle2D.getX(), + DocumentStructureWrapper.RECTANGLE_DELIMITER, + rectangle2D.getY(), + DocumentStructureWrapper.RECTANGLE_DELIMITER, + rectangle2D.getWidth(), + DocumentStructureWrapper.RECTANGLE_DELIMITER, + rectangle2D.getHeight()); } private static Long[] toAtomicTextBlockIds(TextBlock textBlock) { - return textBlock.getAtomicTextBlocks().stream().map(AtomicTextBlock::getId).toArray(Long[]::new); + return textBlock.getAtomicTextBlocks() + .stream() + .map(AtomicTextBlock::getId) + .toArray(Long[]::new); } } diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/TaasDocumentDataMapper.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/TaasDocumentDataMapper.java index 952a7a6..40ac14e 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/TaasDocumentDataMapper.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/services/mapper/TaasDocumentDataMapper.java @@ -6,7 +6,7 @@ import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.IntStream; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.internal.api.data.taas.ParagraphData; import com.knecon.fforesight.service.layoutparser.internal.api.data.taas.Range; import com.knecon.fforesight.service.layoutparser.internal.api.data.taas.ResearchDocumentData; diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/utils/PdfVisualisationUtility.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/utils/PdfVisualisationUtility.java index bcba9e2..b79cd8a 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/utils/PdfVisualisationUtility.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/utils/PdfVisualisationUtility.java @@ -14,7 +14,7 @@ import org.apache.pdfbox.pdmodel.PDPageContentStream; import org.apache.pdfbox.pdmodel.font.PDType1Font; import org.apache.pdfbox.pdmodel.font.Standard14Fonts; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.DocumentTree; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Document; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Page; @@ -117,6 +117,7 @@ public class PdfVisualisationUtility { case TABLE -> Color.ORANGE; case TABLE_CELL -> Color.GRAY; case IMAGE -> Color.MAGENTA; + case UNRECOGNIZED -> Color.PINK; }).build(); } diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/utils/ProtobufUtil.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/utils/ProtobufUtil.java new file mode 100644 index 0000000..8d1a5b1 --- /dev/null +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/utils/ProtobufUtil.java @@ -0,0 +1,42 @@ +package com.knecon.fforesight.service.layoutparser.processor.utils; + +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.zip.GZIPOutputStream; + +import com.google.protobuf.Message; +import com.google.protobuf.MessageOrBuilder; +import com.google.protobuf.Struct; +import com.google.protobuf.util.JsonFormat; + +import lombok.SneakyThrows; +import lombok.experimental.UtilityClass; + +@UtilityClass +public class ProtobufUtil { + + public static String toJson(MessageOrBuilder messageOrBuilder) throws IOException { + return JsonFormat.printer().print(messageOrBuilder); + } + + @SuppressWarnings("unchecked") + public static Message fromJson(String json) throws IOException { + Message.Builder structBuilder = Struct.newBuilder(); + JsonFormat.parser().ignoringUnknownFields().merge(json, structBuilder); + return structBuilder.build(); + } + + + @SneakyThrows + public File serializeToTempFile(T any) { + var tempFile = File.createTempFile("storage-protobuf", ".data"); + + try (var fos = new GZIPOutputStream(new BufferedOutputStream(new FileOutputStream(tempFile)))) { + any.writeTo(fos); + return tempFile; + } + } + +} \ No newline at end of file diff --git a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/visualization/LayoutGrid.java b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/visualization/LayoutGrid.java index a0c2e33..b2822fe 100644 --- a/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/visualization/LayoutGrid.java +++ b/layoutparser-service/layoutparser-service-processor/src/main/java/com/knecon/fforesight/service/layoutparser/processor/visualization/LayoutGrid.java @@ -16,7 +16,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngine; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.DuplicatedParagraph; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Headline; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Image; @@ -125,7 +125,7 @@ public class LayoutGrid extends LayoutGridLayerConfig { Map bBoxMap = section.getBBox(); - List subSections = section.streamAllSubNodesOfType(NodeType.SECTION) + List subSections = section.streamAllSubNodesOfType(NodeTypeProto.NodeType.SECTION) .toList(); Integer maxChildDepth = subSections.stream() .map(node -> node.getTreeId().size()) diff --git a/layoutparser-service/layoutparser-service-server/build.gradle.kts b/layoutparser-service/layoutparser-service-server/build.gradle.kts index c42913e..81a8667 100644 --- a/layoutparser-service/layoutparser-service-server/build.gradle.kts +++ b/layoutparser-service/layoutparser-service-server/build.gradle.kts @@ -29,7 +29,7 @@ dependencies { implementation(project(":layoutparser-service-processor")) implementation(project(":layoutparser-service-internal-api")) - implementation("com.iqser.red.commons:storage-commons:2.45.0") + implementation("com.iqser.red.commons:storage-commons:2.50.0") implementation("com.knecon.fforesight:tenant-commons:0.30.0") implementation("com.knecon.fforesight:tracing-commons:0.5.0") implementation("com.knecon.fforesight:lifecycle-commons:0.6.0") @@ -38,11 +38,14 @@ dependencies { implementation("com.amazonaws:aws-java-sdk-s3:1.12.536") implementation("org.springframework.cloud:spring-cloud-starter-openfeign:4.0.4") implementation("net.logstash.logback:logstash-logback-encoder:7.4") + implementation("ch.qos.logback:logback-classic") + implementation("com.pdftron:PDFNet:10.11.0") // for integration testing only testImplementation(project(":viewer-doc-processor")) testImplementation(project(":layoutparser-service-internal-api")) + testImplementation("com.google.protobuf:protobuf-java-util:4.27.1") testImplementation("org.springframework.boot:spring-boot-starter-amqp:${springBootStarterVersion}") testImplementation("org.springframework.boot:spring-boot-starter-test:${springBootStarterVersion}") diff --git a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/graph/DocumentGraphJsonWritingTest.java b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/graph/DocumentGraphJsonWritingTest.java index bac8d86..99e8c87 100644 --- a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/graph/DocumentGraphJsonWritingTest.java +++ b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/graph/DocumentGraphJsonWritingTest.java @@ -70,7 +70,7 @@ public class DocumentGraphJsonWritingTest extends BuildDocumentTest { var stem = Path.of("/tmp/DocumentGraphJsonWritingTest"); stem.toFile().mkdirs(); var tmpFilePath = stem.resolve(filename.getFileName()); - mapper.writeValue(new FileOutputStream(new File(tmpFilePath + "_structure" + ".json")), documentData.getDocumentStructure()); + mapper.writeValue(new FileOutputStream(new File(tmpFilePath + "_structure" + ".json")), documentData.getDocumentStructureWrapper()); mapper.writeValue(new FileOutputStream(new File(tmpFilePath + "_text" + ".json")), documentData.getDocumentTextData()); mapper.writeValue(new FileOutputStream(new File(tmpFilePath + "_positions" + ".json")), documentData.getDocumentPositions()); mapper.writeValue(new FileOutputStream(new File(tmpFilePath + "_pages" + ".json")), documentData.getDocumentPages()); diff --git a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/graph/DocumentGraphMappingTest.java b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/graph/DocumentGraphMappingTest.java index f8db426..2de181e 100644 --- a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/graph/DocumentGraphMappingTest.java +++ b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/graph/DocumentGraphMappingTest.java @@ -6,11 +6,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentData; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPage; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPositionData; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructure; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentTextData; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPageProto.AllDocumentPages; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentPositionDataProto.AllDocumentPositionData; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructureProto.DocumentStructure; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructureWrapper; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentTextDataProto.AllDocumentTextData; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.EntryDataProto.EntryData; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Document; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Table; import com.knecon.fforesight.service.layoutparser.processor.services.mapper.DocumentDataMapper; @@ -32,21 +34,21 @@ public class DocumentGraphMappingTest extends BuildDocumentTest { Document document = buildGraph(filename); DocumentData documentData = DocumentDataMapper.toDocumentData(document); - storageService.storeJSONObject(TenantContext.getTenantId(), filename + "_PAGES" + ".json", documentData.getDocumentPages()); - storageService.storeJSONObject(TenantContext.getTenantId(), filename + "_TEXT" + ".json", documentData.getDocumentTextData()); - storageService.storeJSONObject(TenantContext.getTenantId(), filename + "_POSITIONS" + ".json", documentData.getDocumentPositions()); - storageService.storeJSONObject(TenantContext.getTenantId(), filename + "_STRUCTURE" + ".json", documentData.getDocumentStructure()); + storageService.storeProtoObject(TenantContext.getTenantId(), filename + "_PAGES" + ".proto", documentData.getDocumentPages()); + storageService.storeProtoObject(TenantContext.getTenantId(), filename + "_TEXT" + ".proto", documentData.getDocumentTextData()); + storageService.storeProtoObject(TenantContext.getTenantId(), filename + "_POSITIONS" + ".proto", documentData.getDocumentPositions()); + storageService.storeProtoObject(TenantContext.getTenantId(), filename + "_STRUCTURE" + ".proto", documentData.getDocumentStructure()); - DocumentPage[] pageData = storageService.readJSONObject(TenantContext.getTenantId(), filename + "_PAGES" + ".json", DocumentPage[].class); - DocumentTextData[] atomicTextBlockData = storageService.readJSONObject(TenantContext.getTenantId(), filename + "_TEXT" + ".json", DocumentTextData[].class); - DocumentPositionData[] atomicPositionBlockData = storageService.readJSONObject(TenantContext.getTenantId(), - filename + "_POSITIONS" + ".json", - DocumentPositionData[].class); - DocumentStructure documentTreeData = storageService.readJSONObject(TenantContext.getTenantId(), filename + "_STRUCTURE" + ".json", DocumentStructure.class); + AllDocumentPages pageData = storageService.readProtoObject(TenantContext.getTenantId(), filename + "_PAGES" + ".proto", AllDocumentPages.parser()); + AllDocumentTextData atomicTextBlockData = storageService.readProtoObject(TenantContext.getTenantId(), filename + "_TEXT" + ".proto", AllDocumentTextData.parser()); + AllDocumentPositionData atomicPositionBlockData = storageService.readProtoObject(TenantContext.getTenantId(), + filename + "_POSITIONS" + ".proto", + AllDocumentPositionData.parser()); + DocumentStructure documentTreeData = storageService.readProtoObject(TenantContext.getTenantId(), filename + "_STRUCTURE" + ".proto", DocumentStructure.parser()); DocumentData documentData2 = DocumentData.builder() .documentPages(pageData) - .documentStructure(documentTreeData) + .documentStructureWrapper(new DocumentStructureWrapper(documentTreeData)) .documentTextData(atomicTextBlockData) .documentPositions(atomicPositionBlockData) .build(); @@ -73,10 +75,9 @@ public class DocumentGraphMappingTest extends BuildDocumentTest { private static boolean allTablesHavePositiveNumberOfRowsAndColumns(DocumentData documentData) { - return documentData.getDocumentStructure() - .streamAllEntries() + return documentData.getDocumentStructureWrapper().streamAllEntries() .filter(entryData -> entryData.getType().equals(NodeType.TABLE)) - .map(DocumentStructure.EntryData::getProperties) + .map(EntryData::getPropertiesMap) .map(properties -> { var builder = Table.builder(); PropertiesMapper.parseTableProperties(properties, builder); diff --git a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/services/RulingCleaningServiceTest.java b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/services/RulingCleaningServiceTest.java index 919aac5..747813d 100644 --- a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/services/RulingCleaningServiceTest.java +++ b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/services/RulingCleaningServiceTest.java @@ -17,8 +17,9 @@ import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentData; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructure; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.DocumentStructureWrapper; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.EntryDataProto.EntryData; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.internal.api.queue.LayoutParsingType; import com.knecon.fforesight.service.layoutparser.processor.model.PageContents; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Document; @@ -119,7 +120,7 @@ public class RulingCleaningServiceTest extends BuildDocumentTest { Map.of("file",filename.toFile().toString()))); DocumentData documentDataBefore = DocumentDataMapper.toDocumentData(documentGraphBefore); DocumentData documentDataAfter = DocumentDataMapper.toDocumentData(documentGraphAfter); - if (!compareStructures(documentDataBefore.getDocumentStructure(), documentDataAfter.getDocumentStructure())) { + if (!compareStructures(documentDataBefore.getDocumentStructureWrapper(), documentDataAfter.getDocumentStructureWrapper())) { String tmpFileNameBefore = "/tmp/before." + filename.getFileName().toString(); try (PDDocument pdDocument = Loader.loadPDF(filename.toFile())) { PdfDraw.drawDocumentGraph(pdDocument, documentGraphBefore); @@ -136,11 +137,11 @@ public class RulingCleaningServiceTest extends BuildDocumentTest { @SneakyThrows - private boolean compareStructures(DocumentStructure structure1, DocumentStructure structure2) { + private boolean compareStructures(DocumentStructureWrapper structure1, DocumentStructureWrapper structure2) { List listStructure1 = structure1.streamAllEntries() .filter(entryData -> entryData.getType().equals(NodeType.TABLE)) - .map(DocumentStructure.EntryData::getProperties) + .map(EntryData::getPropertiesMap) .map(properties -> { var builder = Table.builder(); PropertiesMapper.parseTableProperties(properties, builder); @@ -150,7 +151,7 @@ public class RulingCleaningServiceTest extends BuildDocumentTest { List
listStructure2 = structure2.streamAllEntries() .filter(entryData -> entryData.getType().equals(NodeType.TABLE)) - .map(DocumentStructure.EntryData::getProperties) + .map(EntryData::getPropertiesMap) .map(properties -> { var builder = Table.builder(); PropertiesMapper.parseTableProperties(properties, builder); diff --git a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/utils/visualizations/PdfDraw.java b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/utils/visualizations/PdfDraw.java index cdd247d..6abba6b 100644 --- a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/utils/visualizations/PdfDraw.java +++ b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/utils/visualizations/PdfDraw.java @@ -17,7 +17,7 @@ import org.apache.pdfbox.pdmodel.font.Standard14Fonts; import org.apache.pdfbox.util.Matrix; import org.springframework.core.io.ClassPathResource; -import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeType; +import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.NodeTypeProto.NodeType; import com.knecon.fforesight.service.layoutparser.processor.model.graph.DocumentTree; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Document; import com.knecon.fforesight.service.layoutparser.processor.model.graph.nodes.Page; @@ -233,6 +233,7 @@ public class PdfDraw { case TABLE -> Color.ORANGE; case TABLE_CELL -> Color.GRAY; case IMAGE -> Color.MAGENTA; + case UNRECOGNIZED -> Color.PINK; }).build(); }