1818import com .iab .gpp .encoder .section .UsCa ;
1919import com .iab .gpp .encoder .section .UsCo ;
2020import com .iab .gpp .encoder .section .UsCt ;
21+ import com .iab .gpp .encoder .section .UsDe ;
2122import com .iab .gpp .encoder .section .UsFl ;
23+ import com .iab .gpp .encoder .section .UsIa ;
2224import com .iab .gpp .encoder .section .UsMt ;
2325import com .iab .gpp .encoder .section .UsNat ;
26+ import com .iab .gpp .encoder .section .UsNe ;
27+ import com .iab .gpp .encoder .section .UsNh ;
28+ import com .iab .gpp .encoder .section .UsNj ;
2429import com .iab .gpp .encoder .section .UsOr ;
30+ import com .iab .gpp .encoder .section .UsTn ;
2531import com .iab .gpp .encoder .section .UsTx ;
2632import com .iab .gpp .encoder .section .UsUt ;
2733import com .iab .gpp .encoder .section .UsVa ;
@@ -31,10 +37,10 @@ public class GppModel {
3137 private Map <String , EncodableSection > sections = new HashMap <>();
3238
3339 private String encodedString ;
34-
40+
3541 private boolean dirty = false ;
3642 private boolean decoded = true ;
37-
43+
3844 public GppModel () {
3945
4046 }
@@ -53,7 +59,7 @@ public void setFieldValue(String sectionName, String fieldName, Object value) {
5359 this .dirty = false ;
5460 this .decoded = true ;
5561 }
56-
62+
5763 EncodableSection section = null ;
5864 if (!this .sections .containsKey (sectionName )) {
5965 if (sectionName .equals (TcfCaV1 .NAME )) {
@@ -95,6 +101,24 @@ public void setFieldValue(String sectionName, String fieldName, Object value) {
95101 } else if (sectionName .equals (UsTx .NAME )) {
96102 section = new UsTx ();
97103 this .sections .put (UsTx .NAME , section );
104+ } else if (sectionName .equals (UsDe .NAME )) {
105+ section = new UsDe ();
106+ this .sections .put (UsDe .NAME , section );
107+ } else if (sectionName .equals (UsIa .NAME )) {
108+ section = new UsIa ();
109+ this .sections .put (UsIa .NAME , section );
110+ } else if (sectionName .equals (UsNe .NAME )) {
111+ section = new UsNe ();
112+ this .sections .put (UsNe .NAME , section );
113+ } else if (sectionName .equals (UsNh .NAME )) {
114+ section = new UsNh ();
115+ this .sections .put (UsNh .NAME , section );
116+ } else if (sectionName .equals (UsNj .NAME )) {
117+ section = new UsNj ();
118+ this .sections .put (UsNj .NAME , section );
119+ } else if (sectionName .equals (UsTn .NAME )) {
120+ section = new UsTn ();
121+ this .sections .put (UsTn .NAME , section );
98122 }
99123 } else {
100124 section = this .sections .get (sectionName );
@@ -118,7 +142,7 @@ public Object getFieldValue(String sectionName, String fieldName) {
118142 this .dirty = false ;
119143 this .decoded = true ;
120144 }
121-
145+
122146 if (this .sections .containsKey (sectionName )) {
123147 return this .sections .get (sectionName ).getFieldValue (fieldName );
124148 } else {
@@ -136,7 +160,7 @@ public boolean hasField(String sectionName, String fieldName) {
136160 this .dirty = false ;
137161 this .decoded = true ;
138162 }
139-
163+
140164 if (this .sections .containsKey (sectionName )) {
141165 return this .sections .get (sectionName ).hasField (fieldName );
142166 } else {
@@ -154,7 +178,7 @@ public boolean hasSection(String sectionName) {
154178 this .dirty = false ;
155179 this .decoded = true ;
156180 }
157-
181+
158182 return this .sections .containsKey (sectionName );
159183 }
160184
@@ -164,7 +188,7 @@ public HeaderV1 getHeader() {
164188 this .dirty = false ;
165189 this .decoded = true ;
166190 }
167-
191+
168192 HeaderV1 header = new HeaderV1 ();
169193 try {
170194 header .setFieldValue ("SectionIds" , this .getSectionIds ());
@@ -184,7 +208,7 @@ public EncodableSection getSection(String sectionName) {
184208 this .dirty = false ;
185209 this .decoded = true ;
186210 }
187-
211+
188212 if (this .sections .containsKey (sectionName )) {
189213 return this .sections .get (sectionName );
190214 } else {
@@ -202,7 +226,7 @@ public void deleteSection(String sectionName) {
202226 this .dirty = false ;
203227 this .decoded = true ;
204228 }
205-
229+
206230 if (this .sections .containsKey (sectionName )) {
207231 this .sections .remove (sectionName );
208232 this .dirty = true ;
@@ -251,30 +275,54 @@ public UsUt getUsUtSection() {
251275 public UsCt getUsCtSection () {
252276 return (UsCt ) getSection (UsCt .NAME );
253277 }
254-
278+
255279 public UsFl getUsFlSection () {
256280 return (UsFl ) getSection (UsFl .NAME );
257281 }
258-
282+
259283 public UsMt getUsMtSection () {
260284 return (UsMt ) getSection (UsMt .NAME );
261285 }
262-
286+
263287 public UsOr getUsOrSection () {
264288 return (UsOr ) getSection (UsOr .NAME );
265289 }
266-
290+
267291 public UsTx getUsTxSection () {
268292 return (UsTx ) getSection (UsTx .NAME );
269293 }
270-
294+
295+ public UsDe getUsDeSection () {
296+ return (UsDe ) getSection (UsDe .NAME );
297+ }
298+
299+ public UsIa getUsIaSection () {
300+ return (UsIa ) getSection (UsIa .NAME );
301+ }
302+
303+ public UsNe getUsNeSection () {
304+ return (UsNe ) getSection (UsNe .NAME );
305+ }
306+
307+ public UsNh getUsNhSection () {
308+ return (UsNh ) getSection (UsNh .NAME );
309+ }
310+
311+ public UsNj getUsNjSection () {
312+ return (UsNj ) getSection (UsNj .NAME );
313+ }
314+
315+ public UsTn getUsTnSection () {
316+ return (UsTn ) getSection (UsTn .NAME );
317+ }
318+
271319 public List <Integer > getSectionIds () {
272320 if (!this .decoded ) {
273321 this .sections = this .decodeModel (this .encodedString );
274322 this .dirty = false ;
275323 this .decoded = true ;
276324 }
277-
325+
278326 List <Integer > sectionIds = new ArrayList <>();
279327 for (int i = 0 ; i < Sections .SECTION_ORDER .size (); i ++) {
280328 String sectionName = Sections .SECTION_ORDER .get (i );
@@ -311,14 +359,14 @@ protected String encodeModel(Map<String, EncodableSection> sections) {
311359 }
312360
313361 protected Map <String , EncodableSection > decodeModel (String str ) {
314- if (str == null || str .isEmpty () || str .startsWith ("D" )) {
362+ if (str == null || str .isEmpty () || str .startsWith ("D" )) {
315363 Map <String , EncodableSection > sections = new HashMap <>();
316-
317- if (str != null && !str .isEmpty ()) {
364+
365+ if (str != null && !str .isEmpty ()) {
318366 String [] encodedSections = str .split ("~" );
319367 HeaderV1 header = new HeaderV1 (encodedSections [0 ]);
320368 sections .put (HeaderV1 .NAME , header );
321-
369+
322370 @ SuppressWarnings ("unchecked" )
323371 List <Integer > sectionIds = (List <Integer >) header .getFieldValue ("SectionIds" );
324372 for (int i = 0 ; i < sectionIds .size (); i ++) {
@@ -361,12 +409,30 @@ protected Map<String, EncodableSection> decodeModel(String str) {
361409 } else if (sectionIds .get (i ).equals (UsTx .ID )) {
362410 UsTx section = new UsTx (encodedSections [i + 1 ]);
363411 sections .put (UsTx .NAME , section );
412+ } else if (sectionIds .get (i ).equals (UsDe .ID )) {
413+ UsDe section = new UsDe (encodedSections [i + 1 ]);
414+ sections .put (UsDe .NAME , section );
415+ } else if (sectionIds .get (i ).equals (UsIa .ID )) {
416+ UsIa section = new UsIa (encodedSections [i + 1 ]);
417+ sections .put (UsIa .NAME , section );
418+ } else if (sectionIds .get (i ).equals (UsNe .ID )) {
419+ UsNe section = new UsNe (encodedSections [i + 1 ]);
420+ sections .put (UsNe .NAME , section );
421+ } else if (sectionIds .get (i ).equals (UsNh .ID )) {
422+ UsNh section = new UsNh (encodedSections [i + 1 ]);
423+ sections .put (UsNh .NAME , section );
424+ } else if (sectionIds .get (i ).equals (UsNj .ID )) {
425+ UsNj section = new UsNj (encodedSections [i + 1 ]);
426+ sections .put (UsNj .NAME , section );
427+ } else if (sectionIds .get (i ).equals (UsTn .ID )) {
428+ UsTn section = new UsTn (encodedSections [i + 1 ]);
429+ sections .put (UsTn .NAME , section );
364430 }
365431 }
366432 }
367-
433+
368434 return sections ;
369- } else if (str .startsWith ("C" )) {
435+ } else if (str .startsWith ("C" )) {
370436 // old tcfeu only string
371437 Map <String , EncodableSection > sections = new HashMap <>();
372438
@@ -393,7 +459,7 @@ public String encodeSection(String sectionName) {
393459 this .dirty = false ;
394460 this .decoded = true ;
395461 }
396-
462+
397463 if (this .sections .containsKey (sectionName )) {
398464 return this .sections .get (sectionName ).encode ();
399465 } else {
@@ -447,6 +513,24 @@ public void decodeSection(String sectionName, String encodedString) {
447513 } else if (sectionName .equals (UsTx .NAME )) {
448514 section = new UsTx ();
449515 this .sections .put (UsTx .NAME , section );
516+ }else if (sectionName .equals (UsDe .NAME )) {
517+ section = new UsDe ();
518+ this .sections .put (UsDe .NAME , section );
519+ }else if (sectionName .equals (UsIa .NAME )) {
520+ section = new UsIa ();
521+ this .sections .put (UsIa .NAME , section );
522+ }else if (sectionName .equals (UsNe .NAME )) {
523+ section = new UsNe ();
524+ this .sections .put (UsNe .NAME , section );
525+ }else if (sectionName .equals (UsNh .NAME )) {
526+ section = new UsNh ();
527+ this .sections .put (UsNh .NAME , section );
528+ }else if (sectionName .equals (UsNj .NAME )) {
529+ section = new UsNj ();
530+ this .sections .put (UsNj .NAME , section );
531+ }else if (sectionName .equals (UsTn .NAME )) {
532+ section = new UsTn ();
533+ this .sections .put (UsTn .NAME , section );
450534 }
451535 } else {
452536 section = this .sections .get (sectionName );
@@ -456,7 +540,7 @@ public void decodeSection(String sectionName, String encodedString) {
456540 section .decode (encodedString );
457541 }
458542 }
459-
543+
460544 public String encode () {
461545 if (this .encodedString == null || this .encodedString .isEmpty () || this .dirty ) {
462546 this .encodedString = encodeModel (this .sections );
@@ -466,12 +550,12 @@ public String encode() {
466550
467551 return this .encodedString ;
468552 }
469-
553+
470554 public void decode (String encodedString ) {
471555 this .encodedString = encodedString ;
472556 this .dirty = false ;
473557 this .decoded = false ;
474558 }
475-
476-
477- }
559+
560+
561+ }
0 commit comments