All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.antlr.v4.tool.templates.unicodedata.st Maven / Gradle / Ivy

There is a newer version: 4.13.1.5
Show newest version
unicodedata(propertyCodePointRanges, propertyAliases) ::= <<
package org.antlr.v4.unicode;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.antlr.v4.runtime.misc.IntervalSet;
import org.antlr.v4.runtime.misc.Interval;

/**
 * Code-generated utility class mapping Unicode properties to Unicode code point ranges.
 */
public enum UnicodeData {
	;

	private static final Map\ propertyCodePointRanges = new HashMap\();
	private static final Map\ propertyAliases = new HashMap\();

	// Work around Java 64k bytecode method limit by splitting up static
	// initialization into one method per Unicode property

	"
static private void addProperty() {
	List\ intervals = Arrays.asList(
		, )}; separator=",\n">
	);
	IntervalSet codePointRanges = new IntervalSet(intervals);
	codePointRanges.setReadonly(true);
	propertyCodePointRanges.put("".toLowerCase(Locale.US), codePointRanges);
\}}; separator="\n\n">

	// Property aliases
	static private void addPropertyAliases() {
		".toLowerCase(Locale.US), "".toLowerCase(Locale.US)); }; separator="\n">
	}

	// Put it all together
	static {
		(); }; separator="\n">
		addPropertyAliases();
	}

	private static String normalize(String propertyCodeOrAlias) {
		return propertyCodeOrAlias.toLowerCase(Locale.US).replace('-', '_');
	}

	/**
	 * Given a Unicode property (general category code, binary property name, or script name),
	 * returns the {@link IntervalSet} of Unicode code point ranges which have that property.
	 */
	public static IntervalSet getPropertyCodePoints(String propertyCodeOrAlias) {
		String normalizedPropertyCodeOrAlias = normalize(propertyCodeOrAlias);
		IntervalSet result = propertyCodePointRanges.get(normalizedPropertyCodeOrAlias);
		if (result == null) {
			String propertyCode = propertyAliases.get(normalizedPropertyCodeOrAlias);
			result = propertyCodePointRanges.get(propertyCode);
		}
		return result;
	}
}
>>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy