net.sf.mmm.util.xml.base.jaxb
Class IdResolverContext

java.lang.Object
  extended by net.sf.mmm.util.xml.base.jaxb.IdResolverContext

public class IdResolverContext
extends Object

This class is a context for InternalValidatingIdResolver. JAXB is a little strange: It is using a Callable for resolving XmlIDREF but evaluates it immediately instead of storing it until the initial processing phase has been completed. If it returns null it will try again later but never complains if the ID could not be resolved in the end.
This class solves the problem by tracking the each Callable and check that in the end all are resolved successfully.

Since:
2.0.1
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Nested Class Summary
protected  class IdResolverContext.Resolver
          This inner class resolves an ID on demand.
 
Field Summary
private  List<DuplicateObjectException> duplicateIdErrors
           
private  Map<String,IdResolverContext.Resolver> id2callableMap
           
private  Map<String,Object> id2valueMap
           
 
Constructor Summary
IdResolverContext()
          The constructor.
 
Method Summary
 void disposeAndValidate()
          This method disposes this context and performs a validation that all IDs have been resolved.
 Callable<?> get(String id, Class<?> type)
          This method resolves the value with the given id.
 void put(String id, Object value)
          This method binds the given value with the given id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id2valueMap

private Map<String,Object> id2valueMap
See Also:
put(String, Object)

id2callableMap

private Map<String,IdResolverContext.Resolver> id2callableMap
See Also:
get(String, Class)

duplicateIdErrors

private List<DuplicateObjectException> duplicateIdErrors
See Also:
put(String, Object)
Constructor Detail

IdResolverContext

public IdResolverContext()
The constructor.

Method Detail

put

public void put(String id,
                Object value)
This method binds the given value with the given id.

Parameters:
id - is the XmlID.
value - is the JAXB bean to bind.

get

public Callable<?> get(String id,
                       Class<?> type)
This method resolves the value with the given id.

Parameters:
id - is the XmlIDREF of the requested object. This object should be bound. This may also happen after it has been requested.
type - is the expected type of the object.
Returns:
a Callable that resolves the requested value.

disposeAndValidate

public void disposeAndValidate()
                        throws ObjectNotFoundException,
                               ComposedException
This method disposes this context and performs a validation that all IDs have been resolved.

Throws:
ObjectNotFoundException - if a single ID was NOT resolved.
ComposedException - if multiple IDs have NOT been resolved.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.