protected void convert(Object item, Converter converter) { if (parentObjects.containsId(item)) { ConversionException e = new CircularReferenceException( "Recursive reference to parent object"); e.add("item-type", item.getClass().getName()); e.add("converter-type", converter.getClass().getName()); throw e; } parentObjects.associateId(item, ""); converter.marshal(item, writer, this); parentObjects.removeId(item); }
} else { final Path currentPath = pathTracker.getPath(); Id existingReference = (Id)references.lookupId(item); if (existingReference != null && existingReference.getPath() != currentPath) { String attributeName = getMapper().aliasForSystemAttribute("reference"); fireValidReference(newReferenceKey); lastPath = currentPath; references.associateId(item, new Id(newReferenceKey, currentPath));
public int size() { cleanup(); return map.size(); }
public void registerImplicit(Object item) { if (implicitElements.containsId(item)) { throw new ReferencedImplicitElementException(item, currentPath); } implicitElements.associateId(item, newReferenceKey); } });
public Object lookupReference(Object item) { Id id = (Id)references.lookupId(item); return id.getItem(); }
public void replace(Object original, Object replacement) { references.associateId(replacement, new Id(newReferenceKey, currentPath)); }
public void registerImplicit(Object item) { if (implicitElements.containsId(item)) { throw new ReferencedImplicitElementException(item, currentPath); } implicitElements.associateId(item, newReferenceKey); } });
@Override public R lookupReference(final Object item) { final Id<R> id = references.lookupId(item); return id.getItem(); }
@Override public void replace(final Object original, final Object replacement) { references.associateId(replacement, new Id<>(newReferenceKey, currentPath)); }
protected void convert(Object item, Converter converter) { if (parentObjects.containsId(item)) { throw new CircularReferenceException(); } parentObjects.associateId(item, ""); converter.marshal(item, writer, this); parentObjects.removeId(item); }
@Override public void convertAnother(Object item) { Class<?> targetClass = item.getClass(); while (Enhancer.isEnhanced(targetClass) == true) { targetClass = targetClass.getSuperclass(); } Converter converter = converterLookup.lookupConverterForType(targetClass); Object realItem = HibernateProxyHelper.get(item); if (classMapper.isImmutableValueType(realItem.getClass())) { // strings, ints, dates, etc... don't bother using references. converter.marshal(item, writer, this); } else { Object idOfExistingReference = references.lookupId(realItem); if (idOfExistingReference != null) { writer.addAttribute("reference", idOfExistingReference.toString()); return; } String newId = idGenerator.next(realItem); writer.addAttribute("id", newId); references.associateId(realItem, newId); if (log.isDebugEnabled()) { log.debug("marshalling object " + realItem.getClass() + " to stream"); } converter.marshal(realItem, writer, this); } }
@Override public void registerImplicit(final Object item) { if (implicitElements.containsId(item)) { throw new ReferencedImplicitElementException(item, currentPath); } implicitElements.associateId(item, newReferenceKey); } });
public void removeId(Object item) { map.remove(new IdWrapper(item)); cleanup(); }
public Object lookupReference(Object item) { Id id = (Id)references.lookupId(item); return id.getItem(); }
public void replace(Object original, Object replacement) { references.associateId(replacement, new Id(newReferenceKey, currentPath)); }
protected void convert(Object item, Converter converter) { if (parentObjects.containsId(item)) { throw new CircularReferenceException(); } parentObjects.associateId(item, ""); converter.marshal(item, writer, this); parentObjects.removeId(item); }
public void convert(Object item, Converter converter) { if (getMapper().isImmutableValueType(item.getClass())) { // strings, ints, dates, etc... don't bother using references. converter.marshal(item, writer, this); } else { Path currentPath = pathTracker.getPath(); Object existingReferenceKey = references.lookupId(item); if (existingReferenceKey != null) { String attributeName = getMapper().aliasForSystemAttribute("reference"); if (attributeName != null) { writer.addAttribute(attributeName, createReference(currentPath, existingReferenceKey)); } } else if (implicitElements.lookupId(item) != null) { throw new ReferencedImplicitElementException(item, currentPath); } else { Object newReferenceKey = createReferenceKey(currentPath, item); if (lastPath == null || !currentPath.isAncestor(lastPath)) { fireValidReference(newReferenceKey); lastPath = currentPath; references.associateId(item, newReferenceKey); } else { implicitElements.associateId(item, newReferenceKey); } converter.marshal(item, writer, this); } } }
public void registerImplicit(Object item) { if (implicitElements.containsId(item)) { throw new ReferencedImplicitElementException(item, currentPath); } implicitElements.associateId(item, newReferenceKey); } });
public void associateId(Object obj, Object id) { map.put(new WeakIdWrapper(obj), id); cleanup(); }
public Object lookupReference(Object item) { Id id = (Id)references.lookupId(item); return id.getItem(); }