com.iab.gpp.encoder.section.UsOr Maven / Gradle / Ivy
The newest version!
package com.iab.gpp.encoder.section;
import java.util.ArrayList;
import java.util.List;
import com.iab.gpp.encoder.field.UsOrField;
import com.iab.gpp.encoder.segment.EncodableSegment;
import com.iab.gpp.encoder.segment.UsOrCoreSegment;
import com.iab.gpp.encoder.segment.UsOrGpcSegment;
public class UsOr extends AbstractLazilyEncodableSection {
public static int ID = 15;
public static int VERSION = 1;
public static String NAME = "usor";
public UsOr() {
super();
}
public UsOr(String encodedString) {
super();
decode(encodedString);
}
@Override
public int getId() {
return UsOr.ID;
}
@Override
public String getName() {
return UsOr.NAME;
}
@Override
public int getVersion() {
return UsOr.VERSION;
}
@Override
protected List initializeSegments() {
List segments = new ArrayList<>();
segments.add(new UsOrCoreSegment());
segments.add(new UsOrGpcSegment());
return segments;
}
@Override
protected List decodeSection(String encodedString) {
List segments = initializeSegments();
if(encodedString != null && !encodedString.isEmpty()) {
String[] encodedSegments = encodedString.split("\\.");
if(encodedSegments.length > 0) {
segments.get(0).decode(encodedSegments[0]);
}
if(encodedSegments.length > 1) {
segments.get(1).setFieldValue(UsOrField.GPC_SEGMENT_INCLUDED, true);
segments.get(1).decode(encodedSegments[1]);
} else {
segments.get(1).setFieldValue(UsOrField.GPC_SEGMENT_INCLUDED, false);
}
}
return segments;
}
@Override
protected String encodeSection(List segments) {
List encodedSegments = new ArrayList<>();
if(!segments.isEmpty()) {
encodedSegments.add(segments.get(0).encode());
if(segments.size() >= 2 && segments.get(1).getFieldValue(UsOrField.GPC_SEGMENT_INCLUDED).equals(true)) {
encodedSegments.add(segments.get(1).encode());
}
}
return String.join(".", encodedSegments);
}
public Integer getProcessingNotice() {
return (Integer) this.getFieldValue(UsOrField.PROCESSING_NOTICE);
}
public Integer getSaleOptOutNotice() {
return (Integer) this.getFieldValue(UsOrField.SALE_OPT_OUT_NOTICE);
}
public Integer getTargetedAdvertisingOptOutNotice() {
return (Integer) this.getFieldValue(UsOrField.TARGETED_ADVERTISING_OPT_OUT_NOTICE);
}
public Integer getSaleOptOut() {
return (Integer) this.getFieldValue(UsOrField.SALE_OPT_OUT);
}
public Integer getTargetedAdvertisingOptOut() {
return (Integer) this.getFieldValue(UsOrField.TARGETED_ADVERTISING_OPT_OUT);
}
@SuppressWarnings("unchecked")
public List getSensitiveDataProcessing() {
return (List) this.getFieldValue(UsOrField.SENSITIVE_DATA_PROCESSING);
}
@SuppressWarnings("unchecked")
public List getKnownChildSensitiveDataConsents() {
return (List) this.getFieldValue(UsOrField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS);
}
public Integer getAdditionalDataProcessingConsent() {
return (Integer) this.getFieldValue(UsOrField.ADDITIONAL_DATA_PROCESSING_CONSENT);
}
public Integer getMspaCoveredTransaction() {
return (Integer) this.getFieldValue(UsOrField.MSPA_COVERED_TRANSACTION);
}
public Integer getMspaOptOutOptionMode() {
return (Integer) this.getFieldValue(UsOrField.MSPA_OPT_OUT_OPTION_MODE);
}
public Integer getMspaServiceProviderMode() {
return (Integer) this.getFieldValue(UsOrField.MSPA_SERVICE_PROVIDER_MODE);
}
public Integer getGpcSegmentType() {
return (Integer) this.getFieldValue(UsOrField.GPC_SEGMENT_TYPE);
}
public Boolean getGpcSegmentIncluded() {
return (Boolean) this.getFieldValue(UsOrField.GPC_SEGMENT_INCLUDED);
}
public Boolean getGpc() {
return (Boolean) this.getFieldValue(UsOrField.GPC);
}
}