/** * Sets the price of the item. * * @param value * @param currency */ public void setPrice(float value, String currency) { setPrice(new NumberUnit<Float>(value, currency)); }
/** Sets delivery radius. */ public void setDeliveryRadius(float value, String unit) { setDeliveryRadius(new NumberUnit<Float>(value, unit)); }
/** * Sets the price of the item. * * @param value * @param currency */ public void setPrice(float value, String currency) { setPrice(new NumberUnit<Float>(value, currency)); }
/** Sets delivery radius. */ public void setDeliveryRadius(float value, String unit) { setDeliveryRadius(new NumberUnit<Float>(value, unit)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#INT_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value * @param unit * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addIntUnitAttribute(String name, int value, String unit) { return addIntUnitAttribute(name, new NumberUnit<Integer>(value, unit)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#NUMBER_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value * @param unit * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addNumberUnitAttribute(String name, Number value, String unit) { return addNumberUnitAttribute(name, new NumberUnit<Number>(value, unit)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#NUMBER_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value * @param unit * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addNumberUnitAttribute(String name, Number value, String unit) { return addNumberUnitAttribute(name, new NumberUnit<Number>(value, unit)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#FLOAT_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value * @param unit * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addFloatUnitAttribute(String name, float value, String unit) { return addFloatUnitAttribute(name, new NumberUnit<Float>(value, unit)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#INT_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value * @param unit * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addIntUnitAttribute(String name, int value, String unit) { return addIntUnitAttribute(name, new NumberUnit<Integer>(value, unit)); }
/** * Adds an attribute of type * {@link com.google.api.gbase.client.GoogleBaseAttributeType#FLOAT_UNIT}. * * This method will never remove an attribute, even if it has * the same name as the new attribute. If you would like to set * an attribute that can only appear once, call * {@link #removeAttributes(String, GoogleBaseAttributeType)} first. * * @param name attribute name * @param value * @param unit * @return the attribute object that has been created and added to the item */ public GoogleBaseAttribute addFloatUnitAttribute(String name, float value, String unit) { return addFloatUnitAttribute(name, new NumberUnit<Float>(value, unit)); }
/** * Converts a float followed by a unit name into an object. * * @param string a string of the form: <code>float " " unit</code> or null * @return the corresponding object or null * @exception NumberFormatException if the conversion failed */ public static NumberUnit<Float> toFloatUnit(String string) { if (string == null) { return null; } int firstSpace = findFirstSpace(string); String beforeSpace = beforeSpace(string, firstSpace); return new NumberUnit<Float>(new Float(beforeSpace), parseUnit(string, firstSpace)); }
/** * Converts a integer followed by a unit name into an object. * * @param string a string of the form: <code>integer " " unit</code> or null * @return the corresponding object or null * @exception NumberFormatException if the conversion failed */ public static NumberUnit<Integer> toIntUnit(String string) { if (string == null) { return null; } int firstSpace = findFirstSpace(string); String beforeSpace = beforeSpace(string, firstSpace); return new NumberUnit<Integer>(new Integer(beforeSpace), parseUnit(string, firstSpace)); }
/** * Converts a float followed by a unit name into an object. * * @param string a string of the form: <code>float " " unit</code> or null * @return the corresponding object or null * @exception NumberFormatException if the conversion failed */ public static NumberUnit<Float> toFloatUnit(String string) { if (string == null) { return null; } int firstSpace = findFirstSpace(string); String beforeSpace = beforeSpace(string, firstSpace); return new NumberUnit<Float>(new Float(beforeSpace), parseUnit(string, firstSpace)); }
/** * Converts a integer followed by a unit name into an object. * * @param string a string of the form: <code>integer " " unit</code> or null * @return the corresponding object or null * @exception NumberFormatException if the conversion failed */ public static NumberUnit<Integer> toIntUnit(String string) { if (string == null) { return null; } int firstSpace = findFirstSpace(string); String beforeSpace = beforeSpace(string, firstSpace); return new NumberUnit<Integer>(new Integer(beforeSpace), parseUnit(string, firstSpace)); }
priceUnit = toFloatUnit(price); } catch (NumberFormatException e) { priceUnit = new NumberUnit<Float>(Float.parseFloat(price), null);
priceUnit = toFloatUnit(price); } catch (NumberFormatException e) { priceUnit = new NumberUnit<Float>(Float.parseFloat(price), null);
private static Shipping extractShippingFromElements(GoogleBaseAttribute attribute) { String country = attribute.getSubElementValue(ShippingField.Country.getElemName()); Collection<String> regions = attribute.getSubElementValues(ShippingField.Region.getElemName()); String price = attribute.getSubElementValue(ShippingField.Price.getElemName()); String service = attribute.getSubElementValue(ShippingField.Service.getElemName()); if (price == null) { throw new NumberFormatException( "missing 'price' element in shipping attribute: " + attribute); } NumberUnit<Float> priceUnit; try { priceUnit = toFloatUnit(price); } catch (NumberFormatException e) { priceUnit = new NumberUnit<Float>(Float.parseFloat(price), null); } return new Shipping(country, regions, service, priceUnit.getValue(), priceUnit.getUnit()); }
private static Shipping extractShippingFromElements(GoogleBaseAttribute attribute) { String country = attribute.getSubElementValue(ShippingField.Country.getElemName()); Collection<String> regions = attribute.getSubElementValues(ShippingField.Region.getElemName()); String price = attribute.getSubElementValue(ShippingField.Price.getElemName()); String service = attribute.getSubElementValue(ShippingField.Service.getElemName()); if (price == null) { throw new NumberFormatException( "missing 'price' element in shipping attribute: " + attribute); } NumberUnit<Float> priceUnit; try { priceUnit = toFloatUnit(price); } catch (NumberFormatException e) { priceUnit = new NumberUnit<Float>(Float.parseFloat(price), null); } return new Shipping(country, regions, service, priceUnit.getValue(), priceUnit.getUnit()); }