use of android.icu.util.CaseInsensitiveString in project j2objc by google.
the class TransliteratorRegistry method removeSTV.
/**
* Remove a source-target/variant from the specDAG.
*/
private void removeSTV(String source, String target, String variant) {
// assert(source.length() > 0);
// assert(target.length() > 0);
CaseInsensitiveString cisrc = new CaseInsensitiveString(source);
CaseInsensitiveString citrg = new CaseInsensitiveString(target);
CaseInsensitiveString civar = new CaseInsensitiveString(variant);
Map<CaseInsensitiveString, List<CaseInsensitiveString>> targets = specDAG.get(cisrc);
if (targets == null) {
// should never happen for valid s-t/v
return;
}
List<CaseInsensitiveString> variants = targets.get(citrg);
if (variants == null) {
// should never happen for valid s-t/v
return;
}
variants.remove(civar);
if (variants.size() == 0) {
// should delete variants
targets.remove(citrg);
if (targets.size() == 0) {
// should delete targets
specDAG.remove(cisrc);
}
}
}
use of android.icu.util.CaseInsensitiveString in project j2objc by google.
the class TransliteratorRegistry method registerSTV.
/**
* Register a source-target/variant in the specDAG. Variant may be
* empty, but source and target must not be. If variant is empty then
* the special variant NO_VARIANT is stored in slot zero of the
* UVector of variants.
*/
private void registerSTV(String source, String target, String variant) {
// assert(source.length() > 0);
// assert(target.length() > 0);
CaseInsensitiveString cisrc = new CaseInsensitiveString(source);
CaseInsensitiveString citrg = new CaseInsensitiveString(target);
CaseInsensitiveString civar = new CaseInsensitiveString(variant);
Map<CaseInsensitiveString, List<CaseInsensitiveString>> targets = specDAG.get(cisrc);
if (targets == null) {
targets = Collections.synchronizedMap(new HashMap<CaseInsensitiveString, List<CaseInsensitiveString>>());
specDAG.put(cisrc, targets);
}
List<CaseInsensitiveString> variants = targets.get(citrg);
if (variants == null) {
variants = new ArrayList<CaseInsensitiveString>();
targets.put(citrg, variants);
}
// string, that is, the empty string, we add it at position zero.
if (!variants.contains(civar)) {
if (variant.length() > 0) {
variants.add(civar);
} else {
variants.add(0, civar);
}
}
}
use of android.icu.util.CaseInsensitiveString in project j2objc by google.
the class TransliteratorRegistry method getAvailableTargets.
/**
* Returns an enumeration over visible target names for the given
* source.
*
* @return An <code>Enumeration</code> over <code>String</code> objects
*/
public Enumeration<String> getAvailableTargets(String source) {
CaseInsensitiveString cisrc = new CaseInsensitiveString(source);
Map<CaseInsensitiveString, List<CaseInsensitiveString>> targets = specDAG.get(cisrc);
if (targets == null) {
return new IDEnumeration(null);
}
return new IDEnumeration(Collections.enumeration(targets.keySet()));
}
use of android.icu.util.CaseInsensitiveString in project j2objc by google.
the class TransliteratorRegistry method getAvailableVariants.
/**
* Returns an enumeration over visible variant names for the given
* source and target.
*
* @return An <code>Enumeration</code> over <code>String</code> objects
*/
public Enumeration<String> getAvailableVariants(String source, String target) {
CaseInsensitiveString cisrc = new CaseInsensitiveString(source);
CaseInsensitiveString citrg = new CaseInsensitiveString(target);
Map<CaseInsensitiveString, List<CaseInsensitiveString>> targets = specDAG.get(cisrc);
if (targets == null) {
return new IDEnumeration(null);
}
List<CaseInsensitiveString> variants = targets.get(citrg);
if (variants == null) {
return new IDEnumeration(null);
}
return new IDEnumeration(Collections.enumeration(variants));
}
use of android.icu.util.CaseInsensitiveString in project j2objc by google.
the class TransliteratorRegistry method remove.
/**
* Unregister an ID. This removes an entry from the dynamic store
* if there is one. The static locale resource store is
* unaffected.
*/
public void remove(String ID) {
String[] stv = TransliteratorIDParser.IDtoSTV(ID);
// Only need to do this if ID.indexOf('-') < 0
String id = TransliteratorIDParser.STVtoID(stv[0], stv[1], stv[2]);
registry.remove(new CaseInsensitiveString(id));
removeSTV(stv[0], stv[1], stv[2]);
availableIDs.remove(new CaseInsensitiveString(id));
}
Aggregations