-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TH2-3857 #15
Open
eugene-zheltov
wants to merge
51
commits into
dev
Choose a base branch
from
TH2-3857
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
TH2-3857 #15
Changes from 29 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
e69c873
Self-closing tag and th2-codec error events (#13)
eugene-zheltov 717b38d
[TH2-3778] Set codec version from snapshot with fixes
eugene-zheltov 6ab2f0b
[TH2-3778] Set codec version from snapshot with fixes
eugene-zheltov 75773ee
[TH2-3778] Change verison of codec core
eugene-zheltov d785d78
[TH2-3778] Change verison of codec core
eugene-zheltov 542bde8
[TH2-3778] Change version of codec core
eugene-zheltov a47c0b1
[TH2-3778] Change version of codec core
eugene-zheltov 09e44f9
[TH2-3778] Change version of codec core to 4.7.1-TH2-3778-tmp-2495038…
eugene-zheltov 1e3527b
[TH2-3857] tmp
eugene-zheltov 4764809
[TH2-3857] tmp-2
eugene-zheltov 4f61923
[TH2-3857] tmp-3
eugene-zheltov 8d785c8
[TH2-3857] tmp-4
eugene-zheltov 74c2c5a
[TH2-3857] tmp-4
eugene-zheltov 68f0a0c
[TH2-3857] Successful parsing; to be refactored
eugene-zheltov cec90fe
[TH2-3857] Refactor XMLSchemaCore
eugene-zheltov 16f85d0
[TH2-3857] tmp-5
eugene-zheltov 07d3a28
TH2-3778 (#14)
eugene-zheltov 8cfce4c
[TH2-3857] tmp-6
eugene-zheltov 8cf2d64
[TH2-3857] Fix the absence of some list values
eugene-zheltov 62c3030
[TH2-3857] Remove prints and change xsd processing a bit
eugene-zheltov 24d6d97
[TH2-3857] Disable tests
eugene-zheltov 06e3d3e
[TH2-3857] Minor changes
eugene-zheltov 725b78e
Merge branch 'master' into TH2-3857
eugene-zheltov 0c6a616
[TH2-3857] Move StreamReaderDelegateDecorator
eugene-zheltov 7697106
[TH2-3857] Chagne xsdProperties loading
eugene-zheltov 468a849
[TH2-3857] Add th2-id to the log when th2-codec-xml-via-xsd cannot de…
eugene-zheltov 6e996da
[TH2-3857] Minor changes
eugene-zheltov 90a4ce7
Merge remote-tracking branch 'origin/TH2-3857' into TH2-3857
eugene-zheltov 652cf79
[TH2-3857] tmp
eugene-zheltov c8474de
[TH2-3857] tmp 2
eugene-zheltov 14be420
[TH2-3857] tmp 3
eugene-zheltov 71ff9c2
[TH2-3857] Implement new decoding
eugene-zheltov 17507d0
[TH2-3857] Remove comments
eugene-zheltov 207e5c1
[TH2-3857] Fix repeated elements of lists
eugene-zheltov cba5310
[TH2-3857] Fix missing empty tags
eugene-zheltov 3b6e346
[TH2-3857] Remove usage of XmlPipelineCodec for now
eugene-zheltov fe488b8
[TH2-3857] Remove garbage
eugene-zheltov 8d5a873
[TH2-3857] Fix truncated values
eugene-zheltov cea2111
[TH2-3857] Add missing attributes
eugene-zheltov bbe67f7
[TH2-3857] Disable test
eugene-zheltov 0fb452b
[TH2-3857] Add prefixes to node names
eugene-zheltov 7791388
[TH2-3857] Remove redundant ":" from node names
eugene-zheltov 06dc868
[TH2-3857] Migrated to StAX
Nikita-Smirnov-Exactpro 23f0005
[TH2-3857] Fixed problem related to release sub-nodes
Nikita-Smirnov-Exactpro a6aab96
[TH2-3857] Updated common libraries
Nikita-Smirnov-Exactpro 7a66236
[TH2-3857] Consider empty xmlns property
eugene-zheltov a127615
[TH2-3857] Add a new parameter encodeValidation
eugene-zheltov 3f9843f
[TH2-3857] Update dev-docker-publish.yml and docker-publish.yml
eugene-zheltov 1d327a4
[TH2-3857] Update common version
eugene-zheltov bb17598
[TH2-3857] Update codec-core version
eugene-zheltov 0510415
[TH2-3857] Update slf4j dependencies
eugene-zheltov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
src/main/kotlin/com/exactpro/th2/codec/xml/NodeContent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
package com.exactpro.th2.codec.xml | ||
|
||
import com.exactpro.th2.common.grpc.ListValue | ||
import com.exactpro.th2.common.grpc.Message | ||
import com.exactpro.th2.common.grpc.Value | ||
import com.exactpro.th2.common.grpc.Value.KindCase.SIMPLE_VALUE | ||
import com.exactpro.th2.common.grpc.Value.KindCase.MESSAGE_VALUE | ||
import com.exactpro.th2.common.grpc.Value.KindCase.LIST_VALUE | ||
import com.exactpro.th2.common.message.addField | ||
import com.exactpro.th2.common.message.message | ||
import com.exactpro.th2.common.value.add | ||
import com.exactpro.th2.common.value.listValue | ||
import javax.xml.namespace.QName | ||
|
||
class NodeContent(val nodeName: QName) { | ||
val attributes: MutableMap<String, String> = mutableMapOf() | ||
val childNodes: MutableMap<QName, MutableList<NodeContent>> = mutableMapOf() | ||
Nikita-Smirnov-Exactpro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
var text: String? = null | ||
var type: Value.KindCase = SIMPLE_VALUE | ||
|
||
fun StreamReaderDelegateDecorator.addAttributes() { | ||
if (attributeCount > 0) { | ||
for (i in 0 until attributeCount) { | ||
attributes[getAttributeName(i).localPart] = getAttributeValue(i) | ||
} | ||
} | ||
} | ||
|
||
fun setMessageType() { | ||
Nikita-Smirnov-Exactpro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (this.type == SIMPLE_VALUE) { | ||
this.type = MESSAGE_VALUE | ||
} | ||
} | ||
|
||
fun release(messageBuilder: Message.Builder) { | ||
|
||
// TODO: don't forget about attributes | ||
|
||
childNodes.forEach { | ||
messageBuilder.addNode(it.key, it.value) | ||
} | ||
|
||
messageBuilder.addField(nodeName.localPart, this) | ||
} | ||
|
||
private fun Message.Builder.addNode(nodeName: QName, nodeList: MutableList<NodeContent>) { | ||
println("Message addNode $nodeName") | ||
nodeList.forEach { node -> | ||
when (node.type) { | ||
MESSAGE_VALUE -> { | ||
val count = nodeList.count() | ||
if (count > 1) { | ||
val list = listValue() | ||
|
||
nodeList.forEach { nodeContent -> | ||
nodeContent.childNodes.forEach { | ||
list.addNode(it.key, it.value) | ||
} | ||
} | ||
|
||
addField(nodeName.localPart, list) | ||
} else if (count == 1) { | ||
val message = message() | ||
|
||
node.childNodes.forEach { | ||
message.addNode(it.key, it.value) | ||
} | ||
|
||
addField(nodeName.localPart, message) | ||
} | ||
} | ||
|
||
// TODO: mb I it's possible to have a list of simple values too | ||
SIMPLE_VALUE -> addField(node.nodeName.localPart, node.text) | ||
|
||
else -> throw IllegalArgumentException("Node $node can be either MESSAGE_VALUE or SIMPLE_VALUE") | ||
} | ||
} | ||
} | ||
|
||
private fun ListValue.Builder.addNode(nodeName: QName, nodeList: MutableList<NodeContent>) { | ||
println("List addNode $nodeName, nodeList $nodeList") | ||
nodeList.forEach { node -> | ||
when (node.type) { | ||
MESSAGE_VALUE -> { | ||
val count = nodeList.count() | ||
if (count > 1) { | ||
val list = listValue() | ||
|
||
node.childNodes.forEach { | ||
list.addNode(it.key, it.value) | ||
} | ||
|
||
add(list) | ||
} else if (count == 1) { | ||
val message = message() | ||
|
||
node.childNodes.forEach { | ||
message.addNode(it.key, it.value) | ||
} | ||
|
||
add(message) | ||
} | ||
} | ||
|
||
// TODO: mb I it's possible to have a list of simple values too | ||
SIMPLE_VALUE -> add(node.text) | ||
|
||
else -> throw IllegalArgumentException("Node $node can be either MESSAGE_VALUE or SIMPLE_VALUE") | ||
} | ||
} | ||
} | ||
|
||
override fun toString(): String { | ||
return "NodeContent(attributes=$attributes, childNodes=$childNodes, text=$text, type=$type)" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please write about used technology