-
Notifications
You must be signed in to change notification settings - Fork 38
IterTres15Java
anna-dodd edited this page Jun 3, 2015
·
1 revision
There isn't a way to get an iterator for the TRE fields in the 1.5 release. However, you can get/set field values. Below is an example that illustrates setting the FILCMT field in a JITCID TRE. (i_3228c.ntf is an example NITF file that contains a JITCID TRE in the FileHeader).
Extensions extendedSection = record.getHeader().getExtendedSection();
Iterable<TRE> tres = extendedSection.getTREsByName("JITCID");
if (tres.iterator().hasNext())
{
final TRE tre = tres.iterator().next();
try
{
final Field field = tre.getField("FILCMT");
// let's go ahead and just re-set the field
field.setData("My comment");
}
catch (NoSuchFieldException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Iterable<TRE> tres = extendedSection.getTREsByName("JITCID");
if (tres.iterator().hasNext())
{
final TRE tre = tres.iterator().next();
try
{
final Field field = tre.getField("FILCMT");
// let's go ahead and just re-set the field
field.setData("My comment");
}
catch (NoSuchFieldException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}