/** * Gets a description of the object corresponding to a code. * * @param code Value allocated by authority. * @return A description of the object, or {@code null} if the object corresponding to the * specified {@code code} has no description. * @throws NoSuchAuthorityCodeException if the specified {@code code} was not found. * @throws FactoryException if the query failed for some other reason. */ public InternationalString getDescriptionText(final String code) throws NoSuchAuthorityCodeException, FactoryException { final String wkt = getWKT(code); int start = wkt.indexOf('"'); if (start >= 0) { final int end = wkt.indexOf('"', ++start); if (end >= 0) { return new SimpleInternationalString(wkt.substring(start, end).trim()); } } return null; }
/** * Returns an arbitrary object from a code. If the object type is know at compile time, it is * recommended to invoke the most precise method instead of this one. * * @param code Value allocated by authority. * @throws NoSuchAuthorityCodeException if the specified {@code code} was not found. * @throws FactoryException if the object creation failed for some other reason. */ @Override public IdentifiedObject createObject(final String code) throws NoSuchAuthorityCodeException, FactoryException { final String wkt = getWKT(code); final Parser parser = getParser(); try { synchronized (parser) { parser.code = code; return (IdentifiedObject) parser.parseObject(wkt); } } catch (ParseException exception) { throw new FactoryException(exception); } }
/** * Returns a coordinate reference system from a code. If the object type is know at compile * time, it is recommended to invoke the most precise method instead of this one. * * @param code Value allocated by authority. * @throws NoSuchAuthorityCodeException if the specified {@code code} was not found. * @throws FactoryException if the object creation failed for some other reason. */ @Override public CoordinateReferenceSystem createCoordinateReferenceSystem(final String code) throws NoSuchAuthorityCodeException, FactoryException { final String wkt = getWKT(code); final Parser parser = getParser(); try { synchronized (parser) { parser.code = code; // parseCoordinateReferenceSystem provides a slightly faster path than parseObject. return parser.parseCoordinateReferenceSystem(wkt); } } catch (ParseException exception) { throw new FactoryException(exception); } }