Package jfireeagle.xml

Source Code of jfireeagle.xml.XStreamFactory

package jfireeagle.xml;

import jfireeagle.GpsBox;
import jfireeagle.GpsCoordinate;
import jfireeagle.Location;
import jfireeagle.LocationHierarchy;
import jfireeagle.Locations;
import jfireeagle.PlaceId;
import jfireeagle.Response;
import jfireeagle.User;
import jfireeagle.WhereOnEarthId;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.extended.ToStringConverter;
import com.thoughtworks.xstream.io.xml.XppDriver;

public class XStreamFactory
{
  public static XStream createXStream()
  {
   
    XStream xstream = new XStream(new XppDriver());

   
     xstream.registerConverter(new CalendarConverter(), XStream.PRIORITY_VERY_HIGH);
    
     try
    {
      xstream.registerConverter(new ToStringConverter(GpsCoordinate.class), XStream.PRIORITY_VERY_HIGH);
       xstream.registerConverter(new ToStringConverter(GpsBox.class), XStream.PRIORITY_VERY_HIGH);
       xstream.registerConverter(new ToStringConverter(WhereOnEarthId.class), XStream.PRIORITY_VERY_HIGH);
       xstream.registerConverter(new ToStringConverter(PlaceId.class), XStream.PRIORITY_VERY_HIGH);
    }
     catch (NoSuchMethodException e)
    {
      throw new RuntimeException(e);
    }
   
    xstream.addImplicitCollection(Response.class, "users", User.class);
    xstream.addImplicitCollection(Locations.class, "locations", Location.class);
    xstream.addImplicitCollection(LocationHierarchy.class, "locations", Location.class);
   
    xstream.aliasField("location", Locations.class, "locations");
    xstream.aliasField("location", LocationHierarchy.class, "locations");
   
   
    xstream.alias("user", User.class);
    xstream.alias("location-hierarchy", LocationHierarchy.class);
    xstream.alias("woeid", WhereOnEarthId.class);
    xstream.alias("place-id", PlaceId.class);
    xstream.alias("georss:box", GpsBox.class);
    xstream.alias("georss:point", GpsCoordinate.class);
    xstream.alias("rsp", Response.class);
    xstream.alias("location", Location.class);
    xstream.alias("locations", Locations.class);
   
    xstream.aliasField("level-name", Location.class, "levelName");
    xstream.aliasField("located-at", Location.class, "locatedAt");
    xstream.aliasField("normal-name", Location.class, "normalName");
    xstream.aliasField("place-id", Location.class, "placeId");
    xstream.aliasField("location-hierarchy", User.class, "locationHierarchy");
    xstream.aliasField("georss:point", Location.class, "gpsCoordinate");
    xstream.aliasField("georss:box", Location.class, "box");
    xstream.aliasField("woeid", Location.class, "whereOnEarthId");

    xstream.aliasAttribute(Locations.class, "count", "count");
    xstream.aliasAttribute(Locations.class, "start", "start");
    xstream.aliasAttribute(Locations.class, "total", "total");
   
   
    xstream.aliasAttribute(Location.class, "bestGuess", "best-guess");
   
    xstream.aliasAttribute(LocationHierarchy.class, "timeZone", "timezone");
   
    return xstream;
   
  }
}
TOP

Related Classes of jfireeagle.xml.XStreamFactory

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.