numberFormat = symbols.createNumberFormat();
numberFormat = symbols.createNumberFormat();
/** * Creates a new format to use for parsing and formatting values of the given type. * This method is invoked the first time that a format is needed for the given type. * The {@code valueType} can be any types declared in the * {@linkplain CompoundFormat#createFormat(Class) parent class}. * * @param valueType the base type of values to parse or format. * @return the format to use for parsing of formatting values of the given type, or {@code null} if none. */ @Override protected Format createFormat(final Class<?> valueType) { if (valueType == Number.class) { return symbols.createNumberFormat(); } if (valueType == Date.class) { return new StandardDateFormat(symbols.getLocale(), getTimeZone()); } final Format format = super.createFormat(valueType); if (format instanceof UnitFormat) { ((UnitFormat) format).setStyle(UnitFormat.Style.NAME); } return format; }
/** * Creates a new format to use for parsing and formatting values of the given type. * This method is invoked the first time that a format is needed for the given type. * The {@code valueType} can be any types declared in the * {@linkplain CompoundFormat#createFormat(Class) parent class}. * * @param valueType the base type of values to parse or format. * @return the format to use for parsing of formatting values of the given type, or {@code null} if none. */ @Override protected Format createFormat(final Class<?> valueType) { if (valueType == Number.class) { return symbols.createNumberFormat(); } if (valueType == Date.class) { return new StandardDateFormat(symbols.getLocale(), getTimeZone()); } final Format format = super.createFormat(valueType); if (format instanceof UnitFormat) { ((UnitFormat) format).setStyle(UnitFormat.Style.NAME); } return format; }
/** * Creates a new formatter instance with the specified convention, symbols and indentation. * * @param convention the convention to use. * @param symbols the symbols. * @param indentation the amount of spaces to use in indentation for WKT formatting, * or {@link WKTFormat#SINGLE_LINE} for formatting the whole WKT on a single line. */ public Formatter(final Convention convention, final Symbols symbols, final int indentation) { ArgumentChecks.ensureNonNull("convention", convention); ArgumentChecks.ensureNonNull("symbols", symbols); ArgumentChecks.ensureBetween("indentation", WKTFormat.SINGLE_LINE, Byte.MAX_VALUE, indentation); this.locale = Locale.getDefault(Locale.Category.DISPLAY); this.convention = convention; this.authority = convention.getNameAuthority(); this.symbols = symbols.immutable(); this.separatorNewLine = this.symbols.separatorNewLine(); this.indentation = (byte) indentation; this.numberFormat = symbols.createNumberFormat(); this.dateFormat = new StandardDateFormat(symbols.getLocale()); this.unitFormat = new UnitFormat(symbols.getLocale()); this.buffer = new StringBuffer(); unitFormat.setStyle(UnitFormat.Style.NAME); if (convention.usesCommonUnits) { unitFormat.setLocale(Locale.US); } }
/** * Creates a new formatter instance with the specified convention, symbols and indentation. * * @param convention the convention to use. * @param symbols the symbols. * @param indentation the amount of spaces to use in indentation for WKT formatting, * or {@link WKTFormat#SINGLE_LINE} for formatting the whole WKT on a single line. */ public Formatter(final Convention convention, final Symbols symbols, final int indentation) { ArgumentChecks.ensureNonNull("convention", convention); ArgumentChecks.ensureNonNull("symbols", symbols); ArgumentChecks.ensureBetween("indentation", WKTFormat.SINGLE_LINE, Byte.MAX_VALUE, indentation); this.locale = Locale.getDefault(Locale.Category.DISPLAY); this.convention = convention; this.authority = convention.getNameAuthority(); this.symbols = symbols.immutable(); this.lineSeparator = this.symbols.lineSeparator(); this.indentation = (byte) indentation; this.numberFormat = symbols.createNumberFormat(); this.dateFormat = new StandardDateFormat(symbols.getLocale()); this.unitFormat = new UnitFormat(symbols.getLocale()); this.buffer = new StringBuffer(); unitFormat.setStyle(UnitFormat.Style.NAME); if (convention.usesCommonUnits) { unitFormat.setLocale(Locale.US); } }