com.iab.gpp.encoder.section.UsCa 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.UsCaField;
import com.iab.gpp.encoder.segment.EncodableSegment;
import com.iab.gpp.encoder.segment.UsCaCoreSegment;
import com.iab.gpp.encoder.segment.UsCaGpcSegment;
public class UsCa extends AbstractLazilyEncodableSection {
public static int ID = 8;
public static int VERSION = 1;
public static String NAME = "usca";
public UsCa() {
super();
}
public UsCa(String encodedString) {
super();
decode(encodedString);
}
@Override
public int getId() {
return UsCa.ID;
}
@Override
public String getName() {
return UsCa.NAME;
}
@Override
public int getVersion() {
return UsCa.VERSION;
}
@Override
protected List initializeSegments() {
List segments = new ArrayList<>();
segments.add(new UsCaCoreSegment());
segments.add(new UsCaGpcSegment());
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(UsCaField.GPC_SEGMENT_INCLUDED, true);
segments.get(1).decode(encodedSegments[1]);
} else {
segments.get(1).setFieldValue(UsCaField.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(UsCaField.GPC_SEGMENT_INCLUDED).equals(true)) {
encodedSegments.add(segments.get(1).encode());
}
}
return String.join(".", encodedSegments);
}
public Integer getSaleOptOutNotice() {
return (Integer) this.getFieldValue(UsCaField.SALE_OPT_OUT_NOTICE);
}
public Integer getSensitiveDataLimitUseNotice() {
return (Integer) this.getFieldValue(UsCaField.SENSITIVE_DATA_LIMIT_USE_NOTICE);
}
public Integer getSharingOptOutNotice() {
return (Integer) this.getFieldValue(UsCaField.SHARING_OPT_OUT_NOTICE);
}
public Integer getSaleOptOut() {
return (Integer) this.getFieldValue(UsCaField.SALE_OPT_OUT);
}
public Integer getSharingOptOut() {
return (Integer) this.getFieldValue(UsCaField.SHARING_OPT_OUT);
}
@SuppressWarnings("unchecked")
public List getSensitiveDataProcessing() {
return (List) this.getFieldValue(UsCaField.SENSITIVE_DATA_PROCESSING);
}
@SuppressWarnings("unchecked")
public List getKnownChildSensitiveDataConsents() {
return (List) this.getFieldValue(UsCaField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS);
}
public Integer getPersonalDataConsents() {
return (Integer) this.getFieldValue(UsCaField.PERSONAL_DATA_CONSENTS);
}
public Integer getMspaCoveredTransaction() {
return (Integer) this.getFieldValue(UsCaField.MSPA_COVERED_TRANSACTION);
}
public Integer getMspaOptOutOptionMode() {
return (Integer) this.getFieldValue(UsCaField.MSPA_OPT_OUT_OPTION_MODE);
}
public Integer getMspaServiceProviderMode() {
return (Integer) this.getFieldValue(UsCaField.MSPA_SERVICE_PROVIDER_MODE);
}
public Integer getGpcSegmentType() {
return (Integer) this.getFieldValue(UsCaField.GPC_SEGMENT_TYPE);
}
public Boolean getGpcSegmentIncluded() {
return (Boolean) this.getFieldValue(UsCaField.GPC_SEGMENT_INCLUDED);
}
public Boolean getGpc() {
return (Boolean) this.getFieldValue(UsCaField.GPC);
}
}