/**
* {@inheritDoc}
*/
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
{
IXMappingResolver xMappingResolver = (IXMappingResolver) context.get("xMappingResolver");
IXMappingSet xMappingSet = (IXMappingSet) context.get("xMappingSet");
IXMapping xMapping = xMappingResolver.createMapping();
xMapping.setMappingSet(xMappingSet);
xMapping.initLabelExp(reader.getAttribute("label"));
xMapping.initTooltipExp(reader.getAttribute("tip"));
xMapping.setMatchString(reader.getAttribute("match"));
String maxLength = reader.getAttribute("maxlength");
if (maxLength != null)
{
xMapping.setMaxLength(Integer.parseInt(maxLength));
}
// Icon
String iconPath = reader.getAttribute("icon");
if (iconPath != null)
{
xMapping.setIcon(resolveIcon(iconPath));
}
// Skip mode
String skipModeValue = reader.getAttribute("skip");
xMapping.setSkipMode(XMappingFactoryXmlImpl.readSkipMode(skipModeValue));
try
{
xMappingResolver.validateMapping(xMapping);
}
catch (XMappingException e)
{
// TODO show error to user
LOGGER.warn("Invalid mapping", e);