/** * Creates an object from the given character sequence. * The parsing begins at the index given by the {@code pos} argument. * After successful parsing, {@link ParsePosition#getIndex()} gives the position after the last parsed character. * In case of error, {@link ParseException#getErrorOffset()} gives the position of the first illegal character. * * @param wkt the character sequence for the object to parse. * @param pos the position where to start the parsing. * @return the parsed object (never {@code null}). * @throws ParseException if an error occurred while parsing the WKT. */ @Override public Object parse(final CharSequence wkt, final ParsePosition pos) throws ParseException { warnings = null; sharedValues = null; ArgumentChecks.ensureNonEmpty("wkt", wkt); ArgumentChecks.ensureNonNull ("pos", pos); final AbstractParser parser = parser(); Object object = null; try { return object = parser.parseObject(wkt.toString(), pos); } finally { warnings = parser.getAndClearWarnings(object); } }
/** * Creates an object from the given character sequence. * The parsing begins at the index given by the {@code pos} argument. * After successful parsing, {@link ParsePosition#getIndex()} gives the position after the last parsed character. * In case of error, {@link ParseException#getErrorOffset()} gives the position of the first illegal character. * * @param wkt the character sequence for the object to parse. * @param pos the position where to start the parsing. * @return the parsed object (never {@code null}). * @throws ParseException if an error occurred while parsing the WKT. */ @Override public Object parse(final CharSequence wkt, final ParsePosition pos) throws ParseException { warnings = null; sharedValues = null; ArgumentChecks.ensureNonEmpty("wkt", wkt); ArgumentChecks.ensureNonNull ("pos", pos); final AbstractParser parser = parser(); Object object = null; try { return object = parser.parseObject(wkt.toString(), pos); } finally { warnings = parser.getAndClearWarnings(object); } }
/** * Creates the object from a string and log the warnings if any. * This method is for implementation of {@code createFromWKT(String)} method is SIS factories only. * * @param text coordinate system encoded in Well-Known Text format (version 1 or 2). * @return the result of parsing the given text. * @throws FactoryException if the object creation failed. * * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createFromWKT(String) * @see org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory#createFromWKT(String) */ @Override public final Object createFromWKT(final String text) throws FactoryException { final Object value; try { value = parseObject(text, new ParsePosition(0)); } catch (ParseException exception) { final Throwable cause = exception.getCause(); if (cause instanceof FactoryException) { throw (FactoryException) cause; } throw new FactoryException(exception.getLocalizedMessage(), exception); } final Warnings warnings = getAndClearWarnings(value); if (warnings != null) { log(new LogRecord(Level.WARNING, warnings.toString())); } return value; }
/** * Creates the object from a string and log the warnings if any. * This method is for implementation of {@code createFromWKT(String)} method is SIS factories only. * * @param text coordinate system encoded in Well-Known Text format (version 1 or 2). * @return the result of parsing the given text. * @throws FactoryException if the object creation failed. * * @see org.apache.sis.referencing.factory.GeodeticObjectFactory#createFromWKT(String) * @see org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory#createFromWKT(String) */ @Override public final Object createFromWKT(final String text) throws FactoryException { final Object value; try { value = parseObject(text, new ParsePosition(0)); } catch (ParseException exception) { final Throwable cause = exception.getCause(); if (cause instanceof FactoryException) { throw (FactoryException) cause; } throw new FactoryException(exception.getLocalizedMessage(), exception); } final Warnings warnings = getAndClearWarnings(value); if (warnings != null) { log(new LogRecord(Level.WARNING, warnings.toString())); } return value; }