com.microsoft.bingads.internal.RowValues Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of microsoft.bingads Show documentation
Show all versions of microsoft.bingads Show documentation
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.
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;
}
}