示例#1
0
 // definition may be null
 private <V extends PrismValue> XNode serializeItemValue(
     PrismValue itemValue, ItemDefinition definition, SerializationContext ctx)
     throws SchemaException {
   XNode xnode;
   if (definition == null) {
     if (itemValue.getParent() != null) {
       definition = itemValue.getParent().getDefinition();
     }
   }
   if (beanConverter.getPrismContext() == null) {
     throw new IllegalStateException("No prismContext in beanConverter!");
   }
   if (definition == null && itemValue instanceof PrismPropertyValue) {
     return serializePropertyRawValue((PrismPropertyValue<?>) itemValue);
   }
   if (itemValue instanceof PrismReferenceValue) {
     xnode =
         serializeReferenceValue(
             (PrismReferenceValue) itemValue, (PrismReferenceDefinition) definition, ctx);
   } else if (itemValue instanceof PrismPropertyValue<?>) {
     xnode =
         serializePropertyValue(
             (PrismPropertyValue<?>) itemValue, (PrismPropertyDefinition) definition);
   } else if (itemValue instanceof PrismContainerValue<?>) {
     xnode =
         serializeContainerValue(
             (PrismContainerValue<?>) itemValue, (PrismContainerDefinition) definition, ctx);
   } else {
     throw new IllegalArgumentException("Unsupported value type " + itemValue.getClass());
   }
   if (definition != null && definition.isDynamic()) {
     xnode.setExplicitTypeDeclaration(true);
   }
   return xnode;
 }
示例#2
0
 // region Serializing properties - specific functionality
 private <T> XNode serializePropertyValue(
     PrismPropertyValue<T> value, PrismPropertyDefinition<T> definition) throws SchemaException {
   QName typeQName = definition.getTypeName();
   T realValue = value.getValue();
   if (realValue instanceof PolyString) {
     return serializePolyString((PolyString) realValue);
   } else if (beanConverter.canProcess(typeQName)) {
     XNode xnode = beanConverter.marshall(realValue);
     if (realValue instanceof ProtectedDataType<?> && definition.isDynamic()) { // why is this?
       xnode.setExplicitTypeDeclaration(true);
       xnode.setTypeQName(definition.getTypeName());
     }
     return xnode;
   } else {
     // primitive value
     return createPrimitiveXNode(realValue, typeQName);
   }
 }