com.iab.gpp.encoder.section.UsCt 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.UsCtField;
import com.iab.gpp.encoder.segment.EncodableSegment;
import com.iab.gpp.encoder.segment.UsCtCoreSegment;
import com.iab.gpp.encoder.segment.UsCtGpcSegment;
public class UsCt extends AbstractLazilyEncodableSection {
public static int ID = 12;
public static int VERSION = 1;
public static String NAME = "usct";
public UsCt() {
super();
}
public UsCt(String encodedString) {
super();
decode(encodedString);
}
@Override
public int getId() {
return UsCt.ID;
}
@Override
public String getName() {
return UsCt.NAME;
}
@Override
public int getVersion() {
return UsCt.VERSION;
}
@Override
protected List initializeSegments() {
List segments = new ArrayList<>();
segments.add(new UsCtCoreSegment());
segments.add(new UsCtGpcSegment());
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(UsCtField.GPC_SEGMENT_INCLUDED, true);
segments.get(1).decode(encodedSegments[1]);
} else {
segments.get(1).setFieldValue(UsCtField.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(UsCtField.GPC_SEGMENT_INCLUDED).equals(true)) {
encodedSegments.add(segments.get(1).encode());
}
}
return String.join(".", encodedSegments);
}
public Integer getSharingNotice() {
return (Integer) this.getFieldValue(UsCtField.SHARING_NOTICE);
}
public Integer getSaleOptOutNotice() {
return (Integer) this.getFieldValue(UsCtField.SALE_OPT_OUT_NOTICE);
}
public Integer getTargetedAdvertisingOptOutNotice() {
return (Integer) this.getFieldValue(UsCtField.TARGETED_ADVERTISING_OPT_OUT_NOTICE);
}
public Integer getSaleOptOut() {
return (Integer) this.getFieldValue(UsCtField.SALE_OPT_OUT);
}
public Integer getTargetedAdvertisingOptOut() {
return (Integer) this.getFieldValue(UsCtField.TARGETED_ADVERTISING_OPT_OUT);
}
@SuppressWarnings("unchecked")
public List getSensitiveDataProcessing() {
return (List) this.getFieldValue(UsCtField.SENSITIVE_DATA_PROCESSING);
}
@SuppressWarnings("unchecked")
public List getKnownChildSensitiveDataConsents() {
return (List) this.getFieldValue(UsCtField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS);
}
public Integer getMspaCoveredTransaction() {
return (Integer) this.getFieldValue(UsCtField.MSPA_COVERED_TRANSACTION);
}
public Integer getMspaOptOutOptionMode() {
return (Integer) this.getFieldValue(UsCtField.MSPA_OPT_OUT_OPTION_MODE);
}
public Integer getMspaServiceProviderMode() {
return (Integer) this.getFieldValue(UsCtField.MSPA_SERVICE_PROVIDER_MODE);
}
public Integer getGpcSegmentType() {
return (Integer) this.getFieldValue(UsCtField.GPC_SEGMENT_TYPE);
}
public Boolean getGpcSegmentIncluded() {
return (Boolean) this.getFieldValue(UsCtField.GPC_SEGMENT_INCLUDED);
}
public Boolean getGpc() {
return (Boolean) this.getFieldValue(UsCtField.GPC);
}
}