1/*
2* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3*
4* Licensed under the Apache License, Version 2.0 (the "License").
5* You may not use this file except in compliance with the License.
6* A copy of the License is located at
7*
8* http://aws.amazon.com/apache2.0
9*
10* or in the "license" file accompanying this file. This file is distributed
11* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12* express or implied. See the License for the specific language governing
13* permissions and limitations under the License.
14*/
15
16#include <aws/s3/model/InputSerialization.h>
17#include <aws/core/utils/xml/XmlSerializer.h>
18#include <aws/core/utils/StringUtils.h>
19#include <aws/core/utils/memory/stl/AWSStringStream.h>
20
21#include <utility>
22
23using namespace Aws::Utils::Xml;
24using namespace Aws::Utils;
25
26namespace Aws
27{
28namespace S3
29{
30namespace Model
31{
32
33InputSerialization::InputSerialization() :
34 m_cSVHasBeenSet(false),
35 m_compressionType(CompressionType::NOT_SET),
36 m_compressionTypeHasBeenSet(false),
37 m_jSONHasBeenSet(false),
38 m_parquetHasBeenSet(false)
39{
40}
41
42InputSerialization::InputSerialization(const XmlNode& xmlNode) :
43 m_cSVHasBeenSet(false),
44 m_compressionType(CompressionType::NOT_SET),
45 m_compressionTypeHasBeenSet(false),
46 m_jSONHasBeenSet(false),
47 m_parquetHasBeenSet(false)
48{
49 *this = xmlNode;
50}
51
52InputSerialization& InputSerialization::operator =(const XmlNode& xmlNode)
53{
54 XmlNode resultNode = xmlNode;
55
56 if(!resultNode.IsNull())
57 {
58 XmlNode cSVNode = resultNode.FirstChild("CSV");
59 if(!cSVNode.IsNull())
60 {
61 m_cSV = cSVNode;
62 m_cSVHasBeenSet = true;
63 }
64 XmlNode compressionTypeNode = resultNode.FirstChild("CompressionType");
65 if(!compressionTypeNode.IsNull())
66 {
67 m_compressionType = CompressionTypeMapper::GetCompressionTypeForName(StringUtils::Trim(Aws::Utils::Xml::DecodeEscapedXmlText(compressionTypeNode.GetText()).c_str()).c_str());
68 m_compressionTypeHasBeenSet = true;
69 }
70 XmlNode jSONNode = resultNode.FirstChild("JSON");
71 if(!jSONNode.IsNull())
72 {
73 m_jSON = jSONNode;
74 m_jSONHasBeenSet = true;
75 }
76 XmlNode parquetNode = resultNode.FirstChild("Parquet");
77 if(!parquetNode.IsNull())
78 {
79 m_parquet = parquetNode;
80 m_parquetHasBeenSet = true;
81 }
82 }
83
84 return *this;
85}
86
87void InputSerialization::AddToNode(XmlNode& parentNode) const
88{
89 Aws::StringStream ss;
90 if(m_cSVHasBeenSet)
91 {
92 XmlNode cSVNode = parentNode.CreateChildElement("CSV");
93 m_cSV.AddToNode(cSVNode);
94 }
95
96 if(m_compressionTypeHasBeenSet)
97 {
98 XmlNode compressionTypeNode = parentNode.CreateChildElement("CompressionType");
99 compressionTypeNode.SetText(CompressionTypeMapper::GetNameForCompressionType(m_compressionType));
100 }
101
102 if(m_jSONHasBeenSet)
103 {
104 XmlNode jSONNode = parentNode.CreateChildElement("JSON");
105 m_jSON.AddToNode(jSONNode);
106 }
107
108 if(m_parquetHasBeenSet)
109 {
110 XmlNode parquetNode = parentNode.CreateChildElement("Parquet");
111 m_parquet.AddToNode(parquetNode);
112 }
113
114}
115
116} // namespace Model
117} // namespace S3
118} // namespace Aws
119