@Override
    public JAXBElement<?> map(ArrayItem item, JAXBElement<?> origin) {
      JAXBElement<?> source = origin;
      if (origin == null) {
        if (item instanceof ExtentItem) {
          source = factory.createPhysicalDescriptionTypeExtent(null);
        } else if (item instanceof NoteItem) {
          NoteItem noteItem = (NoteItem) item;
          NoteType noteType = factory.createNoteType();
          noteType.setAtType(noteItem.getType());
          source = factory.createPhysicalDescriptionTypeNote(noteType);
        } else {
          throw new IllegalStateException("unsupported array item: " + item.getClass());
        }
      }

      if (item instanceof ExtentItem) {
        ExtentItem extentItem = (ExtentItem) item;
        JAXBElement<String> extentSource = (JAXBElement<String>) source;
        // delete with empty string to prevent XML nil
        extentSource.setValue(extentItem.getValue() != null ? extentItem.getValue() : "");
      } else if (item instanceof NoteItem && !((NoteItem) item).ignore) {
        NoteItem noteItem = (NoteItem) item;
        NoteType noteType = (NoteType) source.getValue();
        noteType.setValue(noteItem.getValue());
      }
      return source;
    }
 @Override
 public ArrayItem map(JAXBElement<?> source) {
   if (ObjectFactory._PhysicalDescriptionTypeExtent_QNAME.equals(source.getName())) {
     ExtentItem result = new ExtentItem();
     result.setValue((String) source.getValue());
     return result;
   } else if (ObjectFactory._PhysicalDescriptionTypeNote_QNAME.equals(source.getName())) {
     NoteType note = (NoteType) source.getValue();
     return new NoteItem(null, note.getValue(), note.getAtType());
   } else {
     return new UnkownItem();
   }
 }
 public static List<ExtentPair> toPairs(List<ArrayItem> items) {
   ArrayList<ExtentPair> pairs = new ArrayList<ExtentPair>();
   List<ExtentItem> extents = MapperUtils.find(items, ExtentItem.class);
   for (Iterator<ExtentItem> it = extents.iterator(); it.hasNext(); ) {
     ExtentItem item = it.next();
     ExtentPair pair = new ExtentPair(item.getValue(), item.getArrayIndex(), null, null);
     pairs.add(pair);
     if (it.hasNext()) {
       item = it.next();
       pair.setSize(item.getValue());
       pair.setSizeIndex(item.getArrayIndex());
     }
   }
   return pairs;
 }