예제 #1
0
    @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;
    }
예제 #2
0
 @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();
   }
 }