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

com.microsoft.bingads.internal.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.22.1
Show newest version
package com.microsoft.bingads.internal;

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 {

    protected String[] columns;
    protected Map mappings;

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

    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 - 2024 Weber Informatics LLC | Privacy Policy