+ uom + "). Using the previous one: " + defaultUnit.toString());
public String toString() { return unit.toString(); } }
public String getIdentifier(Unit<Length> unit) { String identifier = toId.get(unit); if (identifier == null) { throw new IllegalArgumentException("Unit not supported by YSLD: " + unit.toString()); } return identifier; } }
/** * Returns the optional unit symbol for this {@link NumberItem}. * * @return the optional unit symbol for this {@link NumberItem}. */ public @Nullable String getUnitSymbol() { Unit<?> unit = getUnit(); return unit != null ? unit.toString() : null; }
@Override public String format(@Nullable String pattern) { String formatPattern = pattern; if (formatPattern != null && formatPattern.contains(UnitUtils.UNIT_PLACEHOLDER)) { String unitSymbol = getUnit().equals(SmartHomeUnits.PERCENT) ? "%%" : getUnit().toString(); formatPattern = formatPattern.replace(UnitUtils.UNIT_PLACEHOLDER, unitSymbol); } // The value could be an integer value. Try to convert to BigInteger in // order to have access to more conversion formats. try { return String.format(formatPattern, toBigDecimal().toBigIntegerExact()); } catch (ArithmeticException ae) { // Could not convert to integer value without loss of // information. Fall through to default behavior. } catch (IllegalFormatConversionException ifce) { // The conversion is not valid for the type BigInteger. This // happens, if the format is like "%.1f" but the value is an // integer. Fall through to default behavior. } return String.format(formatPattern, toBigDecimal()); }
protected void doTestNotModifiedUnits(Unit<?> u, UnitFormat unitFormat) throws IOException { Appendable appendable = new StringBuilder(); unitFormat.format(u, appendable); assertEquals("Missing symbol formats", u.toString(), appendable.toString()); } }
throw new IllegalArgumentException( "Error when trying to create a PCS using this linear UoM " + linearUnit.toString()); final Map<String, String> props = new HashMap<String, String>(); props.put("name", Vocabulary.formatInternational(VocabularyKeys.PROJECTED).toString());
unit.toString()); // unitFormat.labelFor(unit)
@Override public String toString() { return pseudoUnit.toString(); }
/** * Returns the symbol of the given unit. * * @param value the unit. * @return the unit symbol. */ @Override public String marshal(final Unit<?> value) { return (value != null) ? value.toString() : null; }
/** * Returns the symbol of the given unit. * * @param value the unit. * @return the unit symbol. */ @Override public String marshal(final Unit<?> value) { return (value != null) ? value.toString() : null; }
public String getIdentifier(Unit<Length> unit) { String identifier = toId.get(unit); if (identifier == null) { throw new IllegalArgumentException("Unit not supported by YSLD: " + unit.toString()); } return identifier; } }
@Override public Appendable format(Unit<?> unit, Appendable appendable) throws IOException { if (!(unit instanceof AbstractUnit)) { return appendable.append(unit.toString()); // Unknown unit (use // intrinsic toString() // method) } formatInternal(unit, appendable); return appendable; }
/** * Returns the optional unit symbol for this {@link NumberItem}. * * @return the optional unit symbol for this {@link NumberItem}. */ public @Nullable String getUnitSymbol() { Unit<?> unit = getUnit(); return unit != null ? unit.toString() : null; }
@Override public Appendable format(Unit<?> unit, Appendable appendable) throws IOException { if (!(unit instanceof AbstractUnit)) { return appendable.append(unit.toString()); // Unknown unit (use // intrinsic toString() // method) } formatInternal(unit, appendable); return appendable; }
if (ellipsoid != null) { buffer.write(' '); buffer.write(ellipsoid.getAxisUnit().toString());
private String getAxisUnit() { CoordinateReferenceSystem crs = this.sampleGranule.getCoordinateReferenceSystem2D(); CoordinateSystemAxis axis = crs.getCoordinateSystem().getAxis(0); Unit<?> unit = axis.getUnit(); if (unit == null) { return ""; } else if (unit == NonSI.DEGREE_ANGLE) { return "degrees"; } else { return unit.toString(); } }
speed = SpeedConverter.toKnots(1, USCustomary.FOOT.toString() + "/s"); assertEquals(0.592483801, speed, 1E-6);
public void testUnitDisplay() { MetricMeasurement timing = new MetricMeasurement(StandardThreadMetrics.CLOCK_TIME, Thread .currentThread()); timing.startTimer(); timing.stopTimer(); assertTrue("Metric value should end with correct unit name", timing.ownTimeValue().toString() .endsWith(StandardThreadMetrics.CLOCK_TIME.getUnit().toString())); } }