org.opengis.util.InternationalString Java Examples
The following examples show how to use
org.opengis.util.InternationalString.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StringAdapter.java From sis with Apache License 2.0 | 6 votes |
/** * Returns a string representation of the given character sequence. If the given * sequence is an instance of {@link InternationalString}, then the locale from * the current unmashalling context is used in order to get a string. * If the context is {@code null} or does not specify any locale, then the choice * of locale is left to the {@link InternationalString#toString()} implementation. * * @param text the {@code CharSequence} to convert to a {@code String}, or {@code null}. * @return the localized representation of the given text, or {@code null} if the text was null. * * @see org.apache.sis.xml.XML#LOCALE */ public static String toString(final CharSequence text) { if (text == null) { return null; } if (text instanceof InternationalString) { final Context context = Context.current(); if (context != null) { final Locale locale = context.getLocale(); if (locale != null) { /* * While Apache SIS accepts null locale, foreigner * implementations are not guaranteed to support null. */ return ((InternationalString) text).toString(locale); } } } return text.toString(); }
Example #2
Source File: DefaultResponsibleParty.java From sis with Apache License 2.0 | 6 votes |
/** * Returns the name of the first party of the given type, or {@code null} if none. * * @param position {@code true} for returning the position name instead than individual name. * @return the name or position of the first individual, or {@code null}. * * @see #getOrganisationName() * @see #getIndividualName() * @see #getPositionName() */ private static InternationalString getName(final Collection<? extends AbstractParty> parties, final Class<? extends AbstractParty> type, final boolean position) { InternationalString name = null; if (parties != null) { // May be null on marshalling. for (final AbstractParty party : parties) { if (type.isInstance(party)) { if (name != null) { LegacyPropertyAdapter.warnIgnoredExtraneous(type, DefaultResponsibleParty.class, position ? "getPositionName" : (type == DefaultIndividual.class) ? "getIndividualName" : "getOrganisationName"); break; } name = position ? ((DefaultIndividual) party).getPositionName() : party.getName(); } } } return name; }
Example #3
Source File: DefaultResponsibleParty.java From sis with Apache License 2.0 | 6 votes |
/** * Returns the name or the position of the first individual. If no individual is found in the list of parties, * then this method will search in the list of organization members. The later structure is used by our netCDF * reader. * * @param position {@code true} for returning the position name instead than individual name. * @return the name or position of the first individual, or {@code null}. * * @see #getIndividualName() * @see #getPositionName() */ private InternationalString getIndividual(final boolean position) { final Collection<AbstractParty> parties = getParties(); InternationalString name = getName(parties, DefaultIndividual.class, position); if (name == null && parties != null) { for (final AbstractParty party : parties) { if (party instanceof DefaultOrganisation) { name = getName(((DefaultOrganisation) party).getIndividual(), DefaultIndividual.class, position); if (name != null) { break; } } } } return name; }
Example #4
Source File: DefaultFormula.java From sis with Apache License 2.0 | 6 votes |
/** * Formats this formula as a pseudo-<cite>Well Known Text</cite> element. * * <div class="note"><b>Compatibility note:</b> * ISO 19162 does not define a WKT representation for {@code Formula} objects. * The text formatted by this method is SIS-specific and causes the text to be * flagged as {@linkplain Formatter#setInvalidWKT(Class, Exception) invalid WKT}. * The WKT content of this element may change in any future SIS version.</div> * * @return {@code "Formula"}. */ @Override protected String formatTo(final Formatter formatter) { InternationalString text = null; final Citation citation = getCitation(); // Gives to users a chance to override properties. if (citation != null) { text = citation.getTitle(); } if (text == null) { text = getFormula(); } if (text != null) { formatter.append(text.toString(formatter.getLocale()), ElementKind.REMARKS); } formatter.setInvalidWKT(Formula.class, null); return WKTKeywords.Formula; }
Example #5
Source File: IndexedResourceBundleTest.java From sis with Apache License 2.0 | 6 votes |
/** * Tests the formatting of an international string. */ @Test @DependsOnMethod("testGetResources") public void testFormatInternational() { InternationalString i18n = Errors.formatInternational(Errors.Keys.NullArgument_1); assertEquals("Argument ‘{0}’ shall not be null.", i18n.toString(Locale.ROOT)); assertEquals("Argument ‘{0}’ shall not be null.", i18n.toString(Locale.ENGLISH)); assertEquals("L’argument ‘{0}’ ne doit pas être nul.", i18n.toString(Locale.FRENCH)); assertNotSame(i18n, assertSerializedEquals(i18n)); i18n = Errors.formatInternational(Errors.Keys.NullArgument_1, "CRS"); assertEquals("Argument ‘CRS’ shall not be null.", i18n.toString(Locale.ROOT)); assertEquals("Argument ‘CRS’ shall not be null.", i18n.toString(Locale.ENGLISH)); assertEquals("L’argument ‘CRS’ ne doit pas être nul.", i18n.toString(Locale.FRENCH)); assertNotSame(i18n, assertSerializedEquals(i18n)); }
Example #6
Source File: TransformCommand.java From sis with Apache License 2.0 | 6 votes |
/** * Prints a textual description of the domain of validity. This method tries to reduce the string length by * the use of some heuristic rules based on the syntax used in EPSG dataset. For example the following string: * * <blockquote>Canada - onshore and offshore - Alberta; British Columbia (BC); Manitoba; New Brunswick (NB); * Newfoundland and Labrador; Northwest Territories (NWT); Nova Scotia (NS); Nunavut; Ontario; Prince Edward * Island (PEI); Quebec; Saskatchewan; Yukon.</blockquote> * * is replaced by: * * <blockquote>Canada - onshore and offshore</blockquote> */ private void printDomainOfValidity(final Extent domain) throws IOException { if (domain != null) { final InternationalString description = domain.getDescription(); if (description != null) { String text = description.toString(locale); if (text.length() >= 80) { int end = text.indexOf(';'); if (end >= 0) { int s = text.lastIndexOf('-', end); if (s >= 0) { end = s; } text = text.substring(0, end).trim(); } } printHeader(Vocabulary.Keys.Domain); outHeader.append(text); outHeader.nextLine(); } } }
Example #7
Source File: Citations.java From sis with Apache License 2.0 | 5 votes |
/** * Returns {@code true} if the {@linkplain DefaultCitation#getTitle() title} or any * {@linkplain DefaultCitation#getAlternateTitles() alternate title} in the given citation * matches the given string. The comparison is case-insensitive and ignores every character * which is not a {@linkplain Character#isLetterOrDigit(int) letter or a digit}. * * @param citation the citation to check for, or {@code null}. * @param title the title or alternate title to compare, or {@code null}. * @return {@code true} if both arguments are non-null, and the title or an alternate * title matches the given string. */ public static boolean titleMatches(final Citation citation, final String title) { if (citation != null && title != null) { InternationalString candidate = citation.getTitle(); Iterator<? extends InternationalString> iterator = null; do { if (candidate != null) { final String unlocalized = candidate.toString(Locale.ROOT); if (equalsFiltered(unlocalized, title)) { return true; } final String localized = candidate.toString(); if (!Objects.equals(localized, unlocalized) // Slight optimization for a common case. && equalsFiltered(localized, title)) { return true; } } if (iterator == null) { iterator = nonEmptyIterator(citation.getAlternateTitles()); if (iterator == null) break; } if (!iterator.hasNext()) break; candidate = iterator.next(); } while (true); } return false; }
Example #8
Source File: GeotoolsProgressMonitorAdapter.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
public void beginTask( String name, int totalWork ) { this.totalWork = totalWork; runningWork = 0; geotoolsMonitor.started(); InternationalString iName = new SimpleInternationalString(name); geotoolsMonitor.setTask(iName); }
Example #9
Source File: ResourceTree.java From sis with Apache License 2.0 | 5 votes |
/** * Returns a label for a resource. Current implementation builds a string containing the resource title * if non-ambiguous, followed by filename in order to resolve ambiguity that may be caused by different * files having the same resource identification in their metadata. * * @param name the result of {@link DataStore#getDisplayName()}, or {@code null} if unknown. * @param metadata the result of {@link DataStore#getMetadata()} (may be {@code null}). */ private static String getTitle(final String name, final Metadata metadata) { if (metadata != null) { String title = null; for (final Identification identification : CollectionsExt.nonNull(metadata.getIdentificationInfo())) { final Citation citation = identification.getCitation(); if (citation != null) { final InternationalString i18n = citation.getTitle(); String id; if (i18n != null) { id = i18n.toString(); // TODO: use display locale. } else { id = Citations.getIdentifier(identification.getCitation()); } if (id != null && !(id = id.trim()).isEmpty()) { if (title == null) { title = id; } else if (!title.equals(id)) { return name; // Ambiguity - will use the filename instead. } } } } if (title != null) { if (name != null) { title += " (" + name + ')'; } return title; } } return name; }
Example #10
Source File: PropertyInformation.java From sis with Apache License 2.0 | 5 votes |
/** * Returns valid values that can be assigned to the extended element, or {@code null} if none. * In the particular case of SIS implementation, this method may return a subclass of * {@link org.apache.sis.measure.NumberRange}. */ @Override @SuppressWarnings({"unchecked","rawtypes"}) public InternationalString getDomainValue() { Object domain = domainValue; if (domain != null) { if (!(domain instanceof DomainRange)) { try { // Not a big deal if we create two instances of that in two concurrent threads. domain = new DomainRange(elementType, (ValueRange) domain); } catch (IllegalArgumentException e) { /* * May happen only if a ValueRange annotation is applied on the wrong method. * The JUnit tests ensure that this never happen at least for the SIS metadata * implementation. If this error happen anyway, the user probably doesn't expect * to have an IllegalArgumentException while he didn't provided any argument. * Returning null as a fallback is compliant with the method contract. */ Logging.unexpectedException(Logging.getLogger(Modules.METADATA), PropertyInformation.class, "getDomainValue", e); domain = null; } domainValue = domain; } } return (DomainRange) domain; }
Example #11
Source File: DefaultKeywords.java From sis with Apache License 2.0 | 5 votes |
/** * Creates keywords initialized to the given key word. * * @param keywords commonly used words or formalised words or phrases used to describe the subject, * or {@code null} if none. */ public DefaultKeywords(final CharSequence... keywords) { if (keywords != null) { for (final CharSequence keyword : keywords) { final InternationalString i18n = Types.toInternationalString(keyword); if (this.keywords == null) { this.keywords = singleton(i18n, InternationalString.class); } else { this.keywords.add(i18n); } } } }
Example #12
Source File: DataSourceInfo.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Gets the property descriptor list. * * @return the property descriptor list */ public Collection<PropertyDescriptor> getPropertyDescriptorList() { if (schema != null) { return schema.getDescriptors(); } else { if (geometryType == GeometryTypeEnum.RASTER) { if (rasterPropertyDescriptorList == null) { rasterPropertyDescriptorList = new ArrayList<>(); CoordinateReferenceSystem crs = null; boolean isIdentifiable = false; boolean isAbstract = false; List<Filter> restrictions = null; AttributeType superType = null; InternationalString description = null; GeometryType type = featureTypeFactory.createGeometryType( new NameImpl(RASTER_GEOMETRY_FIELD), GridCoverage2D.class, crs, isIdentifiable, isAbstract, restrictions, superType, description); GeometryDescriptor descriptor = featureTypeFactory.createGeometryDescriptor( type, new NameImpl(RASTER_GEOMETRY_FIELD), 0, 1, false, null); rasterPropertyDescriptorList.add(descriptor); } return rasterPropertyDescriptorList; } } return null; }
Example #13
Source File: AbstractIdentifiedObject.java From sis with Apache License 2.0 | 5 votes |
/** * Invoked by JAXB for setting the remarks. * * @see #getRemarks() */ private void setRemarks(final InternationalString value) { if (remarks == null) { remarks = value; } else { MetadataUtilities.propertyAlreadySet(AbstractIdentifiedObject.class, "setRemarks", "remarks"); } }
Example #14
Source File: Types.java From sis with Apache License 2.0 | 5 votes |
/** * Returns a description for the given class, or {@code null} if none. * This method can be used for GeoAPI interfaces or {@link CodeList}. * * @param type the GeoAPI interface or code list from which to get the description, or {@code null}. * @return the description, or {@code null} if none or if the given type is {@code null}. * * @see #getDescription(CodeList) */ public static InternationalString getDescription(final Class<?> type) { final String name = getStandardName(type); if (name != null) { final String resources = getResources(type.getName()); if (resources != null) { return new Description(resources, name); } } return null; }
Example #15
Source File: MetadataBuilder.java From sis with Apache License 2.0 | 5 votes |
/** * Returns the concatenation of the given strings. The previous string may be {@code null}. * This method does nothing if the previous string already contains the one to append. */ private static InternationalString append(final InternationalString previous, final InternationalString toAdd) { if (previous == null) { return toAdd; } final String p = previous.toString(); final String a = toAdd.toString(); if (p.contains(a)) { return previous; } return Types.toInternationalString(p + System.lineSeparator() + a); }
Example #16
Source File: AbstractParty.java From sis with Apache License 2.0 | 4 votes |
/** * Return the name of the party. * * @return name of the party. */ @XmlElement(name = "name") @UML(identifier="name", obligation=CONDITIONAL, specification=ISO_19115) public InternationalString getName() { return name; }
Example #17
Source File: DefaultIndividual.java From sis with Apache License 2.0 | 4 votes |
/** * Returns position of the individual in an organization, or {@code null} if none. * * @return position of the individual in an organization, or {@code null} if none. */ @XmlElement(name = "positionName") @UML(identifier="positionName", obligation=CONDITIONAL, specification=ISO_19115) public InternationalString getPositionName() { return positionName; }
Example #18
Source File: ProjectedCrsImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 4 votes |
public InternationalString getRemarks() { return base.getRemarks(); }
Example #19
Source File: DefaultInstrument.java From sis with Apache License 2.0 | 4 votes |
/** * Returns the textual description of the instrument. {@code null} if unspecified. * * @return textual description, or {@code null}. */ @Override @XmlElement(name = "description") public InternationalString getDescription() { return description; }
Example #20
Source File: DefaultSeries.java From sis with Apache License 2.0 | 4 votes |
/** * Returns the name of the series, or aggregate dataset, of which the dataset is a part. * * @return the name of the series or aggregate dataset, or {@code null}. */ @Override @XmlElement(name = "name") public InternationalString getName() { return name; }
Example #21
Source File: DefaultCitation.java From sis with Apache License 2.0 | 4 votes |
/** * Returns the version of the cited resource. * * @return the version, or {@code null} if none. */ @Override @XmlElement(name = "edition") public InternationalString getEdition() { return edition; }
Example #22
Source File: PropertyInformation.java From sis with Apache License 2.0 | 4 votes |
/** * Returns the definition of this property, or {@code null} if none. */ @Override public final InternationalString getDefinition() { return Types.getDescription(parent, code); }
Example #23
Source File: DefaultUsage.java From sis with Apache License 2.0 | 4 votes |
/** * Returns applications, determined by the user for which the resource and/or resource series is not suitable. * * @return applications for which the resource and/or resource series is not suitable, or {@code null}. */ @Override @XmlElement(name = "userDeterminedLimitations") public InternationalString getUserDeterminedLimitations() { return userDeterminedLimitations; }
Example #24
Source File: AuthorityFactoryProxy.java From sis with Apache License 2.0 | 4 votes |
@Override AuthorityFactoryProxy<InternationalString> specialize(String typeName) { return this; }
Example #25
Source File: DefaultSecurityConstraints.java From sis with Apache License 2.0 | 4 votes |
/** * Returns the name of the classification system. * * @return name of the classification system, or {@code null}. */ @Override @XmlElement(name = "classificationSystem") public InternationalString getClassificationSystem() { return classificationSystem; }
Example #26
Source File: GeodeticCrsImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 4 votes |
public InternationalString getRemarks() { return base.getRemarks(); }
Example #27
Source File: SimpleFormat.java From sis with Apache License 2.0 | 4 votes |
/** * @deprecated Replaced by {@link #getAlternateTitles()} * * @return name of the data transfer format(s). */ @Override @Deprecated public InternationalString getName() { return super.getTitle(); }
Example #28
Source File: SimpleMetadata.java From sis with Apache License 2.0 | 4 votes |
/** * Other information required to complete the citation that is not recorded elsewhere. * This is part of the information returned by {@link #getCitation()}. */ @Override public InternationalString getOtherCitationDetails() { return null; }
Example #29
Source File: SimpleCitation.java From sis with Apache License 2.0 | 4 votes |
@Deprecated @Override public InternationalString getCollectiveTitle() {return null;}
Example #30
Source File: UniqueValueRenderer.java From sldeditor with GNU General Public License v3.0 | 4 votes |
@Override public StyledLayerDescriptor convert(JsonObject json, String layerName, double minScale, double maxScale, int transparency) { StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor(); NamedLayer namedLayer = styleFactory.createNamedLayer(); boolean useDefaultSymbol = false; JsonElement useDefaultSymbolElement = json.get(UniqueValueRendererKeys.USE_DEFAULTSYMBOL); if(useDefaultSymbolElement != null) { useDefaultSymbol = useDefaultSymbolElement.getAsBoolean(); } JsonElement jsonElement = json.get(CommonRendererKeys.LABEL); if(jsonElement != null) { namedLayer.setName(jsonElement.getAsString()); } sld.addStyledLayer(namedLayer); Style style = styleFactory.createStyle(); namedLayer.addStyle(style); List<FeatureTypeStyle> ftsList = style.featureTypeStyles(); // style.setAbstract(json.get(IntermediateFileKeys.DESCRIPTION).getAsString()); FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(); ftsList.add(fts); JsonElement element = json.get(UniqueValueRendererKeys.VALUES); if(element != null) { JsonArray valueList = element.getAsJsonArray(); for(int index = 0; index < valueList.size(); index ++) { JsonElement valueElement = valueList.get(index); if(valueElement != null) { Rule rule = styleFactory.createRule(); JsonObject valueObj = valueElement.getAsJsonObject(); String value = getString(valueObj, UniqueValueRendererKeys.VALUES_VALUE); String label = getString(valueObj, UniqueValueRendererKeys.VALUES_LABEL); rule.setName(label); createFilter(rule, json.get(UniqueValueRendererKeys.FIELDS), json.get(UniqueValueRendererKeys.FIELD_DELIMETER), value); // Heading /description String heading = getString(valueObj, UniqueValueRendererKeys.VALUES_HEADING); @SuppressWarnings("unused") String description = getString(valueObj, UniqueValueRendererKeys.VALUES_DESCRIPTION); if((heading != null) && !heading.isEmpty() || (label != null) && !label.isEmpty()) { if(label == null) { label = ""; } InternationalString titleString = Text.text(label); if(heading == null) { heading = ""; } InternationalString descriptionString = Text.text(heading); Description descriptionObj = styleFactory.description(titleString, descriptionString); rule.setDescription(descriptionObj); } if(minScale > 0.0) { rule.setMinScaleDenominator(minScale); } if(maxScale > 0.0) { rule.setMaxScaleDenominator(maxScale); } JsonElement jsonSymbolElement = valueObj.get(UniqueValueRendererKeys.VALUES_SYMBOL); SymbolManager.getInstance().convertSymbols(rule, layerName, transparency, jsonSymbolElement); if(useDefaultSymbol && value == null) { rule.setIsElseFilter(true); } fts.rules().add(rule); } } } return sld; }