Package jfireeagle.xml

Source Code of jfireeagle.xml.UserConverter

package jfireeagle.xml;

import jfireeagle.*;

import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.mapper.Mapper;

public class UserConverter extends com.thoughtworks.xstream.converters.reflection.ReflectionConverter
{

    public UserConverter(Mapper m)
  {
      super(m, new PureJavaReflectionProvider());
  }

  public Object unmarshal(HierarchicalStreamReader reader,
      UnmarshallingContext context)
  {
    User u = (User) super.unmarshal(reader, context);
   
    String token = reader.getAttribute("token");
    u.setToken(token);
   
    String locatedAt = reader.getAttribute("located-at");
   
    if (locatedAt != null)
    {
      CalendarConverter con = new CalendarConverter();
      u.setLocatedAt( (java.util.Calendar) con.fromString(locatedAt));
    }
   
        return u;
  }

  public boolean canConvert(Class type)
  {
    return User.class.isAssignableFrom(type);
  }

  public void marshal(Object source, HierarchicalStreamWriter writer,
      MarshallingContext context)
  {
    // not implemented
   
  }

}
TOP

Related Classes of jfireeagle.xml.UserConverter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.