Examples of Weather


Examples of org.sonatype.mavenbook.weather.model.Weather

public class YahooParser {

    private static Logger log = Logger.getLogger(YahooParser.class);
   
    public Weather parse(String zip, InputStream inputStream) throws Exception {
  Weather weather = new Weather();
 
  log.info( "Creating XML Reader" );
  SAXReader xmlReader = createXmlReader();
  Document doc = xmlReader.read( inputStream );
 
  log.info( "Parsing XML Response" );
  Location location = new Location();
  location.setCity( doc.valueOf("/rss/channel/y:location/@city") );
  location.setRegion( doc.valueOf("/rss/channel/y:location/@region") );
  location.setCountry( doc.valueOf("/rss/channel/y:location/@country") );
  location.setZip( zip );
  weather.setLocation( location );

  Condition condition = new Condition();
  condition.setText( doc.valueOf("/rss/channel/item/y:condition/@text") );
  condition.setTemp( doc.valueOf("/rss/channel/item/y:condition/@temp") );
  condition.setCode( doc.valueOf("/rss/channel/item/y:condition/@code") );
  condition.setDate( doc.valueOf("/rss/channel/item/y:condition/@date") );
  condition.setWeather( weather );
  weather.setCondition( condition );

  Atmosphere atmosphere = new Atmosphere();
  atmosphere.setHumidity( doc.valueOf("/rss/channel/y:atmosphere/@humidity") );
  atmosphere.setVisibility( doc.valueOf("/rss/channel/y:atmosphere/@visibility") );
  atmosphere.setPressure( doc.valueOf("/rss/channel/y:atmosphere/@pressure") );
  atmosphere.setRising( doc.valueOf("/rss/channel/y:atmosphere/@rising") );
  atmosphere.setWeather( weather );
  weather.setAtmosphere( atmosphere );

  Wind wind = new Wind();
  wind.setChill( doc.valueOf("/rss/channel/y:wind/@chill") );
  wind.setDirection( doc.valueOf("/rss/channel/y:wind/@direction") );
  wind.setSpeed( doc.valueOf("/rss/channel/y:wind/@speed") );
  wind.setWeather( weather );
  weather.setWind( wind );

  weather.setDate( new Date() );
 
  return weather;
    }
View Full Code Here

Examples of org.sonatype.mavenbook.weather.model.Weather

  }
 
  public void testParser() throws Exception {
    InputStream nyData =
      getClass().getClassLoader().getResourceAsStream("ny-weather.xml");
    Weather weather = new YahooParser().parse( "10002", nyData );
    assertEquals( "New York", weather.getLocation().getCity() );
    assertEquals( "NY", weather.getLocation().getRegion() );
    assertEquals( "US", weather.getLocation().getCountry() );
    assertEquals( "39", weather.getCondition().getTemp() );
    assertEquals( "Fair", weather.getCondition().getText() );
    assertEquals( "39", weather.getWind().getChill() );
    assertEquals( "67", weather.getAtmosphere().getHumidity() );
  }
View Full Code Here

Examples of org.spout.vanilla.data.Weather

    float secondsUntilWeatherChange = sky.getData().get(VanillaData.WEATHER_CHANGE_TIME);
    secondsUntilWeatherChange -= dt;
    if (forceWeatherUpdate.compareAndSet(true, false) || secondsUntilWeatherChange <= 0) {
      this.sky.updateWeather(getCurrent(), getForecast());
      sky.getData().put(VanillaData.WORLD_WEATHER, getForecast());
      final Weather current = getCurrent();
      Weather forecast = current;
      while (forecast == current) {
        // When Rain/Snow or Thunderstorms occur, always go to Clear after.
        if (current == Weather.RAIN || current == Weather.THUNDERSTORM) {
          forecast = Weather.CLEAR;
        } else {
View Full Code Here

Examples of org.spout.vanilla.data.Weather

    event.getMessages().add(new PlayerGameStateMessage(event.getReason(), event.getGameMode()));
  }

  @EventHandler
  public void onWeatherChanged(WeatherChangeEvent event) {
    Weather newWeather = event.getNewWeather();
    if (newWeather.equals(Weather.RAIN) || newWeather.equals(Weather.THUNDERSTORM)) {
      event.getMessages().add(new PlayerGameStateMessage(PlayerGameStateMessage.BEGIN_RAINING));
    } else {
      event.getMessages().add(new PlayerGameStateMessage(PlayerGameStateMessage.END_RAINING));
    }
  }
View Full Code Here

Examples of org.spout.vanilla.data.Weather

  }

  @CommandDescription (aliases = "weather", usage = "<0|1|2|clear|rain|thunder> (0 = CLEAR, 1 = RAIN/SNOW, 2 = THUNDERSTORM) [world]", desc = "Changes the weather")
  @Permissible ("vanilla.command.weather")
  public void weather(CommandSource source, CommandArguments args) throws CommandException {
    Weather weather = args.popEnumValue("weather", Weather.class);
    World world = args.popWorld("world", source);
    args.assertCompletelyParsed();

    Sky sky = world.get(Sky.class);
    if (sky == null) {
      throw new CommandException("The sky of world '" + world.getName() + "' is not available.");
    }

    sky.setWeather(weather);
    String message;
    switch (weather) {
      case RAIN:
        message = plugin.getPrefix() + ChatStyle.GREEN + "Weather set to " + ChatStyle.WHITE + "RAIN/SNOW" + ChatStyle.GREEN + ".";
        break;
      default:
        message = plugin.getPrefix() + ChatStyle.GREEN + "Weather set to " + ChatStyle.WHITE + weather.name() + ChatStyle.GREEN + ".";
        break;
    }
    if (getEngine() instanceof Client) {
      source.sendMessage(message);
    } else {
View Full Code Here

Examples of sample.pojo.data.Weather

        options.setTo(targetEPR);

        // Setting the weather
        QName opSetWeather = new QName("http://service.pojo.sample/xsd", "setWeather");

        Weather w = new Weather();

        w.setTemperature((float)39.3);
        w.setForecast("Cloudy with showers");
        w.setRain(true);
        w.setHowMuchRain((float)4.5);

        Object[] opSetWeatherArgs = new Object[] { w };

        serviceClient.invokeRobust(opSetWeather, opSetWeatherArgs);


        // Getting the weather
        QName opGetWeather = new QName("http://service.pojo.sample/xsd", "getWeather");

        Object[] opGetWeatherArgs = new Object[] { };
        Class[] returnTypes = new Class[] { Weather.class };
       
       
        Object[] response = serviceClient.invokeBlocking(opGetWeather,
                opGetWeatherArgs, returnTypes);
       
        Weather result = (Weather) response[0];
       
        if (result == null) {
            System.out.println("Weather didn't initialize!");
            return;
        }
       
        // Displaying the result
        System.out.println("Temperature               : " +
                           result.getTemperature());
        System.out.println("Forecast                  : " +
                           result.getForecast());
        System.out.println("Rain                      : " +
                           result.getRain());
        System.out.println("How much rain (in inches) : " +
                           result.getHowMuchRain());
       
    }
View Full Code Here

Examples of sample.pojo.data.Weather

        options.setTo(targetEPR);

        // Setting the weather
        QName opSetWeather = new QName("http://service.pojo.sample", "setWeather");

        Weather w = new Weather();

        w.setTemperature((float)39.3);
        w.setForecast("Cloudy with showers");
        w.setRain(true);
        w.setHowMuchRain((float)4.5);

        Object[] opSetWeatherArgs = new Object[] { w };

        serviceClient.invokeRobust(opSetWeather, opSetWeatherArgs);


        // Getting the weather
        QName opGetWeather = new QName("http://service.pojo.sample", "getWeather");

        Object[] opGetWeatherArgs = new Object[] { };
        Class[] returnTypes = new Class[] { Weather.class };
       
       
        Object[] response = serviceClient.invokeBlocking(opGetWeather,
                opGetWeatherArgs, returnTypes);
       
        Weather result = (Weather) response[0];
       
        if (result == null) {
            System.out.println("Weather didn't initialize!");
            return;
        }
       
        // Displaying the result
        System.out.println("Temperature               : " +
                           result.getTemperature());
        System.out.println("Forecast                  : " +
                           result.getForecast());
        System.out.println("Rain                      : " +
                           result.getRain());
        System.out.println("How much rain (in inches) : " +
                           result.getHowMuchRain());
       
    }
View Full Code Here

Examples of sample.pojo.data.Weather

        options.setTo(targetEPR);

        // Setting the weather
        QName opSetWeather = new QName("http://service.pojo.sample/xsd", "setWeather");

        Weather w = new Weather();

        w.setTemperature((float)39.3);
        w.setForecast("Cloudy with showers");
        w.setRain(true);
        w.setHowMuchRain((float)4.5);

        Object[] opSetWeatherArgs = new Object[] { w };

        serviceClient.invokeRobust(opSetWeather, opSetWeatherArgs);


        // Getting the weather
        QName opGetWeather = new QName("http://service.pojo.sample/xsd", "getWeather");

        Object[] opGetWeatherArgs = new Object[] { };
        Class[] returnTypes = new Class[] { Weather.class };
       
       
        Object[] response = serviceClient.invokeBlocking(opGetWeather,
                opGetWeatherArgs, returnTypes);
       
        Weather result = (Weather) response[0];
       
        if (result == null) {
            System.out.println("Weather didn't initialize!");
            return;
        }
       
        // Displaying the result
        System.out.println("Temperature               : " +
                           result.getTemperature());
        System.out.println("Forecast                  : " +
                           result.getForecast());
        System.out.println("Rain                      : " +
                           result.getRain());
        System.out.println("How much rain (in inches) : " +
                           result.getHowMuchRain());
       
    }
View Full Code Here

Examples of sample.spring.bean.Weather

       
       
        Object[] response = serviceClient.invokeBlocking(opGetWeather,
                opGetWeatherArgs, returnTypes);
       
        Weather result = (Weather) response[0];
       
        // display results
        if (result == null) {
            System.out.println("Weather didn't initialize!");
        }else{
            System.out.println("Temperature               : " +
                               result.getTemperature());
            System.out.println("Forecast                  : " +
                               result.getForecast());
            System.out.println("Rain                      : " +
                               result.getRain());
            System.out.println("How much rain (in inches) : " +
                               result.getHowMuchRain());
        }
    }
View Full Code Here

Examples of sample.spring.bean.Weather

       
       
        Object[] response = serviceClient.invokeBlocking(opGetWeather,
                opGetWeatherArgs, returnTypes);
       
        Weather result = (Weather) response[0];
       
        // display results
        if (result == null) {
            System.out.println("Weather didn't initialize!");
        }else{
            System.out.println("Temperature               : " +
                               result.getTemperature());
            System.out.println("Forecast                  : " +
                               result.getForecast());
            System.out.println("Rain                      : " +
                               result.getRain());
            System.out.println("How much rain (in inches) : " +
                               result.getHowMuchRain());
        }
    }
View Full Code Here
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.