/** * Creates an immutable instance of GeoLat extension with the coordinate * set to the value passed in. * * @param lat The latitude coordinate reprensented by this element. * @throws IllegalArgumentException if the the latitude is not between * -90 and 90. */ public GeoLat(Double lat) throws IllegalArgumentException { super(Namespaces.W3C_GEO_NAMESPACE, "lat", null, null); setRequired(true); if (lat != null) { setLatitude(lat); setImmutable(true); } }
/** * @return the value of the geo:lat element within this Point. */ public Double getLatitude() { GeoLat lat = getExtension(GeoLat.class); return lat != null ? lat.getLatitude() : null; }
/** * Sets the geo location based on the passed in lat and lon values. Both * must be null or non null, and the lat must be between -90 and 90, and the * lon between -180 and 180. */ public void setGeoLocation(Double lat, Double lon) { if (lat != null && lon != null) { setExtension(new GeoLat(lat)); setExtension(new GeoLong(lon)); } else if (lat != null || lon != null) { throw new IllegalArgumentException( "'lat' and 'lon' must either both be null or non-null."); } else { removeExtension(GeoLat.class); removeExtension(GeoLong.class); } }
/** * Overrides base implementation by validating that the string represents * a latitude coordinate between -90 and 90 degrees. Also formats the * the string so that it has a consistent number of significant digits * after the decimal point. */ @Override public void setValue(String value) { Double d = null; if (value != null) { // First ensure that the string is actually a double. try { d = Double.parseDouble(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("'value' must be a double."); } } setLatitude(d); } }
/** * @return the value of the geo:lat element within this Point. */ public Double getLatitude() { GeoLat lat = getExtension(GeoLat.class); return lat != null ? lat.getLatitude() : null; }
/** * Sets the geo location based on the passed in lat and lon values. Both * must be null or non null, and the lat must be between -90 and 90, and the * lon between -180 and 180. */ public void setGeoLocation(Double lat, Double lon) { if (lat != null && lon != null) { setExtension(new GeoLat(lat)); setExtension(new GeoLong(lon)); } else if (lat != null || lon != null) { throw new IllegalArgumentException( "'lat' and 'lon' must either both be null or non-null."); } else { removeExtension(GeoLat.class); removeExtension(GeoLong.class); } }
/** * Overrides base implementation by validating that the string represents * a latitude coordinate between -90 and 90 degrees. Also formats the * the string so that it has a consistent number of significant digits * after the decimal point. */ @Override public void setValue(String value) { Double d = null; if (value != null) { // First ensure that the string is actually a double. try { d = Double.parseDouble(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("'value' must be a double."); } } setLatitude(d); } }
/** * Creates an immutable instance of GeoLat extension with the coordinate * set to the value passed in. * * @param lat The latitude coordinate reprensented by this element. * @throws IllegalArgumentException if the the latitude is not between * -90 and 90. */ public GeoLat(Double lat) throws IllegalArgumentException { super(Namespaces.W3C_GEO_NAMESPACE, "lat", null, null); setRequired(true); if (lat != null) { setLatitude(lat); setImmutable(true); } }
/** * @return the value of the geo:lat element within this Point. */ public Double getLatitude() { GeoLat lat = getExtension(GeoLat.class); return lat != null ? lat.getLatitude() : null; }
/** * Sets the geo location based on the passed in lat and lon values. Both * must be null or non null, and the lat must be between -90 and 90, and the * lon between -180 and 180. */ public void setGeoLocation(Double lat, Double lon) { if (lat != null && lon != null) { setExtension(new GeoLat(lat)); setExtension(new GeoLong(lon)); } else if (lat != null || lon != null) { throw new IllegalArgumentException( "'lat' and 'lon' must either both be null or non-null."); } else { removeExtension(GeoLat.class); removeExtension(GeoLong.class); } }
/** * Overrides base implementation by validating that the string represents * a latitude coordinate between -90 and 90 degrees. Also formats the * the string so that it has a consistent number of significant digits * after the decimal point. */ @Override public void setValue(String value) { Double d = null; if (value != null) { // First ensure that the string is actually a double. try { d = Double.parseDouble(value); } catch (NumberFormatException e) { throw new IllegalArgumentException("'value' must be a double."); } } setLatitude(d); } }
/** * Creates an immutable instance of GeoLat extension with the coordinate * set to the value passed in. * * @param lat The latitude coordinate reprensented by this element. * @throws IllegalArgumentException if the the latitude is not between * -90 and 90. */ public GeoLat(Double lat) throws IllegalArgumentException { super(Namespaces.W3C_GEO_NAMESPACE, "lat", null, null); setRequired(true); if (lat != null) { setLatitude(lat); setImmutable(true); } }