All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.resourcemanager.datafactory.models.XmlReadSettings Maven / Gradle / Ivy

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.datafactory.models;

import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Xml read settings.
 */
@Fluent
public final class XmlReadSettings extends FormatReadSettings {
    /*
     * The read setting type.
     */
    private String type = "XmlReadSettings";

    /*
     * Compression settings.
     */
    private CompressionReadSettings compressionProperties;

    /*
     * Indicates what validation method is used when reading the xml files. Allowed values: 'none', 'xsd', or 'dtd'.
     * Type: string (or Expression with resultType string).
     */
    private Object validationMode;

    /*
     * Indicates whether type detection is enabled when reading the xml files. Type: boolean (or Expression with
     * resultType boolean).
     */
    private Object detectDataType;

    /*
     * Indicates whether namespace is enabled when reading the xml files. Type: boolean (or Expression with resultType
     * boolean).
     */
    private Object namespaces;

    /*
     * Namespace uri to prefix mappings to override the prefixes in column names when namespace is enabled, if no prefix
     * is defined for a namespace uri, the prefix of xml element/attribute name in the xml data file will be used.
     * Example: "{"http://www.example.com/xml":"prefix"}" Type: object (or Expression with resultType object).
     */
    private Object namespacePrefixes;

    /**
     * Creates an instance of XmlReadSettings class.
     */
    public XmlReadSettings() {
    }

    /**
     * Get the type property: The read setting type.
     * 
     * @return the type value.
     */
    @Override
    public String type() {
        return this.type;
    }

    /**
     * Get the compressionProperties property: Compression settings.
     * 
     * @return the compressionProperties value.
     */
    public CompressionReadSettings compressionProperties() {
        return this.compressionProperties;
    }

    /**
     * Set the compressionProperties property: Compression settings.
     * 
     * @param compressionProperties the compressionProperties value to set.
     * @return the XmlReadSettings object itself.
     */
    public XmlReadSettings withCompressionProperties(CompressionReadSettings compressionProperties) {
        this.compressionProperties = compressionProperties;
        return this;
    }

    /**
     * Get the validationMode property: Indicates what validation method is used when reading the xml files. Allowed
     * values: 'none', 'xsd', or 'dtd'. Type: string (or Expression with resultType string).
     * 
     * @return the validationMode value.
     */
    public Object validationMode() {
        return this.validationMode;
    }

    /**
     * Set the validationMode property: Indicates what validation method is used when reading the xml files. Allowed
     * values: 'none', 'xsd', or 'dtd'. Type: string (or Expression with resultType string).
     * 
     * @param validationMode the validationMode value to set.
     * @return the XmlReadSettings object itself.
     */
    public XmlReadSettings withValidationMode(Object validationMode) {
        this.validationMode = validationMode;
        return this;
    }

    /**
     * Get the detectDataType property: Indicates whether type detection is enabled when reading the xml files. Type:
     * boolean (or Expression with resultType boolean).
     * 
     * @return the detectDataType value.
     */
    public Object detectDataType() {
        return this.detectDataType;
    }

    /**
     * Set the detectDataType property: Indicates whether type detection is enabled when reading the xml files. Type:
     * boolean (or Expression with resultType boolean).
     * 
     * @param detectDataType the detectDataType value to set.
     * @return the XmlReadSettings object itself.
     */
    public XmlReadSettings withDetectDataType(Object detectDataType) {
        this.detectDataType = detectDataType;
        return this;
    }

    /**
     * Get the namespaces property: Indicates whether namespace is enabled when reading the xml files. Type: boolean (or
     * Expression with resultType boolean).
     * 
     * @return the namespaces value.
     */
    public Object namespaces() {
        return this.namespaces;
    }

    /**
     * Set the namespaces property: Indicates whether namespace is enabled when reading the xml files. Type: boolean (or
     * Expression with resultType boolean).
     * 
     * @param namespaces the namespaces value to set.
     * @return the XmlReadSettings object itself.
     */
    public XmlReadSettings withNamespaces(Object namespaces) {
        this.namespaces = namespaces;
        return this;
    }

    /**
     * Get the namespacePrefixes property: Namespace uri to prefix mappings to override the prefixes in column names
     * when namespace is enabled, if no prefix is defined for a namespace uri, the prefix of xml element/attribute name
     * in the xml data file will be used. Example: "{"http://www.example.com/xml":"prefix"}" Type: object (or Expression
     * with resultType object).
     * 
     * @return the namespacePrefixes value.
     */
    public Object namespacePrefixes() {
        return this.namespacePrefixes;
    }

    /**
     * Set the namespacePrefixes property: Namespace uri to prefix mappings to override the prefixes in column names
     * when namespace is enabled, if no prefix is defined for a namespace uri, the prefix of xml element/attribute name
     * in the xml data file will be used. Example: "{"http://www.example.com/xml":"prefix"}" Type: object (or Expression
     * with resultType object).
     * 
     * @param namespacePrefixes the namespacePrefixes value to set.
     * @return the XmlReadSettings object itself.
     */
    public XmlReadSettings withNamespacePrefixes(Object namespacePrefixes) {
        this.namespacePrefixes = namespacePrefixes;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        if (compressionProperties() != null) {
            compressionProperties().validate();
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("type", this.type);
        jsonWriter.writeJsonField("compressionProperties", this.compressionProperties);
        jsonWriter.writeUntypedField("validationMode", this.validationMode);
        jsonWriter.writeUntypedField("detectDataType", this.detectDataType);
        jsonWriter.writeUntypedField("namespaces", this.namespaces);
        jsonWriter.writeUntypedField("namespacePrefixes", this.namespacePrefixes);
        if (additionalProperties() != null) {
            for (Map.Entry additionalProperty : additionalProperties().entrySet()) {
                jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue());
            }
        }
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of XmlReadSettings from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of XmlReadSettings if the JsonReader was pointing to an instance of it, or null if it was
     * pointing to JSON null.
     * @throws IOException If an error occurs while reading the XmlReadSettings.
     */
    public static XmlReadSettings fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            XmlReadSettings deserializedXmlReadSettings = new XmlReadSettings();
            Map additionalProperties = null;
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("type".equals(fieldName)) {
                    deserializedXmlReadSettings.type = reader.getString();
                } else if ("compressionProperties".equals(fieldName)) {
                    deserializedXmlReadSettings.compressionProperties = CompressionReadSettings.fromJson(reader);
                } else if ("validationMode".equals(fieldName)) {
                    deserializedXmlReadSettings.validationMode = reader.readUntyped();
                } else if ("detectDataType".equals(fieldName)) {
                    deserializedXmlReadSettings.detectDataType = reader.readUntyped();
                } else if ("namespaces".equals(fieldName)) {
                    deserializedXmlReadSettings.namespaces = reader.readUntyped();
                } else if ("namespacePrefixes".equals(fieldName)) {
                    deserializedXmlReadSettings.namespacePrefixes = reader.readUntyped();
                } else {
                    if (additionalProperties == null) {
                        additionalProperties = new LinkedHashMap<>();
                    }

                    additionalProperties.put(fieldName, reader.readUntyped());
                }
            }
            deserializedXmlReadSettings.withAdditionalProperties(additionalProperties);

            return deserializedXmlReadSettings;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy