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

com.microsoft.bingads.v10.internal.bulk.RowValues Maven / Gradle / Ivy

Go to download

The Bing Ads Java SDK is a library improving developer experience when working with the Bing Ads services by providing high-level access to features such as Bulk API, OAuth Authorization and SOAP API.

There is a newer version: 13.0.23.2
Show newest version
package com.microsoft.bingads.v10.internal.bulk;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

/**
 * Encapsulates a row of csv values and the corresponding header mappings for that array
 *
 */
public class RowValues {

    private String[] columns;
    private Map mappings;

    public RowValues(String[] columns, Map mappings) {
        this.columns = columns;
        this.mappings = mappings;
    }

    public RowValues(Map rowValues) {
        this.mappings = CsvHeaders.getMappings();
        this.columns = new String[this.mappings.keySet().size()];

        for (String key : rowValues.keySet()) {
            this.put(key, rowValues.get(key));
        }
    }

    public RowValues() {
        this(new HashMap());
    }

    public String get(String header) {

        return columns[this.mappings.get(header)];
    }

    public String tryGet(String header) {
        if (!this.mappings.containsKey(header) || this.mappings.get(header) == null) {
            return null;
        }

        return this.get(header);
    }

    public void put(String header, String value) {
        columns[mappings.get(header)] = value;
    }

    public boolean containsHeader(String header) {
        return mappings.containsKey(header);
    }

    public String[] getColumns() {
        return this.columns;
    }

    public Map toMap() {
        Map values = new HashMap();

        for (Entry entry : this.mappings.entrySet()) {
            String value = this.columns[entry.getValue()];

            values.put(entry.getKey(), value);
        }

        return values;
    }

    public String toDebugString() {
        String result = "";

        for (Entry entry : this.mappings.entrySet()) {
            String value = this.columns[entry.getValue()];

            result += String.format("%s = '%s'", entry.getKey(), value) + "; ";
        }

        return result;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy