├── .github
└── workflows
│ └── main.yml
├── .gitignore
├── LICENSE
├── README.md
├── iabgpp-encoder
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iab
│ │ └── gpp
│ │ └── encoder
│ │ ├── GppModel.java
│ │ ├── base64
│ │ ├── AbstractBase64UrlEncoder.java
│ │ ├── CompressedBase64UrlEncoder.java
│ │ └── TraditionalBase64UrlEncoder.java
│ │ ├── bitstring
│ │ └── BitStringEncoder.java
│ │ ├── datatype
│ │ ├── AbstractEncodableBitStringDataType.java
│ │ ├── DataType.java
│ │ ├── EncodableArrayOfFixedIntegerRanges.java
│ │ ├── EncodableBoolean.java
│ │ ├── EncodableDataType.java
│ │ ├── EncodableDatetime.java
│ │ ├── EncodableFibonacciInteger.java
│ │ ├── EncodableFibonacciIntegerRange.java
│ │ ├── EncodableFixedBitfield.java
│ │ ├── EncodableFixedInteger.java
│ │ ├── EncodableFixedIntegerList.java
│ │ ├── EncodableFixedIntegerRange.java
│ │ ├── EncodableFixedString.java
│ │ ├── EncodableFlexibleBitfield.java
│ │ ├── EncodableOptimizedFibonacciRange.java
│ │ ├── EncodableOptimizedFixedRange.java
│ │ ├── RangeEntry.java
│ │ ├── SubstringException.java
│ │ ├── UnencodableCharacter.java
│ │ ├── UnencodableInteger.java
│ │ └── encoder
│ │ │ ├── ArrayOfRangesEntryEncoder.java
│ │ │ ├── BooleanEncoder.java
│ │ │ ├── DatetimeEncoder.java
│ │ │ ├── FibonacciIntegerEncoder.java
│ │ │ ├── FibonacciIntegerRangeEncoder.java
│ │ │ ├── FixedBitfieldEncoder.java
│ │ │ ├── FixedIntegerEncoder.java
│ │ │ ├── FixedIntegerListEncoder.java
│ │ │ ├── FixedIntegerRangeEncoder.java
│ │ │ ├── FixedLongEncoder.java
│ │ │ ├── FixedStringEncoder.java
│ │ │ ├── OptimizedFibonacciRangeEncoder.java
│ │ │ └── OptimizedFixedRangeEncoder.java
│ │ ├── error
│ │ ├── DecodingException.java
│ │ ├── EncodingException.java
│ │ ├── InvalidFieldException.java
│ │ └── ValidationException.java
│ │ ├── field
│ │ ├── EncodableBitStringFields.java
│ │ ├── Fields.java
│ │ ├── GenericFields.java
│ │ ├── HeaderV1Field.java
│ │ ├── TcfCaV1Field.java
│ │ ├── TcfEuV2Field.java
│ │ ├── UsCaField.java
│ │ ├── UsCoField.java
│ │ ├── UsCtField.java
│ │ ├── UsDeField.java
│ │ ├── UsFlField.java
│ │ ├── UsIaField.java
│ │ ├── UsMtField.java
│ │ ├── UsNatField.java
│ │ ├── UsNeField.java
│ │ ├── UsNhField.java
│ │ ├── UsNjField.java
│ │ ├── UsOrField.java
│ │ ├── UsTnField.java
│ │ ├── UsTxField.java
│ │ ├── UsUtField.java
│ │ ├── UsVaField.java
│ │ └── UspV1Field.java
│ │ ├── section
│ │ ├── AbstractEncodableSegmentedBitStringSection.java
│ │ ├── AbstractLazilyEncodableSection.java
│ │ ├── EncodableSection.java
│ │ ├── HeaderV1.java
│ │ ├── Sections.java
│ │ ├── TcfCaV1.java
│ │ ├── TcfEuV2.java
│ │ ├── UsCa.java
│ │ ├── UsCo.java
│ │ ├── UsCt.java
│ │ ├── UsDe.java
│ │ ├── UsFl.java
│ │ ├── UsIa.java
│ │ ├── UsMt.java
│ │ ├── UsNat.java
│ │ ├── UsNe.java
│ │ ├── UsNh.java
│ │ ├── UsNj.java
│ │ ├── UsOr.java
│ │ ├── UsTn.java
│ │ ├── UsTx.java
│ │ ├── UsUt.java
│ │ ├── UsVa.java
│ │ └── UspV1.java
│ │ └── segment
│ │ ├── AbstractLazilyEncodableSegment.java
│ │ ├── EncodableSegment.java
│ │ ├── HeaderV1CoreSegment.java
│ │ ├── TcfCaV1CoreSegment.java
│ │ ├── TcfCaV1DisclosedVendorsSegment.java
│ │ ├── TcfCaV1PublisherPurposesSegment.java
│ │ ├── TcfEuV2CoreSegment.java
│ │ ├── TcfEuV2PublisherPurposesSegment.java
│ │ ├── TcfEuV2VendorsAllowedSegment.java
│ │ ├── TcfEuV2VendorsDisclosedSegment.java
│ │ ├── UsCaCoreSegment.java
│ │ ├── UsCaGpcSegment.java
│ │ ├── UsCoCoreSegment.java
│ │ ├── UsCoGpcSegment.java
│ │ ├── UsCtCoreSegment.java
│ │ ├── UsCtGpcSegment.java
│ │ ├── UsDeCoreSegment.java
│ │ ├── UsDeGpcSegment.java
│ │ ├── UsFlCoreSegment.java
│ │ ├── UsIaCoreSegment.java
│ │ ├── UsIaGpcSegment.java
│ │ ├── UsMtCoreSegment.java
│ │ ├── UsMtGpcSegment.java
│ │ ├── UsNatCoreSegment.java
│ │ ├── UsNatGpcSegment.java
│ │ ├── UsNeCoreSegment.java
│ │ ├── UsNeGpcSegment.java
│ │ ├── UsNhCoreSegment.java
│ │ ├── UsNhGpcSegment.java
│ │ ├── UsNjCoreSegment.java
│ │ ├── UsNjGpcSegment.java
│ │ ├── UsOrCoreSegment.java
│ │ ├── UsOrGpcSegment.java
│ │ ├── UsTnCoreSegment.java
│ │ ├── UsTnGpcSegment.java
│ │ ├── UsTxCoreSegment.java
│ │ ├── UsTxGpcSegment.java
│ │ ├── UsUtCoreSegment.java
│ │ ├── UsVaCoreSegment.java
│ │ └── UspV1CoreSegment.java
│ └── test
│ └── java
│ └── com
│ └── iab
│ └── gpp
│ └── encoder
│ ├── GppModelTest.java
│ ├── base64
│ └── TraditionalBase64UrlEncoderTest.java
│ ├── datatype
│ ├── EncodableBooleanTest.java
│ ├── EncodableDatetimeTest.java
│ ├── EncodableFibonacciIntegerRangeTest.java
│ ├── EncodableFibonacciIntegerTest.java
│ ├── EncodableFixedBitfieldTest.java
│ ├── EncodableFixedIntegerListTest.java
│ ├── EncodableFixedIntegerRangeTest.java
│ ├── EncodableFixedIntegerTest.java
│ ├── EncodableFixedStringTest.java
│ ├── EncodableOptimizedFixedRangeTest.java
│ └── encoder
│ │ ├── BooleanEncoderTest.java
│ │ ├── DatetimeEncoderTest.java
│ │ ├── FibonacciIntegerEncoderTest.java
│ │ ├── FibonacciIntegerRangeEncoderTest.java
│ │ ├── FixedBitfieldEncoderTest.java
│ │ ├── FixedIntegerEncoderTest.java
│ │ ├── FixedIntegerListEncoderTest.java
│ │ ├── FixedIntegerRangeEncoderTest.java
│ │ ├── FixedLongEncoderTest.java
│ │ └── FixedStringEncoderTest.java
│ └── section
│ ├── .UsNatV1Test.java.swp
│ ├── HeaderV1Test.java
│ ├── TcfCaV1Test.java
│ ├── TcfEuV2Test.java
│ ├── UsCaTest.java
│ ├── UsCoTest.java
│ ├── UsCtTest.java
│ ├── UsDeTest.java
│ ├── UsFlTest.java
│ ├── UsIaTest.java
│ ├── UsMtTest.java
│ ├── UsNatTest.java
│ ├── UsNeTest.java
│ ├── UsNhTest.java
│ ├── UsNjTest.java
│ ├── UsOrTest.java
│ ├── UsTnTest.java
│ ├── UsTxTest.java
│ ├── UsUtTest.java
│ ├── UsVaTest.java
│ └── UspV1Test.java
├── iabgpp-extras-jackson
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── iab
│ │ └── gpp
│ │ └── extras
│ │ └── jackson
│ │ ├── Loader.java
│ │ ├── cmp
│ │ ├── Cmp.java
│ │ └── CmpList.java
│ │ └── gvl
│ │ ├── DataCategory.java
│ │ ├── DataRetention.java
│ │ ├── Feature.java
│ │ ├── Gvl.java
│ │ ├── Overflow.java
│ │ ├── Purpose.java
│ │ ├── SpecialFeature.java
│ │ ├── SpecialPurpose.java
│ │ ├── Stack.java
│ │ ├── Vendor.java
│ │ └── VendorUrl.java
│ └── test
│ ├── java
│ └── com
│ │ └── iab
│ │ └── gpp
│ │ └── extras
│ │ └── jackson
│ │ ├── cmp
│ │ └── CmpListTest.java
│ │ └── gvl
│ │ ├── GvlCanadaTest.java
│ │ ├── GvlV2Test.java
│ │ └── GvlV3Test.java
│ └── resources
│ ├── cmpList.json
│ └── vendorlist
│ ├── v2
│ ├── ca
│ │ └── vendor-list.json
│ ├── purposes-fr.json
│ ├── vendor-list-v51.json
│ └── vendor-list.json
│ └── v3.0
│ ├── purposes-fr.json
│ └── vendor-list.json
├── iabgpp-extras
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── iab
│ └── gpp
│ └── extras
│ ├── cmp
│ ├── Cmp.java
│ └── CmpList.java
│ └── gvl
│ ├── DataCategory.java
│ ├── DataRetention.java
│ ├── Feature.java
│ ├── Gvl.java
│ ├── Overflow.java
│ ├── Purpose.java
│ ├── SpecialFeature.java
│ ├── SpecialPurpose.java
│ ├── Stack.java
│ ├── Vendor.java
│ └── VendorUrl.java
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | target
3 | /.idea/
4 | /iabtcf-core.iml
5 | *~
6 | .checkstyle
7 | .classpath
8 | .project
9 | .settings
10 | iabtcf-decoder/iabtcf-decoder.iml
11 | iabtcf-encoder/iabtcf-encoder.iml
12 | iabtcf-extras/iabtcf-extras.iml
13 | iabtcf-extras-jackson/iabtcf-extras-jackson.iml
14 |
--------------------------------------------------------------------------------
/iabgpp-encoder/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.iabgpp
9 | iabgpp-core
10 | 3.2.4-SNAPSHOT
11 |
12 |
13 | iabgpp-encoder
14 | jar
15 |
16 |
17 |
18 | org.junit.jupiter
19 | junit-jupiter-engine
20 | 5.9.2
21 | test
22 |
23 |
24 |
25 |
26 |
27 |
28 | maven-surefire-plugin
29 | 2.22.2
30 |
31 |
32 |
33 |
34 |
35 |
36 | release
37 |
38 |
39 |
40 | org.apache.maven.plugins
41 | maven-source-plugin
42 |
43 |
44 | org.apache.maven.plugins
45 | maven-javadoc-plugin
46 |
47 |
48 | org.apache.maven.plugins
49 | maven-gpg-plugin
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/base64/CompressedBase64UrlEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.base64;
2 |
3 | import java.util.Arrays;
4 |
5 | public class CompressedBase64UrlEncoder extends AbstractBase64UrlEncoder {
6 |
7 | private static CompressedBase64UrlEncoder instance = new CompressedBase64UrlEncoder();
8 |
9 | private CompressedBase64UrlEncoder() {
10 |
11 | }
12 |
13 | public static CompressedBase64UrlEncoder getInstance() {
14 | return instance;
15 | }
16 |
17 | @Override
18 | protected String pad(String bitString) {
19 | char[] chars1 = null;
20 | if(bitString.length() % 8 > 0) {
21 | chars1 = new char[8 - (bitString.length() % 8)];
22 | } else {
23 | chars1 = new char[0];
24 | }
25 | Arrays.fill(chars1, '0');
26 |
27 | char[] chars2 = null;
28 | if((bitString.length() + chars1.length) % 6 > 0) {
29 | chars2 = new char[6 - ((bitString.length() + chars1.length) % 6)];
30 | } else {
31 | chars2 = new char[0];
32 | }
33 | Arrays.fill(chars2, '0');
34 |
35 | return bitString + new String(chars1) + new String(chars2);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/base64/TraditionalBase64UrlEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.base64;
2 |
3 | import java.util.Arrays;
4 |
5 | public class TraditionalBase64UrlEncoder extends AbstractBase64UrlEncoder {
6 |
7 | private static TraditionalBase64UrlEncoder instance = new TraditionalBase64UrlEncoder();
8 |
9 | private TraditionalBase64UrlEncoder() {
10 |
11 | }
12 |
13 | public static TraditionalBase64UrlEncoder getInstance() {
14 | return instance;
15 | }
16 |
17 | @Override
18 | protected String pad(String bitString) {
19 | if(bitString.length() % 24 > 0) {
20 | char[] chars = new char[24 - (bitString.length() % 24)];
21 | Arrays.fill(chars, '0');
22 | return bitString + new String(chars);
23 | } else {
24 | return bitString;
25 | }
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/bitstring/BitStringEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.bitstring;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.datatype.AbstractEncodableBitStringDataType;
5 | import com.iab.gpp.encoder.datatype.SubstringException;
6 | import com.iab.gpp.encoder.error.DecodingException;
7 | import com.iab.gpp.encoder.error.EncodingException;
8 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
9 |
10 | public class BitStringEncoder {
11 |
12 | private static BitStringEncoder instance = new BitStringEncoder();
13 |
14 | private BitStringEncoder() {
15 |
16 | }
17 |
18 | public static BitStringEncoder getInstance() {
19 | return instance;
20 | }
21 |
22 | public String encode(EncodableBitStringFields fields, List fieldNames) {
23 | String bitString = "";
24 | for (int i = 0; i < fieldNames.size(); i++) {
25 | String fieldName = fieldNames.get(i);
26 | if (fields.containsKey(fieldName)) {
27 | AbstractEncodableBitStringDataType> field = fields.get(fieldName);
28 | bitString += field.encode();
29 | } else {
30 | throw new EncodingException("Field not found: '" + fieldName + "'");
31 | }
32 | }
33 |
34 | return bitString;
35 | }
36 |
37 | public void decode(String bitString, List fieldNames, EncodableBitStringFields fields) {
38 | int index = 0;
39 | for (int i = 0; i < fieldNames.size(); i++) {
40 | String fieldName = fieldNames.get(i);
41 | if (fields.containsKey(fieldName)) {
42 | AbstractEncodableBitStringDataType> field = fields.get(fieldName);
43 | try {
44 | String substring = field.substring(bitString, index);
45 | field.decode(substring);
46 | index += substring.length();
47 | } catch (SubstringException e) {
48 | if(field.getHardFailIfMissing()) {
49 | throw new DecodingException("Unable to decode " + fieldName, e);
50 | } else {
51 | return;
52 | }
53 | } catch (Exception e) {
54 | throw new DecodingException("Unable to decode " + fieldName, e);
55 | }
56 | } else {
57 | throw new DecodingException("Field not found: '" + fieldName + "'");
58 | }
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/AbstractEncodableBitStringDataType.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import java.util.Collection;
4 | import java.util.function.Predicate;
5 | import java.util.stream.Collectors;
6 | import com.iab.gpp.encoder.error.ValidationException;
7 |
8 | public abstract class AbstractEncodableBitStringDataType implements EncodableDataType {
9 | //this if for backwards compatibility with the newer fields
10 | protected boolean hardFailIfMissing = true;
11 | protected Predicate validator = null;
12 | protected T value;
13 |
14 | protected AbstractEncodableBitStringDataType(boolean hardFailIfMissing) {
15 | this.hardFailIfMissing = hardFailIfMissing;
16 | }
17 |
18 | public AbstractEncodableBitStringDataType withValidator(Predicate validator) {
19 | this.validator = validator;
20 | return this;
21 | }
22 |
23 | public boolean hasValue() {
24 | return this.value != null;
25 | }
26 |
27 | public T getValue() {
28 | return this.value;
29 | }
30 |
31 | @SuppressWarnings("unchecked")
32 | public void setValue(Object value) {
33 | T v = (T) value;
34 | if (validator == null || validator.test(v)) {
35 | this.value = v;
36 | } else {
37 | if (v instanceof Collection) {
38 | throw new ValidationException("Invalid value '"
39 | + ((Collection>) v).stream().map(i -> i.toString()).collect(Collectors.joining(",")) + "'");
40 | } else {
41 | throw new ValidationException("Invalid value '" + v + "'");
42 | }
43 | }
44 |
45 | }
46 |
47 | public boolean getHardFailIfMissing() {
48 | return this.hardFailIfMissing;
49 | }
50 |
51 | public abstract String encode();
52 |
53 | public abstract void decode(String bitString);
54 |
55 | public abstract String substring(String bitString, int fromIndex) throws SubstringException;
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/DataType.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | public interface DataType {
4 | boolean hasValue();
5 | T getValue();
6 | void setValue(Object value);
7 | }
8 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/EncodableBoolean.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import com.iab.gpp.encoder.datatype.encoder.BooleanEncoder;
4 | import com.iab.gpp.encoder.error.DecodingException;
5 | import com.iab.gpp.encoder.error.EncodingException;
6 |
7 | public class EncodableBoolean extends AbstractEncodableBitStringDataType {
8 |
9 | protected EncodableBoolean() {
10 | super(true);
11 | }
12 |
13 | public EncodableBoolean(Boolean value) {
14 | super(true);
15 | setValue(value);
16 | }
17 |
18 | public EncodableBoolean(Boolean value, boolean hardFailIfMissing) {
19 | super(hardFailIfMissing);
20 | setValue(value);
21 | }
22 |
23 | public String encode() {
24 | try {
25 | return BooleanEncoder.encode(this.value);
26 | } catch (Exception e) {
27 | throw new EncodingException(e);
28 | }
29 | }
30 |
31 | public void decode(String bitString) {
32 | try {
33 | this.value = BooleanEncoder.decode(bitString);
34 | } catch (Exception e) {
35 | throw new DecodingException(e);
36 | }
37 | }
38 |
39 | public String substring(String bitString, int fromIndex) throws SubstringException {
40 | try {
41 | return bitString.substring(fromIndex, fromIndex + 1);
42 | } catch (Exception e) {
43 | throw new SubstringException(e);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/EncodableDataType.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | public interface EncodableDataType extends DataType {
4 | String encode();
5 |
6 | void decode(String str);
7 | }
8 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/EncodableDatetime.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import java.time.ZonedDateTime;
4 | import com.iab.gpp.encoder.datatype.encoder.DatetimeEncoder;
5 | import com.iab.gpp.encoder.error.DecodingException;
6 | import com.iab.gpp.encoder.error.EncodingException;
7 |
8 | public class EncodableDatetime extends AbstractEncodableBitStringDataType {
9 |
10 | protected EncodableDatetime() {
11 | super(true);
12 | }
13 |
14 | public EncodableDatetime(ZonedDateTime value) {
15 | super(true);
16 | setValue(value);
17 | }
18 |
19 | public EncodableDatetime(ZonedDateTime value, boolean hardFailIfMissing) {
20 | super(hardFailIfMissing);
21 | setValue(value);
22 | }
23 |
24 | public String encode() {
25 | try {
26 | return DatetimeEncoder.encode(this.value);
27 | } catch (Exception e) {
28 | throw new EncodingException(e);
29 | }
30 | }
31 |
32 | public void decode(String bitString) {
33 | try {
34 | this.value = DatetimeEncoder.decode(bitString);
35 | } catch (Exception e) {
36 | throw new DecodingException(e);
37 | }
38 | }
39 |
40 | public String substring(String bitString, int fromIndex) throws SubstringException {
41 | try {
42 | return bitString.substring(fromIndex, fromIndex + 36);
43 | } catch (Exception e) {
44 | throw new SubstringException(e);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/EncodableFibonacciInteger.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import com.iab.gpp.encoder.datatype.encoder.FibonacciIntegerEncoder;
4 | import com.iab.gpp.encoder.error.DecodingException;
5 | import com.iab.gpp.encoder.error.EncodingException;
6 |
7 | public class EncodableFibonacciInteger extends AbstractEncodableBitStringDataType {
8 |
9 | protected EncodableFibonacciInteger() {
10 | super(true);
11 | }
12 |
13 | public EncodableFibonacciInteger(Integer value) {
14 | super(true);
15 | setValue(value);
16 | }
17 |
18 | public EncodableFibonacciInteger(Integer value, boolean hardFailIfMissing) {
19 | super(hardFailIfMissing);
20 | setValue(value);
21 | }
22 |
23 | public String encode() {
24 | try {
25 | return FibonacciIntegerEncoder.encode(this.value);
26 | } catch (Exception e) {
27 | throw new EncodingException(e);
28 | }
29 | }
30 |
31 | public void decode(String bitString) {
32 | try {
33 | this.value = FibonacciIntegerEncoder.decode(bitString);
34 | } catch (Exception e) {
35 | throw new DecodingException(e);
36 | }
37 | }
38 |
39 | public String substring(String bitString, int fromIndex) throws SubstringException {
40 | try {
41 | int index = bitString.indexOf("11", fromIndex);
42 | if (index > 0) {
43 | return bitString.substring(fromIndex, index + 2);
44 | } else {
45 | return bitString;
46 | }
47 | } catch (Exception e) {
48 | throw new SubstringException(e);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/EncodableFibonacciIntegerRange.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.TreeSet;
6 | import com.iab.gpp.encoder.datatype.encoder.FibonacciIntegerRangeEncoder;
7 | import com.iab.gpp.encoder.datatype.encoder.FixedIntegerEncoder;
8 | import com.iab.gpp.encoder.error.DecodingException;
9 | import com.iab.gpp.encoder.error.EncodingException;
10 |
11 | public class EncodableFibonacciIntegerRange extends AbstractEncodableBitStringDataType> {
12 |
13 | protected EncodableFibonacciIntegerRange() {
14 | super(true);
15 | }
16 |
17 | public EncodableFibonacciIntegerRange(List value) {
18 | super(true);
19 | setValue(value);
20 | }
21 |
22 | public EncodableFibonacciIntegerRange(List value, boolean hardFailIfMissing) {
23 | super(hardFailIfMissing);
24 | setValue(value);
25 | }
26 |
27 | public String encode() {
28 | try {
29 | return FibonacciIntegerRangeEncoder.encode(this.value);
30 | } catch (Exception e) {
31 | throw new EncodingException(e);
32 | }
33 | }
34 |
35 | public void decode(String bitString) {
36 | try {
37 | this.value = FibonacciIntegerRangeEncoder.decode(bitString);
38 | } catch (Exception e) {
39 | throw new DecodingException(e);
40 | }
41 | }
42 |
43 | public String substring(String bitString, int fromIndex) throws SubstringException {
44 | try {
45 | int count = FixedIntegerEncoder.decode(bitString.substring(fromIndex, fromIndex + 12));
46 | int index = fromIndex + 12;
47 | for (int i = 0; i < count; i++) {
48 | if (bitString.charAt(index) == '1') {
49 | index = bitString.indexOf("11", bitString.indexOf("11", index + 1) + 2) + 2;
50 | } else {
51 | index = bitString.indexOf("11", index + 1) + 2;
52 | }
53 | }
54 | return bitString.substring(fromIndex, index);
55 | } catch (Exception e) {
56 | throw new SubstringException(e);
57 | }
58 | }
59 |
60 | @SuppressWarnings("unchecked")
61 | @Override
62 | public void setValue(Object value) {
63 | super.setValue(new ArrayList<>(new TreeSet<>((List) value)));
64 | }
65 |
66 | @Override
67 | public List getValue() {
68 | return new ArrayList<>(super.getValue());
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/EncodableFixedBitfield.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import com.iab.gpp.encoder.datatype.encoder.FixedBitfieldEncoder;
6 | import com.iab.gpp.encoder.error.DecodingException;
7 | import com.iab.gpp.encoder.error.EncodingException;
8 |
9 | public class EncodableFixedBitfield extends AbstractEncodableBitStringDataType> {
10 |
11 | private int numElements;
12 |
13 | protected EncodableFixedBitfield(int numElements) {
14 | super(true);
15 | this.numElements = numElements;
16 | }
17 |
18 | protected EncodableFixedBitfield(int numElements, boolean hardFailIfMissing) {
19 | super(hardFailIfMissing);
20 | this.numElements = numElements;
21 | }
22 |
23 | public EncodableFixedBitfield(List value) {
24 | super(true);
25 | this.numElements = value.size();
26 | setValue(value);
27 | }
28 |
29 | public EncodableFixedBitfield(List value, boolean hardFailIfMissing) {
30 | super(hardFailIfMissing);
31 | this.numElements = value.size();
32 | setValue(value);
33 | }
34 |
35 | public String encode() {
36 | try {
37 | return FixedBitfieldEncoder.encode(this.value, this.numElements);
38 | } catch (Exception e) {
39 | throw new EncodingException(e);
40 | }
41 | }
42 |
43 | public void decode(String bitString) {
44 | try {
45 | this.value = FixedBitfieldEncoder.decode(bitString);
46 | } catch (Exception e) {
47 | throw new DecodingException(e);
48 | }
49 | }
50 |
51 | public String substring(String bitString, int fromIndex) throws SubstringException {
52 | try {
53 | return bitString.substring(fromIndex, fromIndex + this.numElements);
54 | } catch (Exception e) {
55 | throw new SubstringException(e);
56 | }
57 | }
58 |
59 | @SuppressWarnings("unchecked")
60 | @Override
61 | public void setValue(Object value) {
62 | List v = new ArrayList<>((List) value);
63 | for (int i = v.size(); i < numElements; i++) {
64 | v.add(false);
65 | }
66 | if (v.size() > numElements) {
67 | v = v.subList(0, numElements);
68 | }
69 | super.setValue(v);
70 | }
71 |
72 | @Override
73 | public List getValue() {
74 | return new ArrayList<>(super.getValue());
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/EncodableFixedInteger.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import com.iab.gpp.encoder.datatype.encoder.FixedIntegerEncoder;
4 | import com.iab.gpp.encoder.error.DecodingException;
5 | import com.iab.gpp.encoder.error.EncodingException;
6 |
7 | public class EncodableFixedInteger extends AbstractEncodableBitStringDataType {
8 |
9 | private int bitStringLength;
10 |
11 | protected EncodableFixedInteger(int bitStringLength) {
12 | super(true);
13 | this.bitStringLength = bitStringLength;
14 | }
15 |
16 | public EncodableFixedInteger(int bitStringLength, Integer value) {
17 | super(true);
18 | this.bitStringLength = bitStringLength;
19 | setValue(value);
20 | }
21 |
22 | public EncodableFixedInteger(int bitStringLength, Integer value, boolean hardFailIfMissing) {
23 | super(hardFailIfMissing);
24 | this.bitStringLength = bitStringLength;
25 | setValue(value);
26 | }
27 |
28 | public String encode() {
29 | try {
30 | return FixedIntegerEncoder.encode(this.value, this.bitStringLength);
31 | } catch (Exception e) {
32 | throw new EncodingException(e);
33 | }
34 | }
35 |
36 | public void decode(String bitString) {
37 | try {
38 | this.value = FixedIntegerEncoder.decode(bitString);
39 | } catch (Exception e) {
40 | throw new DecodingException(e);
41 | }
42 | }
43 |
44 | public String substring(String bitString, int fromIndex) throws SubstringException {
45 | try {
46 | return bitString.substring(fromIndex, fromIndex + this.bitStringLength);
47 | } catch (Exception e) {
48 | throw new SubstringException(e);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/EncodableFixedIntegerList.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import com.iab.gpp.encoder.datatype.encoder.FixedIntegerListEncoder;
6 | import com.iab.gpp.encoder.error.DecodingException;
7 | import com.iab.gpp.encoder.error.EncodingException;
8 |
9 | public class EncodableFixedIntegerList extends AbstractEncodableBitStringDataType> {
10 |
11 | private int elementBitStringLength;
12 | private int numElements;
13 |
14 | protected EncodableFixedIntegerList(int elementBitStringLength, int numElements) {
15 | super(true);
16 | this.elementBitStringLength = elementBitStringLength;
17 | this.numElements = numElements;
18 | }
19 |
20 | public EncodableFixedIntegerList(int elementBitStringLength, List value) {
21 | super(true);
22 | this.elementBitStringLength = elementBitStringLength;
23 | this.numElements = value.size();
24 | setValue(value);
25 | }
26 |
27 | public EncodableFixedIntegerList(int elementBitStringLength, List value, boolean hardFailIfMissing) {
28 | super(hardFailIfMissing);
29 | this.elementBitStringLength = elementBitStringLength;
30 | this.numElements = value.size();
31 | setValue(value);
32 | }
33 |
34 | public String encode() {
35 | try {
36 | return FixedIntegerListEncoder.encode(this.value, this.elementBitStringLength, this.numElements);
37 | } catch (Exception e) {
38 | throw new EncodingException(e);
39 | }
40 | }
41 |
42 | public void decode(String bitString) {
43 | try {
44 | this.value = FixedIntegerListEncoder.decode(bitString, this.elementBitStringLength, this.numElements);
45 | } catch (Exception e) {
46 | throw new DecodingException(e);
47 | }
48 | }
49 |
50 | public String substring(String bitString, int fromIndex) throws SubstringException {
51 | try {
52 | return bitString.substring(fromIndex, fromIndex + (this.elementBitStringLength * numElements));
53 | } catch (Exception e) {
54 | throw new SubstringException(e);
55 | }
56 | }
57 |
58 | @SuppressWarnings("unchecked")
59 | @Override
60 | public void setValue(Object value) {
61 | List v = new ArrayList<>((List) value);
62 | for (int i = v.size(); i < numElements; i++) {
63 | v.add(0);
64 | }
65 | if (v.size() > numElements) {
66 | v = v.subList(0, numElements);
67 | }
68 | super.setValue(v);
69 | }
70 |
71 | @Override
72 | public List getValue() {
73 | return new ArrayList<>(super.getValue());
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/EncodableFixedIntegerRange.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.TreeSet;
6 | import com.iab.gpp.encoder.datatype.encoder.FixedIntegerEncoder;
7 | import com.iab.gpp.encoder.datatype.encoder.FixedIntegerRangeEncoder;
8 | import com.iab.gpp.encoder.error.DecodingException;
9 | import com.iab.gpp.encoder.error.EncodingException;
10 |
11 | public class EncodableFixedIntegerRange extends AbstractEncodableBitStringDataType> {
12 |
13 | protected EncodableFixedIntegerRange() {
14 | super(true);
15 | }
16 |
17 | public EncodableFixedIntegerRange(List value) {
18 | super(true);
19 | setValue(value);
20 | }
21 |
22 | public EncodableFixedIntegerRange(List value, boolean hardFailIfMissing) {
23 | super(hardFailIfMissing);
24 | setValue(value);
25 | }
26 |
27 | public String encode() {
28 | try {
29 | return FixedIntegerRangeEncoder.encode(this.value);
30 | } catch (Exception e) {
31 | throw new EncodingException(e);
32 | }
33 | }
34 |
35 | public void decode(String bitString) {
36 | try {
37 | this.value = FixedIntegerRangeEncoder.decode(bitString);
38 | } catch (Exception e) {
39 | throw new DecodingException(e);
40 | }
41 | }
42 |
43 | public String substring(String bitString, int fromIndex) throws SubstringException {
44 | try {
45 | int count = FixedIntegerEncoder.decode(bitString.substring(fromIndex, fromIndex + 12));
46 | int index = fromIndex + 12;
47 | for (int i = 0; i < count; i++) {
48 | if (bitString.charAt(index) == '1') {
49 | index += 33;
50 | } else {
51 | index += 17;
52 | }
53 | }
54 | return bitString.substring(fromIndex, index);
55 | } catch (Exception e) {
56 | throw new SubstringException(e);
57 | }
58 | }
59 |
60 | @SuppressWarnings("unchecked")
61 | @Override
62 | public void setValue(Object value) {
63 | super.setValue(new ArrayList<>(new TreeSet<>((List) value)));
64 | }
65 |
66 | @Override
67 | public List getValue() {
68 | return new ArrayList<>(super.getValue());
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/EncodableFixedString.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import com.iab.gpp.encoder.datatype.encoder.FixedStringEncoder;
4 | import com.iab.gpp.encoder.error.DecodingException;
5 | import com.iab.gpp.encoder.error.EncodingException;
6 |
7 | public class EncodableFixedString extends AbstractEncodableBitStringDataType {
8 |
9 | private int stringLength;
10 |
11 | protected EncodableFixedString(int stringLength) {
12 | super(true);
13 | this.stringLength = stringLength;
14 | }
15 |
16 | public EncodableFixedString(int stringLength, String value) {
17 | super(true);
18 | this.stringLength = stringLength;
19 | setValue(value);
20 | }
21 |
22 | public EncodableFixedString(int stringLength, String value, boolean hardFailIfMissing) {
23 | super(hardFailIfMissing);
24 | this.stringLength = stringLength;
25 | setValue(value);
26 | }
27 |
28 | public String encode() {
29 | try {
30 | return FixedStringEncoder.encode(this.value, this.stringLength);
31 | } catch (Exception e) {
32 | throw new EncodingException(e);
33 | }
34 | }
35 |
36 | public void decode(String bitString) {
37 | try {
38 | this.value = FixedStringEncoder.decode(bitString);
39 | } catch (Exception e) {
40 | throw new DecodingException(e);
41 | }
42 | }
43 |
44 | public String substring(String bitString, int fromIndex) throws SubstringException {
45 | try {
46 | return bitString.substring(fromIndex, fromIndex + this.stringLength * 6);
47 | } catch (Exception e) {
48 | throw new SubstringException(e);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/EncodableFlexibleBitfield.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.function.IntSupplier;
6 | import com.iab.gpp.encoder.datatype.encoder.FixedBitfieldEncoder;
7 | import com.iab.gpp.encoder.error.DecodingException;
8 | import com.iab.gpp.encoder.error.EncodingException;
9 |
10 | public class EncodableFlexibleBitfield extends AbstractEncodableBitStringDataType> {
11 |
12 | private IntSupplier getLengthSupplier;
13 |
14 | protected EncodableFlexibleBitfield(IntSupplier getLengthSupplier) {
15 | super(true);
16 | this.getLengthSupplier = getLengthSupplier;
17 | }
18 |
19 | public EncodableFlexibleBitfield(IntSupplier getLengthSupplier, List value) {
20 | super(true);
21 | this.getLengthSupplier = getLengthSupplier;
22 | this.setValue(value);
23 | }
24 |
25 | public EncodableFlexibleBitfield(IntSupplier getLengthSupplier, List value, boolean hardFailIfMissing) {
26 | super(hardFailIfMissing);
27 | this.getLengthSupplier = getLengthSupplier;
28 | this.setValue(value);
29 | }
30 |
31 | public String encode() {
32 | try {
33 | return FixedBitfieldEncoder.encode(this.value, this.getLengthSupplier.getAsInt());
34 | } catch (Exception e) {
35 | throw new EncodingException(e);
36 | }
37 | }
38 |
39 | public void decode(String bitString) {
40 | try {
41 | this.value = FixedBitfieldEncoder.decode(bitString);
42 | } catch (Exception e) {
43 | throw new DecodingException(e);
44 | }
45 | }
46 |
47 | public String substring(String bitString, int fromIndex) throws SubstringException {
48 | try {
49 | return bitString.substring(fromIndex, fromIndex + this.getLengthSupplier.getAsInt());
50 | } catch (Exception e) {
51 | throw new SubstringException(e);
52 | }
53 | }
54 |
55 | @SuppressWarnings("unchecked")
56 | @Override
57 | public void setValue(Object value) {
58 | int numElements = this.getLengthSupplier.getAsInt();
59 | List v = new ArrayList<>((List) value);
60 | for (int i = v.size(); i < numElements; i++) {
61 | v.add(false);
62 | }
63 | if (v.size() > numElements) {
64 | v = v.subList(0, numElements);
65 | }
66 | super.setValue(v);
67 | }
68 |
69 | @Override
70 | public List getValue() {
71 | return new ArrayList<>(super.getValue());
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/EncodableOptimizedFibonacciRange.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.TreeSet;
6 | import com.iab.gpp.encoder.datatype.encoder.FixedIntegerEncoder;
7 | import com.iab.gpp.encoder.datatype.encoder.OptimizedFibonacciRangeEncoder;
8 | import com.iab.gpp.encoder.error.DecodingException;
9 | import com.iab.gpp.encoder.error.EncodingException;
10 |
11 | public class EncodableOptimizedFibonacciRange extends AbstractEncodableBitStringDataType> {
12 |
13 | protected EncodableOptimizedFibonacciRange() {
14 | super(true);
15 | }
16 |
17 | public EncodableOptimizedFibonacciRange(List value) {
18 | super(true);
19 | setValue(value);
20 | }
21 |
22 | public EncodableOptimizedFibonacciRange(List value, boolean hardFailIfMissing) {
23 | super(hardFailIfMissing);
24 | setValue(value);
25 | }
26 |
27 | public String encode() {
28 | try {
29 | return OptimizedFibonacciRangeEncoder.encode(this.value);
30 | } catch (Exception e) {
31 | throw new EncodingException(e);
32 | }
33 | }
34 |
35 | public void decode(String bitString) {
36 | try {
37 | this.value = OptimizedFibonacciRangeEncoder.decode(bitString);
38 | } catch (Exception e) {
39 | throw new DecodingException(e);
40 | }
41 | }
42 |
43 | public String substring(String bitString, int fromIndex) throws SubstringException {
44 | try {
45 | int max = FixedIntegerEncoder.decode(bitString.substring(fromIndex, fromIndex + 16));
46 | if (bitString.charAt(fromIndex + 16) == '1') {
47 | return (bitString.substring(fromIndex, fromIndex + 17)
48 | + new EncodableFibonacciIntegerRange().substring(bitString, fromIndex + 17));
49 | } else {
50 | return bitString.substring(fromIndex, fromIndex + 17 + max);
51 | }
52 | } catch (Exception e) {
53 | throw new SubstringException(e);
54 | }
55 | }
56 |
57 | @SuppressWarnings("unchecked")
58 | @Override
59 | public void setValue(Object value) {
60 | super.setValue(new ArrayList<>(new TreeSet<>((List) value)));
61 | }
62 |
63 | @Override
64 | public List getValue() {
65 | return new ArrayList<>(super.getValue());
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/EncodableOptimizedFixedRange.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.TreeSet;
6 | import com.iab.gpp.encoder.datatype.encoder.FixedIntegerEncoder;
7 | import com.iab.gpp.encoder.datatype.encoder.OptimizedFixedRangeEncoder;
8 | import com.iab.gpp.encoder.error.DecodingException;
9 | import com.iab.gpp.encoder.error.EncodingException;
10 |
11 |
12 | public class EncodableOptimizedFixedRange extends AbstractEncodableBitStringDataType> {
13 |
14 | protected EncodableOptimizedFixedRange() {
15 | super(true);
16 | }
17 |
18 | public EncodableOptimizedFixedRange(List value) {
19 | super(true);
20 | setValue(value);
21 | }
22 |
23 | public EncodableOptimizedFixedRange(List value, boolean hardFailIfMissing) {
24 | super(hardFailIfMissing);
25 | setValue(value);
26 | }
27 |
28 | public String encode() {
29 | try {
30 | return OptimizedFixedRangeEncoder.encode(this.value);
31 | } catch (Exception e) {
32 | throw new EncodingException(e);
33 | }
34 | }
35 |
36 | public void decode(String bitString) {
37 | try {
38 | this.value = OptimizedFixedRangeEncoder.decode(bitString);
39 | } catch (Exception e) {
40 | throw new DecodingException(e);
41 | }
42 | }
43 |
44 | public String substring(String bitString, int fromIndex) throws SubstringException {
45 | try {
46 | int max = FixedIntegerEncoder.decode(bitString.substring(fromIndex, fromIndex + 16));
47 | if (bitString.charAt(fromIndex + 16) == '1') {
48 | return bitString.substring(fromIndex, fromIndex + 17)
49 | + new EncodableFixedIntegerRange().substring(bitString, fromIndex + 17);
50 | } else {
51 | return bitString.substring(fromIndex, fromIndex + 17 + max);
52 | }
53 | } catch (Exception e) {
54 | throw new SubstringException(e);
55 | }
56 | }
57 |
58 | @SuppressWarnings("unchecked")
59 | @Override
60 | public void setValue(Object value) {
61 | super.setValue(new ArrayList<>(new TreeSet<>((List) value)));
62 | }
63 |
64 | @Override
65 | public List getValue() {
66 | return new ArrayList<>(super.getValue());
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/RangeEntry.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import java.util.List;
4 |
5 | public class RangeEntry {
6 |
7 | private int key;
8 | private int type;
9 | private List ids;
10 |
11 | public RangeEntry(int key, int type, List ids) {
12 | super();
13 | this.key = key;
14 | this.type = type;
15 | this.ids = ids;
16 | }
17 |
18 | public int getKey() {
19 | return key;
20 | }
21 |
22 | public void setKey(int key) {
23 | this.key = key;
24 | }
25 |
26 | public int getType() {
27 | return type;
28 | }
29 |
30 | public void setType(int type) {
31 | this.type = type;
32 | }
33 |
34 | public List getIds() {
35 | return ids;
36 | }
37 |
38 | public void setIds(List ids) {
39 | this.ids = ids;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/SubstringException.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | public class SubstringException extends Exception {
4 |
5 | private static final long serialVersionUID = 1825100490468259890L;
6 |
7 | public SubstringException(String msg) {
8 | super(msg);
9 | }
10 |
11 | public SubstringException(Exception e) {
12 | super(e);
13 | }
14 |
15 | public SubstringException(String msg, Exception e) {
16 | super(msg, e);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/UnencodableCharacter.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import java.util.function.Predicate;
4 | import com.iab.gpp.encoder.error.ValidationException;
5 |
6 | public class UnencodableCharacter implements DataType {
7 |
8 | private Predicate validator;
9 | private Character value = null;
10 |
11 | public UnencodableCharacter() {
12 | this.validator = v -> true;
13 | }
14 |
15 | public UnencodableCharacter(Character value) {
16 | this.validator = v -> true;
17 | setValue(value);
18 | }
19 |
20 | public UnencodableCharacter(Character value, Predicate validator) {
21 | this.validator = validator;
22 | setValue(value);
23 | }
24 |
25 | public void setValidator(Predicate validator) {
26 | this.validator = validator;
27 | }
28 |
29 | @Override
30 | public boolean hasValue() {
31 | return this.value != null;
32 | }
33 |
34 | @Override
35 | public Character getValue() {
36 | return this.value;
37 | }
38 |
39 | @Override
40 | public void setValue(Object value) {
41 | Character c = (Character)value.toString().charAt(0);
42 | if(validator.test(c)) {
43 | this.value = c;
44 | } else {
45 | throw new ValidationException("Invalid value '" + c + "'");
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/UnencodableInteger.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import java.util.function.Predicate;
4 | import com.iab.gpp.encoder.error.ValidationException;
5 |
6 | public class UnencodableInteger implements DataType {
7 |
8 | private Predicate validator;
9 | private Integer value = null;
10 |
11 | public UnencodableInteger() {
12 | this.validator = v -> true;
13 | }
14 |
15 | public UnencodableInteger(Integer value) {
16 | this.validator = v -> true;
17 | setValue(value);
18 | }
19 |
20 | public UnencodableInteger(Integer value, Predicate validator) {
21 | this.validator = validator;
22 | setValue(value);
23 | }
24 |
25 | public void setValidator(Predicate validator) {
26 | this.validator = validator;
27 | }
28 |
29 | @Override
30 | public boolean hasValue() {
31 | return this.value != null;
32 | }
33 |
34 | @Override
35 | public Integer getValue() {
36 | return this.value;
37 | }
38 |
39 | @Override
40 | public void setValue(Object value) {
41 | Integer i = (Integer)value;
42 | if(validator.test(i)) {
43 | this.value = i;
44 | } else {
45 | throw new ValidationException("Invalid value '" + i + "'");
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/encoder/ArrayOfRangesEntryEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import java.util.regex.Pattern;
4 | import com.iab.gpp.encoder.error.DecodingException;
5 |
6 | public class ArrayOfRangesEntryEncoder {
7 |
8 | private static Pattern BITSTRING_VERIFICATION_PATTERN = Pattern.compile("^[0-1]*$", Pattern.CASE_INSENSITIVE);
9 |
10 | public static String encode(long value, int bitStringLength) {
11 | String bitString = "";
12 | while (value > 0) {
13 | if ((value & 1) == 1) {
14 | bitString = "1" + bitString;
15 | } else {
16 | bitString = "0" + bitString;
17 | }
18 | value = value >> 1;
19 | }
20 |
21 | while (bitString.length() < bitStringLength) {
22 | bitString = "0" + bitString;
23 | }
24 |
25 | return bitString;
26 | }
27 |
28 | public static long decode(String bitString) throws DecodingException {
29 | if (!BITSTRING_VERIFICATION_PATTERN.matcher(bitString).matches()) {
30 | throw new DecodingException("Undecodable FixedLong '" + bitString + "'");
31 | }
32 |
33 | long value = 0;
34 |
35 | for (int i = 0; i < bitString.length(); i++) {
36 | if (bitString.charAt(bitString.length() - (i + 1)) == '1') {
37 | value += 1L << i;
38 | }
39 | }
40 |
41 | return value;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/encoder/BooleanEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import com.iab.gpp.encoder.error.DecodingException;
4 | import com.iab.gpp.encoder.error.EncodingException;
5 |
6 | public class BooleanEncoder {
7 | public static String encode(Boolean value) {
8 | if (value == true) {
9 | return "1";
10 | } else if (value == false) {
11 | return "0";
12 | } else {
13 | throw new EncodingException("Unencodable Boolean '" + value + "'");
14 | }
15 | }
16 |
17 | public static boolean decode(String bitString) {
18 | if (bitString.equals("1")) {
19 | return true;
20 | } else if (bitString.equals("0")) {
21 | return false;
22 | } else {
23 | throw new DecodingException("Undecodable Boolean '" + bitString + "'");
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/encoder/DatetimeEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import java.time.Instant;
4 | import java.time.ZoneId;
5 | import java.time.ZonedDateTime;
6 | import java.util.regex.Pattern;
7 | import com.iab.gpp.encoder.error.DecodingException;
8 |
9 | public class DatetimeEncoder {
10 | private static Pattern BITSTRING_VERIFICATION_PATTERN = Pattern.compile("^[0-1]*$", Pattern.CASE_INSENSITIVE);
11 |
12 | public static String encode(ZonedDateTime value) {
13 | if (value != null) {
14 | return FixedLongEncoder.encode(value.toInstant().toEpochMilli() / 100, 36);
15 | } else {
16 | return FixedLongEncoder.encode(0, 36);
17 | }
18 | }
19 |
20 | public static ZonedDateTime decode(String bitString) throws DecodingException {
21 | if (!BITSTRING_VERIFICATION_PATTERN.matcher(bitString).matches() || bitString.length() != 36) {
22 | throw new DecodingException("Undecodable Datetime '" + bitString + "'");
23 | }
24 |
25 | return ZonedDateTime.ofInstant(Instant.ofEpochMilli(FixedLongEncoder.decode(bitString) * 100L), ZoneId.of("UTC"));
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/encoder/FibonacciIntegerEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.regex.Pattern;
6 | import com.iab.gpp.encoder.error.DecodingException;
7 |
8 | public class FibonacciIntegerEncoder {
9 | private static Pattern BITSTRING_VERIFICATION_PATTERN = Pattern.compile("^[0-1]*$", Pattern.CASE_INSENSITIVE);
10 |
11 | public static String encode(int value) {
12 | List fib = new ArrayList();
13 | if (value >= 1) {
14 | fib.add(1);
15 |
16 | if (value >= 2) {
17 | fib.add(2);
18 |
19 | int i = 2;
20 | while (value >= fib.get(i - 1) + fib.get(i - 2)) {
21 | fib.add(fib.get(i - 1) + fib.get(i - 2));
22 | i++;
23 | }
24 | }
25 | }
26 |
27 | String bitString = "1";
28 | for (int i = fib.size() - 1; i >= 0; i--) {
29 | int f = fib.get(i);
30 | if (value >= f) {
31 | bitString = "1" + bitString;
32 | value -= f;
33 | } else {
34 | bitString = "0" + bitString;
35 | }
36 | }
37 |
38 | return bitString;
39 | }
40 |
41 | public static int decode(String bitString) throws DecodingException {
42 | if (!BITSTRING_VERIFICATION_PATTERN.matcher(bitString).matches() || bitString.length() < 2
43 | || bitString.indexOf("11") != bitString.length() - 2) {
44 | throw new DecodingException("Undecodable FibonacciInteger '" + bitString + "'");
45 | }
46 |
47 | int value = 0;
48 |
49 | List fib = new ArrayList<>();
50 | for (int i = 0; i < bitString.length() - 1; i++) {
51 | if (i == 0) {
52 | fib.add(1);
53 | } else if (i == 1) {
54 | fib.add(2);
55 | } else {
56 | fib.add(fib.get(i - 1) + fib.get(i - 2));
57 | }
58 | }
59 |
60 | for (int i = 0; i < bitString.length() - 1; i++) {
61 | if (bitString.charAt(i) == '1') {
62 | value += fib.get(i);
63 | }
64 | }
65 | return value;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/encoder/FixedBitfieldEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.regex.Pattern;
6 | import com.iab.gpp.encoder.error.DecodingException;
7 | import com.iab.gpp.encoder.error.EncodingException;
8 |
9 | public class FixedBitfieldEncoder {
10 |
11 | private static Pattern BITSTRING_VERIFICATION_PATTERN = Pattern.compile("^[0-1]*$", Pattern.CASE_INSENSITIVE);
12 |
13 | public static String encode(List value, int bitStringLength) {
14 | if (value.size() > bitStringLength) {
15 | throw new EncodingException("Too many values '" + value.size() + "'");
16 | }
17 |
18 | String bitString = "";
19 | for (int i = 0; i < value.size(); i++) {
20 | bitString += BooleanEncoder.encode(value.get(i));
21 | }
22 |
23 | while (bitString.length() < bitStringLength) {
24 | bitString += "0";
25 | }
26 |
27 | return bitString;
28 | }
29 |
30 | public static List decode(String bitString) {
31 | if (!BITSTRING_VERIFICATION_PATTERN.matcher(bitString).matches()) {
32 | throw new DecodingException("Undecodable FixedBitfield '" + bitString + "'");
33 | }
34 |
35 | List value = new ArrayList<>();
36 | for (int i = 0; i < bitString.length(); i++) {
37 | value.add(BooleanEncoder.decode(bitString.substring(i, i + 1)));
38 | }
39 | return value;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/encoder/FixedIntegerEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import java.util.regex.Pattern;
4 | import com.iab.gpp.encoder.error.DecodingException;
5 | import com.iab.gpp.encoder.error.EncodingException;
6 |
7 | public class FixedIntegerEncoder {
8 |
9 | private static Pattern BITSTRING_VERIFICATION_PATTERN = Pattern.compile("^[0-1]*$", Pattern.CASE_INSENSITIVE);
10 |
11 | public static String encode(int value, int bitStringLength) {
12 | // let bitString = value.toString(2);
13 |
14 | String bitString = "";
15 | while (value > 0) {
16 | if ((value & 1) == 1) {
17 | bitString = "1" + bitString;
18 | } else {
19 | bitString = "0" + bitString;
20 | }
21 | value = value >> 1;
22 | }
23 |
24 | if (bitString.length() > bitStringLength) {
25 | throw new EncodingException(
26 | "Numeric value '" + value + "' is too large for a bit string length of '" + bitStringLength + "'");
27 | }
28 |
29 | while (bitString.length() < bitStringLength) {
30 | bitString = "0" + bitString;
31 | }
32 |
33 | return bitString;
34 | }
35 |
36 | public static int decode(String bitString) throws DecodingException {
37 | if (!BITSTRING_VERIFICATION_PATTERN.matcher(bitString).matches()) {
38 | throw new DecodingException("Undecodable FixedInteger '" + bitString + "'");
39 | }
40 | int value = 0;
41 |
42 | for (int i = 0; i < bitString.length(); i++) {
43 | if (bitString.charAt(bitString.length() - (i + 1)) == '1') {
44 | value += 1 << i;
45 | }
46 | }
47 |
48 | return value;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/encoder/FixedIntegerListEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.regex.Pattern;
6 | import com.iab.gpp.encoder.error.DecodingException;
7 | import com.iab.gpp.encoder.error.EncodingException;
8 |
9 | public class FixedIntegerListEncoder {
10 |
11 | private static Pattern BITSTRING_VERIFICATION_PATTERN = Pattern.compile("^[0-1]*$", Pattern.CASE_INSENSITIVE);
12 |
13 | public static String encode(List value, int elementBitStringLength, int numElements) {
14 | if(value.size() > numElements) {
15 | throw new EncodingException("Too many values '" + value.size() + "'");
16 | }
17 |
18 | String bitString = "";
19 | for (int i = 0; i < value.size(); i++) {
20 | bitString += FixedIntegerEncoder.encode(value.get(i), elementBitStringLength);
21 | }
22 |
23 | while (bitString.length() < elementBitStringLength * numElements) {
24 | bitString += "0";
25 | }
26 |
27 | return bitString;
28 | }
29 |
30 | public static List decode(String bitString, int elementBitStringLength, int numElements)
31 | throws DecodingException {
32 | if (!BITSTRING_VERIFICATION_PATTERN.matcher(bitString).matches()) {
33 | throw new DecodingException("Undecodable FixedIntegerList '" + bitString + "'");
34 | }
35 |
36 | if (bitString.length() > elementBitStringLength * numElements) {
37 | throw new DecodingException("Undecodable FixedIntegerList '" + bitString + "'");
38 | }
39 |
40 | if (bitString.length() % elementBitStringLength != 0) {
41 | throw new DecodingException("Undecodable FixedIntegerList '" + bitString + "'");
42 | }
43 |
44 | while (bitString.length() < elementBitStringLength * numElements) {
45 | bitString += "0";
46 | }
47 |
48 | if (bitString.length() > elementBitStringLength * numElements) {
49 | bitString = bitString.substring(0, elementBitStringLength * numElements);
50 | }
51 |
52 | List value = new ArrayList<>();
53 | for (int i = 0; i < bitString.length(); i += elementBitStringLength) {
54 | value.add(FixedIntegerEncoder.decode(bitString.substring(i, i + elementBitStringLength)));
55 | }
56 |
57 | while (value.size() < numElements) {
58 | value.add(0);
59 | }
60 |
61 | return value;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/encoder/FixedLongEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import java.util.regex.Pattern;
4 | import com.iab.gpp.encoder.error.DecodingException;
5 | import com.iab.gpp.encoder.error.EncodingException;
6 |
7 | public class FixedLongEncoder {
8 |
9 | private static Pattern BITSTRING_VERIFICATION_PATTERN = Pattern.compile("^[0-1]*$", Pattern.CASE_INSENSITIVE);
10 |
11 | public static String encode(long value, int bitStringLength) {
12 | String bitString = "";
13 | while (value > 0) {
14 | if ((value & 1) == 1) {
15 | bitString = "1" + bitString;
16 | } else {
17 | bitString = "0" + bitString;
18 | }
19 | value = value >> 1;
20 | }
21 |
22 | if (bitString.length() > bitStringLength) {
23 | throw new EncodingException(
24 | "Numeric value '" + value + "' is too large for a bit string length of '" + bitStringLength + "'");
25 | }
26 |
27 | while (bitString.length() < bitStringLength) {
28 | bitString = "0" + bitString;
29 | }
30 |
31 | return bitString;
32 | }
33 |
34 | public static long decode(String bitString) throws DecodingException {
35 | if (!BITSTRING_VERIFICATION_PATTERN.matcher(bitString).matches()) {
36 | throw new DecodingException("Undecodable FixedLong '" + bitString + "'");
37 | }
38 |
39 | long value = 0;
40 |
41 | for (int i = 0; i < bitString.length(); i++) {
42 | if (bitString.charAt(bitString.length() - (i + 1)) == '1') {
43 | value += 1L << i;
44 | }
45 | }
46 |
47 | return value;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/encoder/FixedStringEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import java.util.regex.Pattern;
4 | import com.iab.gpp.encoder.error.DecodingException;
5 | import com.iab.gpp.encoder.error.EncodingException;
6 |
7 | public class FixedStringEncoder {
8 |
9 | private static Pattern BITSTRING_VERIFICATION_PATTERN = Pattern.compile("^[0-1]*$", Pattern.CASE_INSENSITIVE);
10 |
11 | public static String encode(String value, int stringLength) {
12 | while (value.length() < stringLength) {
13 | value += " ";
14 | }
15 |
16 | String bitString = "";
17 | for (int i = 0; i < value.length(); i++) {
18 | int code = (int) value.charAt(i);
19 | if (code == 32) {
20 | // space
21 | bitString += FixedIntegerEncoder.encode(63, 6);
22 | } else if (code >= 65) {
23 | bitString += FixedIntegerEncoder.encode(((int) value.charAt(i)) - 65, 6);
24 | } else {
25 | throw new EncodingException("Unencodable FixedString '" + value + "'");
26 | }
27 | }
28 |
29 | return bitString;
30 | }
31 |
32 | public static String decode(String bitString) {
33 | if (!BITSTRING_VERIFICATION_PATTERN.matcher(bitString).matches() || bitString.length() % 6 != 0) {
34 | throw new DecodingException("Undecodable FixedString '" + bitString + "'");
35 | }
36 |
37 | String value = "";
38 |
39 | for (int i = 0; i < bitString.length(); i += 6) {
40 | int code = FixedIntegerEncoder.decode(bitString.substring(i, i + 6));
41 | if (code == 63) {
42 | value += " ";
43 | } else {
44 | value += (char) (code + 65);
45 | }
46 | }
47 |
48 | return value.trim();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/encoder/OptimizedFibonacciRangeEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.regex.Pattern;
6 | import com.iab.gpp.encoder.error.DecodingException;
7 | import com.iab.gpp.encoder.error.EncodingException;
8 |
9 | public class OptimizedFibonacciRangeEncoder {
10 |
11 | private static Pattern BITSTRING_VERIFICATION_PATTERN = Pattern.compile("^[0-1]*$", Pattern.CASE_INSENSITIVE);
12 |
13 | public static String encode(List value) throws EncodingException {
14 | // TODO: encoding the range before choosing the shortest is inefficient. There is probably a way
15 | // to identify in advance which will be shorter based on the array length and values
16 | int max = value.size() > 0 ? value.get(value.size() - 1) : 0;
17 | String rangeBitString = FibonacciIntegerRangeEncoder.encode(value);
18 | int rangeLength = rangeBitString.length();
19 | int bitFieldLength = max;
20 |
21 | if (rangeLength <= bitFieldLength) {
22 | return FixedIntegerEncoder.encode(max, 16) + "1" + rangeBitString;
23 | } else {
24 | List bits = new ArrayList<>();
25 | int index = 0;
26 | for (int i = 0; i < max; i++) {
27 | if (i == value.get(index) - 1) {
28 | bits.add(true);
29 | index++;
30 | } else {
31 | bits.add(false);
32 | }
33 | }
34 | return FixedIntegerEncoder.encode(max, 16) + "0" + FixedBitfieldEncoder.encode(bits, bitFieldLength);
35 | }
36 | }
37 |
38 | public static List decode(String bitString) throws DecodingException {
39 | if (!BITSTRING_VERIFICATION_PATTERN.matcher(bitString).matches() || bitString.length() < 12) {
40 | throw new DecodingException("Undecodable FibonacciIntegerRange '" + bitString + "'");
41 | }
42 |
43 | if (bitString.charAt(16) == '1') {
44 | return FibonacciIntegerRangeEncoder.decode(bitString.substring(17));
45 | } else {
46 | List value = new ArrayList<>();
47 | List bits = FixedBitfieldEncoder.decode(bitString.substring(17));
48 | for (int i = 0; i < bits.size(); i++) {
49 | if (bits.get(i) == true) {
50 | value.add(i + 1);
51 | }
52 | }
53 | return value;
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/datatype/encoder/OptimizedFixedRangeEncoder.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.regex.Pattern;
6 | import com.iab.gpp.encoder.error.DecodingException;
7 | import com.iab.gpp.encoder.error.EncodingException;
8 |
9 | public class OptimizedFixedRangeEncoder {
10 |
11 | private static Pattern BITSTRING_VERIFICATION_PATTERN = Pattern.compile("^[0-1]*$", Pattern.CASE_INSENSITIVE);
12 |
13 | public static String encode(List value) throws EncodingException {
14 | // TODO: encoding the range before choosing the shortest is inefficient. There is probably a way
15 | // to identify in advance which will be shorter based on the array length and values
16 | int max = value.size() > 0 ? value.get(value.size() - 1) : 0;
17 | String rangeBitString = FixedIntegerRangeEncoder.encode(value);
18 | int rangeLength = rangeBitString.length();
19 | int bitFieldLength = max;
20 |
21 | if (rangeLength <= bitFieldLength) {
22 | return FixedIntegerEncoder.encode(max, 16) + "1" + rangeBitString;
23 | } else {
24 | List bits = new ArrayList<>();
25 | int index = 0;
26 | for (int i = 0; i < max; i++) {
27 | if (i == value.get(index) - 1) {
28 | bits.add(true);
29 | index++;
30 | } else {
31 | bits.add(false);
32 | }
33 | }
34 |
35 | return FixedIntegerEncoder.encode(max, 16) + "0" + FixedBitfieldEncoder.encode(bits, bitFieldLength);
36 | }
37 | }
38 |
39 | public static List decode(String bitString) throws DecodingException {
40 | if (!BITSTRING_VERIFICATION_PATTERN.matcher(bitString).matches() || bitString.length() < 12) {
41 | throw new DecodingException("Undecodable FixedIntegerRange '" + bitString + "'");
42 | }
43 |
44 | if (bitString.charAt(16) == '1') {
45 | return FixedIntegerRangeEncoder.decode(bitString.substring(17));
46 | } else {
47 | List value = new ArrayList<>();
48 | List bits = FixedBitfieldEncoder.decode(bitString.substring(17));
49 | for (int i = 0; i < bits.size(); i++) {
50 | if (bits.get(i) == true) {
51 | value.add(i + 1);
52 | }
53 | }
54 | return value;
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/error/DecodingException.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.error;
2 |
3 | public class DecodingException extends RuntimeException {
4 |
5 | private static final long serialVersionUID = 2098268445119981680L;
6 |
7 | public DecodingException(String msg) {
8 | super(msg);
9 | }
10 |
11 | public DecodingException(Exception e) {
12 | super(e);
13 | }
14 |
15 | public DecodingException(String msg, Exception e) {
16 | super(msg, e);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/error/EncodingException.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.error;
2 |
3 | public class EncodingException extends RuntimeException {
4 |
5 | private static final long serialVersionUID = 1161321945571871601L;
6 |
7 | public EncodingException(String msg) {
8 | super(msg);
9 | }
10 |
11 | public EncodingException(Exception e) {
12 | super(e);
13 | }
14 |
15 | public EncodingException(String msg, Exception e) {
16 | super(msg, e);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/error/InvalidFieldException.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.error;
2 |
3 | public class InvalidFieldException extends RuntimeException {
4 |
5 | private static final long serialVersionUID = 2098268445119981680L;
6 |
7 | public InvalidFieldException(String msg) {
8 | super(msg);
9 | }
10 |
11 | public InvalidFieldException(Exception e) {
12 | super(e);
13 | }
14 |
15 | public InvalidFieldException(String msg, Exception e) {
16 | super(msg, e);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/error/ValidationException.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.error;
2 |
3 | public class ValidationException extends DecodingException {
4 |
5 | private static final long serialVersionUID = 2098268445119981680L;
6 |
7 | public ValidationException(String msg) {
8 | super(msg);
9 | }
10 |
11 | public ValidationException(Exception e) {
12 | super(e);
13 | }
14 |
15 | public ValidationException(String msg, Exception e) {
16 | super(msg, e);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/EncodableBitStringFields.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 | import com.iab.gpp.encoder.datatype.AbstractEncodableBitStringDataType;
6 |
7 | public class EncodableBitStringFields implements Fields> {
8 |
9 | private Map> fields = new HashMap<>();
10 |
11 | public boolean containsKey(String key) {
12 | return this.fields.containsKey(key);
13 | }
14 |
15 | public void put(String key, AbstractEncodableBitStringDataType> value) {
16 | this.fields.put(key, value);
17 | }
18 |
19 | public AbstractEncodableBitStringDataType> get(String key) {
20 | return this.fields.get(key);
21 | }
22 |
23 | public Map> getAll() {
24 | return new HashMap<>(this.fields);
25 | }
26 |
27 | public void reset(Fields> fields) {
28 | this.fields.clear();
29 | this.fields.putAll(fields.getAll());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/Fields.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Map;
4 | import com.iab.gpp.encoder.datatype.DataType;
5 |
6 | public interface Fields> {
7 |
8 | boolean containsKey(String key);
9 | void put(String key, T value);
10 | T get(String key);
11 | Map getAll();
12 | void reset(Fields fields);
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/GenericFields.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 | import com.iab.gpp.encoder.datatype.DataType;
6 |
7 | public class GenericFields implements Fields> {
8 |
9 | private Map> fields = new HashMap<>();
10 |
11 | public boolean containsKey(String key) {
12 | return this.fields.containsKey(key);
13 | }
14 |
15 | public void put(String key, DataType> value) {
16 | this.fields.put(key, value);
17 | }
18 |
19 | public DataType> get(String key) {
20 | return this.fields.get(key);
21 | }
22 |
23 | public Map> getAll() {
24 | return new HashMap<>(this.fields);
25 | }
26 |
27 | public void reset(Fields> fields) {
28 | this.fields.clear();
29 | this.fields.putAll(fields.getAll());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/HeaderV1Field.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class HeaderV1Field {
7 |
8 | public static String ID = "Id";
9 | public static String VERSION = "Version";
10 | public static String SECTION_IDS = "SectionIds";
11 |
12 | //@formatter:off
13 | public static List HEADER_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
14 | HeaderV1Field.ID,
15 | HeaderV1Field.VERSION,
16 | HeaderV1Field.SECTION_IDS
17 | });
18 | //@formatter:on
19 |
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsCaField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsCaField {
7 |
8 | public static String VERSION = "Version";
9 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
10 | public static String SHARING_OPT_OUT_NOTICE = "SharingOptOutNotice";
11 | public static String SENSITIVE_DATA_LIMIT_USE_NOTICE = "SensitiveDataLimitUseNotice";
12 | public static String SALE_OPT_OUT = "SaleOptOut";
13 | public static String SHARING_OPT_OUT = "SharingOptOut";
14 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16 | public static String PERSONAL_DATA_CONSENTS = "PersonalDataConsents";
17 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20 |
21 | public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
22 | public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
23 | public static String GPC = "Gpc";
24 |
25 | //@formatter:off
26 | public static List USCA_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27 | UsCaField.VERSION,
28 | UsCaField.SALE_OPT_OUT_NOTICE,
29 | UsCaField.SHARING_OPT_OUT_NOTICE,
30 | UsCaField.SENSITIVE_DATA_LIMIT_USE_NOTICE,
31 | UsCaField.SALE_OPT_OUT,
32 | UsCaField.SHARING_OPT_OUT,
33 | UsCaField.SENSITIVE_DATA_PROCESSING,
34 | UsCaField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
35 | UsCaField.PERSONAL_DATA_CONSENTS,
36 | UsCaField.MSPA_COVERED_TRANSACTION,
37 | UsCaField.MSPA_OPT_OUT_OPTION_MODE,
38 | UsCaField.MSPA_SERVICE_PROVIDER_MODE
39 | });
40 | //@formatter:on
41 |
42 | //@formatter:off
43 | public static List USCA_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44 | UsCaField.GPC_SEGMENT_TYPE,
45 | UsCaField.GPC
46 | });
47 | //@formatter:on
48 | }
49 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsCoField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsCoField {
7 |
8 | public static String VERSION = "Version";
9 | public static String SHARING_NOTICE = "SharingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SALE_OPT_OUT = "SaleOptOut";
13 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
14 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
17 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
18 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
19 |
20 | public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
21 | public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
22 | public static String GPC = "Gpc";
23 |
24 | //@formatter:off
25 | public static List USCO_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
26 | UsCoField.VERSION,
27 | UsCoField.SHARING_NOTICE,
28 | UsCoField.SALE_OPT_OUT_NOTICE,
29 | UsCoField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
30 | UsCoField.SALE_OPT_OUT,
31 | UsCoField.TARGETED_ADVERTISING_OPT_OUT,
32 | UsCoField.SENSITIVE_DATA_PROCESSING,
33 | UsCoField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
34 | UsCoField.MSPA_COVERED_TRANSACTION,
35 | UsCoField.MSPA_OPT_OUT_OPTION_MODE,
36 | UsCoField.MSPA_SERVICE_PROVIDER_MODE
37 | });
38 | //@formatter:on
39 |
40 | //@formatter:off
41 | public static List USCO_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
42 | UsCoField.GPC_SEGMENT_TYPE,
43 | UsCoField.GPC
44 | });
45 | //@formatter:on
46 | }
47 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsCtField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsCtField {
7 |
8 | public static String VERSION = "Version";
9 | public static String SHARING_NOTICE = "SharingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SALE_OPT_OUT = "SaleOptOut";
13 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
14 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
17 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
18 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
19 |
20 | public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
21 | public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
22 | public static String GPC = "Gpc";
23 |
24 | //@formatter:off
25 | public static List USCT_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
26 | UsCtField.VERSION,
27 | UsCtField.SHARING_NOTICE,
28 | UsCtField.SALE_OPT_OUT_NOTICE,
29 | UsCtField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
30 | UsCtField.SALE_OPT_OUT,
31 | UsCtField.TARGETED_ADVERTISING_OPT_OUT,
32 | UsCtField.SENSITIVE_DATA_PROCESSING,
33 | UsCtField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
34 | UsCtField.MSPA_COVERED_TRANSACTION,
35 | UsCtField.MSPA_OPT_OUT_OPTION_MODE,
36 | UsCtField.MSPA_SERVICE_PROVIDER_MODE
37 | });
38 | //@formatter:on
39 |
40 | //@formatter:off
41 | public static List USCT_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
42 | UsCtField.GPC_SEGMENT_TYPE,
43 | UsCtField.GPC
44 | });
45 | //@formatter:on
46 | }
47 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsDeField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsDeField {
7 |
8 | public static String VERSION = "Version";
9 | public static String PROCESSING_NOTICE = "ProcessingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SALE_OPT_OUT = "SaleOptOut";
13 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
14 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16 | public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";
17 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20 |
21 | public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
22 | public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
23 | public static String GPC = "Gpc";
24 |
25 | //@formatter:off
26 | public static List USDE_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27 | UsDeField.VERSION,
28 | UsDeField.PROCESSING_NOTICE,
29 | UsDeField.SALE_OPT_OUT_NOTICE,
30 | UsDeField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
31 | UsDeField.SALE_OPT_OUT,
32 | UsDeField.TARGETED_ADVERTISING_OPT_OUT,
33 | UsDeField.SENSITIVE_DATA_PROCESSING,
34 | UsDeField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
35 | UsDeField.ADDITIONAL_DATA_PROCESSING_CONSENT,
36 | UsDeField.MSPA_COVERED_TRANSACTION,
37 | UsDeField.MSPA_OPT_OUT_OPTION_MODE,
38 | UsDeField.MSPA_SERVICE_PROVIDER_MODE
39 | });
40 | //@formatter:on
41 |
42 | //@formatter:off
43 | public static List USDE_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44 | UsDeField.GPC_SEGMENT_TYPE,
45 | UsDeField.GPC
46 | });
47 | //@formatter:on
48 | }
49 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsFlField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsFlField {
7 |
8 | public static String VERSION = "Version";
9 | public static String PROCESSING_NOTICE = "ProcessingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SALE_OPT_OUT = "SaleOptOut";
13 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
14 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16 | public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";
17 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20 |
21 | //@formatter:off
22 | public static List USFL_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
23 | UsFlField.VERSION,
24 | UsFlField.PROCESSING_NOTICE,
25 | UsFlField.SALE_OPT_OUT_NOTICE,
26 | UsFlField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
27 | UsFlField.SALE_OPT_OUT,
28 | UsFlField.TARGETED_ADVERTISING_OPT_OUT,
29 | UsFlField.SENSITIVE_DATA_PROCESSING,
30 | UsFlField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
31 | UsFlField.ADDITIONAL_DATA_PROCESSING_CONSENT,
32 | UsFlField.MSPA_COVERED_TRANSACTION,
33 | UsFlField.MSPA_OPT_OUT_OPTION_MODE,
34 | UsFlField.MSPA_SERVICE_PROVIDER_MODE
35 | });
36 | //@formatter:on
37 | }
38 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsIaField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsIaField {
7 |
8 | public static String VERSION = "Version";
9 | public static String PROCESSING_NOTICE = "ProcessingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SENSITIVE_DATA_OPT_OUT_NOTICE = "SensitiveDataOptOutNotice";
13 | public static String SALE_OPT_OUT = "SaleOptOut";
14 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
15 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
16 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
17 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20 |
21 | public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
22 | public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
23 | public static String GPC = "Gpc";
24 |
25 | //@formatter:off
26 | public static List USIA_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27 | UsIaField.VERSION,
28 | UsIaField.PROCESSING_NOTICE,
29 | UsIaField.SALE_OPT_OUT_NOTICE,
30 | UsIaField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
31 | UsIaField.SENSITIVE_DATA_OPT_OUT_NOTICE,
32 | UsIaField.SALE_OPT_OUT,
33 | UsIaField.TARGETED_ADVERTISING_OPT_OUT,
34 | UsIaField.SENSITIVE_DATA_PROCESSING,
35 | UsIaField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
36 | UsIaField.MSPA_COVERED_TRANSACTION,
37 | UsIaField.MSPA_OPT_OUT_OPTION_MODE,
38 | UsIaField.MSPA_SERVICE_PROVIDER_MODE
39 | });
40 | //@formatter:on
41 |
42 | //@formatter:off
43 | public static List USIA_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44 | UsIaField.GPC_SEGMENT_TYPE,
45 | UsIaField.GPC
46 | });
47 | //@formatter:on
48 | }
49 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsMtField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsMtField {
7 |
8 | public static String VERSION = "Version";
9 | public static String SHARING_NOTICE = "SharingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SALE_OPT_OUT = "SaleOptOut";
13 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
14 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16 | public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";
17 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20 |
21 | public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
22 | public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
23 | public static String GPC = "Gpc";
24 |
25 | //@formatter:off
26 | public static List USMT_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27 | UsMtField.VERSION,
28 | UsMtField.SHARING_NOTICE,
29 | UsMtField.SALE_OPT_OUT_NOTICE,
30 | UsMtField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
31 | UsMtField.SALE_OPT_OUT,
32 | UsMtField.TARGETED_ADVERTISING_OPT_OUT,
33 | UsMtField.SENSITIVE_DATA_PROCESSING,
34 | UsMtField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
35 | UsMtField.ADDITIONAL_DATA_PROCESSING_CONSENT,
36 | UsMtField.MSPA_COVERED_TRANSACTION,
37 | UsMtField.MSPA_OPT_OUT_OPTION_MODE,
38 | UsMtField.MSPA_SERVICE_PROVIDER_MODE
39 | });
40 | //@formatter:on
41 |
42 | //@formatter:off
43 | public static List USMT_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44 | UsMtField.GPC_SEGMENT_TYPE,
45 | UsMtField.GPC
46 | });
47 | //@formatter:on
48 | }
49 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsNatField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsNatField {
7 |
8 | public static String VERSION = "Version";
9 | public static String SHARING_NOTICE = "SharingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String SHARING_OPT_OUT_NOTICE = "SharingOptOutNotice";
12 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
13 | public static String SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE = "SensitiveDataProcessingOptOutNotice";
14 | public static String SENSITIVE_DATA_LIMIT_USE_NOTICE = "SensitiveDataLimitUseNotice";
15 | public static String SALE_OPT_OUT = "SaleOptOut";
16 | public static String SHARING_OPT_OUT = "SharingOptOut";
17 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
18 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
19 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
20 | public static String PERSONAL_DATA_CONSENTS = "PersonalDataConsents";
21 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
22 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
23 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
24 |
25 | public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
26 | public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
27 | public static String GPC = "Gpc";
28 |
29 | //@formatter:off
30 | public static List USNAT_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
31 | UsNatField.VERSION,
32 | UsNatField.SHARING_NOTICE,
33 | UsNatField.SALE_OPT_OUT_NOTICE,
34 | UsNatField.SHARING_OPT_OUT_NOTICE,
35 | UsNatField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
36 | UsNatField.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE,
37 | UsNatField.SENSITIVE_DATA_LIMIT_USE_NOTICE,
38 | UsNatField.SALE_OPT_OUT,
39 | UsNatField.SHARING_OPT_OUT,
40 | UsNatField.TARGETED_ADVERTISING_OPT_OUT,
41 | UsNatField.SENSITIVE_DATA_PROCESSING,
42 | UsNatField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
43 | UsNatField.PERSONAL_DATA_CONSENTS,
44 | UsNatField.MSPA_COVERED_TRANSACTION,
45 | UsNatField.MSPA_OPT_OUT_OPTION_MODE,
46 | UsNatField.MSPA_SERVICE_PROVIDER_MODE
47 | });
48 | //@formatter:on
49 |
50 | //@formatter:off
51 | public static List USNAT_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
52 | UsNatField.GPC_SEGMENT_TYPE,
53 | UsNatField.GPC
54 | });
55 | //@formatter:on
56 | }
57 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsNeField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsNeField {
7 |
8 | public static String VERSION = "Version";
9 | public static String PROCESSING_NOTICE = "ProcessingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SALE_OPT_OUT = "SaleOptOut";
13 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
14 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16 | public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";
17 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20 |
21 | public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
22 | public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
23 | public static String GPC = "Gpc";
24 |
25 | //@formatter:off
26 | public static List USNE_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27 | UsNeField.VERSION,
28 | UsNeField.PROCESSING_NOTICE,
29 | UsNeField.SALE_OPT_OUT_NOTICE,
30 | UsNeField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
31 | UsNeField.SALE_OPT_OUT,
32 | UsNeField.TARGETED_ADVERTISING_OPT_OUT,
33 | UsNeField.SENSITIVE_DATA_PROCESSING,
34 | UsNeField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
35 | UsNeField.ADDITIONAL_DATA_PROCESSING_CONSENT,
36 | UsNeField.MSPA_COVERED_TRANSACTION,
37 | UsNeField.MSPA_OPT_OUT_OPTION_MODE,
38 | UsNeField.MSPA_SERVICE_PROVIDER_MODE
39 | });
40 | //@formatter:on
41 |
42 | //@formatter:off
43 | public static List USNE_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44 | UsNeField.GPC_SEGMENT_TYPE,
45 | UsNeField.GPC
46 | });
47 | //@formatter:on
48 | }
49 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsNhField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsNhField {
7 |
8 | public static String VERSION = "Version";
9 | public static String PROCESSING_NOTICE = "ProcessingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SALE_OPT_OUT = "SaleOptOut";
13 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
14 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16 | public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";
17 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20 |
21 | public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
22 | public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
23 | public static String GPC = "Gpc";
24 |
25 | //@formatter:off
26 | public static List USNH_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27 | UsNhField.VERSION,
28 | UsNhField.PROCESSING_NOTICE,
29 | UsNhField.SALE_OPT_OUT_NOTICE,
30 | UsNhField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
31 | UsNhField.SALE_OPT_OUT,
32 | UsNhField.TARGETED_ADVERTISING_OPT_OUT,
33 | UsNhField.SENSITIVE_DATA_PROCESSING,
34 | UsNhField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
35 | UsNhField.ADDITIONAL_DATA_PROCESSING_CONSENT,
36 | UsNhField.MSPA_COVERED_TRANSACTION,
37 | UsNhField.MSPA_OPT_OUT_OPTION_MODE,
38 | UsNhField.MSPA_SERVICE_PROVIDER_MODE
39 | });
40 | //@formatter:on
41 |
42 | //@formatter:off
43 | public static List USNH_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44 | UsNhField.GPC_SEGMENT_TYPE,
45 | UsNhField.GPC
46 | });
47 | //@formatter:on
48 | }
49 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsNjField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsNjField {
7 |
8 | public static String VERSION = "Version";
9 | public static String PROCESSING_NOTICE = "ProcessingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SALE_OPT_OUT = "SaleOptOut";
13 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
14 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16 | public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";
17 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20 |
21 | public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
22 | public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
23 | public static String GPC = "Gpc";
24 |
25 | //@formatter:off
26 | public static List USNJ_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27 | UsNjField.VERSION,
28 | UsNjField.PROCESSING_NOTICE,
29 | UsNjField.SALE_OPT_OUT_NOTICE,
30 | UsNjField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
31 | UsNjField.SALE_OPT_OUT,
32 | UsNjField.TARGETED_ADVERTISING_OPT_OUT,
33 | UsNjField.SENSITIVE_DATA_PROCESSING,
34 | UsNjField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
35 | UsNjField.ADDITIONAL_DATA_PROCESSING_CONSENT,
36 | UsNjField.MSPA_COVERED_TRANSACTION,
37 | UsNjField.MSPA_OPT_OUT_OPTION_MODE,
38 | UsNjField.MSPA_SERVICE_PROVIDER_MODE
39 | });
40 | //@formatter:on
41 |
42 | //@formatter:off
43 | public static List USNJ_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44 | UsNjField.GPC_SEGMENT_TYPE,
45 | UsNjField.GPC
46 | });
47 | //@formatter:on
48 | }
49 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsOrField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsOrField {
7 |
8 | public static String VERSION = "Version";
9 | public static String PROCESSING_NOTICE = "ProcessingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SALE_OPT_OUT = "SaleOptOut";
13 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
14 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16 | public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";
17 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20 |
21 | public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
22 | public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
23 | public static String GPC = "Gpc";
24 |
25 | //@formatter:off
26 | public static List USOR_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27 | UsOrField.VERSION,
28 | UsOrField.PROCESSING_NOTICE,
29 | UsOrField.SALE_OPT_OUT_NOTICE,
30 | UsOrField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
31 | UsOrField.SALE_OPT_OUT,
32 | UsOrField.TARGETED_ADVERTISING_OPT_OUT,
33 | UsOrField.SENSITIVE_DATA_PROCESSING,
34 | UsOrField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
35 | UsOrField.ADDITIONAL_DATA_PROCESSING_CONSENT,
36 | UsOrField.MSPA_COVERED_TRANSACTION,
37 | UsOrField.MSPA_OPT_OUT_OPTION_MODE,
38 | UsOrField.MSPA_SERVICE_PROVIDER_MODE
39 | });
40 | //@formatter:on
41 |
42 | //@formatter:off
43 | public static List USOR_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44 | UsOrField.GPC_SEGMENT_TYPE,
45 | UsOrField.GPC
46 | });
47 | //@formatter:on
48 | }
49 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsTnField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsTnField {
7 |
8 | public static String VERSION = "Version";
9 | public static String PROCESSING_NOTICE = "ProcessingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SALE_OPT_OUT = "SaleOptOut";
13 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
14 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16 | public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";
17 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20 |
21 | public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
22 | public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
23 | public static String GPC = "Gpc";
24 |
25 | //@formatter:off
26 | public static List USTN_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27 | UsTnField.VERSION,
28 | UsTnField.PROCESSING_NOTICE,
29 | UsTnField.SALE_OPT_OUT_NOTICE,
30 | UsTnField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
31 | UsTnField.SALE_OPT_OUT,
32 | UsTnField.TARGETED_ADVERTISING_OPT_OUT,
33 | UsTnField.SENSITIVE_DATA_PROCESSING,
34 | UsTnField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
35 | UsTnField.ADDITIONAL_DATA_PROCESSING_CONSENT,
36 | UsTnField.MSPA_COVERED_TRANSACTION,
37 | UsTnField.MSPA_OPT_OUT_OPTION_MODE,
38 | UsTnField.MSPA_SERVICE_PROVIDER_MODE
39 | });
40 | //@formatter:on
41 |
42 | //@formatter:off
43 | public static List USTN_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44 | UsTnField.GPC_SEGMENT_TYPE,
45 | UsTnField.GPC
46 | });
47 | //@formatter:on
48 | }
49 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsTxField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsTxField {
7 |
8 | public static String VERSION = "Version";
9 | public static String PROCESSING_NOTICE = "ProcessingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SALE_OPT_OUT = "SaleOptOut";
13 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
14 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16 | public static String ADDITIONAL_DATA_PROCESSING_CONSENT = "AdditionalDataProcessingConsent";
17 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20 |
21 | public static String GPC_SEGMENT_TYPE = "GpcSegmentType";
22 | public static String GPC_SEGMENT_INCLUDED = "GpcSegmentIncluded";
23 | public static String GPC = "Gpc";
24 |
25 | //@formatter:off
26 | public static List USTX_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
27 | UsTxField.VERSION,
28 | UsTxField.PROCESSING_NOTICE,
29 | UsTxField.SALE_OPT_OUT_NOTICE,
30 | UsTxField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
31 | UsTxField.SALE_OPT_OUT,
32 | UsTxField.TARGETED_ADVERTISING_OPT_OUT,
33 | UsTxField.SENSITIVE_DATA_PROCESSING,
34 | UsTxField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
35 | UsTxField.ADDITIONAL_DATA_PROCESSING_CONSENT,
36 | UsTxField.MSPA_COVERED_TRANSACTION,
37 | UsTxField.MSPA_OPT_OUT_OPTION_MODE,
38 | UsTxField.MSPA_SERVICE_PROVIDER_MODE
39 | });
40 | //@formatter:on
41 |
42 | //@formatter:off
43 | public static List USTX_GPC_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
44 | UsTxField.GPC_SEGMENT_TYPE,
45 | UsTxField.GPC
46 | });
47 | //@formatter:on
48 | }
49 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsUtField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsUtField {
7 |
8 | public static String VERSION = "Version";
9 | public static String SHARING_NOTICE = "SharingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE = "SensitiveDataProcessingOptOutNotice";
13 | public static String SALE_OPT_OUT = "SaleOptOut";
14 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
15 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
16 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
17 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
18 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
19 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
20 |
21 | //@formatter:off
22 | public static List USUT_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
23 | UsUtField.VERSION,
24 | UsUtField.SHARING_NOTICE,
25 | UsUtField.SALE_OPT_OUT_NOTICE,
26 | UsUtField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
27 | UsUtField.SENSITIVE_DATA_PROCESSING_OPT_OUT_NOTICE,
28 | UsUtField.SALE_OPT_OUT,
29 | UsUtField.TARGETED_ADVERTISING_OPT_OUT,
30 | UsUtField.SENSITIVE_DATA_PROCESSING,
31 | UsUtField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
32 | UsUtField.MSPA_COVERED_TRANSACTION,
33 | UsUtField.MSPA_OPT_OUT_OPTION_MODE,
34 | UsUtField.MSPA_SERVICE_PROVIDER_MODE
35 | });
36 | //@formatter:on
37 | }
38 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UsVaField.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UsVaField {
7 |
8 | public static String VERSION = "Version";
9 | public static String SHARING_NOTICE = "SharingNotice";
10 | public static String SALE_OPT_OUT_NOTICE = "SaleOptOutNotice";
11 | public static String TARGETED_ADVERTISING_OPT_OUT_NOTICE = "TargetedAdvertisingOptOutNotice";
12 | public static String SALE_OPT_OUT = "SaleOptOut";
13 | public static String TARGETED_ADVERTISING_OPT_OUT = "TargetedAdvertisingOptOut";
14 | public static String SENSITIVE_DATA_PROCESSING = "SensitiveDataProcessing";
15 | public static String KNOWN_CHILD_SENSITIVE_DATA_CONSENTS = "KnownChildSensitiveDataConsents";
16 | public static String MSPA_COVERED_TRANSACTION = "MspaCoveredTransaction";
17 | public static String MSPA_OPT_OUT_OPTION_MODE = "MspaOptOutOptionMode";
18 | public static String MSPA_SERVICE_PROVIDER_MODE = "MspaServiceProviderMode";
19 |
20 | //@formatter:off
21 | public static List USVA_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
22 | UsVaField.VERSION,
23 | UsVaField.SHARING_NOTICE,
24 | UsVaField.SALE_OPT_OUT_NOTICE,
25 | UsVaField.TARGETED_ADVERTISING_OPT_OUT_NOTICE,
26 | UsVaField.SALE_OPT_OUT,
27 | UsVaField.TARGETED_ADVERTISING_OPT_OUT,
28 | UsVaField.SENSITIVE_DATA_PROCESSING,
29 | UsVaField.KNOWN_CHILD_SENSITIVE_DATA_CONSENTS,
30 | UsVaField.MSPA_COVERED_TRANSACTION,
31 | UsVaField.MSPA_OPT_OUT_OPTION_MODE,
32 | UsVaField.MSPA_SERVICE_PROVIDER_MODE
33 | });
34 | //@formatter:on
35 | }
36 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/field/UspV1Field.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.field;
2 |
3 | import java.util.Arrays;
4 | import java.util.List;
5 |
6 | public class UspV1Field {
7 |
8 | public static String VERSION = "Version";
9 | public static String NOTICE = "Notice";
10 | public static String OPT_OUT_SALE = "OptOutSale";
11 | public static String LSPA_COVERED = "LspaCovered";
12 |
13 | //@formatter:off
14 | public static List USPV1_CORE_SEGMENT_FIELD_NAMES = Arrays.asList(new String[] {
15 | UspV1Field.VERSION,
16 | UspV1Field.NOTICE,
17 | UspV1Field.OPT_OUT_SALE,
18 | UspV1Field.LSPA_COVERED
19 | });
20 | //@formatter:on
21 | }
22 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/section/EncodableSection.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.section;
2 |
3 | public interface EncodableSection {
4 |
5 | int getId();
6 |
7 | String getName();
8 |
9 | int getVersion();
10 |
11 | boolean hasField(String fieldName);
12 |
13 | Object getFieldValue(String fieldName);
14 |
15 | void setFieldValue(String fieldName, Object value);
16 |
17 | String encode();
18 |
19 | void decode(String encodedString);
20 | }
21 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/section/HeaderV1.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.section;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import com.iab.gpp.encoder.field.HeaderV1Field;
6 | import com.iab.gpp.encoder.segment.EncodableSegment;
7 | import com.iab.gpp.encoder.segment.HeaderV1CoreSegment;
8 |
9 | public class HeaderV1 extends AbstractLazilyEncodableSection {
10 |
11 | public static int ID = 3;
12 | public static int VERSION = 1;
13 | public static String NAME = "header";
14 |
15 | public HeaderV1() {
16 | super();
17 | }
18 |
19 | public HeaderV1(String encodedString) {
20 | super();
21 | decode(encodedString);
22 | }
23 |
24 | @Override
25 | public int getId() {
26 | return HeaderV1.ID;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return HeaderV1.NAME;
32 | }
33 |
34 | @Override
35 | public int getVersion() {
36 | return HeaderV1.VERSION;
37 | }
38 |
39 | @Override
40 | protected List initializeSegments() {
41 | List segments = new ArrayList<>();
42 | segments.add(new HeaderV1CoreSegment());
43 | return segments;
44 | }
45 |
46 | @Override
47 | protected List decodeSection(String encodedString) {
48 | List segments = initializeSegments();
49 |
50 | if(encodedString != null && !encodedString.isEmpty()) {
51 | String[] encodedSegments = encodedString.split("\\.");
52 |
53 | for(int i=0; i i) {
55 | segments.get(i).decode(encodedSegments[i]);
56 | }
57 | }
58 | }
59 |
60 | return segments;
61 | }
62 |
63 | @Override
64 | protected String encodeSection(List segments) {
65 | List encodedSegments = new ArrayList<>();
66 | for(EncodableSegment segment : segments) {
67 | encodedSegments.add(segment.encode());
68 | }
69 | return String.join(".", encodedSegments);
70 | }
71 |
72 |
73 | @SuppressWarnings("unchecked")
74 | public List getSectionsIds() {
75 | return (List) this.getFieldValue(HeaderV1Field.SECTION_IDS);
76 | }
77 |
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/section/Sections.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.section;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.List;
6 | import java.util.Map;
7 | import java.util.stream.Collectors;
8 |
9 | public class Sections {
10 |
11 | public static List SECTION_ORDER;
12 |
13 | public static Map SECTION_ID_NAME_MAP;
14 |
15 | static {
16 | SECTION_ID_NAME_MAP = new HashMap<>();
17 |
18 | SECTION_ID_NAME_MAP.put(TcfEuV2.ID, TcfEuV2.NAME);
19 | SECTION_ID_NAME_MAP.put(TcfCaV1.ID, TcfCaV1.NAME);
20 | SECTION_ID_NAME_MAP.put(UspV1.ID, UspV1.NAME);
21 | SECTION_ID_NAME_MAP.put(UsNat.ID, UsNat.NAME);
22 | SECTION_ID_NAME_MAP.put(UsCa.ID, UsCa.NAME);
23 | SECTION_ID_NAME_MAP.put(UsVa.ID, UsVa.NAME);
24 | SECTION_ID_NAME_MAP.put(UsCo.ID, UsCo.NAME);
25 | SECTION_ID_NAME_MAP.put(UsUt.ID, UsUt.NAME);
26 | SECTION_ID_NAME_MAP.put(UsCt.ID, UsCt.NAME);
27 | SECTION_ID_NAME_MAP.put(UsFl.ID, UsFl.NAME);
28 | SECTION_ID_NAME_MAP.put(UsMt.ID, UsMt.NAME);
29 | SECTION_ID_NAME_MAP.put(UsOr.ID, UsOr.NAME);
30 | SECTION_ID_NAME_MAP.put(UsTx.ID, UsTx.NAME);
31 | SECTION_ID_NAME_MAP.put(UsDe.ID, UsDe.NAME);
32 | SECTION_ID_NAME_MAP.put(UsIa.ID, UsIa.NAME);
33 | SECTION_ID_NAME_MAP.put(UsNe.ID, UsNe.NAME);
34 | SECTION_ID_NAME_MAP.put(UsNh.ID, UsNh.NAME);
35 | SECTION_ID_NAME_MAP.put(UsNj.ID, UsNj.NAME);
36 | SECTION_ID_NAME_MAP.put(UsTn.ID, UsTn.NAME);
37 |
38 | SECTION_ORDER = new ArrayList(SECTION_ID_NAME_MAP.keySet()).stream().sorted()
39 | .map(id -> SECTION_ID_NAME_MAP.get(id)).collect(Collectors.toList());
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/section/UspV1.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.section;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import com.iab.gpp.encoder.field.UspV1Field;
6 | import com.iab.gpp.encoder.segment.EncodableSegment;
7 | import com.iab.gpp.encoder.segment.UspV1CoreSegment;
8 |
9 | public class UspV1 extends AbstractLazilyEncodableSection {
10 |
11 | public static int ID = 6;
12 | public static int VERSION = 1;
13 | public static String NAME = "uspv1";
14 |
15 | public UspV1() {
16 | super();
17 | }
18 |
19 | public UspV1(String encodedString) {
20 | super();
21 | decode(encodedString);
22 | }
23 |
24 | @Override
25 | public int getId() {
26 | return UspV1.ID;
27 | }
28 |
29 | @Override
30 | public String getName() {
31 | return UspV1.NAME;
32 | }
33 |
34 | @Override
35 | public int getVersion() {
36 | return UspV1.VERSION;
37 | }
38 |
39 | @Override
40 | protected List initializeSegments() {
41 | List segments = new ArrayList<>();
42 | segments.add(new UspV1CoreSegment());
43 | return segments;
44 | }
45 |
46 | @Override
47 | protected List decodeSection(String encodedString) {
48 | List segments = initializeSegments();
49 |
50 | if(encodedString != null && !encodedString.isEmpty()) {
51 | String[] encodedSegments = encodedString.split("\\.");
52 |
53 | for(int i=0; i i) {
55 | segments.get(i).decode(encodedSegments[i]);
56 | }
57 | }
58 | }
59 |
60 | return segments;
61 | }
62 |
63 | @Override
64 | protected String encodeSection(List segments) {
65 | List encodedSegments = new ArrayList<>();
66 | for(EncodableSegment segment : segments) {
67 | encodedSegments.add(segment.encode());
68 | }
69 | return String.join(".", encodedSegments);
70 | }
71 |
72 |
73 | public Character getNotice() {
74 | return (Character) this.getFieldValue(UspV1Field.NOTICE);
75 | }
76 |
77 | public Character getOptOutSale() {
78 | return (Character) this.getFieldValue(UspV1Field.OPT_OUT_SALE);
79 | }
80 |
81 | public Character getLspaCovered() {
82 | return (Character) this.getFieldValue(UspV1Field.LSPA_COVERED);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/AbstractLazilyEncodableSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import com.iab.gpp.encoder.error.InvalidFieldException;
4 | import com.iab.gpp.encoder.field.Fields;
5 |
6 | public abstract class AbstractLazilyEncodableSegment> implements EncodableSegment {
7 |
8 | protected T fields;
9 |
10 | private String encodedString = null;
11 |
12 | private boolean dirty = false;
13 | private boolean decoded = true;
14 |
15 | public AbstractLazilyEncodableSegment() {
16 | this.fields = initializeFields();
17 | }
18 |
19 | protected abstract T initializeFields();
20 |
21 | protected abstract String encodeSegment(T fields);
22 |
23 | protected abstract void decodeSegment(String encodedString, T Fields);
24 |
25 | public boolean hasField(String fieldName) {
26 | return this.fields.containsKey(fieldName);
27 | }
28 |
29 | public Object getFieldValue(String fieldName) {
30 | if (!this.decoded) {
31 | this.decodeSegment(this.encodedString, this.fields);
32 | this.dirty = false;
33 | this.decoded = true;
34 | }
35 |
36 | if (this.fields.containsKey(fieldName)) {
37 | return this.fields.get(fieldName).getValue();
38 | } else {
39 | throw new InvalidFieldException("Invalid field: '" + fieldName + "'");
40 | }
41 | }
42 |
43 | public void setFieldValue(String fieldName, Object value) {
44 | if (!this.decoded) {
45 | this.decodeSegment(this.encodedString, this.fields);
46 | this.dirty = false;
47 | this.decoded = true;
48 | }
49 |
50 | if (this.fields.containsKey(fieldName)) {
51 | this.fields.get(fieldName).setValue(value);
52 | this.dirty = true;
53 | } else {
54 | throw new InvalidFieldException(fieldName + " not found");
55 | }
56 | }
57 |
58 | public String encode() {
59 | if (this.encodedString == null || this.encodedString.isEmpty() || this.dirty) {
60 | this.validate();
61 | this.encodedString = encodeSegment(this.fields);
62 | this.dirty = false;
63 | this.decoded = true;
64 | }
65 |
66 | return this.encodedString;
67 | }
68 |
69 | public void decode(String encodedString) {
70 | this.encodedString = encodedString;
71 | this.dirty = false;
72 | this.decoded = false;
73 | }
74 |
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/EncodableSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 |
5 | public interface EncodableSegment {
6 |
7 | List getFieldNames();
8 |
9 | boolean hasField(String fieldName);
10 |
11 | Object getFieldValue(String fieldName);
12 |
13 | void setFieldValue(String fieldName, Object value);
14 |
15 | String encode();
16 |
17 | void decode(String encodedString);
18 |
19 | default void validate() {};
20 | }
21 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/HeaderV1CoreSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
6 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
7 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
8 | import com.iab.gpp.encoder.datatype.EncodableFibonacciIntegerRange;
9 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
10 | import com.iab.gpp.encoder.error.DecodingException;
11 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
12 | import com.iab.gpp.encoder.field.HeaderV1Field;
13 | import com.iab.gpp.encoder.section.HeaderV1;
14 |
15 | public class HeaderV1CoreSegment extends AbstractLazilyEncodableSegment {
16 |
17 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
18 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
19 |
20 | public HeaderV1CoreSegment() {
21 | super();
22 | }
23 |
24 | public HeaderV1CoreSegment(String encodedString) {
25 | super();
26 | this.decode(encodedString);
27 | }
28 |
29 | @Override
30 | public List getFieldNames() {
31 | return HeaderV1Field.HEADER_CORE_SEGMENT_FIELD_NAMES;
32 | }
33 |
34 | @Override
35 | protected EncodableBitStringFields initializeFields() {
36 | EncodableBitStringFields fields = new EncodableBitStringFields();
37 | fields.put(HeaderV1Field.ID, new EncodableFixedInteger(6, HeaderV1.ID));
38 | fields.put(HeaderV1Field.VERSION, new EncodableFixedInteger(6, HeaderV1.VERSION));
39 | fields.put(HeaderV1Field.SECTION_IDS, new EncodableFibonacciIntegerRange(new ArrayList<>()));
40 | return fields;
41 | }
42 |
43 | @Override
44 | protected String encodeSegment(EncodableBitStringFields fields) {
45 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
46 | String encodedString = base64UrlEncoder.encode(bitString);
47 | return encodedString;
48 | }
49 |
50 | @Override
51 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
52 | if(encodedString == null || encodedString.isEmpty()) {
53 | this.fields.reset(fields);
54 | }
55 | try {
56 | String bitString = base64UrlEncoder.decode(encodedString);
57 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
58 | } catch (Exception e) {
59 | throw new DecodingException("Unable to decode HeaderV1CoreSegment '" + encodedString + "'", e);
60 | }
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/TcfCaV1DisclosedVendorsSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
6 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
7 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.datatype.EncodableOptimizedFixedRange;
10 | import com.iab.gpp.encoder.error.DecodingException;
11 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
12 | import com.iab.gpp.encoder.field.TcfCaV1Field;
13 |
14 | public class TcfCaV1DisclosedVendorsSegment extends AbstractLazilyEncodableSegment {
15 |
16 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
17 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
18 |
19 | public TcfCaV1DisclosedVendorsSegment() {
20 | super();
21 | }
22 |
23 | public TcfCaV1DisclosedVendorsSegment(String encodedString) {
24 | super();
25 | this.decode(encodedString);
26 | }
27 |
28 | @Override
29 | public List getFieldNames() {
30 | return TcfCaV1Field.TCFCAV1_DISCLOSED_VENDORS_SEGMENT_FIELD_NAMES;
31 | }
32 |
33 | @Override
34 | protected EncodableBitStringFields initializeFields() {
35 | EncodableBitStringFields fields = new EncodableBitStringFields();
36 | fields.put(TcfCaV1Field.DISCLOSED_VENDORS_SEGMENT_TYPE, new EncodableFixedInteger(3, 1));
37 | fields.put(TcfCaV1Field.DISCLOSED_VENDORS, new EncodableOptimizedFixedRange(new ArrayList<>()));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if (encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode TcfCaV1DisclosedVendorsSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/TcfEuV2VendorsAllowedSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
6 | import com.iab.gpp.encoder.base64.TraditionalBase64UrlEncoder;
7 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.datatype.EncodableOptimizedFixedRange;
10 | import com.iab.gpp.encoder.error.DecodingException;
11 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
12 | import com.iab.gpp.encoder.field.TcfEuV2Field;
13 |
14 | public class TcfEuV2VendorsAllowedSegment extends AbstractLazilyEncodableSegment {
15 |
16 | private AbstractBase64UrlEncoder base64UrlEncoder = TraditionalBase64UrlEncoder.getInstance();
17 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
18 |
19 | public TcfEuV2VendorsAllowedSegment() {
20 | super();
21 | }
22 |
23 | public TcfEuV2VendorsAllowedSegment(String encodedString) {
24 | super();
25 | this.decode(encodedString);
26 | }
27 |
28 | @Override
29 | public List getFieldNames() {
30 | return TcfEuV2Field.TCFEUV2_VENDORS_ALLOWED_SEGMENT_FIELD_NAMES;
31 | }
32 |
33 | @Override
34 | protected EncodableBitStringFields initializeFields() {
35 | EncodableBitStringFields fields = new EncodableBitStringFields();
36 | fields.put(TcfEuV2Field.VENDORS_ALLOWED_SEGMENT_TYPE, new EncodableFixedInteger(3, 2));
37 | fields.put(TcfEuV2Field.VENDORS_ALLOWED, new EncodableOptimizedFixedRange(new ArrayList<>()));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode TcfEuV2VendorsAllowedSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/TcfEuV2VendorsDisclosedSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
6 | import com.iab.gpp.encoder.base64.TraditionalBase64UrlEncoder;
7 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.datatype.EncodableOptimizedFixedRange;
10 | import com.iab.gpp.encoder.error.DecodingException;
11 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
12 | import com.iab.gpp.encoder.field.TcfEuV2Field;
13 |
14 | public class TcfEuV2VendorsDisclosedSegment extends AbstractLazilyEncodableSegment {
15 |
16 | private AbstractBase64UrlEncoder base64UrlEncoder = TraditionalBase64UrlEncoder.getInstance();
17 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
18 |
19 | public TcfEuV2VendorsDisclosedSegment() {
20 | super();
21 | }
22 |
23 | public TcfEuV2VendorsDisclosedSegment(String encodedString) {
24 | super();
25 | this.decode(encodedString);
26 | }
27 |
28 | @Override
29 | public List getFieldNames() {
30 | return TcfEuV2Field.TCFEUV2_VENDORS_DISCLOSED_SEGMENT_FIELD_NAMES;
31 | }
32 |
33 | @Override
34 | protected EncodableBitStringFields initializeFields() {
35 | EncodableBitStringFields fields = new EncodableBitStringFields();
36 | fields.put(TcfEuV2Field.VENDORS_DISCLOSED_SEGMENT_TYPE, new EncodableFixedInteger(3, 1));
37 | fields.put(TcfEuV2Field.VENDORS_DISCLOSED, new EncodableOptimizedFixedRange(new ArrayList<>()));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode TcfEuV2VendorsDisclosedSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsCaGpcSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
5 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
6 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
7 | import com.iab.gpp.encoder.datatype.EncodableBoolean;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.error.DecodingException;
10 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
11 | import com.iab.gpp.encoder.field.UsCaField;
12 |
13 | public class UsCaGpcSegment extends AbstractLazilyEncodableSegment {
14 |
15 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
16 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
17 |
18 | public UsCaGpcSegment() {
19 | super();
20 | }
21 |
22 | public UsCaGpcSegment(String encodedString) {
23 | super();
24 | this.decode(encodedString);
25 | }
26 |
27 | @Override
28 | public List getFieldNames() {
29 | return UsCaField.USCA_GPC_SEGMENT_FIELD_NAMES;
30 | }
31 |
32 | @Override
33 | protected EncodableBitStringFields initializeFields() {
34 | EncodableBitStringFields fields = new EncodableBitStringFields();
35 | fields.put(UsCaField.GPC_SEGMENT_TYPE, new EncodableFixedInteger(2, 1));
36 | fields.put(UsCaField.GPC_SEGMENT_INCLUDED, new EncodableBoolean(true));
37 | fields.put(UsCaField.GPC, new EncodableBoolean(false));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode UsCaGpcSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsCoGpcSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
5 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
6 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
7 | import com.iab.gpp.encoder.datatype.EncodableBoolean;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.error.DecodingException;
10 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
11 | import com.iab.gpp.encoder.field.UsCoField;
12 |
13 | public class UsCoGpcSegment extends AbstractLazilyEncodableSegment {
14 |
15 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
16 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
17 |
18 | public UsCoGpcSegment() {
19 | super();
20 | }
21 |
22 | public UsCoGpcSegment(String encodedString) {
23 | super();
24 | this.decode(encodedString);
25 | }
26 |
27 | @Override
28 | public List getFieldNames() {
29 | return UsCoField.USCO_GPC_SEGMENT_FIELD_NAMES;
30 | }
31 |
32 | @Override
33 | protected EncodableBitStringFields initializeFields() {
34 | EncodableBitStringFields fields = new EncodableBitStringFields();
35 | fields.put(UsCoField.GPC_SEGMENT_TYPE, new EncodableFixedInteger(2, 1));
36 | fields.put(UsCoField.GPC_SEGMENT_INCLUDED, new EncodableBoolean(true));
37 | fields.put(UsCoField.GPC, new EncodableBoolean(false));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode UsCoGpcSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsCtGpcSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
5 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
6 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
7 | import com.iab.gpp.encoder.datatype.EncodableBoolean;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.error.DecodingException;
10 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
11 | import com.iab.gpp.encoder.field.UsCtField;
12 |
13 | public class UsCtGpcSegment extends AbstractLazilyEncodableSegment {
14 |
15 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
16 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
17 |
18 | public UsCtGpcSegment() {
19 | super();
20 | }
21 |
22 | public UsCtGpcSegment(String encodedString) {
23 | super();
24 | this.decode(encodedString);
25 | }
26 |
27 | @Override
28 | public List getFieldNames() {
29 | return UsCtField.USCT_GPC_SEGMENT_FIELD_NAMES;
30 | }
31 |
32 | @Override
33 | protected EncodableBitStringFields initializeFields() {
34 | EncodableBitStringFields fields = new EncodableBitStringFields();
35 | fields.put(UsCtField.GPC_SEGMENT_TYPE, new EncodableFixedInteger(2, 1));
36 | fields.put(UsCtField.GPC_SEGMENT_INCLUDED, new EncodableBoolean(true));
37 | fields.put(UsCtField.GPC, new EncodableBoolean(false));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode UsCtGpcSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsDeGpcSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
5 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
6 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
7 | import com.iab.gpp.encoder.datatype.EncodableBoolean;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.error.DecodingException;
10 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
11 | import com.iab.gpp.encoder.field.UsDeField;
12 |
13 | public class UsDeGpcSegment extends AbstractLazilyEncodableSegment {
14 |
15 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
16 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
17 |
18 | public UsDeGpcSegment() {
19 | super();
20 | }
21 |
22 | public UsDeGpcSegment(String encodedString) {
23 | super();
24 | this.decode(encodedString);
25 | }
26 |
27 | @Override
28 | public List getFieldNames() {
29 | return UsDeField.USDE_GPC_SEGMENT_FIELD_NAMES;
30 | }
31 |
32 | @Override
33 | protected EncodableBitStringFields initializeFields() {
34 | EncodableBitStringFields fields = new EncodableBitStringFields();
35 | fields.put(UsDeField.GPC_SEGMENT_TYPE, new EncodableFixedInteger(2, 1));
36 | fields.put(UsDeField.GPC_SEGMENT_INCLUDED, new EncodableBoolean(true));
37 | fields.put(UsDeField.GPC, new EncodableBoolean(false));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode UsDeGpcSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsIaGpcSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
5 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
6 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
7 | import com.iab.gpp.encoder.datatype.EncodableBoolean;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.error.DecodingException;
10 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
11 | import com.iab.gpp.encoder.field.UsIaField;
12 |
13 | public class UsIaGpcSegment extends AbstractLazilyEncodableSegment {
14 |
15 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
16 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
17 |
18 | public UsIaGpcSegment() {
19 | super();
20 | }
21 |
22 | public UsIaGpcSegment(String encodedString) {
23 | super();
24 | this.decode(encodedString);
25 | }
26 |
27 | @Override
28 | public List getFieldNames() {
29 | return UsIaField.USIA_GPC_SEGMENT_FIELD_NAMES;
30 | }
31 |
32 | @Override
33 | protected EncodableBitStringFields initializeFields() {
34 | EncodableBitStringFields fields = new EncodableBitStringFields();
35 | fields.put(UsIaField.GPC_SEGMENT_TYPE, new EncodableFixedInteger(2, 1));
36 | fields.put(UsIaField.GPC_SEGMENT_INCLUDED, new EncodableBoolean(true));
37 | fields.put(UsIaField.GPC, new EncodableBoolean(false));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode UsIaGpcSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsMtGpcSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
5 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
6 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
7 | import com.iab.gpp.encoder.datatype.EncodableBoolean;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.error.DecodingException;
10 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
11 | import com.iab.gpp.encoder.field.UsMtField;
12 |
13 | public class UsMtGpcSegment extends AbstractLazilyEncodableSegment {
14 |
15 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
16 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
17 |
18 | public UsMtGpcSegment() {
19 | super();
20 | }
21 |
22 | public UsMtGpcSegment(String encodedString) {
23 | super();
24 | this.decode(encodedString);
25 | }
26 |
27 | @Override
28 | public List getFieldNames() {
29 | return UsMtField.USMT_GPC_SEGMENT_FIELD_NAMES;
30 | }
31 |
32 | @Override
33 | protected EncodableBitStringFields initializeFields() {
34 | EncodableBitStringFields fields = new EncodableBitStringFields();
35 | fields.put(UsMtField.GPC_SEGMENT_TYPE, new EncodableFixedInteger(2, 1));
36 | fields.put(UsMtField.GPC_SEGMENT_INCLUDED, new EncodableBoolean(true));
37 | fields.put(UsMtField.GPC, new EncodableBoolean(false));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode UsMtGpcSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsNatGpcSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
5 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
6 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
7 | import com.iab.gpp.encoder.datatype.EncodableBoolean;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.error.DecodingException;
10 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
11 | import com.iab.gpp.encoder.field.UsNatField;
12 |
13 | public class UsNatGpcSegment extends AbstractLazilyEncodableSegment {
14 |
15 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
16 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
17 |
18 | public UsNatGpcSegment() {
19 | super();
20 | }
21 |
22 | public UsNatGpcSegment(String encodedString) {
23 | super();
24 | this.decode(encodedString);
25 | }
26 |
27 | @Override
28 | public List getFieldNames() {
29 | return UsNatField.USNAT_GPC_SEGMENT_FIELD_NAMES;
30 | }
31 |
32 | @Override
33 | protected EncodableBitStringFields initializeFields() {
34 | EncodableBitStringFields fields = new EncodableBitStringFields();
35 | fields.put(UsNatField.GPC_SEGMENT_TYPE, new EncodableFixedInteger(2, 1));
36 | fields.put(UsNatField.GPC_SEGMENT_INCLUDED, new EncodableBoolean(true));
37 | fields.put(UsNatField.GPC, new EncodableBoolean(false));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode UsNatGpcSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsNeGpcSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
5 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
6 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
7 | import com.iab.gpp.encoder.datatype.EncodableBoolean;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.error.DecodingException;
10 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
11 | import com.iab.gpp.encoder.field.UsNeField;
12 |
13 | public class UsNeGpcSegment extends AbstractLazilyEncodableSegment {
14 |
15 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
16 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
17 |
18 | public UsNeGpcSegment() {
19 | super();
20 | }
21 |
22 | public UsNeGpcSegment(String encodedString) {
23 | super();
24 | this.decode(encodedString);
25 | }
26 |
27 | @Override
28 | public List getFieldNames() {
29 | return UsNeField.USNE_GPC_SEGMENT_FIELD_NAMES;
30 | }
31 |
32 | @Override
33 | protected EncodableBitStringFields initializeFields() {
34 | EncodableBitStringFields fields = new EncodableBitStringFields();
35 | fields.put(UsNeField.GPC_SEGMENT_TYPE, new EncodableFixedInteger(2, 1));
36 | fields.put(UsNeField.GPC_SEGMENT_INCLUDED, new EncodableBoolean(true));
37 | fields.put(UsNeField.GPC, new EncodableBoolean(false));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode UsNeGpcSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsNhGpcSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
5 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
6 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
7 | import com.iab.gpp.encoder.datatype.EncodableBoolean;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.error.DecodingException;
10 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
11 | import com.iab.gpp.encoder.field.UsNhField;
12 |
13 | public class UsNhGpcSegment extends AbstractLazilyEncodableSegment {
14 |
15 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
16 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
17 |
18 | public UsNhGpcSegment() {
19 | super();
20 | }
21 |
22 | public UsNhGpcSegment(String encodedString) {
23 | super();
24 | this.decode(encodedString);
25 | }
26 |
27 | @Override
28 | public List getFieldNames() {
29 | return UsNhField.USNH_GPC_SEGMENT_FIELD_NAMES;
30 | }
31 |
32 | @Override
33 | protected EncodableBitStringFields initializeFields() {
34 | EncodableBitStringFields fields = new EncodableBitStringFields();
35 | fields.put(UsNhField.GPC_SEGMENT_TYPE, new EncodableFixedInteger(2, 1));
36 | fields.put(UsNhField.GPC_SEGMENT_INCLUDED, new EncodableBoolean(true));
37 | fields.put(UsNhField.GPC, new EncodableBoolean(false));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode UsNhGpcSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsNjGpcSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
5 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
6 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
7 | import com.iab.gpp.encoder.datatype.EncodableBoolean;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.error.DecodingException;
10 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
11 | import com.iab.gpp.encoder.field.UsNjField;
12 |
13 | public class UsNjGpcSegment extends AbstractLazilyEncodableSegment {
14 |
15 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
16 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
17 |
18 | public UsNjGpcSegment() {
19 | super();
20 | }
21 |
22 | public UsNjGpcSegment(String encodedString) {
23 | super();
24 | this.decode(encodedString);
25 | }
26 |
27 | @Override
28 | public List getFieldNames() {
29 | return UsNjField.USNJ_GPC_SEGMENT_FIELD_NAMES;
30 | }
31 |
32 | @Override
33 | protected EncodableBitStringFields initializeFields() {
34 | EncodableBitStringFields fields = new EncodableBitStringFields();
35 | fields.put(UsNjField.GPC_SEGMENT_TYPE, new EncodableFixedInteger(2, 1));
36 | fields.put(UsNjField.GPC_SEGMENT_INCLUDED, new EncodableBoolean(true));
37 | fields.put(UsNjField.GPC, new EncodableBoolean(false));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode UsNjGpcSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsOrGpcSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
5 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
6 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
7 | import com.iab.gpp.encoder.datatype.EncodableBoolean;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.error.DecodingException;
10 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
11 | import com.iab.gpp.encoder.field.UsOrField;
12 |
13 | public class UsOrGpcSegment extends AbstractLazilyEncodableSegment {
14 |
15 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
16 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
17 |
18 | public UsOrGpcSegment() {
19 | super();
20 | }
21 |
22 | public UsOrGpcSegment(String encodedString) {
23 | super();
24 | this.decode(encodedString);
25 | }
26 |
27 | @Override
28 | public List getFieldNames() {
29 | return UsOrField.USOR_GPC_SEGMENT_FIELD_NAMES;
30 | }
31 |
32 | @Override
33 | protected EncodableBitStringFields initializeFields() {
34 | EncodableBitStringFields fields = new EncodableBitStringFields();
35 | fields.put(UsOrField.GPC_SEGMENT_TYPE, new EncodableFixedInteger(2, 1));
36 | fields.put(UsOrField.GPC_SEGMENT_INCLUDED, new EncodableBoolean(true));
37 | fields.put(UsOrField.GPC, new EncodableBoolean(false));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode UsOrGpcSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsTnGpcSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
5 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
6 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
7 | import com.iab.gpp.encoder.datatype.EncodableBoolean;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.error.DecodingException;
10 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
11 | import com.iab.gpp.encoder.field.UsTnField;
12 |
13 | public class UsTnGpcSegment extends AbstractLazilyEncodableSegment {
14 |
15 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
16 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
17 |
18 | public UsTnGpcSegment() {
19 | super();
20 | }
21 |
22 | public UsTnGpcSegment(String encodedString) {
23 | super();
24 | this.decode(encodedString);
25 | }
26 |
27 | @Override
28 | public List getFieldNames() {
29 | return UsTnField.USTN_GPC_SEGMENT_FIELD_NAMES;
30 | }
31 |
32 | @Override
33 | protected EncodableBitStringFields initializeFields() {
34 | EncodableBitStringFields fields = new EncodableBitStringFields();
35 | fields.put(UsTnField.GPC_SEGMENT_TYPE, new EncodableFixedInteger(2, 1));
36 | fields.put(UsTnField.GPC_SEGMENT_INCLUDED, new EncodableBoolean(true));
37 | fields.put(UsTnField.GPC, new EncodableBoolean(false));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode UsTnGpcSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UsTxGpcSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.base64.AbstractBase64UrlEncoder;
5 | import com.iab.gpp.encoder.base64.CompressedBase64UrlEncoder;
6 | import com.iab.gpp.encoder.bitstring.BitStringEncoder;
7 | import com.iab.gpp.encoder.datatype.EncodableBoolean;
8 | import com.iab.gpp.encoder.datatype.EncodableFixedInteger;
9 | import com.iab.gpp.encoder.error.DecodingException;
10 | import com.iab.gpp.encoder.field.EncodableBitStringFields;
11 | import com.iab.gpp.encoder.field.UsTxField;
12 |
13 | public class UsTxGpcSegment extends AbstractLazilyEncodableSegment {
14 |
15 | private AbstractBase64UrlEncoder base64UrlEncoder = CompressedBase64UrlEncoder.getInstance();
16 | private BitStringEncoder bitStringEncoder = BitStringEncoder.getInstance();
17 |
18 | public UsTxGpcSegment() {
19 | super();
20 | }
21 |
22 | public UsTxGpcSegment(String encodedString) {
23 | super();
24 | this.decode(encodedString);
25 | }
26 |
27 | @Override
28 | public List getFieldNames() {
29 | return UsTxField.USTX_GPC_SEGMENT_FIELD_NAMES;
30 | }
31 |
32 | @Override
33 | protected EncodableBitStringFields initializeFields() {
34 | EncodableBitStringFields fields = new EncodableBitStringFields();
35 | fields.put(UsTxField.GPC_SEGMENT_TYPE, new EncodableFixedInteger(2, 1));
36 | fields.put(UsTxField.GPC_SEGMENT_INCLUDED, new EncodableBoolean(true));
37 | fields.put(UsTxField.GPC, new EncodableBoolean(false));
38 | return fields;
39 | }
40 |
41 | @Override
42 | protected String encodeSegment(EncodableBitStringFields fields) {
43 | String bitString = bitStringEncoder.encode(fields, getFieldNames());
44 | String encodedString = base64UrlEncoder.encode(bitString);
45 | return encodedString;
46 | }
47 |
48 | @Override
49 | protected void decodeSegment(String encodedString, EncodableBitStringFields fields) {
50 | if(encodedString == null || encodedString.isEmpty()) {
51 | this.fields.reset(fields);
52 | }
53 | try {
54 | String bitString = base64UrlEncoder.decode(encodedString);
55 | bitStringEncoder.decode(bitString, getFieldNames(), fields);
56 | } catch (Exception e) {
57 | throw new DecodingException("Unable to decode UsTxGpcSegment '" + encodedString + "'", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/main/java/com/iab/gpp/encoder/segment/UspV1CoreSegment.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.segment;
2 |
3 | import java.util.List;
4 | import com.iab.gpp.encoder.datatype.UnencodableCharacter;
5 | import com.iab.gpp.encoder.datatype.UnencodableInteger;
6 | import com.iab.gpp.encoder.error.DecodingException;
7 | import com.iab.gpp.encoder.field.GenericFields;
8 | import com.iab.gpp.encoder.field.UspV1Field;
9 | import com.iab.gpp.encoder.section.UspV1;
10 |
11 | public class UspV1CoreSegment extends AbstractLazilyEncodableSegment {
12 |
13 | public UspV1CoreSegment() {
14 | super();
15 | }
16 |
17 | public UspV1CoreSegment(String encodedString) {
18 | super();
19 | this.decode(encodedString);
20 | }
21 |
22 | @Override
23 | public List getFieldNames() {
24 | return UspV1Field.USPV1_CORE_SEGMENT_FIELD_NAMES;
25 | }
26 |
27 | @Override
28 | protected GenericFields initializeFields() {
29 | GenericFields fields = new GenericFields();
30 | fields.put(UspV1Field.VERSION, new UnencodableInteger(UspV1.VERSION));
31 | fields.put(UspV1Field.NOTICE, new UnencodableCharacter('-', (v -> v == 'Y' || v == 'N' || v == '-')));
32 | fields.put(UspV1Field.OPT_OUT_SALE, new UnencodableCharacter('-', (v -> v == 'Y' || v == 'N' || v == '-')));
33 | fields.put(UspV1Field.LSPA_COVERED, new UnencodableCharacter('-', (v -> v == 'Y' || v == 'N' || v == '-')));
34 | return fields;
35 | }
36 |
37 | @Override
38 | protected String encodeSegment(GenericFields fields) {
39 | String str = "";
40 | str += fields.get(UspV1Field.VERSION).getValue();
41 | str += fields.get(UspV1Field.NOTICE).getValue();
42 | str += fields.get(UspV1Field.OPT_OUT_SALE).getValue();
43 | str += fields.get(UspV1Field.LSPA_COVERED).getValue();
44 | return str;
45 | }
46 |
47 | @Override
48 | protected void decodeSegment(String encodedString, GenericFields fields) {
49 | if (encodedString == null || encodedString.length() != 4) {
50 | throw new DecodingException("Invalid uspv1 string: '" + encodedString + "'");
51 | }
52 |
53 | try {
54 | fields.get(UspV1Field.VERSION).setValue(Integer.parseInt(encodedString.substring(0, 1)));
55 | fields.get(UspV1Field.NOTICE).setValue(encodedString.charAt(1));
56 | fields.get(UspV1Field.OPT_OUT_SALE).setValue(encodedString.charAt(2));
57 | fields.get(UspV1Field.LSPA_COVERED).setValue(encodedString.charAt(3));
58 | } catch (Exception e) {
59 | throw new DecodingException("Unable to decode UspV1CoreSegment '" + encodedString + "'", e);
60 | }
61 | }
62 |
63 | }
64 |
65 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/base64/TraditionalBase64UrlEncoderTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.base64;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 |
6 | public class TraditionalBase64UrlEncoderTest {
7 |
8 | private TraditionalBase64UrlEncoder base64UrlEncoder = TraditionalBase64UrlEncoder.getInstance();
9 |
10 | @Test
11 | public void testEncode1() {
12 | Assertions.assertEquals("DBABMAAA", base64UrlEncoder.encode("0000110000010000000000010011"));
13 | }
14 |
15 | @Test
16 | public void testEncode2() {
17 | Assertions.assertEquals("DBACNYAA", base64UrlEncoder.encode("000011000001000000000010001101011"));
18 | }
19 |
20 | @Test
21 | public void testEncode3() {
22 | Assertions.assertEquals("DBABjwAA", base64UrlEncoder.encode("00001100000100000000000110001111"));
23 | }
24 |
25 | @Test
26 | public void testDecode1() {
27 | Assertions.assertEquals("000011000001000000000001001100000000000000000000", base64UrlEncoder.decode("DBABMAAA"));
28 | }
29 |
30 | @Test
31 | public void testDecode2() {
32 | Assertions.assertEquals("000011000001000000000010001101011000000000000000", base64UrlEncoder.decode("DBACNYAA"));
33 | }
34 |
35 | @Test
36 | public void testDecode3() {
37 | Assertions.assertEquals("000011000001000000000001100011110000000000000000", base64UrlEncoder.decode("DBABjwAA"));
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/EncodableBooleanTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 |
6 | public class EncodableBooleanTest {
7 |
8 | @Test
9 | public void testSubstring1() throws SubstringException {
10 | Assertions.assertEquals("000000000000000000000000000000000000",
11 | new EncodableDatetime().substring("10000000000000000000000000000000000001", 1));
12 | }
13 |
14 | @Test
15 | public void testSubstring2() throws SubstringException {
16 | Assertions.assertEquals("111111111111111111111111111111111111",
17 | new EncodableDatetime().substring("01111111111111111111111111111111111110", 1));
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/EncodableDatetimeTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 | import com.iab.gpp.encoder.error.DecodingException;
6 |
7 | public class EncodableDatetimeTest {
8 |
9 | @Test
10 | public void testSubstring1() throws DecodingException, SubstringException {
11 | Assertions.assertEquals("000000000000000000000000000000000000",
12 | new EncodableDatetime().substring("10000000000000000000000000000000000001", 1));
13 | }
14 |
15 | @Test
16 | public void testSubstring2() throws DecodingException, SubstringException {
17 | Assertions.assertEquals("111111111111111111111111111111111111",
18 | new EncodableDatetime().substring("01111111111111111111111111111111111110", 1));
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/EncodableFibonacciIntegerRangeTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 | import com.iab.gpp.encoder.error.DecodingException;
6 |
7 | public class EncodableFibonacciIntegerRangeTest {
8 |
9 | @Test
10 | public void testSubstring1() throws DecodingException, SubstringException {
11 | Assertions.assertEquals("0000000000100001110110011",
12 | new EncodableFibonacciIntegerRange().substring("100000000001000011101100110", 1));
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/EncodableFibonacciIntegerTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 | import com.iab.gpp.encoder.error.DecodingException;
6 |
7 | public class EncodableFibonacciIntegerTest {
8 |
9 | @Test
10 | public void testSubstring1() throws DecodingException, SubstringException {
11 | Assertions.assertEquals("0011", new EncodableFibonacciInteger().substring("100111", 1));
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/EncodableFixedBitfieldTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 |
6 | public class EncodableFixedBitfieldTest {
7 |
8 | @Test
9 | public void testSubstring1() throws SubstringException {
10 | Assertions.assertEquals("000", new EncodableFixedBitfield(3).substring("10001", 1));
11 | }
12 |
13 | @Test
14 | public void testSubstring2() throws SubstringException {
15 | Assertions.assertEquals("111", new EncodableFixedBitfield(3).substring("01110", 1));
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/EncodableFixedIntegerListTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 |
6 | public class EncodableFixedIntegerListTest {
7 |
8 | @Test
9 | public void testSubstring1() throws SubstringException {
10 | Assertions.assertEquals("1000", new EncodableFixedIntegerList(2, 2).substring("10001", 0));
11 | }
12 |
13 | @Test
14 | public void testSubstring2() throws SubstringException {
15 | Assertions.assertEquals("1110", new EncodableFixedIntegerList(2, 2).substring("01110", 1));
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/EncodableFixedIntegerRangeTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import java.util.Arrays;
4 | import org.junit.jupiter.api.Assertions;
5 | import org.junit.jupiter.api.Test;
6 | import com.iab.gpp.encoder.error.DecodingException;
7 | import com.iab.gpp.encoder.error.EncodingException;
8 |
9 | public class EncodableFixedIntegerRangeTest {
10 |
11 | @Test
12 | public void testSubstring1() throws DecodingException, SubstringException {
13 | Assertions.assertEquals("00000000001000000000000000011100000000000001010000000000001000",
14 | new EncodableFixedIntegerRange().substring("1000000000010000000000000000111000000000000010100000000000010001",
15 | 1));
16 | }
17 |
18 | @Test
19 | public void testSubstring2() throws DecodingException, SubstringException {
20 | Assertions.assertEquals("00000000000100000000000011101", new EncodableFixedIntegerRange().substring(
21 | "000010001111010010000110111111111100000000001111010010000110111111111100000000000000000000000000000000000000000100001101000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000001110110000000000010000000000001110100000000000000000000000000000",
22 | 230));
23 | }
24 |
25 | @Test
26 | public void testEncode1() throws EncodingException {
27 | EncodableFixedIntegerRange encodableFixedIntegerRange = new EncodableFixedIntegerRange();
28 | encodableFixedIntegerRange.setValue(Arrays.asList(28));
29 | Assertions.assertEquals("00000000000100000000000011100", encodableFixedIntegerRange.encode());
30 | }
31 |
32 | @Test
33 | public void testEncode2() throws EncodingException {
34 | EncodableFixedIntegerRange encodableFixedIntegerRange = new EncodableFixedIntegerRange();
35 | encodableFixedIntegerRange.setValue(Arrays.asList(29));
36 | Assertions.assertEquals("00000000000100000000000011101", encodableFixedIntegerRange.encode());
37 | }
38 |
39 | @Test
40 | public void testDecode1() throws DecodingException {
41 | EncodableFixedIntegerRange encodableFixedIntegerRange = new EncodableFixedIntegerRange();
42 | encodableFixedIntegerRange.decode("00000000000100000000000011100");
43 | Assertions.assertEquals(Arrays.asList(28), encodableFixedIntegerRange.getValue());
44 | }
45 |
46 | @Test
47 | public void testDecode2() throws DecodingException {
48 | EncodableFixedIntegerRange encodableFixedIntegerRange = new EncodableFixedIntegerRange();
49 | encodableFixedIntegerRange.decode("00000000000100000000000011101");
50 | Assertions.assertEquals(Arrays.asList(29), encodableFixedIntegerRange.getValue());
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/EncodableFixedIntegerTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 |
6 | public class EncodableFixedIntegerTest {
7 |
8 | @Test
9 | public void testSubstring1() throws SubstringException {
10 | Assertions.assertEquals("000", new EncodableFixedInteger(3).substring("10001", 1));
11 | }
12 |
13 | @Test
14 | public void testSubstring2() throws SubstringException {
15 | Assertions.assertEquals("111", new EncodableFixedInteger(3).substring("01110", 1));
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/EncodableFixedStringTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 |
6 | public class EncodableFixedStringTest {
7 |
8 | @Test
9 | public void testSubstring1() throws SubstringException {
10 | Assertions.assertEquals("000000000000", new EncodableFixedString(2).substring("10000000000001", 1));
11 | }
12 |
13 | @Test
14 | public void testSubstring2() throws SubstringException {
15 | Assertions.assertEquals("111111111111", new EncodableFixedString(2).substring("01111111111110", 1));
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/encoder/BooleanEncoderTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 | import com.iab.gpp.encoder.error.DecodingException;
6 |
7 | public class BooleanEncoderTest {
8 |
9 | @Test
10 | public void testEncode1() {
11 | Assertions.assertEquals("0", BooleanEncoder.encode(false));
12 | }
13 |
14 | @Test
15 | public void testEncode2() {
16 | Assertions.assertEquals("1", BooleanEncoder.encode(true));
17 | }
18 |
19 | @Test
20 | public void testDecode1() {
21 | Assertions.assertEquals(false, BooleanEncoder.decode("0"));
22 | }
23 |
24 | @Test
25 | public void testDecode2() {
26 | Assertions.assertEquals(true, BooleanEncoder.decode("1"));
27 | }
28 |
29 | @Test
30 | public void testDecode3() {
31 | try {
32 | BooleanEncoder.decode("");
33 | Assertions.fail("DecodingException expected");
34 | } catch (DecodingException e) {
35 |
36 | }
37 | }
38 |
39 | @Test
40 | public void testDecode4() {
41 | try {
42 | BooleanEncoder.decode("2");
43 | Assertions.fail("DecodingException expected");
44 | } catch (DecodingException e) {
45 |
46 | }
47 | }
48 |
49 | @Test
50 | public void testDecode5() {
51 | try {
52 | BooleanEncoder.decode("00");
53 | Assertions.fail("DecodingException expected");
54 | } catch (DecodingException e) {
55 |
56 | }
57 | }
58 |
59 | @Test
60 | public void testDecode6() {
61 | try {
62 | BooleanEncoder.decode("01");
63 | Assertions.fail("DecodingException expected");
64 | } catch (DecodingException e) {
65 |
66 | }
67 | }
68 |
69 | @Test
70 | public void testDecode7() {
71 | try {
72 | BooleanEncoder.decode("10");
73 | Assertions.fail("DecodingException expected");
74 | } catch (DecodingException e) {
75 |
76 | }
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/encoder/DatetimeEncoderTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import java.time.ZoneId;
4 | import java.time.ZonedDateTime;
5 | import org.junit.jupiter.api.Assertions;
6 | import org.junit.jupiter.api.Test;
7 | import com.iab.gpp.encoder.error.DecodingException;
8 |
9 | public class DatetimeEncoderTest {
10 |
11 | @Test
12 | public void test1() throws DecodingException {
13 | ZonedDateTime date1 = ZonedDateTime.now(ZoneId.of("UTC"));
14 | String encodedDate1 = DatetimeEncoder.encode(date1);
15 | ZonedDateTime date2 = DatetimeEncoder.decode(encodedDate1);
16 |
17 | Assertions.assertEquals((date1.toInstant().toEpochMilli() / 100L) * 100L, date2.toInstant().toEpochMilli());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/encoder/FixedIntegerEncoderTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 | import com.iab.gpp.encoder.error.DecodingException;
6 | import com.iab.gpp.encoder.error.EncodingException;
7 |
8 | public class FixedIntegerEncoderTest {
9 |
10 | @Test
11 | public void testEncode1() {
12 | Assertions.assertEquals("0", FixedIntegerEncoder.encode(0, 1));
13 | }
14 |
15 | @Test
16 | public void testEncode2() {
17 | Assertions.assertEquals("000000", FixedIntegerEncoder.encode(0, 6));
18 | }
19 |
20 | @Test
21 | public void testEncode3() {
22 | Assertions.assertEquals("1", FixedIntegerEncoder.encode(1, 1));
23 | }
24 |
25 | @Test
26 | public void testEncode4() {
27 | Assertions.assertEquals("0001", FixedIntegerEncoder.encode(1, 4));
28 | }
29 |
30 | @Test
31 | public void testEncode5() {
32 | Assertions.assertEquals("00000111", FixedIntegerEncoder.encode(7, 8));
33 | }
34 |
35 | @Test
36 | public void testEncode6() {
37 | try {
38 | FixedIntegerEncoder.encode(8, 1);
39 | Assertions.fail("EncodingException expected");
40 | } catch (EncodingException e) {
41 |
42 | }
43 | }
44 |
45 | @Test
46 | public void testDecode1() throws DecodingException {
47 | Assertions.assertEquals(0, FixedIntegerEncoder.decode(""));
48 | }
49 |
50 | @Test
51 | public void testDecode2() throws DecodingException {
52 | Assertions.assertEquals(0, FixedIntegerEncoder.decode("0"));
53 | }
54 |
55 | @Test
56 | public void testDecode3() throws DecodingException {
57 | Assertions.assertEquals(0, FixedIntegerEncoder.decode("000000"));
58 | }
59 |
60 | @Test
61 | public void testDecode4() throws DecodingException {
62 | Assertions.assertEquals(1, FixedIntegerEncoder.decode("1"));
63 | }
64 |
65 | @Test
66 | public void testDecode5() throws DecodingException {
67 | Assertions.assertEquals(1, FixedIntegerEncoder.decode("000001"));
68 | }
69 |
70 | @Test
71 | public void testDecode6() throws DecodingException {
72 | Assertions.assertEquals(8, FixedIntegerEncoder.decode("1000"));
73 | }
74 |
75 | @Test
76 | public void testDecode7() throws DecodingException {
77 | Assertions.assertEquals(8, FixedIntegerEncoder.decode("0000001000"));
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/encoder/FixedLongEncoderTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 | import com.iab.gpp.encoder.error.DecodingException;
6 | import com.iab.gpp.encoder.error.EncodingException;
7 |
8 | public class FixedLongEncoderTest {
9 |
10 | @Test
11 | public void testEncode1() {
12 | Assertions.assertEquals("0", FixedLongEncoder.encode(0, 1));
13 | }
14 |
15 | @Test
16 | public void testEncode2() {
17 | Assertions.assertEquals("000000", FixedLongEncoder.encode(0, 6));
18 | }
19 |
20 | @Test
21 | public void testEncode3() {
22 | Assertions.assertEquals("1", FixedLongEncoder.encode(1, 1));
23 | }
24 |
25 | @Test
26 | public void testEncode4() {
27 | Assertions.assertEquals("0001", FixedLongEncoder.encode(1, 4));
28 | }
29 |
30 | @Test
31 | public void testEncode5() {
32 | Assertions.assertEquals("00000111", FixedLongEncoder.encode(7, 8));
33 | }
34 |
35 |
36 | @Test
37 | public void testEncode6() {
38 | Assertions.assertEquals("001111011111010001110101111011110101", FixedLongEncoder.encode(16630898421L, 36));
39 | }
40 |
41 | @Test
42 | public void testEncode7() {
43 | try {
44 | FixedIntegerEncoder.encode(8, 1);
45 | Assertions.fail("EncodingException expected");
46 | } catch (EncodingException e) {
47 |
48 | }
49 | }
50 |
51 | @Test
52 | public void testDecode1() throws DecodingException {
53 | Assertions.assertEquals(0, FixedLongEncoder.decode(""));
54 | }
55 |
56 | @Test
57 | public void testDecode2() throws DecodingException {
58 | Assertions.assertEquals(0, FixedLongEncoder.decode("0"));
59 | }
60 |
61 | @Test
62 | public void testDecode3() throws DecodingException {
63 | Assertions.assertEquals(0, FixedLongEncoder.decode("000000"));
64 | }
65 |
66 | @Test
67 | public void testDecode4() throws DecodingException {
68 | Assertions.assertEquals(1, FixedLongEncoder.decode("1"));
69 | }
70 |
71 | @Test
72 | public void testDecode5() throws DecodingException {
73 | Assertions.assertEquals(1, FixedLongEncoder.decode("000001"));
74 | }
75 |
76 | @Test
77 | public void testDecode6() throws DecodingException {
78 | Assertions.assertEquals(16630898421L, FixedLongEncoder.decode("001111011111010001110101111011110101"));
79 | }
80 |
81 | @Test
82 | public void testDecode7() throws DecodingException {
83 | Assertions.assertEquals(8, FixedLongEncoder.decode("1000"));
84 | }
85 |
86 | @Test
87 | public void testDecode8() throws DecodingException {
88 | Assertions.assertEquals(8, FixedLongEncoder.decode("0000001000"));
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/datatype/encoder/FixedStringEncoderTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.datatype.encoder;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 | import com.iab.gpp.encoder.error.DecodingException;
6 | import com.iab.gpp.encoder.error.EncodingException;
7 |
8 | public class FixedStringEncoderTest {
9 |
10 | @Test
11 | public void testEncode1() {
12 | Assertions.assertEquals("000000000001", FixedStringEncoder.encode("AB", 2));
13 | }
14 |
15 | @Test
16 | public void testEncode2() {
17 | Assertions.assertEquals("100000111111", FixedStringEncoder.encode("a", 2));
18 | }
19 |
20 | @Test
21 | public void testEncode3() {
22 | try {
23 | FixedStringEncoder.encode("1", 2);
24 | Assertions.fail("DecodingException expected");
25 | } catch (EncodingException e) {
26 |
27 | }
28 | }
29 |
30 | @Test
31 | public void testDecode1() {
32 | Assertions.assertEquals("AB", FixedStringEncoder.decode("000000000001"));
33 | }
34 |
35 | @Test
36 | public void testDecode2() {
37 | Assertions.assertEquals("a", FixedStringEncoder.decode("100000111111"));
38 | }
39 |
40 | @Test
41 | public void testDecode3() {
42 | try {
43 | FixedStringEncoder.decode("2");
44 | Assertions.fail("DecodingException expected");
45 | } catch (DecodingException e) {
46 |
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/section/.UsNatV1Test.java.swp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IABTechLab/iabgpp-java/eb6e8c76a71c75b59ba075334853459c334008e0/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/section/.UsNatV1Test.java.swp
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/section/HeaderV1Test.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.section;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Arrays;
5 | import org.junit.jupiter.api.Assertions;
6 | import org.junit.jupiter.api.Test;
7 | import com.iab.gpp.encoder.error.DecodingException;
8 |
9 | public class HeaderV1Test {
10 |
11 | @Test
12 | public void testEncode1() {
13 | HeaderV1 headerV1 = new HeaderV1();
14 | headerV1.setFieldValue("SectionIds", new ArrayList<>());
15 | Assertions.assertEquals("DBAA", headerV1.encode());
16 | }
17 |
18 | @Test
19 | public void testEncode2() {
20 | HeaderV1 headerV1 = new HeaderV1();
21 | headerV1.setFieldValue("SectionIds", Arrays.asList(2));
22 | Assertions.assertEquals("DBABMA", headerV1.encode());
23 | }
24 |
25 | @Test
26 | public void testEncode3() {
27 | HeaderV1 headerV1 = new HeaderV1();
28 | headerV1.setFieldValue("SectionIds", Arrays.asList(2, 6));
29 | Assertions.assertEquals("DBACNYA", headerV1.encode());
30 | }
31 |
32 | @Test
33 | public void testDecode1() {
34 | HeaderV1 headerV1 = new HeaderV1();
35 | headerV1.decode("DBAA");
36 | Assertions.assertEquals(new ArrayList<>(), headerV1.getFieldValue("SectionIds"));
37 | Assertions.assertEquals(headerV1.getFieldValue("Version"), headerV1.getVersion());
38 | Assertions.assertEquals(headerV1.getFieldValue("SectionIds"), headerV1.getSectionsIds());
39 | }
40 |
41 | @Test
42 | public void testDecode2() {
43 | HeaderV1 headerV1 = new HeaderV1();
44 | headerV1.decode("DBABMA");
45 | Assertions.assertEquals(Arrays.asList(2), headerV1.getFieldValue("SectionIds"));
46 | Assertions.assertEquals(headerV1.getFieldValue("Version"), headerV1.getVersion());
47 | Assertions.assertEquals(headerV1.getFieldValue("SectionIds"), headerV1.getSectionsIds());
48 | }
49 |
50 | @Test
51 | public void testDecode3() {
52 | HeaderV1 headerV1 = new HeaderV1();
53 | headerV1.decode("DBACNYA");
54 | Assertions.assertEquals(Arrays.asList(2, 6), headerV1.getFieldValue("SectionIds"));
55 | Assertions.assertEquals(headerV1.getFieldValue("Version"), headerV1.getVersion());
56 | Assertions.assertEquals(headerV1.getFieldValue("SectionIds"), headerV1.getSectionsIds());
57 | }
58 |
59 | @Test()
60 | public void testDecodeGarbage() {
61 | Assertions.assertThrows(DecodingException.class, () -> {
62 | new HeaderV1("z").getSectionsIds();
63 | });
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/iabgpp-encoder/src/test/java/com/iab/gpp/encoder/section/UspV1Test.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.encoder.section;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 | import com.iab.gpp.encoder.error.DecodingException;
6 | import com.iab.gpp.encoder.error.InvalidFieldException;
7 |
8 | public class UspV1Test {
9 |
10 | @Test
11 | public void testEncode1() {
12 | UspV1 uspv1 = new UspV1();
13 | Assertions.assertEquals("1---", uspv1.encode());
14 | }
15 |
16 | @Test
17 | public void testEncode2() {
18 | UspV1 uspv1 = new UspV1();
19 | uspv1.setFieldValue("Notice", 'Y');
20 | uspv1.setFieldValue("OptOutSale", 'N');
21 | uspv1.setFieldValue("LspaCovered", 'N');
22 |
23 | Assertions.assertEquals("1YNN", uspv1.encode());
24 | }
25 |
26 | @Test
27 | public void testEncode3() {
28 | UspV1 uspv1 = new UspV1();
29 | uspv1.setFieldValue("Version", 2);
30 | uspv1.setFieldValue("Notice", 'N');
31 | uspv1.setFieldValue("OptOutSale", 'Y');
32 | uspv1.setFieldValue("LspaCovered", 'Y');
33 |
34 | Assertions.assertEquals("2NYY", uspv1.encode());
35 | }
36 |
37 | @Test
38 | public void testDecode1() throws DecodingException, InvalidFieldException {
39 | UspV1 uspv1 = new UspV1("1NYN");
40 | Assertions.assertEquals(1, uspv1.getFieldValue("Version"));
41 | Assertions.assertEquals('N', uspv1.getFieldValue("Notice"));
42 | Assertions.assertEquals('Y', uspv1.getFieldValue("OptOutSale"));
43 | Assertions.assertEquals('N', uspv1.getFieldValue("LspaCovered"));
44 |
45 | Assertions.assertEquals(uspv1.getFieldValue("Version"), uspv1.getVersion());
46 | Assertions.assertEquals(uspv1.getFieldValue("Notice"), uspv1.getNotice());
47 | Assertions.assertEquals(uspv1.getFieldValue("OptOutSale"), uspv1.getOptOutSale());
48 | Assertions.assertEquals(uspv1.getFieldValue("LspaCovered"), uspv1.getLspaCovered());
49 | }
50 |
51 | @Test
52 | public void testDecode2() throws DecodingException, InvalidFieldException {
53 | UspV1 uspv1 = new UspV1("1YNY");
54 | Assertions.assertEquals(1, uspv1.getFieldValue("Version"));
55 | Assertions.assertEquals('Y', uspv1.getFieldValue("Notice"));
56 | Assertions.assertEquals('N', uspv1.getFieldValue("OptOutSale"));
57 | Assertions.assertEquals('Y', uspv1.getFieldValue("LspaCovered"));
58 |
59 | Assertions.assertEquals(uspv1.getFieldValue("Version"), uspv1.getVersion());
60 | Assertions.assertEquals(uspv1.getFieldValue("Notice"), uspv1.getNotice());
61 | Assertions.assertEquals(uspv1.getFieldValue("OptOutSale"), uspv1.getOptOutSale());
62 | Assertions.assertEquals(uspv1.getFieldValue("LspaCovered"), uspv1.getLspaCovered());
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | iabgpp-core
9 | com.iabgpp
10 | 3.2.4-SNAPSHOT
11 |
12 |
13 | iabgpp-extras-jackson
14 | jar
15 |
16 |
17 |
18 | org.junit.jupiter
19 | junit-jupiter-engine
20 | 5.9.2
21 | test
22 |
23 |
24 |
25 | com.iabgpp
26 | iabgpp-extras
27 | 3.2.4-SNAPSHOT
28 |
29 |
30 |
31 | com.fasterxml.jackson.core
32 | jackson-databind
33 | 2.14.1
34 |
35 |
36 |
37 | com.fasterxml.jackson.datatype
38 | jackson-datatype-jsr310
39 | 2.14.1
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | maven-surefire-plugin
48 | 2.22.2
49 |
50 |
51 |
52 |
53 |
54 |
55 | release
56 |
57 |
58 |
59 | org.apache.maven.plugins
60 | maven-source-plugin
61 |
62 |
63 | org.apache.maven.plugins
64 | maven-javadoc-plugin
65 |
66 |
67 | org.apache.maven.plugins
68 | maven-gpg-plugin
69 |
70 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/src/main/java/com/iab/gpp/extras/jackson/cmp/Cmp.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.jackson.cmp;
2 |
3 | /*-
4 | * #%L
5 | * IAB TCF Java CMP List Jackson
6 | * %%
7 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
8 | * %%
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | * #L%
21 | */
22 |
23 | import com.fasterxml.jackson.annotation.JsonProperty;
24 |
25 | import java.time.Instant;
26 | import java.util.Optional;
27 |
28 | public class Cmp implements com.iab.gpp.extras.cmp.Cmp {
29 |
30 | private int id;
31 | private String name;
32 |
33 | @JsonProperty("isCommercial")
34 | private boolean isCommercial;
35 |
36 | private Instant deletedDate;
37 |
38 |
39 | /**
40 | * A CMP id: a numeric ID which is incrementally assigned and never re-used – inactive CMPs are
41 | * marked as deleted
42 | *
43 | * @return CMP id
44 | */
45 | @Override
46 | public int getId() {
47 | return this.id;
48 | }
49 |
50 | /**
51 | * Name of the CMP
52 | *
53 | * @return CMP name
54 | */
55 | @Override
56 | public String getName() {
57 | return this.name;
58 | }
59 |
60 | /**
61 | * Whether or not the CMP is a commercial service
62 | *
63 | * @return true, if the CMP is available as a commercial service
64 | */
65 | @Override
66 | public boolean isCommercial() {
67 | return this.isCommercial;
68 | }
69 |
70 | /**
71 | * If available, the date/time after which CMP is considered inactive
72 | *
73 | * @return {@link Optional} time after which CMP is inactive
74 | */
75 | @Override
76 | public Optional getDeletedDate() {
77 | return Optional.ofNullable(this.deletedDate);
78 | }
79 |
80 | /**
81 | * Check whether the CMP is deleted
82 | *
83 | * @return true, if the CMP is considered deleted
84 | */
85 | @Override
86 | public boolean isDeleted() {
87 | return Optional.ofNullable(this.deletedDate).map(deleteDate -> !deleteDate.isAfter(Instant.now())).orElse(false);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/src/main/java/com/iab/gpp/extras/jackson/cmp/CmpList.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.jackson.cmp;
2 |
3 | /*-
4 | * #%L
5 | * IAB TCF Java CMP List Jackson
6 | * %%
7 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
8 | * %%
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | * #L%
21 | */
22 |
23 | import java.time.Instant;
24 | import java.util.ArrayList;
25 | import java.util.List;
26 | import java.util.Map;
27 |
28 | public class CmpList implements com.iab.gpp.extras.cmp.CmpList {
29 |
30 | private Instant lastUpdated;
31 | private Map cmps;
32 |
33 | /**
34 | * Last Updated Date
35 | *
36 | * @return {@link Instant} time when the record was last updated
37 | */
38 | @Override
39 | public Instant getLastUpdated() {
40 | return lastUpdated;
41 | }
42 |
43 | /**
44 | * List of CMPs
45 | *
46 | * @return {@link List} of {@link com.iab.gpp.extras.cmp.Cmp} objects
47 | */
48 | @Override
49 | public List getCmps() {
50 | return new ArrayList<>(cmps.values());
51 | }
52 |
53 | /**
54 | * Get the CMP object for a give CMP id
55 | *
56 | * @param cmpId CMP id
57 | * @return {@link com.iab.gpp.extras.cmp.Cmp} object
58 | */
59 | @Override
60 | public com.iab.gpp.extras.cmp.Cmp getCmp(int cmpId) {
61 | return cmps.get(cmpId);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/src/main/java/com/iab/gpp/extras/jackson/gvl/DataCategory.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.jackson.gvl;
2 |
3 | /*-
4 | * #%L
5 | * IAB TCF Java GVL Jackson
6 | * %%
7 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
8 | * %%
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | * #L%
21 | */
22 |
23 | /*
24 | * DataCategory
25 | */
26 | public class DataCategory implements com.iab.gpp.extras.gvl.DataCategory {
27 |
28 | private int id;
29 | private String name;
30 | private String description;
31 |
32 | /**
33 | * A id
34 | *
35 | * @return id
36 | */
37 | @Override
38 | public Integer getId() {
39 | return id;
40 | }
41 |
42 | /**
43 | * Name
44 | *
45 | * @return name
46 | */
47 | @Override
48 | public String getName() {
49 | return name;
50 | }
51 |
52 | /**
53 | * Description
54 | *
55 | * @return description
56 | */
57 | @Override
58 | public String getDescription() {
59 | return description;
60 | }
61 |
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/src/main/java/com/iab/gpp/extras/jackson/gvl/DataRetention.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.jackson.gvl;
2 |
3 | import java.util.Map;
4 | import java.util.Optional;
5 |
6 | /*-
7 | * #%L
8 | * IAB TCF Java GVL Jackson
9 | * %%
10 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /*
27 | * DataRetention
28 | */
29 | public class DataRetention implements com.iab.gpp.extras.gvl.DataRetention {
30 |
31 | private Integer stdRetention;
32 | private Map purposes;
33 | private Map specialPurposes;
34 |
35 | /**
36 | * stdRetention
37 | *
38 | * @return stdRetention
39 | */
40 | @Override
41 | public Optional getStdRetention() {
42 | return Optional.ofNullable(stdRetention);
43 | }
44 |
45 | /**
46 | * purposes
47 | *
48 | * @return purposes
49 | */
50 | @Override
51 | public Map getPurposes() {
52 | return purposes;
53 | }
54 |
55 | /**
56 | * specialPurposes
57 | *
58 | * @return specialPurposes
59 | */
60 | @Override
61 | public Map getSpecialPurposes() {
62 | return specialPurposes;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/src/main/java/com/iab/gpp/extras/jackson/gvl/Feature.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.jackson.gvl;
2 |
3 | import java.util.List;
4 | import java.util.Optional;
5 |
6 | /*-
7 | * #%L
8 | * IAB TCF Java GVL Jackson
9 | * %%
10 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /*
27 | * List of Features the Vendor may utilize when performing some declared Purposes processing
28 | */
29 | public class Feature implements com.iab.gpp.extras.gvl.Feature {
30 |
31 | private int id;
32 | private String name;
33 | private String description;
34 | private String descriptionLegal;
35 | private List illustrations;
36 |
37 | /**
38 | * A feature id
39 | *
40 | * @return feature id
41 | */
42 | @Override
43 | public int getId() {
44 | return id;
45 | }
46 |
47 | /**
48 | * Name of the feature
49 | *
50 | * @return feature name string
51 | */
52 | @Override
53 | public String getName() {
54 | return name;
55 | }
56 |
57 | /**
58 | * Description of the feature
59 | *
60 | * @return feature description string
61 | */
62 | @Override
63 | public String getDescription() {
64 | return description;
65 | }
66 |
67 | /**
68 | * Legal description of the feature
69 | *
70 | * @return legal description string
71 | */
72 | @Override
73 | public Optional getDescriptionLegal() {
74 | return Optional.ofNullable(descriptionLegal);
75 | }
76 |
77 | /**
78 | * illustrations
79 | *
80 | * @return illustrations
81 | */
82 | @Override
83 | public Optional> getIllustrations() {
84 | return Optional.ofNullable(illustrations);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/src/main/java/com/iab/gpp/extras/jackson/gvl/Overflow.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.jackson.gvl;
2 |
3 | /*-
4 | * #%L
5 | * IAB TCF Java GVL Jackson
6 | * %%
7 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
8 | * %%
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | * #L%
21 | */
22 |
23 |
24 | public class Overflow implements com.iab.gpp.extras.gvl.Overflow {
25 |
26 | private int httpGetLimit;
27 |
28 | /**
29 | * The vendor's http GET request length limit; 32 or 128 are the only supported options
30 | *
31 | * @return vendor's http GET request length limit
32 | */
33 | @Override
34 | public int getHttpGetLimit() {
35 | return httpGetLimit;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/src/main/java/com/iab/gpp/extras/jackson/gvl/SpecialFeature.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.jackson.gvl;
2 |
3 | /*-
4 | * #%L
5 | * IAB TCF Java GVL Jackson
6 | * %%
7 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
8 | * %%
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | * #L%
21 | */
22 |
23 | /**
24 | * Special features differ from simple features in that CMPs MUST provide users with a means to
25 | * signal an opt-in choice as to whether vendors may employ the feature when performing any purpose
26 | * processing. See Policies for specifics.
27 | */
28 | public class SpecialFeature extends Feature implements com.iab.gpp.extras.gvl.SpecialFeature {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/src/main/java/com/iab/gpp/extras/jackson/gvl/SpecialPurpose.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.jackson.gvl;
2 |
3 | /*-
4 | * #%L
5 | * IAB TCF Java GVL Jackson
6 | * %%
7 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
8 | * %%
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | * #L%
21 | */
22 |
23 | /**
24 | * A special purpose declared as performed on the legal basis of a legitimate interest
25 | */
26 | public class SpecialPurpose extends Purpose implements com.iab.gpp.extras.gvl.SpecialPurpose {
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/src/main/java/com/iab/gpp/extras/jackson/gvl/Stack.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.jackson.gvl;
2 |
3 | /*-
4 | * #%L
5 | * IAB TCF Java GVL Jackson
6 | * %%
7 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
8 | * %%
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | * #L%
21 | */
22 |
23 | import java.util.List;
24 |
25 | /*
26 | * Stacks may be used to substitute Initial Layer information about two or more Purposes and/or
27 | * Special Features
28 | */
29 | public class Stack implements com.iab.gpp.extras.gvl.Stack {
30 |
31 | private int id;
32 | private List specialFeatures;
33 | private List purposes;
34 | private String name;
35 | private String description;
36 |
37 | /**
38 | * Stack id
39 | *
40 | * @return stack id
41 | */
42 | @Override
43 | public int getId() {
44 | return id;
45 | }
46 |
47 | /**
48 | * A list of special features
49 | *
50 | * @return A {@link List} of special feature ids
51 | */
52 | @Override
53 | public List getSpecialFeatures() {
54 | return specialFeatures;
55 | }
56 |
57 | /**
58 | * A list of purposes
59 | *
60 | * @return A {@link List} of purpose ids
61 | */
62 | @Override
63 | public List getPurposes() {
64 | return purposes;
65 | }
66 |
67 | /**
68 | * Name of the stack
69 | *
70 | * @return stack name string
71 | */
72 | @Override
73 | public String getName() {
74 | return name;
75 | }
76 |
77 | /**
78 | * Description of the stack
79 | *
80 | * @return stack description string
81 | */
82 | @Override
83 | public String getDescription() {
84 | return description;
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/src/main/java/com/iab/gpp/extras/jackson/gvl/VendorUrl.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.jackson.gvl;
2 |
3 | import java.util.Optional;
4 |
5 | /*-
6 | * #%L
7 | * IAB TCF Java GVL Jackson
8 | * %%
9 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
10 | * %%
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | * #L%
23 | */
24 |
25 | /*
26 | * DataCategory
27 | */
28 | public class VendorUrl implements com.iab.gpp.extras.gvl.VendorUrl {
29 |
30 | private String langId;
31 | private String privacy;
32 | private String legIntClaim;
33 |
34 | /**
35 | * langId
36 | *
37 | * @return lang id
38 | */
39 | @Override
40 | public String getLangId() {
41 | return langId;
42 | }
43 |
44 | /**
45 | * privacy
46 | *
47 | * @return privacy
48 | */
49 | @Override
50 | public String getPrivacy() {
51 | return privacy;
52 | }
53 |
54 | /**
55 | * legIntClaim
56 | *
57 | * @return legIntClaim
58 | */
59 | @Override
60 | public Optional getLegIntClaim() {
61 | return Optional.ofNullable(legIntClaim);
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/src/test/java/com/iab/gpp/extras/jackson/cmp/CmpListTest.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.jackson.cmp;
2 |
3 | import java.io.IOException;
4 | import java.time.Instant;
5 | import org.junit.jupiter.api.Assertions;
6 | import org.junit.jupiter.api.BeforeAll;
7 | import org.junit.jupiter.api.Test;
8 | import com.iab.gpp.extras.cmp.Cmp;
9 |
10 | /*-
11 | * #%L
12 | * IAB TCF Java CMP List Jackson
13 | * %%
14 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
15 | * %%
16 | * Licensed under the Apache License, Version 2.0 (the "License");
17 | * you may not use this file except in compliance with the License.
18 | * You may obtain a copy of the License at
19 | *
20 | * http://www.apache.org/licenses/LICENSE-2.0
21 | *
22 | * Unless required by applicable law or agreed to in writing, software
23 | * distributed under the License is distributed on an "AS IS" BASIS,
24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 | * See the License for the specific language governing permissions and
26 | * limitations under the License.
27 | * #L%
28 | */
29 |
30 | import com.iab.gpp.extras.cmp.CmpList;
31 | import com.iab.gpp.extras.jackson.Loader;
32 |
33 | public class CmpListTest {
34 |
35 | private static CmpList cmpList;
36 | private static Cmp cmpThree;
37 | private static Cmp cmpTwentyThree;
38 |
39 | @BeforeAll
40 | public static void setUpBeforeClass() throws IOException {
41 | cmpList = new Loader().cmpList(CmpListTest.class.getClassLoader().getResourceAsStream("cmpList.json"));
42 | cmpThree = cmpList.getCmps().stream().filter(o -> o.getId() == 3).findFirst().orElse(null);
43 | cmpTwentyThree = cmpList.getCmps().stream().filter(o -> o.getId() == 23).findFirst().orElse(null);
44 | }
45 |
46 | @Test
47 | public void getLastUpdated() {
48 | Assertions.assertEquals(Instant.parse("2020-04-09T17:03:06Z"), cmpList.getLastUpdated());
49 | }
50 |
51 | @Test
52 | public void getCmps() {
53 | Assertions.assertEquals(12, cmpList.getCmps().size());
54 | }
55 |
56 | @Test
57 | public void getId() {
58 | Assertions.assertEquals(3, cmpThree.getId());
59 | }
60 |
61 | @Test
62 | public void getName() {
63 | String name = "LiveRamp";
64 | Assertions.assertEquals(name, cmpThree.getName());
65 | }
66 |
67 | @Test
68 | public void isCommercial() {
69 | Assertions.assertTrue(cmpThree.isCommercial());
70 | }
71 |
72 | @Test
73 | public void getDeletedDate() {
74 | Assertions.assertNull(cmpThree.getDeletedDate().orElse(null));
75 | Assertions.assertNotNull(cmpTwentyThree.getDeletedDate().orElse(null));
76 | }
77 |
78 | @Test
79 | public void isDeleted() {
80 | Assertions.assertFalse(cmpThree.isDeleted());
81 | Assertions.assertTrue(cmpTwentyThree.isDeleted());
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/src/test/resources/cmpList.json:
--------------------------------------------------------------------------------
1 | {
2 | "lastUpdated": "2020-04-09T17:03:06Z",
3 | "cmps": {
4 | "3": {
5 | "id": 3,
6 | "name": "LiveRamp",
7 | "isCommercial": true
8 | },
9 | "23": {
10 | "id": 23,
11 | "name": "Conversant Europe Ltd.",
12 | "isCommercial": true,
13 | "deletedDate" : "2020-04-09T00:00:00Z"
14 | },
15 | "25": {
16 | "id": 25,
17 | "name": "ShareThis, Inc.",
18 | "isCommercial": true
19 | },
20 | "28": {
21 | "id": 28,
22 | "name": "OneTrust LLC",
23 | "isCommercial": true
24 | },
25 | "63": {
26 | "id": 63,
27 | "name": "ALZ Software Ltd (trading as Clickio)",
28 | "isCommercial": true
29 | },
30 | "68": {
31 | "id": 68,
32 | "name": "Transfon Ltd",
33 | "isCommercial": true
34 | },
35 | "92": {
36 | "id": 92,
37 | "name": "SIRDATA",
38 | "isCommercial": true
39 | },
40 | "96": {
41 | "id": 96,
42 | "name": "Triboo Data Analytics",
43 | "isCommercial": true
44 | },
45 | "123": {
46 | "id": 123,
47 | "name": "iubenda",
48 | "isCommercial": true
49 | },
50 | "273": {
51 | "id": 273,
52 | "name": "Next14 SpA",
53 | "isCommercial": true
54 | },
55 | "291": {
56 | "id": 291,
57 | "name": "Consent Desk LLC",
58 | "isCommercial": true
59 | },
60 | "299": {
61 | "id": 299,
62 | "name": "Ezoic",
63 | "isCommercial": true
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/iabgpp-extras-jackson/src/test/resources/vendorlist/v2/vendor-list.json:
--------------------------------------------------------------------------------
1 | vendor-list-v51.json
--------------------------------------------------------------------------------
/iabgpp-extras/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 |
8 | com.iabgpp
9 | iabgpp-core
10 | 3.2.4-SNAPSHOT
11 |
12 |
13 | iabgpp-extras
14 | jar
15 |
16 |
17 |
18 |
19 | maven-surefire-plugin
20 | 2.22.2
21 |
22 |
23 |
24 |
25 |
26 |
27 | release
28 |
29 |
30 |
31 | org.apache.maven.plugins
32 | maven-source-plugin
33 |
34 |
35 | org.apache.maven.plugins
36 | maven-javadoc-plugin
37 |
38 |
39 | org.apache.maven.plugins
40 | maven-gpg-plugin
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/iabgpp-extras/src/main/java/com/iab/gpp/extras/cmp/Cmp.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.cmp;
2 |
3 | /*-
4 | * #%L
5 | * IAB TCF Java GVL and CMP List
6 | * %%
7 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
8 | * %%
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | * #L%
21 | */
22 |
23 | import java.time.Instant;
24 | import java.util.Optional;
25 |
26 | public interface Cmp {
27 |
28 | /**
29 | * A CMP id: a numeric ID which is incrementally assigned and never re-used – inactive CMPs are
30 | * marked as deleted
31 | *
32 | * @return CMP id
33 | */
34 | int getId();
35 |
36 | /**
37 | * Name of the CMP
38 | *
39 | * @return CMP name
40 | */
41 | String getName();
42 |
43 | /**
44 | * Whether or not the CMP is a commercial service
45 | *
46 | * @return true, if the CMP is available as a commercial service
47 | */
48 | boolean isCommercial();
49 |
50 | /**
51 | * If available, the date/time after which CMP is considered inactive
52 | *
53 | * @return {@link Optional} time after which CMP is inactive
54 | */
55 | Optional getDeletedDate();
56 |
57 | /**
58 | * Check whether the CMP is deleted
59 | *
60 | * @return true, if the CMP is considered deleted
61 | */
62 | boolean isDeleted();
63 | }
64 |
--------------------------------------------------------------------------------
/iabgpp-extras/src/main/java/com/iab/gpp/extras/cmp/CmpList.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.cmp;
2 |
3 | /*-
4 | * #%L
5 | * IAB TCF Java GVL and CMP List
6 | * %%
7 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
8 | * %%
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | * #L%
21 | */
22 |
23 | import java.time.Instant;
24 | import java.util.List;
25 |
26 | public interface CmpList {
27 |
28 | /**
29 | * Last Updated Date
30 | *
31 | * @return {@link Instant} time when the record was last updated
32 | */
33 | Instant getLastUpdated();
34 |
35 | /**
36 | * List of CMPs
37 | *
38 | * @return {@link List} of {@link Cmp} objects
39 | */
40 | List getCmps();
41 |
42 | /**
43 | * Get the CMP object for a give CMP id
44 | *
45 | * @param cmpId CMP id
46 | * @return {@link Cmp} object
47 | */
48 | Cmp getCmp(int cmpId);
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/iabgpp-extras/src/main/java/com/iab/gpp/extras/gvl/DataCategory.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.gvl;
2 |
3 | /*
4 | * DataCategory
5 | */
6 | public interface DataCategory {
7 |
8 | /**
9 | * id
10 | *
11 | * @return id
12 | */
13 | Integer getId();
14 |
15 | /**
16 | * name
17 | *
18 | * @return name
19 | */
20 | String getName();
21 |
22 | /**
23 | * description
24 | *
25 | * @return description
26 | */
27 | String getDescription();
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/iabgpp-extras/src/main/java/com/iab/gpp/extras/gvl/DataRetention.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.gvl;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 | import java.util.Optional;
6 |
7 | /*-
8 | * #%L
9 | * IAB TCF Java GVL and CMP List
10 | * %%
11 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
12 | * %%
13 | * Licensed under the Apache License, Version 2.0 (the "License");
14 | * you may not use this file except in compliance with the License.
15 | * You may obtain a copy of the License at
16 | *
17 | * http://www.apache.org/licenses/LICENSE-2.0
18 | *
19 | * Unless required by applicable law or agreed to in writing, software
20 | * distributed under the License is distributed on an "AS IS" BASIS,
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 | * See the License for the specific language governing permissions and
23 | * limitations under the License.
24 | * #L%
25 | */
26 |
27 | /*
28 | * DataRetention
29 | */
30 | public interface DataRetention {
31 |
32 | /**
33 | * stdRetention
34 | *
35 | * @return stdRetention
36 | */
37 | Optional getStdRetention();
38 |
39 | /**
40 | * purposes
41 | *
42 | * @return purposes
43 | */
44 | Map getPurposes();
45 |
46 | /**
47 | * specialPurposes
48 | *
49 | * @return specialPurposes
50 | */
51 | Map getSpecialPurposes();
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/iabgpp-extras/src/main/java/com/iab/gpp/extras/gvl/Feature.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.gvl;
2 |
3 | import java.util.List;
4 | import java.util.Optional;
5 |
6 | /*-
7 | * #%L
8 | * IAB TCF Java GVL and CMP List
9 | * %%
10 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /*
27 | * List of Features the Vendor may utilize when performing some declared Purposes processing
28 | */
29 | public interface Feature {
30 |
31 | /**
32 | * A feature id
33 | *
34 | * @return feature id
35 | */
36 | int getId();
37 |
38 | /**
39 | * Name of the feature
40 | *
41 | * @return feature name string
42 | */
43 | String getName();
44 |
45 | /**
46 | * Description of the feature
47 | *
48 | * @return feature description string
49 | */
50 | String getDescription();
51 |
52 | /**
53 | * Legal description of the feature
54 | *
55 | * @return legal description string
56 | */
57 | Optional getDescriptionLegal();
58 |
59 | /**
60 | * A list of illustrations
61 | *
62 | * @return A {@link List} of strings
63 | */
64 | Optional> getIllustrations();
65 | }
66 |
--------------------------------------------------------------------------------
/iabgpp-extras/src/main/java/com/iab/gpp/extras/gvl/Overflow.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.gvl;
2 |
3 | /*-
4 | * #%L
5 | * IAB TCF Java GVL and CMP List
6 | * %%
7 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
8 | * %%
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | * #L%
21 | */
22 |
23 |
24 | public interface Overflow {
25 |
26 | /**
27 | * The vendor's http GET request length limit; 32 or 128 are the only supported options
28 | *
29 | * @return vendor's http GET request length limit
30 | */
31 | int getHttpGetLimit();
32 | }
33 |
--------------------------------------------------------------------------------
/iabgpp-extras/src/main/java/com/iab/gpp/extras/gvl/Purpose.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.gvl;
2 |
3 | import java.util.List;
4 | import java.util.Optional;
5 |
6 | /*-
7 | * #%L
8 | * IAB TCF Java GVL and CMP List
9 | * %%
10 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
11 | * %%
12 | * Licensed under the Apache License, Version 2.0 (the "License");
13 | * you may not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * http://www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an "AS IS" BASIS,
20 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | * #L%
24 | */
25 |
26 | /**
27 | * A standard purpose
28 | */
29 | public interface Purpose {
30 |
31 | /**
32 | * A purpose id
33 | *
34 | * @return purpose id
35 | */
36 | int getId();
37 |
38 | /**
39 | * Name of the purpose
40 | *
41 | * @return purpose name string
42 | */
43 | String getName();
44 |
45 | /**
46 | * Description of the purpose
47 | *
48 | * @return purpose description string
49 | */
50 | String getDescription();
51 |
52 | /**
53 | * Legal description of the purpose
54 | * @return legal description string
55 | */
56 | Optional getDescriptionLegal();
57 |
58 | /**
59 | * A list of illustrations
60 | * @since 3.0
61 | * @return A {@link List} of strings
62 | */
63 | Optional> getIllustrations();
64 |
65 | /**
66 | * An optional flag where false means CMPs should never afford users the means to provide an opt-in
67 | * consent choice
68 | *
69 | * @return consentable boolean
70 | */
71 | boolean getConsentable();
72 |
73 | /**
74 | * An optional flag where false means CMPs should never afford users the means to exercise a right
75 | * to object
76 | *
77 | * @return consentable boolean
78 | */
79 | boolean getRightToObject();
80 | }
81 |
--------------------------------------------------------------------------------
/iabgpp-extras/src/main/java/com/iab/gpp/extras/gvl/SpecialFeature.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.gvl;
2 |
3 | /*-
4 | * #%L
5 | * IAB TCF Java GVL and CMP List
6 | * %%
7 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
8 | * %%
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | * #L%
21 | */
22 |
23 | /**
24 | * Special features differ from simple features in that CMPs MUST provide users with a means to
25 | * signal an opt-in choice as to whether vendors may employ the feature when performing any purpose
26 | * processing. See Policies for specifics.
27 | */
28 | public interface SpecialFeature extends Feature {
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/iabgpp-extras/src/main/java/com/iab/gpp/extras/gvl/SpecialPurpose.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.gvl;
2 |
3 | /*-
4 | * #%L
5 | * IAB TCF Java GVL and CMP List
6 | * %%
7 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
8 | * %%
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | * #L%
21 | */
22 |
23 | /**
24 | * A special purpose declared as performed on the legal basis of a legitimate interest
25 | */
26 | public interface SpecialPurpose extends Purpose {
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/iabgpp-extras/src/main/java/com/iab/gpp/extras/gvl/Stack.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.gvl;
2 |
3 | /*-
4 | * #%L
5 | * IAB TCF Java GVL and CMP List
6 | * %%
7 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
8 | * %%
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | * #L%
21 | */
22 |
23 | import java.util.List;
24 |
25 | /*
26 | * Stacks may be used to substitute Initial Layer information about two or more Purposes and/or
27 | * Special Features
28 | */
29 | public interface Stack {
30 |
31 | /**
32 | * Stack id
33 | *
34 | * @return stack id
35 | */
36 | int getId();
37 |
38 | /**
39 | * A list of special features
40 | *
41 | * @return A {@link List} of special feature ids
42 | */
43 | List getSpecialFeatures();
44 |
45 | /**
46 | * A list of purposes
47 | *
48 | * @return A {@link List} of purpose ids
49 | */
50 | List getPurposes();
51 |
52 | /**
53 | * Name of the stack
54 | *
55 | * @return stack name string
56 | */
57 | String getName();
58 |
59 | /**
60 | * Description of the stack
61 | *
62 | * @return stack description string
63 | */
64 | String getDescription();
65 | }
66 |
--------------------------------------------------------------------------------
/iabgpp-extras/src/main/java/com/iab/gpp/extras/gvl/VendorUrl.java:
--------------------------------------------------------------------------------
1 | package com.iab.gpp.extras.gvl;
2 |
3 | import java.util.Optional;
4 |
5 | /*-
6 | * #%L
7 | * IAB TCF Java GVL and CMP List
8 | * %%
9 | * Copyright (C) 2020 IAB Technology Laboratory, Inc
10 | * %%
11 | * Licensed under the Apache License, Version 2.0 (the "License");
12 | * you may not use this file except in compliance with the License.
13 | * You may obtain a copy of the License at
14 | *
15 | * http://www.apache.org/licenses/LICENSE-2.0
16 | *
17 | * Unless required by applicable law or agreed to in writing, software
18 | * distributed under the License is distributed on an "AS IS" BASIS,
19 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 | * See the License for the specific language governing permissions and
21 | * limitations under the License.
22 | * #L%
23 | */
24 |
25 | /*
26 | * VendorUrl
27 | */
28 | public interface VendorUrl {
29 |
30 | /**
31 | * langId
32 | *
33 | * @return lang id
34 | */
35 | String getLangId();
36 |
37 | /**
38 | * privacy
39 | *
40 | * @return privacy
41 | */
42 | String getPrivacy();
43 |
44 | /**
45 | * legIntClaim
46 | *
47 | * @return legIntClaim
48 | */
49 | Optional getLegIntClaim();
50 |
51 | }
52 |
--------------------------------------------------------------------------------