repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
Berico-Technologies/CLAVIN
src/main/java/com/bericotech/clavin/gazetteer/query/LuceneGazetteer.java
LuceneGazetteer.sanitizeQueryText
private String sanitizeQueryText(final GazetteerQuery query) { String sanitized = ""; if (query != null && query.getOccurrence() != null) { String text = query.getOccurrence().getText(); if (text != null) { sanitized = escape(text.trim().toLowerCase()); ...
java
private String sanitizeQueryText(final GazetteerQuery query) { String sanitized = ""; if (query != null && query.getOccurrence() != null) { String text = query.getOccurrence().getText(); if (text != null) { sanitized = escape(text.trim().toLowerCase()); ...
[ "private", "String", "sanitizeQueryText", "(", "final", "GazetteerQuery", "query", ")", "{", "String", "sanitized", "=", "\"\"", ";", "if", "(", "query", "!=", "null", "&&", "query", ".", "getOccurrence", "(", ")", "!=", "null", ")", "{", "String", "text",...
Sanitizes the text of the LocationOccurrence in the query parameters for use in a Lucene query, returning an empty string if no text is found. @param query the query configuration @return the santitized query text or the empty string if there is no query text
[ "Sanitizes", "the", "text", "of", "the", "LocationOccurrence", "in", "the", "query", "parameters", "for", "use", "in", "a", "Lucene", "query", "returning", "an", "empty", "string", "if", "no", "text", "is", "found", "." ]
f73c741f33a01b91aa5b06e71860bc354ef3010d
https://github.com/Berico-Technologies/CLAVIN/blob/f73c741f33a01b91aa5b06e71860bc354ef3010d/src/main/java/com/bericotech/clavin/gazetteer/query/LuceneGazetteer.java#L332-L341
train
Berico-Technologies/CLAVIN
src/main/java/com/bericotech/clavin/gazetteer/query/LuceneGazetteer.java
LuceneGazetteer.buildFilter
private Filter buildFilter(final GazetteerQuery params) { List<Query> queryParts = new ArrayList<Query>(); // create the historical locations restriction if we are not including historical locations if (!params.isIncludeHistorical()) { int val = IndexField.getBooleanIndexValue(false...
java
private Filter buildFilter(final GazetteerQuery params) { List<Query> queryParts = new ArrayList<Query>(); // create the historical locations restriction if we are not including historical locations if (!params.isIncludeHistorical()) { int val = IndexField.getBooleanIndexValue(false...
[ "private", "Filter", "buildFilter", "(", "final", "GazetteerQuery", "params", ")", "{", "List", "<", "Query", ">", "queryParts", "=", "new", "ArrayList", "<", "Query", ">", "(", ")", ";", "// create the historical locations restriction if we are not including historical...
Builds a Lucene search filter based on the provided parameters. @param params the query configuration parameters @return a Lucene search filter that will restrict the returned documents to the criteria provided or <code>null</code> if no filtering is necessary
[ "Builds", "a", "Lucene", "search", "filter", "based", "on", "the", "provided", "parameters", "." ]
f73c741f33a01b91aa5b06e71860bc354ef3010d
https://github.com/Berico-Technologies/CLAVIN/blob/f73c741f33a01b91aa5b06e71860bc354ef3010d/src/main/java/com/bericotech/clavin/gazetteer/query/LuceneGazetteer.java#L349-L389
train
Berico-Technologies/CLAVIN
src/main/java/com/bericotech/clavin/gazetteer/query/LuceneGazetteer.java
LuceneGazetteer.resolveParents
private void resolveParents(final Map<Integer, Set<GeoName>> childMap) throws IOException { Map<Integer, GeoName> parentMap = new HashMap<Integer, GeoName>(); Map<Integer, Set<GeoName>> grandParentMap = new HashMap<Integer, Set<GeoName>>(); for (Integer parentId : childMap.keySet()) { ...
java
private void resolveParents(final Map<Integer, Set<GeoName>> childMap) throws IOException { Map<Integer, GeoName> parentMap = new HashMap<Integer, GeoName>(); Map<Integer, Set<GeoName>> grandParentMap = new HashMap<Integer, Set<GeoName>>(); for (Integer parentId : childMap.keySet()) { ...
[ "private", "void", "resolveParents", "(", "final", "Map", "<", "Integer", ",", "Set", "<", "GeoName", ">", ">", "childMap", ")", "throws", "IOException", "{", "Map", "<", "Integer", ",", "GeoName", ">", "parentMap", "=", "new", "HashMap", "<", "Integer", ...
Retrieves and sets the parents of the provided children. @param childMap the map of parent geonameID to the set of children that belong to it @throws IOException if an error occurs during parent resolution
[ "Retrieves", "and", "sets", "the", "parents", "of", "the", "provided", "children", "." ]
f73c741f33a01b91aa5b06e71860bc354ef3010d
https://github.com/Berico-Technologies/CLAVIN/blob/f73c741f33a01b91aa5b06e71860bc354ef3010d/src/main/java/com/bericotech/clavin/gazetteer/query/LuceneGazetteer.java#L396-L439
train
Berico-Technologies/CLAVIN
src/main/java/com/bericotech/clavin/index/WhitespaceLowerCaseAnalyzer.java
WhitespaceLowerCaseAnalyzer.createComponents
@Override protected TokenStreamComponents createComponents(final String fieldName, final Reader reader) { return new TokenStreamComponents(new WhitespaceLowerCaseTokenizer(matchVersion, reader)); }
java
@Override protected TokenStreamComponents createComponents(final String fieldName, final Reader reader) { return new TokenStreamComponents(new WhitespaceLowerCaseTokenizer(matchVersion, reader)); }
[ "@", "Override", "protected", "TokenStreamComponents", "createComponents", "(", "final", "String", "fieldName", ",", "final", "Reader", "reader", ")", "{", "return", "new", "TokenStreamComponents", "(", "new", "WhitespaceLowerCaseTokenizer", "(", "matchVersion", ",", ...
Provides tokenizer access for the analyzer. @param fieldName field to be tokenized @param reader
[ "Provides", "tokenizer", "access", "for", "the", "analyzer", "." ]
f73c741f33a01b91aa5b06e71860bc354ef3010d
https://github.com/Berico-Technologies/CLAVIN/blob/f73c741f33a01b91aa5b06e71860bc354ef3010d/src/main/java/com/bericotech/clavin/index/WhitespaceLowerCaseAnalyzer.java#L60-L63
train
Berico-Technologies/CLAVIN
src/main/java/com/bericotech/clavin/index/IndexDirectoryBuilder.java
IndexDirectoryBuilder.main
public static void main(String[] args) throws IOException { Options options = getOptions(); CommandLine cmd = null; CommandLineParser parser = new GnuParser(); try { cmd = parser.parse(options, args); } catch (ParseException pe) { LOG.error(pe.getMessage()...
java
public static void main(String[] args) throws IOException { Options options = getOptions(); CommandLine cmd = null; CommandLineParser parser = new GnuParser(); try { cmd = parser.parse(options, args); } catch (ParseException pe) { LOG.error(pe.getMessage()...
[ "public", "static", "void", "main", "(", "String", "[", "]", "args", ")", "throws", "IOException", "{", "Options", "options", "=", "getOptions", "(", ")", ";", "CommandLine", "cmd", "=", "null", ";", "CommandLineParser", "parser", "=", "new", "GnuParser", ...
Turns a GeoNames gazetteer file into a Lucene index, and adds some supplementary gazetteer records at the end. @param args not used @throws IOException
[ "Turns", "a", "GeoNames", "gazetteer", "file", "into", "a", "Lucene", "index", "and", "adds", "some", "supplementary", "gazetteer", "records", "at", "the", "end", "." ]
f73c741f33a01b91aa5b06e71860bc354ef3010d
https://github.com/Berico-Technologies/CLAVIN/blob/f73c741f33a01b91aa5b06e71860bc354ef3010d/src/main/java/com/bericotech/clavin/index/IndexDirectoryBuilder.java#L504-L564
train
bekkopen/NoCommons
src/main/java/no/bekk/bekkopen/banking/KontonummerValidator.java
KontonummerValidator.isValid
public static boolean isValid(String kontonummer) { try { KontonummerValidator.getKontonummer(kontonummer); return true; } catch (IllegalArgumentException e) { return false; } }
java
public static boolean isValid(String kontonummer) { try { KontonummerValidator.getKontonummer(kontonummer); return true; } catch (IllegalArgumentException e) { return false; } }
[ "public", "static", "boolean", "isValid", "(", "String", "kontonummer", ")", "{", "try", "{", "KontonummerValidator", ".", "getKontonummer", "(", "kontonummer", ")", ";", "return", "true", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "ret...
Return true if the provided String is a valid Kontonummmer. @param kontonummer A String containing a Kontonummer @return true or false
[ "Return", "true", "if", "the", "provided", "String", "is", "a", "valid", "Kontonummmer", "." ]
5a576696390cecaac111fa97fde581e0c1afb9b8
https://github.com/bekkopen/NoCommons/blob/5a576696390cecaac111fa97fde581e0c1afb9b8/src/main/java/no/bekk/bekkopen/banking/KontonummerValidator.java#L34-L41
train
bekkopen/NoCommons
src/main/java/no/bekk/bekkopen/banking/KontonummerValidator.java
KontonummerValidator.getKontonummer
public static Kontonummer getKontonummer(String kontonummer) throws IllegalArgumentException { validateSyntax(kontonummer); validateChecksum(kontonummer); return new Kontonummer(kontonummer); }
java
public static Kontonummer getKontonummer(String kontonummer) throws IllegalArgumentException { validateSyntax(kontonummer); validateChecksum(kontonummer); return new Kontonummer(kontonummer); }
[ "public", "static", "Kontonummer", "getKontonummer", "(", "String", "kontonummer", ")", "throws", "IllegalArgumentException", "{", "validateSyntax", "(", "kontonummer", ")", ";", "validateChecksum", "(", "kontonummer", ")", ";", "return", "new", "Kontonummer", "(", ...
Returns an object that represents a Kontonummer. @param kontonummer A String containing a Kontonummer @return A Kontonummer instance @throws IllegalArgumentException thrown if String contains an invalid Kontonummer
[ "Returns", "an", "object", "that", "represents", "a", "Kontonummer", "." ]
5a576696390cecaac111fa97fde581e0c1afb9b8
https://github.com/bekkopen/NoCommons/blob/5a576696390cecaac111fa97fde581e0c1afb9b8/src/main/java/no/bekk/bekkopen/banking/KontonummerValidator.java#L50-L54
train
bekkopen/NoCommons
src/main/java/no/bekk/bekkopen/banking/KontonummerValidator.java
KontonummerValidator.getAndForceValidKontonummer
public static Kontonummer getAndForceValidKontonummer(String kontonummer) { validateSyntax(kontonummer); try { validateChecksum(kontonummer); } catch (IllegalArgumentException iae) { Kontonummer k = new Kontonummer(kontonummer); int checksum = calculateMod11Ch...
java
public static Kontonummer getAndForceValidKontonummer(String kontonummer) { validateSyntax(kontonummer); try { validateChecksum(kontonummer); } catch (IllegalArgumentException iae) { Kontonummer k = new Kontonummer(kontonummer); int checksum = calculateMod11Ch...
[ "public", "static", "Kontonummer", "getAndForceValidKontonummer", "(", "String", "kontonummer", ")", "{", "validateSyntax", "(", "kontonummer", ")", ";", "try", "{", "validateChecksum", "(", "kontonummer", ")", ";", "}", "catch", "(", "IllegalArgumentException", "ia...
Returns an object that represents a Kontonummer. The checksum of the supplied kontonummer is changed to a valid checksum if the original kontonummer has an invalid checksum. @param kontonummer A String containing a Kontonummer @return A Kontonummer instance @throws IllegalArgumentException thrown if String contains an...
[ "Returns", "an", "object", "that", "represents", "a", "Kontonummer", ".", "The", "checksum", "of", "the", "supplied", "kontonummer", "is", "changed", "to", "a", "valid", "checksum", "if", "the", "original", "kontonummer", "has", "an", "invalid", "checksum", "....
5a576696390cecaac111fa97fde581e0c1afb9b8
https://github.com/bekkopen/NoCommons/blob/5a576696390cecaac111fa97fde581e0c1afb9b8/src/main/java/no/bekk/bekkopen/banking/KontonummerValidator.java#L66-L76
train
Berico-Technologies/CLAVIN
src/main/java/com/bericotech/clavin/resolver/ClavinLocationResolver.java
ClavinLocationResolver.pickBestCandidates
private List<ResolvedLocation> pickBestCandidates(final List<List<ResolvedLocation>> allCandidates) { // initialize return object List<ResolvedLocation> bestCandidates = new ArrayList<ResolvedLocation>(); // variables used in heuristic matching Set<CountryCode> countries; Set<St...
java
private List<ResolvedLocation> pickBestCandidates(final List<List<ResolvedLocation>> allCandidates) { // initialize return object List<ResolvedLocation> bestCandidates = new ArrayList<ResolvedLocation>(); // variables used in heuristic matching Set<CountryCode> countries; Set<St...
[ "private", "List", "<", "ResolvedLocation", ">", "pickBestCandidates", "(", "final", "List", "<", "List", "<", "ResolvedLocation", ">", ">", "allCandidates", ")", "{", "// initialize return object", "List", "<", "ResolvedLocation", ">", "bestCandidates", "=", "new",...
Uses heuristics to select the best match for each location name extracted from a document, choosing from among a list of lists of candidate matches. Although not guaranteeing an optimal solution (enumerating & evaluating each possible combination is too costly), it does a decent job of cracking the "Springfield Proble...
[ "Uses", "heuristics", "to", "select", "the", "best", "match", "for", "each", "location", "name", "extracted", "from", "a", "document", "choosing", "from", "among", "a", "list", "of", "lists", "of", "candidate", "matches", "." ]
f73c741f33a01b91aa5b06e71860bc354ef3010d
https://github.com/Berico-Technologies/CLAVIN/blob/f73c741f33a01b91aa5b06e71860bc354ef3010d/src/main/java/com/bericotech/clavin/resolver/ClavinLocationResolver.java#L264-L332
train
Berico-Technologies/CLAVIN
src/main/java/com/bericotech/clavin/gazetteer/query/QueryBuilder.java
QueryBuilder.build
public GazetteerQuery build() { return new GazetteerQuery(location, maxResults, fuzzyMode, ancestryMode, includeHistorical, filterDupes, parentIds, featureCodes); }
java
public GazetteerQuery build() { return new GazetteerQuery(location, maxResults, fuzzyMode, ancestryMode, includeHistorical, filterDupes, parentIds, featureCodes); }
[ "public", "GazetteerQuery", "build", "(", ")", "{", "return", "new", "GazetteerQuery", "(", "location", ",", "maxResults", ",", "fuzzyMode", ",", "ancestryMode", ",", "includeHistorical", ",", "filterDupes", ",", "parentIds", ",", "featureCodes", ")", ";", "}" ]
Constructs a query from the current configuration of this Builder. @return a {@link GazetteerQuery} configuration object
[ "Constructs", "a", "query", "from", "the", "current", "configuration", "of", "this", "Builder", "." ]
f73c741f33a01b91aa5b06e71860bc354ef3010d
https://github.com/Berico-Technologies/CLAVIN/blob/f73c741f33a01b91aa5b06e71860bc354ef3010d/src/main/java/com/bericotech/clavin/gazetteer/query/QueryBuilder.java#L124-L126
train
Berico-Technologies/CLAVIN
src/main/java/com/bericotech/clavin/util/DamerauLevenshtein.java
DamerauLevenshtein.isEditDistance1
public static boolean isEditDistance1(String str1, String str2) { // one or both strings is empty or null if ((str1 == null) || str1.isEmpty()) { if ((str2 == null) || str2.isEmpty()) { return true; } else { return (str2.length() <= 1); ...
java
public static boolean isEditDistance1(String str1, String str2) { // one or both strings is empty or null if ((str1 == null) || str1.isEmpty()) { if ((str2 == null) || str2.isEmpty()) { return true; } else { return (str2.length() <= 1); ...
[ "public", "static", "boolean", "isEditDistance1", "(", "String", "str1", ",", "String", "str2", ")", "{", "// one or both strings is empty or null", "if", "(", "(", "str1", "==", "null", ")", "||", "str1", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "("...
Fast method for determining whether the Damerau-Levenshtein edit distance between two strings is less than 2. Returns as quick as possibly by stopping once multiple edits are found. Significantly faster than {@link #damerauLevenshteinDistance(String str1, String str2)} which explores every path between every string to...
[ "Fast", "method", "for", "determining", "whether", "the", "Damerau", "-", "Levenshtein", "edit", "distance", "between", "two", "strings", "is", "less", "than", "2", "." ]
f73c741f33a01b91aa5b06e71860bc354ef3010d
https://github.com/Berico-Technologies/CLAVIN/blob/f73c741f33a01b91aa5b06e71860bc354ef3010d/src/main/java/com/bericotech/clavin/util/DamerauLevenshtein.java#L143-L185
train
Berico-Technologies/CLAVIN
src/main/java/com/bericotech/clavin/util/DamerauLevenshtein.java
InfiniteCharArray.remainder
protected String remainder(int index) { if (index > this.array.length) return ""; else return new String(Arrays.copyOfRange(this.array, index, this.array.length)); }
java
protected String remainder(int index) { if (index > this.array.length) return ""; else return new String(Arrays.copyOfRange(this.array, index, this.array.length)); }
[ "protected", "String", "remainder", "(", "int", "index", ")", "{", "if", "(", "index", ">", "this", ".", "array", ".", "length", ")", "return", "\"\"", ";", "else", "return", "new", "String", "(", "Arrays", ".", "copyOfRange", "(", "this", ".", "array"...
Get the contents of the char array to the right of the given index, and return it as a String. @param index left bound of the string we're pulling from the char array @return a string representing everything to the right of the index
[ "Get", "the", "contents", "of", "the", "char", "array", "to", "the", "right", "of", "the", "given", "index", "and", "return", "it", "as", "a", "String", "." ]
f73c741f33a01b91aa5b06e71860bc354ef3010d
https://github.com/Berico-Technologies/CLAVIN/blob/f73c741f33a01b91aa5b06e71860bc354ef3010d/src/main/java/com/bericotech/clavin/util/DamerauLevenshtein.java#L230-L234
train
psjava/psjava
src/main/java/org/psjava/algo/PermutationWithRepetitionIterable.java
PermutationWithRepetitionIterable.create
public static <T> Iterable<PSArray<T>> create(Iterable<T> items, final Comparator<T> comparator) { MutableArray<T> initial = MutableArrayFromIterable.create(items); GoodSortingAlgorithm.getInstance().sort(initial, comparator); return IterableUsingStatusUpdater.create(initial, new Updater<PSArray...
java
public static <T> Iterable<PSArray<T>> create(Iterable<T> items, final Comparator<T> comparator) { MutableArray<T> initial = MutableArrayFromIterable.create(items); GoodSortingAlgorithm.getInstance().sort(initial, comparator); return IterableUsingStatusUpdater.create(initial, new Updater<PSArray...
[ "public", "static", "<", "T", ">", "Iterable", "<", "PSArray", "<", "T", ">", ">", "create", "(", "Iterable", "<", "T", ">", "items", ",", "final", "Comparator", "<", "T", ">", "comparator", ")", "{", "MutableArray", "<", "T", ">", "initial", "=", ...
SRM464-1-250 is a good problem to solve using this.
[ "SRM464", "-", "1", "-", "250", "is", "a", "good", "problem", "to", "solve", "using", "this", "." ]
6a160e385fad340109eca00e3a9042071b1eea1e
https://github.com/psjava/psjava/blob/6a160e385fad340109eca00e3a9042071b1eea1e/src/main/java/org/psjava/algo/PermutationWithRepetitionIterable.java#L17-L28
train
psjava/psjava
src/main/java/org/psjava/algo/graph/dfs/AllSourceDFS.java
AllSourceDFS.traverse
public static <V, E extends DirectedEdge<V>> void traverse(Graph<V, E> graph, DFSVisitor<V, E> visitor) { MultiSourceDFS.traverse(graph, graph.getVertices(), visitor); }
java
public static <V, E extends DirectedEdge<V>> void traverse(Graph<V, E> graph, DFSVisitor<V, E> visitor) { MultiSourceDFS.traverse(graph, graph.getVertices(), visitor); }
[ "public", "static", "<", "V", ",", "E", "extends", "DirectedEdge", "<", "V", ">", ">", "void", "traverse", "(", "Graph", "<", "V", ",", "E", ">", "graph", ",", "DFSVisitor", "<", "V", ",", "E", ">", "visitor", ")", "{", "MultiSourceDFS", ".", "trav...
Remember that visiting order is not ordered.
[ "Remember", "that", "visiting", "order", "is", "not", "ordered", "." ]
6a160e385fad340109eca00e3a9042071b1eea1e
https://github.com/psjava/psjava/blob/6a160e385fad340109eca00e3a9042071b1eea1e/src/main/java/org/psjava/algo/graph/dfs/AllSourceDFS.java#L11-L13
train
psjava/psjava
src/main/java/org/psjava/algo/geometry/convexhull/DivideAndConquerConvexHull.java
DivideAndConquerConvexHull.findBridgeIndexes
private static <T> IntPair findBridgeIndexes(PSArray<Point2D<T>> earlyHull, PSArray<Point2D<T>> laterHull, int earlyStart, int laterStart, MultipliableNumberSystem<T> ns) { int early = earlyStart; int later = laterStart; while (true) { int nextEarly = getPreIndex(early, earlyHull.siz...
java
private static <T> IntPair findBridgeIndexes(PSArray<Point2D<T>> earlyHull, PSArray<Point2D<T>> laterHull, int earlyStart, int laterStart, MultipliableNumberSystem<T> ns) { int early = earlyStart; int later = laterStart; while (true) { int nextEarly = getPreIndex(early, earlyHull.siz...
[ "private", "static", "<", "T", ">", "IntPair", "findBridgeIndexes", "(", "PSArray", "<", "Point2D", "<", "T", ">", ">", "earlyHull", ",", "PSArray", "<", "Point2D", "<", "T", ">", ">", "laterHull", ",", "int", "earlyStart", ",", "int", "laterStart", ",",...
early, later are ordered by ccw order.
[ "early", "later", "are", "ordered", "by", "ccw", "order", "." ]
6a160e385fad340109eca00e3a9042071b1eea1e
https://github.com/psjava/psjava/blob/6a160e385fad340109eca00e3a9042071b1eea1e/src/main/java/org/psjava/algo/geometry/convexhull/DivideAndConquerConvexHull.java#L75-L89
train
psjava/psjava
src/main/java/org/psjava/ds/tree/trie/TrieNodeFactoryForBooleanKey.java
TrieNodeFactoryForBooleanKey.getInstance
public static TrieNodeFactory<Boolean> getInstance() { return new TrieNodeFactory<Boolean>() { @Override public TrieNode<Boolean> create() { return new BooleanTrieNode(); } }; }
java
public static TrieNodeFactory<Boolean> getInstance() { return new TrieNodeFactory<Boolean>() { @Override public TrieNode<Boolean> create() { return new BooleanTrieNode(); } }; }
[ "public", "static", "TrieNodeFactory", "<", "Boolean", ">", "getInstance", "(", ")", "{", "return", "new", "TrieNodeFactory", "<", "Boolean", ">", "(", ")", "{", "@", "Override", "public", "TrieNode", "<", "Boolean", ">", "create", "(", ")", "{", "return",...
specialized in speed for boolean keyed nodes.
[ "specialized", "in", "speed", "for", "boolean", "keyed", "nodes", "." ]
6a160e385fad340109eca00e3a9042071b1eea1e
https://github.com/psjava/psjava/blob/6a160e385fad340109eca00e3a9042071b1eea1e/src/main/java/org/psjava/ds/tree/trie/TrieNodeFactoryForBooleanKey.java#L10-L17
train
greenlaw110/play-excel
src/play/modules/excel/Excel.java
Excel.renderTemplateAsExcel
public static void renderTemplateAsExcel(String templateName, Object... args) { // Template datas Scope.RenderArgs templateBinding = Scope.RenderArgs.current(); for (Object o : args) { List<String> names = LocalvariablesNamesEnhancer.LocalVariablesNamesTracer .getAllLocalVariableNames(o); for (String ...
java
public static void renderTemplateAsExcel(String templateName, Object... args) { // Template datas Scope.RenderArgs templateBinding = Scope.RenderArgs.current(); for (Object o : args) { List<String> names = LocalvariablesNamesEnhancer.LocalVariablesNamesTracer .getAllLocalVariableNames(o); for (String ...
[ "public", "static", "void", "renderTemplateAsExcel", "(", "String", "templateName", ",", "Object", "...", "args", ")", "{", "// Template datas", "Scope", ".", "RenderArgs", "templateBinding", "=", "Scope", ".", "RenderArgs", ".", "current", "(", ")", ";", "for",...
Render a specific template @param templateName The template name @param args The template data
[ "Render", "a", "specific", "template" ]
6bf18419a52213d06787308c52cb70bfebcac3ab
https://github.com/greenlaw110/play-excel/blob/6bf18419a52213d06787308c52cb70bfebcac3ab/src/play/modules/excel/Excel.java#L48-L88
train
greenlaw110/play-excel
src/play/modules/excel/Excel.java
Excel.renderExcel
public static void renderExcel(Object... args) { String templateName = null; final Http.Request request = Http.Request.current(); if (args.length > 0 && args[0] instanceof String && LocalvariablesNamesEnhancer.LocalVariablesNamesTracer .getAllLocalVariableNames(args[0]).isEmpty()) { templateName...
java
public static void renderExcel(Object... args) { String templateName = null; final Http.Request request = Http.Request.current(); if (args.length > 0 && args[0] instanceof String && LocalvariablesNamesEnhancer.LocalVariablesNamesTracer .getAllLocalVariableNames(args[0]).isEmpty()) { templateName...
[ "public", "static", "void", "renderExcel", "(", "Object", "...", "args", ")", "{", "String", "templateName", "=", "null", ";", "final", "Http", ".", "Request", "request", "=", "Http", ".", "Request", ".", "current", "(", ")", ";", "if", "(", "args", "....
Render the corresponding template @param args The template data
[ "Render", "the", "corresponding", "template" ]
6bf18419a52213d06787308c52cb70bfebcac3ab
https://github.com/greenlaw110/play-excel/blob/6bf18419a52213d06787308c52cb70bfebcac3ab/src/play/modules/excel/Excel.java#L96-L116
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/numbers/NumberFormattingUtils.java
NumberFormattingUtils.setup
public static BigDecimal setup( BigDecimal n, // number to be formatted NumberRoundMode roundMode, // rounding mode NumberFormatMode formatMode, // formatting mode (significant digits, etc) int minIntDigits, // maximum integer digits to emit ...
java
public static BigDecimal setup( BigDecimal n, // number to be formatted NumberRoundMode roundMode, // rounding mode NumberFormatMode formatMode, // formatting mode (significant digits, etc) int minIntDigits, // maximum integer digits to emit ...
[ "public", "static", "BigDecimal", "setup", "(", "BigDecimal", "n", ",", "// number to be formatted", "NumberRoundMode", "roundMode", ",", "// rounding mode", "NumberFormatMode", "formatMode", ",", "// formatting mode (significant digits, etc)", "int", "minIntDigits", ",", "//...
Calculates the number of integer and fractional digits to emit, returning them in a 2-element array, and updates the operands. In one of the two significant digit modes, SIGNIFICANT and SIGNIFICANT_MAXFRAC, a min/max number significant digits will be emitted. This is useful for formatting compact formats where the wid...
[ "Calculates", "the", "number", "of", "integer", "and", "fractional", "digits", "to", "emit", "returning", "them", "in", "a", "2", "-", "element", "array", "and", "updates", "the", "operands", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/numbers/NumberFormattingUtils.java#L34-L89
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/numbers/NumberFormattingUtils.java
NumberFormattingUtils.format
public static void format( BigDecimal n, DigitBuffer buf, NumberFormatterParams params, boolean currencyMode, boolean grouping, int minIntDigits, int primaryGroupingSize, int secondaryGroupingSize) { // Setup integer digit grouping. if (secondaryGroupingSize <= 0...
java
public static void format( BigDecimal n, DigitBuffer buf, NumberFormatterParams params, boolean currencyMode, boolean grouping, int minIntDigits, int primaryGroupingSize, int secondaryGroupingSize) { // Setup integer digit grouping. if (secondaryGroupingSize <= 0...
[ "public", "static", "void", "format", "(", "BigDecimal", "n", ",", "DigitBuffer", "buf", ",", "NumberFormatterParams", "params", ",", "boolean", "currencyMode", ",", "boolean", "grouping", ",", "int", "minIntDigits", ",", "int", "primaryGroupingSize", ",", "int", ...
Formats the number into the digit buffer.
[ "Formats", "the", "number", "into", "the", "digit", "buffer", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/numbers/NumberFormattingUtils.java#L94-L199
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/DistanceTable.java
DistanceTable.distance
public int distance(CLDR.Locale desired, CLDR.Locale supported) { return distance(desired, supported, DEFAULT_THRESHOLD); }
java
public int distance(CLDR.Locale desired, CLDR.Locale supported) { return distance(desired, supported, DEFAULT_THRESHOLD); }
[ "public", "int", "distance", "(", "CLDR", ".", "Locale", "desired", ",", "CLDR", ".", "Locale", "supported", ")", "{", "return", "distance", "(", "desired", ",", "supported", ",", "DEFAULT_THRESHOLD", ")", ";", "}" ]
Returns the distance between the desired and supported locale, using the default distance threshold.
[ "Returns", "the", "distance", "between", "the", "desired", "and", "supported", "locale", "using", "the", "default", "distance", "threshold", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/DistanceTable.java#L86-L88
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/DistanceTable.java
DistanceTable.distance
public int distance(CLDR.Locale desired, CLDR.Locale supported, int threshold) { // Query the top level LANGUAGE boolean langEquals = desired.language().equals(supported.language()); Node node = distanceMap.get(desired.language(), supported.language()); if (node == null) { node = distanceMap.get(A...
java
public int distance(CLDR.Locale desired, CLDR.Locale supported, int threshold) { // Query the top level LANGUAGE boolean langEquals = desired.language().equals(supported.language()); Node node = distanceMap.get(desired.language(), supported.language()); if (node == null) { node = distanceMap.get(A...
[ "public", "int", "distance", "(", "CLDR", ".", "Locale", "desired", ",", "CLDR", ".", "Locale", "supported", ",", "int", "threshold", ")", "{", "// Query the top level LANGUAGE", "boolean", "langEquals", "=", "desired", ".", "language", "(", ")", ".", "equals"...
Returns the distance between the desired and supported locale, using the given distance threshold. Any distance equal to or greater than the threshold will return the maximum distance.
[ "Returns", "the", "distance", "between", "the", "desired", "and", "supported", "locale", "using", "the", "given", "distance", "threshold", ".", "Any", "distance", "equal", "to", "or", "greater", "than", "the", "threshold", "will", "return", "the", "maximum", "...
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/DistanceTable.java#L95-L166
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/DistanceTable.java
DistanceTable.scanTerritory
private Node scanTerritory(DistanceMap map, String desired, String supported) { Node node; for (String partition : PARTITION_TABLE.getRegionPartition(desired)) { node = map.get(partition, supported); if (node != null) { return node; } } for (String partition : PARTITION_TA...
java
private Node scanTerritory(DistanceMap map, String desired, String supported) { Node node; for (String partition : PARTITION_TABLE.getRegionPartition(desired)) { node = map.get(partition, supported); if (node != null) { return node; } } for (String partition : PARTITION_TA...
[ "private", "Node", "scanTerritory", "(", "DistanceMap", "map", ",", "String", "desired", ",", "String", "supported", ")", "{", "Node", "node", ";", "for", "(", "String", "partition", ":", "PARTITION_TABLE", ".", "getRegionPartition", "(", "desired", ")", ")", ...
Scan the desired region against the supported partitions and vice versa. Return the first matching node.
[ "Scan", "the", "desired", "region", "against", "the", "supported", "partitions", "and", "vice", "versa", ".", "Return", "the", "first", "matching", "node", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/DistanceTable.java#L172-L189
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/MetaZone.java
MetaZone.applies
public String applies(ZonedDateTime d) { long epoch = d.toEpochSecond(); for (int i = 0; i < size; i++) { Entry entry = entries[i]; if (entry.from == -1) { if (entry.to == -1 || epoch < entry.to) { return entry.metazoneId; } } else if (entry.to == -1) { if (en...
java
public String applies(ZonedDateTime d) { long epoch = d.toEpochSecond(); for (int i = 0; i < size; i++) { Entry entry = entries[i]; if (entry.from == -1) { if (entry.to == -1 || epoch < entry.to) { return entry.metazoneId; } } else if (entry.to == -1) { if (en...
[ "public", "String", "applies", "(", "ZonedDateTime", "d", ")", "{", "long", "epoch", "=", "d", ".", "toEpochSecond", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "{", "Entry", "entry", "=", "entries...
Find the metazone that applies for a given timestamp.
[ "Find", "the", "metazone", "that", "applies", "for", "a", "given", "timestamp", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/MetaZone.java#L30-L47
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/LanguageMatcher.java
LanguageMatcher.match
public Match match(List<String> desired, int threshold) { return matchImpl(parse(desired), threshold); }
java
public Match match(List<String> desired, int threshold) { return matchImpl(parse(desired), threshold); }
[ "public", "Match", "match", "(", "List", "<", "String", ">", "desired", ",", "int", "threshold", ")", "{", "return", "matchImpl", "(", "parse", "(", "desired", ")", ",", "threshold", ")", ";", "}" ]
Return the best match that exceeds the threshold. If the default is returned its distance is set to MAX_DISTANCE.
[ "Return", "the", "best", "match", "that", "exceeds", "the", "threshold", ".", "If", "the", "default", "is", "returned", "its", "distance", "is", "set", "to", "MAX_DISTANCE", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/LanguageMatcher.java#L117-L119
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/LanguageMatcher.java
LanguageMatcher.matches
public List<Match> matches(List<String> desired) { return matchesImpl(parse(desired), DEFAULT_THRESHOLD); }
java
public List<Match> matches(List<String> desired) { return matchesImpl(parse(desired), DEFAULT_THRESHOLD); }
[ "public", "List", "<", "Match", ">", "matches", "(", "List", "<", "String", ">", "desired", ")", "{", "return", "matchesImpl", "(", "parse", "(", "desired", ")", ",", "DEFAULT_THRESHOLD", ")", ";", "}" ]
Return all matches and their distances, if they exceed the default threshold. If no match exceeds the threshold this returns an empty list.
[ "Return", "all", "matches", "and", "their", "distances", "if", "they", "exceed", "the", "default", "threshold", ".", "If", "no", "match", "exceeds", "the", "threshold", "this", "returns", "an", "empty", "list", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/LanguageMatcher.java#L141-L143
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/LanguageMatcher.java
LanguageMatcher.matchImpl
private Match matchImpl(List<Entry> desiredLocales, int threshold) { int bestDistance = MAX_DISTANCE; Entry bestMatch = null; for (Entry desired : desiredLocales) { List<String> exact = exactMatch.get(desired.locale); if (exact != null) { return new Match(exact.get(0), 0); } ...
java
private Match matchImpl(List<Entry> desiredLocales, int threshold) { int bestDistance = MAX_DISTANCE; Entry bestMatch = null; for (Entry desired : desiredLocales) { List<String> exact = exactMatch.get(desired.locale); if (exact != null) { return new Match(exact.get(0), 0); } ...
[ "private", "Match", "matchImpl", "(", "List", "<", "Entry", ">", "desiredLocales", ",", "int", "threshold", ")", "{", "int", "bestDistance", "=", "MAX_DISTANCE", ";", "Entry", "bestMatch", "=", "null", ";", "for", "(", "Entry", "desired", ":", "desiredLocale...
Return the best match that exceeds the threshold, or the default. If the default is returned its distance is set to MAX_DISTANCE. An exact match has distance of 0.
[ "Return", "the", "best", "match", "that", "exceeds", "the", "threshold", "or", "the", "default", ".", "If", "the", "default", "is", "returned", "its", "distance", "is", "set", "to", "MAX_DISTANCE", ".", "An", "exact", "match", "has", "distance", "of", "0",...
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/LanguageMatcher.java#L158-L177
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java
PluralCodeGenerator.generate
public void generate(Path outputDir, DataReader reader) throws IOException { String className = "_PluralRules"; TypeSpec.Builder type = TypeSpec.classBuilder(className) .addModifiers(PUBLIC) .superclass(TYPE_BASE); Map<String, FieldSpec> fieldMap = buildConditionFields(reader.cardinals(), r...
java
public void generate(Path outputDir, DataReader reader) throws IOException { String className = "_PluralRules"; TypeSpec.Builder type = TypeSpec.classBuilder(className) .addModifiers(PUBLIC) .superclass(TYPE_BASE); Map<String, FieldSpec> fieldMap = buildConditionFields(reader.cardinals(), r...
[ "public", "void", "generate", "(", "Path", "outputDir", ",", "DataReader", "reader", ")", "throws", "IOException", "{", "String", "className", "=", "\"_PluralRules\"", ";", "TypeSpec", ".", "Builder", "type", "=", "TypeSpec", ".", "classBuilder", "(", "className...
Generate a class for plural rule evaluation. This will build several Condition fields which evaluate specific AND conditions, and methods which call these AND conditions joined by an OR operator.
[ "Generate", "a", "class", "for", "plural", "rule", "evaluation", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java#L55-L70
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java
PluralCodeGenerator.buildRuleMethod
private MethodSpec buildRuleMethod(String methodName, PluralData data, Map<String, FieldSpec> fieldMap) { MethodSpec.Builder method = MethodSpec.methodBuilder(methodName) .addModifiers(PRIVATE, STATIC) .addParameter(NUMBER_OPERANDS, "o") .returns(PLURAL_CATEGORY); for (Map.Entry<String,...
java
private MethodSpec buildRuleMethod(String methodName, PluralData data, Map<String, FieldSpec> fieldMap) { MethodSpec.Builder method = MethodSpec.methodBuilder(methodName) .addModifiers(PRIVATE, STATIC) .addParameter(NUMBER_OPERANDS, "o") .returns(PLURAL_CATEGORY); for (Map.Entry<String,...
[ "private", "MethodSpec", "buildRuleMethod", "(", "String", "methodName", ",", "PluralData", "data", ",", "Map", "<", "String", ",", "FieldSpec", ">", "fieldMap", ")", "{", "MethodSpec", ".", "Builder", "method", "=", "MethodSpec", ".", "methodBuilder", "(", "m...
Builds a method that when called evaluates the rule and returns a PluralCategory.
[ "Builds", "a", "method", "that", "when", "called", "evaluates", "the", "rule", "and", "returns", "a", "PluralCategory", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java#L110-L165
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java
PluralCodeGenerator.buildConditionFields
@SafeVarargs private final Map<String, FieldSpec> buildConditionFields(Map<String, PluralData>... pluralMaps) { Map<String, FieldSpec> index = new LinkedHashMap<>(); int seq = 0; for (Map<String, PluralData> pluralMap : pluralMaps) { for (Map.Entry<String, PluralData> entry : pluralMap.entrySet()) ...
java
@SafeVarargs private final Map<String, FieldSpec> buildConditionFields(Map<String, PluralData>... pluralMaps) { Map<String, FieldSpec> index = new LinkedHashMap<>(); int seq = 0; for (Map<String, PluralData> pluralMap : pluralMaps) { for (Map.Entry<String, PluralData> entry : pluralMap.entrySet()) ...
[ "@", "SafeVarargs", "private", "final", "Map", "<", "String", ",", "FieldSpec", ">", "buildConditionFields", "(", "Map", "<", "String", ",", "PluralData", ">", "...", "pluralMaps", ")", "{", "Map", "<", "String", ",", "FieldSpec", ">", "index", "=", "new",...
Maps an integer to each AND condition's canonical representation.
[ "Maps", "an", "integer", "to", "each", "AND", "condition", "s", "canonical", "representation", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java#L170-L205
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java
PluralCodeGenerator.buildConditionField
public FieldSpec buildConditionField(int index, Struct<PluralType> branch) { String fieldDoc = PluralRulePrinter.print(branch); String name = String.format("COND_%d", index); FieldSpec.Builder field = FieldSpec.builder(PLURAL_CONDITION, name, PRIVATE, STATIC, FINAL) .addJavadoc(fieldDoc + "\n"); ...
java
public FieldSpec buildConditionField(int index, Struct<PluralType> branch) { String fieldDoc = PluralRulePrinter.print(branch); String name = String.format("COND_%d", index); FieldSpec.Builder field = FieldSpec.builder(PLURAL_CONDITION, name, PRIVATE, STATIC, FINAL) .addJavadoc(fieldDoc + "\n"); ...
[ "public", "FieldSpec", "buildConditionField", "(", "int", "index", ",", "Struct", "<", "PluralType", ">", "branch", ")", "{", "String", "fieldDoc", "=", "PluralRulePrinter", ".", "print", "(", "branch", ")", ";", "String", "name", "=", "String", ".", "format...
Constructs a lambda Condition field that represents a chain of AND conditions, that together is a single branch in an OR condition.
[ "Constructs", "a", "lambda", "Condition", "field", "that", "represents", "a", "chain", "of", "AND", "conditions", "that", "together", "is", "a", "single", "branch", "in", "an", "OR", "condition", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java#L211-L231
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java
PluralCodeGenerator.renderExpr
private static void renderExpr(boolean first, CodeBlock.Builder code, Node<PluralType> expr) { Iterator<Node<PluralType>> iter = expr.asStruct().nodes().iterator(); // Parse out the two forms of operand expressions we support: // // n = <rangelist> // n % m = <rangelist> // Atom<Plura...
java
private static void renderExpr(boolean first, CodeBlock.Builder code, Node<PluralType> expr) { Iterator<Node<PluralType>> iter = expr.asStruct().nodes().iterator(); // Parse out the two forms of operand expressions we support: // // n = <rangelist> // n % m = <rangelist> // Atom<Plura...
[ "private", "static", "void", "renderExpr", "(", "boolean", "first", ",", "CodeBlock", ".", "Builder", "code", ",", "Node", "<", "PluralType", ">", "expr", ")", "{", "Iterator", "<", "Node", "<", "PluralType", ">>", "iter", "=", "expr", ".", "asStruct", "...
Render the header of a branch method.
[ "Render", "the", "header", "of", "a", "branch", "method", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java#L236-L281
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java
PluralCodeGenerator.renderExpr
private static void renderExpr( CodeBlock.Builder code, List<Node<PluralType>> rangeList, boolean equal, boolean decimalsZero) { int size = rangeList.size(); String r = ""; // Join the range list expressions with the OR operator. for (int i = 0; i < size; i++) { if (i > 0) { r ...
java
private static void renderExpr( CodeBlock.Builder code, List<Node<PluralType>> rangeList, boolean equal, boolean decimalsZero) { int size = rangeList.size(); String r = ""; // Join the range list expressions with the OR operator. for (int i = 0; i < size; i++) { if (i > 0) { r ...
[ "private", "static", "void", "renderExpr", "(", "CodeBlock", ".", "Builder", "code", ",", "List", "<", "Node", "<", "PluralType", ">", ">", "rangeList", ",", "boolean", "equal", ",", "boolean", "decimalsZero", ")", "{", "int", "size", "=", "rangeList", "."...
Render the expression body of a branch method.
[ "Render", "the", "expression", "body", "of", "a", "branch", "method", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java#L286-L318
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java
PluralCodeGenerator.renderRange
private static String renderRange(String name, Node<PluralType> node) { if (node.type() == PluralType.RANGE) { Struct<PluralType> range = node.asStruct(); int start = (Integer) range.nodes().get(0).asAtom().value(); int end = (Integer) range.nodes().get(1).asAtom().value(); return String.f...
java
private static String renderRange(String name, Node<PluralType> node) { if (node.type() == PluralType.RANGE) { Struct<PluralType> range = node.asStruct(); int start = (Integer) range.nodes().get(0).asAtom().value(); int end = (Integer) range.nodes().get(1).asAtom().value(); return String.f...
[ "private", "static", "String", "renderRange", "(", "String", "name", ",", "Node", "<", "PluralType", ">", "node", ")", "{", "if", "(", "node", ".", "type", "(", ")", "==", "PluralType", ".", "RANGE", ")", "{", "Struct", "<", "PluralType", ">", "range",...
Render a the range segment of an expression.
[ "Render", "a", "the", "range", "segment", "of", "an", "expression", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/PluralCodeGenerator.java#L323-L331
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/parse/PluralRulePrinter.java
PluralRulePrinter.print
public static String print(Node<PluralType> node) { StringBuilder buf = new StringBuilder(); print(buf, node); return buf.toString(); }
java
public static String print(Node<PluralType> node) { StringBuilder buf = new StringBuilder(); print(buf, node); return buf.toString(); }
[ "public", "static", "String", "print", "(", "Node", "<", "PluralType", ">", "node", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "print", "(", "buf", ",", "node", ")", ";", "return", "buf", ".", "toString", "(", ")", ...
Return a recursive representation of the given pluralization node or tree.
[ "Return", "a", "recursive", "representation", "of", "the", "given", "pluralization", "node", "or", "tree", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/parse/PluralRulePrinter.java#L17-L21
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/parse/PluralRulePrinter.java
PluralRulePrinter.print
private static void print(StringBuilder buf, Node<PluralType> node) { switch (node.type()) { case RULE: join(buf, node, " "); break; case AND_CONDITION: join(buf, node, " and "); break; case OR_CONDITION: join(buf, node, " or "); break; case...
java
private static void print(StringBuilder buf, Node<PluralType> node) { switch (node.type()) { case RULE: join(buf, node, " "); break; case AND_CONDITION: join(buf, node, " and "); break; case OR_CONDITION: join(buf, node, " or "); break; case...
[ "private", "static", "void", "print", "(", "StringBuilder", "buf", ",", "Node", "<", "PluralType", ">", "node", ")", "{", "switch", "(", "node", ".", "type", "(", ")", ")", "{", "case", "RULE", ":", "join", "(", "buf", ",", "node", ",", "\" \"", ")...
Recursively visit the structs and atoms in the pluralization node or tree, appending the representations to a string buffer.
[ "Recursively", "visit", "the", "structs", "and", "atoms", "in", "the", "pluralization", "node", "or", "tree", "appending", "the", "representations", "to", "a", "string", "buffer", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/parse/PluralRulePrinter.java#L27-L64
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/parse/PluralRulePrinter.java
PluralRulePrinter.join
private static void join(StringBuilder buf, Node<PluralType> parent, String delimiter) { List<Node<PluralType>> nodes = parent.asStruct().nodes(); int size = nodes.size(); for (int i = 0; i < size; i++) { if (i > 0) { buf.append(delimiter); } print(buf, nodes.get(i)); } }
java
private static void join(StringBuilder buf, Node<PluralType> parent, String delimiter) { List<Node<PluralType>> nodes = parent.asStruct().nodes(); int size = nodes.size(); for (int i = 0; i < size; i++) { if (i > 0) { buf.append(delimiter); } print(buf, nodes.get(i)); } }
[ "private", "static", "void", "join", "(", "StringBuilder", "buf", ",", "Node", "<", "PluralType", ">", "parent", ",", "String", "delimiter", ")", "{", "List", "<", "Node", "<", "PluralType", ">>", "nodes", "=", "parent", ".", "asStruct", "(", ")", ".", ...
Print each child node of a struct, joining them together with a delimiter string.
[ "Print", "each", "child", "node", "of", "a", "struct", "joining", "them", "together", "with", "a", "delimiter", "string", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/parse/PluralRulePrinter.java#L70-L79
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.format
@Override public void format(ZonedDateTime datetime, CalendarFormatOptions options, StringBuilder buffer) { String dateSkeleton = options.dateSkeleton() == null ? null : options.dateSkeleton().skeleton(); String timeSkeleton = options.timeSkeleton() == null ? null : options.timeSkeleton().skeleton(); Cal...
java
@Override public void format(ZonedDateTime datetime, CalendarFormatOptions options, StringBuilder buffer) { String dateSkeleton = options.dateSkeleton() == null ? null : options.dateSkeleton().skeleton(); String timeSkeleton = options.timeSkeleton() == null ? null : options.timeSkeleton().skeleton(); Cal...
[ "@", "Override", "public", "void", "format", "(", "ZonedDateTime", "datetime", ",", "CalendarFormatOptions", "options", ",", "StringBuilder", "buffer", ")", "{", "String", "dateSkeleton", "=", "options", ".", "dateSkeleton", "(", ")", "==", "null", "?", "null", ...
Main entry point for date time formatting.
[ "Main", "entry", "point", "for", "date", "time", "formatting", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L137-L175
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.format
@Override public void format( ZonedDateTime start, ZonedDateTime end, DateTimeIntervalSkeleton skeleton, StringBuilder buffer) { DateTimeField field = CalendarFormattingUtils.greatestDifference(start, end); if (skeleton == null) { switch (field) { case YEAR: case MONTH: ...
java
@Override public void format( ZonedDateTime start, ZonedDateTime end, DateTimeIntervalSkeleton skeleton, StringBuilder buffer) { DateTimeField field = CalendarFormattingUtils.greatestDifference(start, end); if (skeleton == null) { switch (field) { case YEAR: case MONTH: ...
[ "@", "Override", "public", "void", "format", "(", "ZonedDateTime", "start", ",", "ZonedDateTime", "end", ",", "DateTimeIntervalSkeleton", "skeleton", ",", "StringBuilder", "buffer", ")", "{", "DateTimeField", "field", "=", "CalendarFormattingUtils", ".", "greatestDiff...
Format a date time interval, guessing at the best skeleton to use based on the field of greatest difference between the start and end date-time. If the end date-time has a different time zone than the start, this is corrected for comparison. If the skeleton is null, one is selected automatically using the field of gre...
[ "Format", "a", "date", "time", "interval", "guessing", "at", "the", "best", "skeleton", "to", "use", "based", "on", "the", "field", "of", "greatest", "difference", "between", "the", "start", "and", "end", "date", "-", "time", ".", "If", "the", "end", "da...
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L187-L206
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.resolveTimeZoneId
public String resolveTimeZoneId(String zoneId) { String alias = _CalendarUtils.getTimeZoneAlias(zoneId); if (alias != null) { zoneId = alias; } alias = TimeZoneAliases.getAlias(zoneId); if (alias != null) { zoneId = alias; } return zoneId; }
java
public String resolveTimeZoneId(String zoneId) { String alias = _CalendarUtils.getTimeZoneAlias(zoneId); if (alias != null) { zoneId = alias; } alias = TimeZoneAliases.getAlias(zoneId); if (alias != null) { zoneId = alias; } return zoneId; }
[ "public", "String", "resolveTimeZoneId", "(", "String", "zoneId", ")", "{", "String", "alias", "=", "_CalendarUtils", ".", "getTimeZoneAlias", "(", "zoneId", ")", ";", "if", "(", "alias", "!=", "null", ")", "{", "zoneId", "=", "alias", ";", "}", "alias", ...
Check if the zoneId has an alias in the CLDR data.
[ "Check", "if", "the", "zoneId", "has", "an", "alias", "in", "the", "CLDR", "data", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L219-L229
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatField
public void formatField(ZonedDateTime datetime, String pattern, StringBuilder buffer) { int length = pattern.length(); if (length == 0) { return; } // Current position in pattern int i = 0; // Skip over prefix indicating we want to format a single field. if (pattern.charAt(i) == '+')...
java
public void formatField(ZonedDateTime datetime, String pattern, StringBuilder buffer) { int length = pattern.length(); if (length == 0) { return; } // Current position in pattern int i = 0; // Skip over prefix indicating we want to format a single field. if (pattern.charAt(i) == '+')...
[ "public", "void", "formatField", "(", "ZonedDateTime", "datetime", ",", "String", "pattern", ",", "StringBuilder", "buffer", ")", "{", "int", "length", "=", "pattern", ".", "length", "(", ")", ";", "if", "(", "length", "==", "0", ")", "{", "return", ";",...
Formats a single field, based on the first character in the pattern string, with repeated characters indicating the field width.
[ "Formats", "a", "single", "field", "based", "on", "the", "first", "character", "in", "the", "pattern", "string", "with", "repeated", "characters", "indicating", "the", "field", "width", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L255-L283
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatField
public void formatField(ZonedDateTime datetime, char field, int width, StringBuilder buffer) { switch (field) { case 'G': formatEra(buffer, datetime, width, eras); break; case 'y': formatYear(buffer, datetime, width); break; case 'Y': formatISOYearWeekOfYe...
java
public void formatField(ZonedDateTime datetime, char field, int width, StringBuilder buffer) { switch (field) { case 'G': formatEra(buffer, datetime, width, eras); break; case 'y': formatYear(buffer, datetime, width); break; case 'Y': formatISOYearWeekOfYe...
[ "public", "void", "formatField", "(", "ZonedDateTime", "datetime", ",", "char", "field", ",", "int", "width", ",", "StringBuilder", "buffer", ")", "{", "switch", "(", "field", ")", "{", "case", "'", "'", ":", "formatEra", "(", "buffer", ",", "datetime", ...
Format a single field of a given width.
[ "Format", "a", "single", "field", "of", "a", "given", "width", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L288-L441
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatEra
void formatEra(StringBuilder b, ZonedDateTime d, int width, FieldVariants eras) { int year = d.getYear(); int index = year < 0 ? 0 : 1; switch (width) { case 5: b.append(eras.narrow[index]); break; case 4: b.append(eras.wide[index]); break; case 3: c...
java
void formatEra(StringBuilder b, ZonedDateTime d, int width, FieldVariants eras) { int year = d.getYear(); int index = year < 0 ? 0 : 1; switch (width) { case 5: b.append(eras.narrow[index]); break; case 4: b.append(eras.wide[index]); break; case 3: c...
[ "void", "formatEra", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ",", "FieldVariants", "eras", ")", "{", "int", "year", "=", "d", ".", "getYear", "(", ")", ";", "int", "index", "=", "year", "<", "0", "?", "0", ":", "1...
Format the era based on the year.
[ "Format", "the", "era", "based", "on", "the", "year", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L446-L464
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatYear
void formatYear(StringBuilder b, ZonedDateTime d, int width) { int year = d.getYear(); _formatYearValue(b, year, width); }
java
void formatYear(StringBuilder b, ZonedDateTime d, int width) { int year = d.getYear(); _formatYearValue(b, year, width); }
[ "void", "formatYear", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ")", "{", "int", "year", "=", "d", ".", "getYear", "(", ")", ";", "_formatYearValue", "(", "b", ",", "year", ",", "width", ")", ";", "}" ]
Format the numeric year, zero padding as necessary.
[ "Format", "the", "numeric", "year", "zero", "padding", "as", "necessary", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L469-L472
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatISOYearWeekOfYear
void formatISOYearWeekOfYear(StringBuilder b, ZonedDateTime d, int width) { int year = d.get(IsoFields.WEEK_BASED_YEAR); _formatYearValue(b, year, width); }
java
void formatISOYearWeekOfYear(StringBuilder b, ZonedDateTime d, int width) { int year = d.get(IsoFields.WEEK_BASED_YEAR); _formatYearValue(b, year, width); }
[ "void", "formatISOYearWeekOfYear", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ")", "{", "int", "year", "=", "d", ".", "get", "(", "IsoFields", ".", "WEEK_BASED_YEAR", ")", ";", "_formatYearValue", "(", "b", ",", "year", ",",...
Formats the year according to ISO week-year.
[ "Formats", "the", "year", "according", "to", "ISO", "week", "-", "year", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L477-L480
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatQuarter
void formatQuarter(StringBuilder b, ZonedDateTime d, int width, FieldVariants quarters) { int quarter = (d.getMonth().getValue() - 1) / 3; switch (width) { case 5: b.append(quarters.narrow[quarter]); break; case 4: b.append(quarters.wide[quarter]); break; case...
java
void formatQuarter(StringBuilder b, ZonedDateTime d, int width, FieldVariants quarters) { int quarter = (d.getMonth().getValue() - 1) / 3; switch (width) { case 5: b.append(quarters.narrow[quarter]); break; case 4: b.append(quarters.wide[quarter]); break; case...
[ "void", "formatQuarter", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ",", "FieldVariants", "quarters", ")", "{", "int", "quarter", "=", "(", "d", ".", "getMonth", "(", ")", ".", "getValue", "(", ")", "-", "1", ")", "/", ...
Format the quarter based on the month.
[ "Format", "the", "quarter", "based", "on", "the", "month", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L503-L526
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatMonth
void formatMonth(StringBuilder b, ZonedDateTime d, int width, FieldVariants months) { int month = d.getMonth().getValue(); switch (width) { case 5: b.append(months.narrow[month-1]); break; case 4: b.append(months.wide[month-1]); break; case 3: b.append...
java
void formatMonth(StringBuilder b, ZonedDateTime d, int width, FieldVariants months) { int month = d.getMonth().getValue(); switch (width) { case 5: b.append(months.narrow[month-1]); break; case 4: b.append(months.wide[month-1]); break; case 3: b.append...
[ "void", "formatMonth", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ",", "FieldVariants", "months", ")", "{", "int", "month", "=", "d", ".", "getMonth", "(", ")", ".", "getValue", "(", ")", ";", "switch", "(", "width", ")"...
Format the month, numeric or a string name variant.
[ "Format", "the", "month", "numeric", "or", "a", "string", "name", "variant", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L531-L556
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatWeekOfMonth
void formatWeekOfMonth(StringBuilder b, ZonedDateTime d, int width) { int w = d.get(ChronoField.ALIGNED_WEEK_OF_MONTH); if (width == 1) { b.append(w); } }
java
void formatWeekOfMonth(StringBuilder b, ZonedDateTime d, int width) { int w = d.get(ChronoField.ALIGNED_WEEK_OF_MONTH); if (width == 1) { b.append(w); } }
[ "void", "formatWeekOfMonth", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ")", "{", "int", "w", "=", "d", ".", "get", "(", "ChronoField", ".", "ALIGNED_WEEK_OF_MONTH", ")", ";", "if", "(", "width", "==", "1", ")", "{", "b"...
Format the week number of the month.
[ "Format", "the", "week", "number", "of", "the", "month", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L561-L566
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatISOWeekOfYear
void formatISOWeekOfYear(StringBuilder b, ZonedDateTime d, int width) { int w = d.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR); switch (width) { case 2: zeroPad2(b, w, 2); break; case 1: b.append(w); break; } }
java
void formatISOWeekOfYear(StringBuilder b, ZonedDateTime d, int width) { int w = d.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR); switch (width) { case 2: zeroPad2(b, w, 2); break; case 1: b.append(w); break; } }
[ "void", "formatISOWeekOfYear", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ")", "{", "int", "w", "=", "d", ".", "get", "(", "IsoFields", ".", "WEEK_OF_WEEK_BASED_YEAR", ")", ";", "switch", "(", "width", ")", "{", "case", "2...
Format the week number of the year.
[ "Format", "the", "week", "number", "of", "the", "year", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L571-L582
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatWeekday
void formatWeekday(StringBuilder b, ZonedDateTime d, int width, FieldVariants weekdays) { int weekday = d.getDayOfWeek().getValue() % 7; switch (width) { case 6: b.append(weekdays.short_[weekday]); break; case 5: b.append(weekdays.narrow[weekday]); break; case...
java
void formatWeekday(StringBuilder b, ZonedDateTime d, int width, FieldVariants weekdays) { int weekday = d.getDayOfWeek().getValue() % 7; switch (width) { case 6: b.append(weekdays.short_[weekday]); break; case 5: b.append(weekdays.narrow[weekday]); break; case...
[ "void", "formatWeekday", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ",", "FieldVariants", "weekdays", ")", "{", "int", "weekday", "=", "d", ".", "getDayOfWeek", "(", ")", ".", "getValue", "(", ")", "%", "7", ";", "switch",...
Format the weekday name.
[ "Format", "the", "weekday", "name", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L587-L608
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatLocalWeekday
void formatLocalWeekday(StringBuilder b, ZonedDateTime d, int width, FieldVariants weekdays, int firstDay) { if (width > 2) { formatWeekday(b, d, width, weekdays); return; } if (width == 2) { b.append('0'); } formatWeekdayNumeric(b, d, firstDay); }
java
void formatLocalWeekday(StringBuilder b, ZonedDateTime d, int width, FieldVariants weekdays, int firstDay) { if (width > 2) { formatWeekday(b, d, width, weekdays); return; } if (width == 2) { b.append('0'); } formatWeekdayNumeric(b, d, firstDay); }
[ "void", "formatLocalWeekday", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ",", "FieldVariants", "weekdays", ",", "int", "firstDay", ")", "{", "if", "(", "width", ">", "2", ")", "{", "formatWeekday", "(", "b", ",", "d", ",",...
Format the numeric weekday, or the format name variant.
[ "Format", "the", "numeric", "weekday", "or", "the", "format", "name", "variant", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L613-L622
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatLocalWeekdayStandalone
void formatLocalWeekdayStandalone(StringBuilder b, ZonedDateTime d, int width, FieldVariants weekdays, int firstDay) { if (width > 2) { formatWeekday(b, d, width, weekdays); return; } formatWeekdayNumeric(b, d, firstDay); }
java
void formatLocalWeekdayStandalone(StringBuilder b, ZonedDateTime d, int width, FieldVariants weekdays, int firstDay) { if (width > 2) { formatWeekday(b, d, width, weekdays); return; } formatWeekdayNumeric(b, d, firstDay); }
[ "void", "formatLocalWeekdayStandalone", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ",", "FieldVariants", "weekdays", ",", "int", "firstDay", ")", "{", "if", "(", "width", ">", "2", ")", "{", "formatWeekday", "(", "b", ",", "...
Format the numeric weekday, or the stand-alone name variant.
[ "Format", "the", "numeric", "weekday", "or", "the", "stand", "-", "alone", "name", "variant", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L627-L633
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatWeekdayNumeric
private void formatWeekdayNumeric(StringBuilder b, ZonedDateTime d, int firstDay) { // Java returns ISO-8601 where Monday = 1 and Sunday = 7. int weekday = d.getDayOfWeek().getValue(); // Adjust to the localized "first day of the week" int w = (7 - firstDay + weekday) % 7 + 1; b.append(w); }
java
private void formatWeekdayNumeric(StringBuilder b, ZonedDateTime d, int firstDay) { // Java returns ISO-8601 where Monday = 1 and Sunday = 7. int weekday = d.getDayOfWeek().getValue(); // Adjust to the localized "first day of the week" int w = (7 - firstDay + weekday) % 7 + 1; b.append(w); }
[ "private", "void", "formatWeekdayNumeric", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "firstDay", ")", "{", "// Java returns ISO-8601 where Monday = 1 and Sunday = 7.", "int", "weekday", "=", "d", ".", "getDayOfWeek", "(", ")", ".", "getValue", ...
Convert from Java's ISO-8601 week number, where Monday = 1 and Sunday = 7. We need to adjust this according to the locale's "first day of the week" which in the US is Sunday = 0. In the US, Tuesday will produce '3' or the 3rd day of the week: weekday = 2 (ISO-8601 Tuesday == 2) int w = (7 - 0 + weekday) % 7 + 1 w ==...
[ "Convert", "from", "Java", "s", "ISO", "-", "8601", "week", "number", "where", "Monday", "=", "1", "and", "Sunday", "=", "7", ".", "We", "need", "to", "adjust", "this", "according", "to", "the", "locale", "s", "first", "day", "of", "the", "week", "wh...
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L653-L660
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatDayOfMonth
void formatDayOfMonth(StringBuilder b, ZonedDateTime d, int width) { int day = d.getDayOfMonth(); zeroPad2(b, day, width); }
java
void formatDayOfMonth(StringBuilder b, ZonedDateTime d, int width) { int day = d.getDayOfMonth(); zeroPad2(b, day, width); }
[ "void", "formatDayOfMonth", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ")", "{", "int", "day", "=", "d", ".", "getDayOfMonth", "(", ")", ";", "zeroPad2", "(", "b", ",", "day", ",", "width", ")", ";", "}" ]
Format the day of the month, optionally zero-padded.
[ "Format", "the", "day", "of", "the", "month", "optionally", "zero", "-", "padded", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L665-L668
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatDayOfYear
void formatDayOfYear(StringBuilder b, ZonedDateTime d, int width) { int day = d.getDayOfYear(); int digits = day < 10 ? 1 : day < 100 ? 2 : 3; switch (digits) { case 1: if (width > 1) { b.append('0'); } // fall through case 2: if (width > 2) { ...
java
void formatDayOfYear(StringBuilder b, ZonedDateTime d, int width) { int day = d.getDayOfYear(); int digits = day < 10 ? 1 : day < 100 ? 2 : 3; switch (digits) { case 1: if (width > 1) { b.append('0'); } // fall through case 2: if (width > 2) { ...
[ "void", "formatDayOfYear", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ")", "{", "int", "day", "=", "d", ".", "getDayOfYear", "(", ")", ";", "int", "digits", "=", "day", "<", "10", "?", "1", ":", "day", "<", "100", "?...
Format the 3-digit day of the year, zero padded.
[ "Format", "the", "3", "-", "digit", "day", "of", "the", "year", "zero", "padded", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L673-L693
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatDayOfWeekInMonth
void formatDayOfWeekInMonth(StringBuilder b, ZonedDateTime d, int width) { int day = ((d.getDayOfMonth() - 1) / 7) + 1; b.append(day); }
java
void formatDayOfWeekInMonth(StringBuilder b, ZonedDateTime d, int width) { int day = ((d.getDayOfMonth() - 1) / 7) + 1; b.append(day); }
[ "void", "formatDayOfWeekInMonth", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ")", "{", "int", "day", "=", "(", "(", "d", ".", "getDayOfMonth", "(", ")", "-", "1", ")", "/", "7", ")", "+", "1", ";", "b", ".", "append"...
Numeric day of week in month, as in "2nd Wednesday in July".
[ "Numeric", "day", "of", "week", "in", "month", "as", "in", "2nd", "Wednesday", "in", "July", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L698-L701
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatDayPeriod
void formatDayPeriod(StringBuilder b, ZonedDateTime d, int width, FieldVariants dayPeriods) { int hours = d.getHour(); int index = hours < 12 ? 0 : 1; switch (width) { case 5: b.append(dayPeriods.narrow[index]); break; case 4: b.append(dayPeriods.wide[index]); br...
java
void formatDayPeriod(StringBuilder b, ZonedDateTime d, int width, FieldVariants dayPeriods) { int hours = d.getHour(); int index = hours < 12 ? 0 : 1; switch (width) { case 5: b.append(dayPeriods.narrow[index]); break; case 4: b.append(dayPeriods.wide[index]); br...
[ "void", "formatDayPeriod", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ",", "FieldVariants", "dayPeriods", ")", "{", "int", "hours", "=", "d", ".", "getHour", "(", ")", ";", "int", "index", "=", "hours", "<", "12", "?", "...
Format the day period variant.
[ "Format", "the", "day", "period", "variant", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L706-L724
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatHours
void formatHours(StringBuilder b, ZonedDateTime d, int width, boolean twelveHour) { int hours = d.getHour(); if (twelveHour && hours > 12) { hours = hours - 12; } if (twelveHour && hours == 0) { hours = 12; } zeroPad2(b, hours, width); }
java
void formatHours(StringBuilder b, ZonedDateTime d, int width, boolean twelveHour) { int hours = d.getHour(); if (twelveHour && hours > 12) { hours = hours - 12; } if (twelveHour && hours == 0) { hours = 12; } zeroPad2(b, hours, width); }
[ "void", "formatHours", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ",", "boolean", "twelveHour", ")", "{", "int", "hours", "=", "d", ".", "getHour", "(", ")", ";", "if", "(", "twelveHour", "&&", "hours", ">", "12", ")", ...
Format the hours in 12- or 24-hour format, optionally zero-padded.
[ "Format", "the", "hours", "in", "12", "-", "or", "24", "-", "hour", "format", "optionally", "zero", "-", "padded", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L729-L738
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatMinutes
void formatMinutes(StringBuilder b, ZonedDateTime d, int width) { zeroPad2(b, d.getMinute(), width); }
java
void formatMinutes(StringBuilder b, ZonedDateTime d, int width) { zeroPad2(b, d.getMinute(), width); }
[ "void", "formatMinutes", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ")", "{", "zeroPad2", "(", "b", ",", "d", ".", "getMinute", "(", ")", ",", "width", ")", ";", "}" ]
Format the minutes, optionally zero-padded.
[ "Format", "the", "minutes", "optionally", "zero", "-", "padded", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L758-L760
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatSeconds
void formatSeconds(StringBuilder b, ZonedDateTime d, int width) { zeroPad2(b, d.getSecond(), width); }
java
void formatSeconds(StringBuilder b, ZonedDateTime d, int width) { zeroPad2(b, d.getSecond(), width); }
[ "void", "formatSeconds", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ")", "{", "zeroPad2", "(", "b", ",", "d", ".", "getSecond", "(", ")", ",", "width", ")", ";", "}" ]
Format the seconds, optionally zero-padded.
[ "Format", "the", "seconds", "optionally", "zero", "-", "padded", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L765-L767
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatFractionalSeconds
void formatFractionalSeconds(StringBuilder b, ZonedDateTime d, int width) { // format up to 9 digits at nanosecond resolution. int nano = d.getNano(); int f = 100000000; while (width > 0 && f > 0) { int digit = nano / f; nano -= (digit * f); f /= 10; b.append(digit); width-...
java
void formatFractionalSeconds(StringBuilder b, ZonedDateTime d, int width) { // format up to 9 digits at nanosecond resolution. int nano = d.getNano(); int f = 100000000; while (width > 0 && f > 0) { int digit = nano / f; nano -= (digit * f); f /= 10; b.append(digit); width-...
[ "void", "formatFractionalSeconds", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ")", "{", "// format up to 9 digits at nanosecond resolution.", "int", "nano", "=", "d", ".", "getNano", "(", ")", ";", "int", "f", "=", "100000000", ";...
Format fractional seconds up to N digits.
[ "Format", "fractional", "seconds", "up", "to", "N", "digits", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L772-L789
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatTimeZone_O
void formatTimeZone_O(StringBuilder b, ZonedDateTime d, int width) { int[] tz = getTzComponents(d); switch (width) { case 1: wrapTimeZoneGMT(b, tz[TZNEG] == -1, tz[TZHOURS], tz[TZMINS], true); break; case 4: wrapTimeZoneGMT(b, tz[TZNEG] == -1, tz[TZHOURS], tz[TZMINS]...
java
void formatTimeZone_O(StringBuilder b, ZonedDateTime d, int width) { int[] tz = getTzComponents(d); switch (width) { case 1: wrapTimeZoneGMT(b, tz[TZNEG] == -1, tz[TZHOURS], tz[TZMINS], true); break; case 4: wrapTimeZoneGMT(b, tz[TZNEG] == -1, tz[TZHOURS], tz[TZMINS]...
[ "void", "formatTimeZone_O", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ")", "{", "int", "[", "]", "tz", "=", "getTzComponents", "(", "d", ")", ";", "switch", "(", "width", ")", "{", "case", "1", ":", "wrapTimeZoneGMT", "...
Format timezone in localized GMT format for field 'O'.
[ "Format", "timezone", "in", "localized", "GMT", "format", "for", "field", "O", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L795-L806
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.formatTimeZone_z
void formatTimeZone_z(StringBuilder b, ZonedDateTime d, int width) { if (width > 4) { return; } ZoneId zone = d.getZone(); ZoneRules zoneRules = null; try { zoneRules = zone.getRules(); } catch (ZoneRulesException e) { // not expected, but catching for safety return; ...
java
void formatTimeZone_z(StringBuilder b, ZonedDateTime d, int width) { if (width > 4) { return; } ZoneId zone = d.getZone(); ZoneRules zoneRules = null; try { zoneRules = zone.getRules(); } catch (ZoneRulesException e) { // not expected, but catching for safety return; ...
[ "void", "formatTimeZone_z", "(", "StringBuilder", "b", ",", "ZonedDateTime", "d", ",", "int", "width", ")", "{", "if", "(", "width", ">", "4", ")", "{", "return", ";", "}", "ZoneId", "zone", "=", "d", ".", "getZone", "(", ")", ";", "ZoneRules", "zone...
Format a time zone using a non-location format.
[ "Format", "a", "time", "zone", "using", "a", "non", "-", "location", "format", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L916-L961
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.getTzComponents
private int[] getTzComponents(ZonedDateTime d) { ZoneOffset offset = d.getOffset(); int secs = offset.getTotalSeconds(); boolean negative = secs < 0; if (negative) { secs = -secs; } int hours = secs / 3600; int mins = (secs % 3600) / 60; return new int[] { negative ? -1 : 1, secs, ...
java
private int[] getTzComponents(ZonedDateTime d) { ZoneOffset offset = d.getOffset(); int secs = offset.getTotalSeconds(); boolean negative = secs < 0; if (negative) { secs = -secs; } int hours = secs / 3600; int mins = (secs % 3600) / 60; return new int[] { negative ? -1 : 1, secs, ...
[ "private", "int", "[", "]", "getTzComponents", "(", "ZonedDateTime", "d", ")", "{", "ZoneOffset", "offset", "=", "d", ".", "getOffset", "(", ")", ";", "int", "secs", "=", "offset", ".", "getTotalSeconds", "(", ")", ";", "boolean", "negative", "=", "secs"...
Decode some fields about a time zone.
[ "Decode", "some", "fields", "about", "a", "time", "zone", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L1013-L1023
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java
CalendarFormatterBase.zeroPad2
void zeroPad2(StringBuilder b, int value, int width) { switch (width) { case 2: if (value < 10) { b.append('0'); } // fall through case 1: b.append(value); break; } }
java
void zeroPad2(StringBuilder b, int value, int width) { switch (width) { case 2: if (value < 10) { b.append('0'); } // fall through case 1: b.append(value); break; } }
[ "void", "zeroPad2", "(", "StringBuilder", "b", ",", "int", "value", ",", "int", "width", ")", "{", "switch", "(", "width", ")", "{", "case", "2", ":", "if", "(", "value", "<", "10", ")", "{", "b", ".", "append", "(", "'", "'", ")", ";", "}", ...
Format 2-digit number with 0-padding.
[ "Format", "2", "-", "digit", "number", "with", "0", "-", "padding", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/dates/CalendarFormatterBase.java#L1028-L1040
train
Squarespace/cldr
examples/src/main/java/com/squarespace/cldr/examples/NumberFormatterDemo.java
NumberFormatterDemo.decimal
private static void decimal(CLDR.Locale locale, String[] numbers, DecimalFormatOptions opts) { for (String num : numbers) { BigDecimal n = new BigDecimal(num); StringBuilder buf = new StringBuilder(" "); NumberFormatter fmt = CLDR.get().getNumberFormatter(locale); fmt.formatDecimal(n, buf, ...
java
private static void decimal(CLDR.Locale locale, String[] numbers, DecimalFormatOptions opts) { for (String num : numbers) { BigDecimal n = new BigDecimal(num); StringBuilder buf = new StringBuilder(" "); NumberFormatter fmt = CLDR.get().getNumberFormatter(locale); fmt.formatDecimal(n, buf, ...
[ "private", "static", "void", "decimal", "(", "CLDR", ".", "Locale", "locale", ",", "String", "[", "]", "numbers", ",", "DecimalFormatOptions", "opts", ")", "{", "for", "(", "String", "num", ":", "numbers", ")", "{", "BigDecimal", "n", "=", "new", "BigDec...
Format decimal numbers in this locale.
[ "Format", "decimal", "numbers", "in", "this", "locale", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/examples/src/main/java/com/squarespace/cldr/examples/NumberFormatterDemo.java#L111-L119
train
Squarespace/cldr
examples/src/main/java/com/squarespace/cldr/examples/NumberFormatterDemo.java
NumberFormatterDemo.money
private static void money( CLDR.Locale locale, CLDR.Currency[] currencies, String[] numbers, CurrencyFormatOptions opts) { for (CLDR.Currency currency : currencies) { System.out.println("Currency " + currency); for (String num : numbers) { BigDecimal n = new BigDecimal(num); N...
java
private static void money( CLDR.Locale locale, CLDR.Currency[] currencies, String[] numbers, CurrencyFormatOptions opts) { for (CLDR.Currency currency : currencies) { System.out.println("Currency " + currency); for (String num : numbers) { BigDecimal n = new BigDecimal(num); N...
[ "private", "static", "void", "money", "(", "CLDR", ".", "Locale", "locale", ",", "CLDR", ".", "Currency", "[", "]", "currencies", ",", "String", "[", "]", "numbers", ",", "CurrencyFormatOptions", "opts", ")", "{", "for", "(", "CLDR", ".", "Currency", "cu...
Format numbers in this locale for several currencies.
[ "Format", "numbers", "in", "this", "locale", "for", "several", "currencies", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/examples/src/main/java/com/squarespace/cldr/examples/NumberFormatterDemo.java#L124-L139
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java
UnitFactorMap.getFactors
public List<UnitValue> getFactors(Unit base, RoundingMode mode, Unit...units) { List<UnitValue> result = new ArrayList<>(); for (int i = 0; i < units.length; i++) { UnitFactor factor = resolve(units[i], base); if (factor != null) { BigDecimal n = factor.rational().compute(mode); resu...
java
public List<UnitValue> getFactors(Unit base, RoundingMode mode, Unit...units) { List<UnitValue> result = new ArrayList<>(); for (int i = 0; i < units.length; i++) { UnitFactor factor = resolve(units[i], base); if (factor != null) { BigDecimal n = factor.rational().compute(mode); resu...
[ "public", "List", "<", "UnitValue", ">", "getFactors", "(", "Unit", "base", ",", "RoundingMode", "mode", ",", "Unit", "...", "units", ")", "{", "List", "<", "UnitValue", ">", "result", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "int", ...
Return an array of factors to convert the array of units to the given base.
[ "Return", "an", "array", "of", "factors", "to", "convert", "the", "array", "of", "units", "to", "the", "given", "base", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java#L87-L97
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java
UnitFactorMap.add
protected UnitFactorMap add(Unit unit, String n, Unit base) { check(unit); check(base); if (unit == base) { throw new IllegalArgumentException("Attempt to define a unit " + unit + " in terms of itself."); } // Set the factor and its inverse if nothing already exists. Rational rational = n...
java
protected UnitFactorMap add(Unit unit, String n, Unit base) { check(unit); check(base); if (unit == base) { throw new IllegalArgumentException("Attempt to define a unit " + unit + " in terms of itself."); } // Set the factor and its inverse if nothing already exists. Rational rational = n...
[ "protected", "UnitFactorMap", "add", "(", "Unit", "unit", ",", "String", "n", ",", "Unit", "base", ")", "{", "check", "(", "unit", ")", ";", "check", "(", "base", ")", ";", "if", "(", "unit", "==", "base", ")", "{", "throw", "new", "IllegalArgumentEx...
Set a factor to convert the unit into a given base.
[ "Set", "a", "factor", "to", "convert", "the", "unit", "into", "a", "given", "base", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java#L102-L113
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java
UnitFactorMap.complete
protected UnitFactorMap complete() { Set<Unit> units = new LinkedHashSet<>(); // Add reverse mappings for all populated units. for (Unit from : factors.keySet()) { units.add(from); for (Map.Entry<Unit, UnitFactor> entry : factors.get(from).entrySet()) { Unit to = entry.getKey(); ...
java
protected UnitFactorMap complete() { Set<Unit> units = new LinkedHashSet<>(); // Add reverse mappings for all populated units. for (Unit from : factors.keySet()) { units.add(from); for (Map.Entry<Unit, UnitFactor> entry : factors.get(from).entrySet()) { Unit to = entry.getKey(); ...
[ "protected", "UnitFactorMap", "complete", "(", ")", "{", "Set", "<", "Unit", ">", "units", "=", "new", "LinkedHashSet", "<>", "(", ")", ";", "// Add reverse mappings for all populated units.", "for", "(", "Unit", "from", ":", "factors", ".", "keySet", "(", ")"...
Creates direct conversion factors between all units by resolving the best conversion path and setting an explicit mapping if one does not already exist.
[ "Creates", "direct", "conversion", "factors", "between", "all", "units", "by", "resolving", "the", "best", "conversion", "path", "and", "setting", "an", "explicit", "mapping", "if", "one", "does", "not", "already", "exist", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java#L127-L195
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java
UnitFactorMap.resolve
protected UnitFactor resolve(Unit from, Unit to) { if (from == to) { return new UnitFactor(Rational.ONE, to); } List<UnitFactor> path = getPath(from, to); if (path.isEmpty()) { throw new IllegalStateException("Can't find a path to convert " + from + " units into " + to); } UnitFacto...
java
protected UnitFactor resolve(Unit from, Unit to) { if (from == to) { return new UnitFactor(Rational.ONE, to); } List<UnitFactor> path = getPath(from, to); if (path.isEmpty()) { throw new IllegalStateException("Can't find a path to convert " + from + " units into " + to); } UnitFacto...
[ "protected", "UnitFactor", "resolve", "(", "Unit", "from", ",", "Unit", "to", ")", "{", "if", "(", "from", "==", "to", ")", "{", "return", "new", "UnitFactor", "(", "Rational", ".", "ONE", ",", "to", ")", ";", "}", "List", "<", "UnitFactor", ">", "...
Find the best conversion factor path between the FROM and TO units, multiply them together and return the resulting factor.
[ "Find", "the", "best", "conversion", "factor", "path", "between", "the", "FROM", "and", "TO", "units", "multiply", "them", "together", "and", "return", "the", "resulting", "factor", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java#L201-L216
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java
UnitFactorMap.precisionSum
private int precisionSum(List<UnitFactor> factors) { return factors.stream().map(f -> totalPrecision(f.rational())).reduce(0, Math::addExact); }
java
private int precisionSum(List<UnitFactor> factors) { return factors.stream().map(f -> totalPrecision(f.rational())).reduce(0, Math::addExact); }
[ "private", "int", "precisionSum", "(", "List", "<", "UnitFactor", ">", "factors", ")", "{", "return", "factors", ".", "stream", "(", ")", ".", "map", "(", "f", "->", "totalPrecision", "(", "f", ".", "rational", "(", ")", ")", ")", ".", "reduce", "(",...
Reduces the list of factors by adding together the precision for all numerators and denominators.
[ "Reduces", "the", "list", "of", "factors", "by", "adding", "together", "the", "precision", "for", "all", "numerators", "and", "denominators", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java#L250-L252
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java
UnitFactorMap.get
public UnitFactor get(Unit from, Unit to) { Map<Unit, UnitFactor> map = factors.get(from); if (map != null) { UnitFactor factor = map.get(to); if (factor != null) { return factor; } } return null; }
java
public UnitFactor get(Unit from, Unit to) { Map<Unit, UnitFactor> map = factors.get(from); if (map != null) { UnitFactor factor = map.get(to); if (factor != null) { return factor; } } return null; }
[ "public", "UnitFactor", "get", "(", "Unit", "from", ",", "Unit", "to", ")", "{", "Map", "<", "Unit", ",", "UnitFactor", ">", "map", "=", "factors", ".", "get", "(", "from", ")", ";", "if", "(", "map", "!=", "null", ")", "{", "UnitFactor", "factor",...
Find an exact conversion factor between the from and to units, or return null if none exists.
[ "Find", "an", "exact", "conversion", "factor", "between", "the", "from", "and", "to", "units", "or", "return", "null", "if", "none", "exists", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java#L305-L314
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java
UnitFactorMap.dump
public String dump(Unit unit) { StringBuilder buf = new StringBuilder(); buf.append(unit).append(":\n"); Map<Unit, UnitFactor> map = factors.get(unit); for (Unit base : map.keySet()) { UnitFactor factor = map.get(base); buf.append(" ").append(factor).append(" "); buf.append(factor.ra...
java
public String dump(Unit unit) { StringBuilder buf = new StringBuilder(); buf.append(unit).append(":\n"); Map<Unit, UnitFactor> map = factors.get(unit); for (Unit base : map.keySet()) { UnitFactor factor = map.get(base); buf.append(" ").append(factor).append(" "); buf.append(factor.ra...
[ "public", "String", "dump", "(", "Unit", "unit", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "buf", ".", "append", "(", "unit", ")", ".", "append", "(", "\":\\n\"", ")", ";", "Map", "<", "Unit", ",", "UnitFactor", ">...
Debugging conversion factors.
[ "Debugging", "conversion", "factors", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java#L319-L329
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java
UnitFactorMap.set
private void set(Unit unit, Rational rational, Unit base, boolean replace) { Map<Unit, UnitFactor> map = factors.get(unit); if (map == null) { map = new EnumMap<>(Unit.class); factors.put(unit, map); } if (replace || !map.containsKey(base)) { map.put(base, new UnitFactor(rational, bas...
java
private void set(Unit unit, Rational rational, Unit base, boolean replace) { Map<Unit, UnitFactor> map = factors.get(unit); if (map == null) { map = new EnumMap<>(Unit.class); factors.put(unit, map); } if (replace || !map.containsKey(base)) { map.put(base, new UnitFactor(rational, bas...
[ "private", "void", "set", "(", "Unit", "unit", ",", "Rational", "rational", ",", "Unit", "base", ",", "boolean", "replace", ")", "{", "Map", "<", "Unit", ",", "UnitFactor", ">", "map", "=", "factors", ".", "get", "(", "unit", ")", ";", "if", "(", "...
Set a conversion factor that converts UNIT to BASE. If the replace flag is true we always overwrite the mapping.
[ "Set", "a", "conversion", "factor", "that", "converts", "UNIT", "to", "BASE", ".", "If", "the", "replace", "flag", "is", "true", "we", "always", "overwrite", "the", "mapping", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java#L335-L344
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java
UnitFactorMap.list
private List<UnitFactor> list(UnitFactor factor) { List<UnitFactor> list = new ArrayList<>(); list.add(factor); return list; }
java
private List<UnitFactor> list(UnitFactor factor) { List<UnitFactor> list = new ArrayList<>(); list.add(factor); return list; }
[ "private", "List", "<", "UnitFactor", ">", "list", "(", "UnitFactor", "factor", ")", "{", "List", "<", "UnitFactor", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "list", ".", "add", "(", "factor", ")", ";", "return", "list", ";", "}" ]
Construct a list containing just this factor.
[ "Construct", "a", "list", "containing", "just", "this", "factor", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java#L349-L353
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java
UnitFactorMap.getBases
private List<Unit> getBases(Unit unit) { Map<Unit, UnitFactor> map = factors.get(unit); if (map != null) { return map.values().stream().map(u -> u.unit()).collect(Collectors.toList()); } return Collections.emptyList(); }
java
private List<Unit> getBases(Unit unit) { Map<Unit, UnitFactor> map = factors.get(unit); if (map != null) { return map.values().stream().map(u -> u.unit()).collect(Collectors.toList()); } return Collections.emptyList(); }
[ "private", "List", "<", "Unit", ">", "getBases", "(", "Unit", "unit", ")", "{", "Map", "<", "Unit", ",", "UnitFactor", ">", "map", "=", "factors", ".", "get", "(", "unit", ")", ";", "if", "(", "map", "!=", "null", ")", "{", "return", "map", ".", ...
Fetch all of the existing bases for the given unit. A base is a conversion factor that was directly added, or the inverse of one that was directly added.
[ "Fetch", "all", "of", "the", "existing", "bases", "for", "the", "given", "unit", ".", "A", "base", "is", "a", "conversion", "factor", "that", "was", "directly", "added", "or", "the", "inverse", "of", "one", "that", "was", "directly", "added", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/units/UnitFactorMap.java#L369-L375
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/DistanceMap.java
DistanceMap.hash
private static int hash(String k1, String k2) { int h = (k1.hashCode() * 33) + k2.hashCode(); return h ^ (h >>> 16); }
java
private static int hash(String k1, String k2) { int h = (k1.hashCode() * 33) + k2.hashCode(); return h ^ (h >>> 16); }
[ "private", "static", "int", "hash", "(", "String", "k1", ",", "String", "k2", ")", "{", "int", "h", "=", "(", "k1", ".", "hashCode", "(", ")", "*", "33", ")", "+", "k2", ".", "hashCode", "(", ")", ";", "return", "h", "^", "(", "h", ">>>", "16...
Combine the hash codes for the two keys, then mix.
[ "Combine", "the", "hash", "codes", "for", "the", "two", "keys", "then", "mix", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/DistanceMap.java#L103-L106
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/numbers/NumberFormatContext.java
NumberFormatContext.setPattern
public void setPattern(NumberPattern pattern, int _maxSigDigits, int _minSigDigits) { Format format = pattern.format(); minIntDigits = orDefault(options.minimumIntegerDigits(), format.minimumIntegerDigits()); maxFracDigits = currencyDigits == -1 ? format.maximumFractionDigits() : currencyDigits; maxFra...
java
public void setPattern(NumberPattern pattern, int _maxSigDigits, int _minSigDigits) { Format format = pattern.format(); minIntDigits = orDefault(options.minimumIntegerDigits(), format.minimumIntegerDigits()); maxFracDigits = currencyDigits == -1 ? format.maximumFractionDigits() : currencyDigits; maxFra...
[ "public", "void", "setPattern", "(", "NumberPattern", "pattern", ",", "int", "_maxSigDigits", ",", "int", "_minSigDigits", ")", "{", "Format", "format", "=", "pattern", ".", "format", "(", ")", ";", "minIntDigits", "=", "orDefault", "(", "options", ".", "min...
Set the pattern and initialize parameters based on the arguments, pattern and options settings.
[ "Set", "the", "pattern", "and", "initialize", "parameters", "based", "on", "the", "arguments", "pattern", "and", "options", "settings", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/numbers/NumberFormatContext.java#L54-L72
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/numbers/NumberFormatContext.java
NumberFormatContext.adjust
public BigDecimal adjust(BigDecimal n) { return NumberFormattingUtils.setup(n, options.roundMode(), formatMode, minIntDigits, maxFracDigits, minFracDigits, maxSigDigits, minSigDigits); }
java
public BigDecimal adjust(BigDecimal n) { return NumberFormattingUtils.setup(n, options.roundMode(), formatMode, minIntDigits, maxFracDigits, minFracDigits, maxSigDigits, minSigDigits); }
[ "public", "BigDecimal", "adjust", "(", "BigDecimal", "n", ")", "{", "return", "NumberFormattingUtils", ".", "setup", "(", "n", ",", "options", ".", "roundMode", "(", ")", ",", "formatMode", ",", "minIntDigits", ",", "maxFracDigits", ",", "minFracDigits", ",", ...
Adjust the number using all of the options.
[ "Adjust", "the", "number", "using", "all", "of", "the", "options", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/numbers/NumberFormatContext.java#L77-L80
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/parse/DateTimePatternParser.java
DateTimePatternParser.splitIntervalPattern
public Pair<List<Node>, List<Node>> splitIntervalPattern(String raw) { List<Node> pattern = parse(raw); Set<Character> seen = new HashSet<>(); List<Node> fst = new ArrayList<>(); List<Node> snd = new ArrayList<>(); // Indicates we've seen a repeated field. boolean boundary = false; for (N...
java
public Pair<List<Node>, List<Node>> splitIntervalPattern(String raw) { List<Node> pattern = parse(raw); Set<Character> seen = new HashSet<>(); List<Node> fst = new ArrayList<>(); List<Node> snd = new ArrayList<>(); // Indicates we've seen a repeated field. boolean boundary = false; for (N...
[ "public", "Pair", "<", "List", "<", "Node", ">", ",", "List", "<", "Node", ">", ">", "splitIntervalPattern", "(", "String", "raw", ")", "{", "List", "<", "Node", ">", "pattern", "=", "parse", "(", "raw", ")", ";", "Set", "<", "Character", ">", "see...
Looks for the first repeated field in the pattern, splitting it into two parts on that boundary. For example, the pattern "HH:mm - HH:mm v" will be split into two patterns: "HH:mm - " and "HH:mm v" when we see the 'H' field for the 2nd time.
[ "Looks", "for", "the", "first", "repeated", "field", "in", "the", "pattern", "splitting", "it", "into", "two", "parts", "on", "that", "boundary", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/parse/DateTimePatternParser.java#L27-L54
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/parse/DateTimePatternParser.java
DateTimePatternParser.render
public static String render(List<Node> nodes) { StringBuilder buf = new StringBuilder(); for (Node node : nodes) { if (node instanceof Text) { String text = ((Text) node).text; boolean inquote = false; for (int i = 0; i < text.length(); i++) { char ch = text.charAt(i); ...
java
public static String render(List<Node> nodes) { StringBuilder buf = new StringBuilder(); for (Node node : nodes) { if (node instanceof Text) { String text = ((Text) node).text; boolean inquote = false; for (int i = 0; i < text.length(); i++) { char ch = text.charAt(i); ...
[ "public", "static", "String", "render", "(", "List", "<", "Node", ">", "nodes", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Node", "node", ":", "nodes", ")", "{", "if", "(", "node", "instanceof", "Text", ...
Render the compiled pattern back into string form.
[ "Render", "the", "compiled", "pattern", "back", "into", "string", "form", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/parse/DateTimePatternParser.java#L59-L131
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/parse/DateTimePatternParser.java
DateTimePatternParser.parse
public List<Node> parse(String raw) { // holds literal text as we parse StringBuilder buf = new StringBuilder(); // current field character, \0 if none char field = '\0'; // current field width int width = 0; // flag indicating we're inside a literal string boolean inquote = false; ...
java
public List<Node> parse(String raw) { // holds literal text as we parse StringBuilder buf = new StringBuilder(); // current field character, \0 if none char field = '\0'; // current field width int width = 0; // flag indicating we're inside a literal string boolean inquote = false; ...
[ "public", "List", "<", "Node", ">", "parse", "(", "String", "raw", ")", "{", "// holds literal text as we parse", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "// current field character, \\0 if none", "char", "field", "=", "'", "'", ";", ...
Parses a CLDR date-time pattern into a series of Text and Field nodes.
[ "Parses", "a", "CLDR", "date", "-", "time", "pattern", "into", "a", "series", "of", "Text", "and", "Field", "nodes", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/parse/DateTimePatternParser.java#L136-L272
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java
CodeGenerator.generate
public static void generate(Path outputDir) throws IOException { DataReader reader = DataReader.get(); CalendarCodeGenerator datetimeGenerator = new CalendarCodeGenerator(); Map<LocaleID, ClassName> dateClasses = datetimeGenerator.generate(outputDir, reader); PluralCodeGenerator pluralGenerator = new P...
java
public static void generate(Path outputDir) throws IOException { DataReader reader = DataReader.get(); CalendarCodeGenerator datetimeGenerator = new CalendarCodeGenerator(); Map<LocaleID, ClassName> dateClasses = datetimeGenerator.generate(outputDir, reader); PluralCodeGenerator pluralGenerator = new P...
[ "public", "static", "void", "generate", "(", "Path", "outputDir", ")", "throws", "IOException", "{", "DataReader", "reader", "=", "DataReader", ".", "get", "(", ")", ";", "CalendarCodeGenerator", "datetimeGenerator", "=", "new", "CalendarCodeGenerator", "(", ")", ...
Loads all CLDR data and invokes the code generators for each data type. Output is a series of Java classes under the outputDir.
[ "Loads", "all", "CLDR", "data", "and", "invokes", "the", "code", "generators", "for", "each", "data", "type", ".", "Output", "is", "a", "series", "of", "Java", "classes", "under", "the", "outputDir", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java#L59-L123
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java
CodeGenerator.saveClass
public static void saveClass(Path rootDir, String packageName, String className, TypeSpec type) throws IOException { List<String> packagePath = Splitter.on('.').splitToList(packageName); Path classPath = Paths.get(rootDir.toString(), packagePath.toArray(EMPTY)); Path outputFile = classPath.resolve(cl...
java
public static void saveClass(Path rootDir, String packageName, String className, TypeSpec type) throws IOException { List<String> packagePath = Splitter.on('.').splitToList(packageName); Path classPath = Paths.get(rootDir.toString(), packagePath.toArray(EMPTY)); Path outputFile = classPath.resolve(cl...
[ "public", "static", "void", "saveClass", "(", "Path", "rootDir", ",", "String", "packageName", ",", "String", "className", ",", "TypeSpec", "type", ")", "throws", "IOException", "{", "List", "<", "String", ">", "packagePath", "=", "Splitter", ".", "on", "(",...
Saves a Java class file to a path for the given package, rooted in rootDir.
[ "Saves", "a", "Java", "class", "file", "to", "a", "path", "for", "the", "given", "package", "rooted", "in", "rootDir", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java#L128-L144
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java
CodeGenerator.addPluralRules
private static void addPluralRules(TypeSpec.Builder type) { FieldSpec field = FieldSpec.builder(PLURAL_RULES, "pluralRules", PRIVATE, STATIC, FINAL) .initializer("new $T()", PLURAL_RULES) .build(); MethodSpec method = MethodSpec.methodBuilder("getPluralRules") .addModifiers(PUBLIC) ...
java
private static void addPluralRules(TypeSpec.Builder type) { FieldSpec field = FieldSpec.builder(PLURAL_RULES, "pluralRules", PRIVATE, STATIC, FINAL) .initializer("new $T()", PLURAL_RULES) .build(); MethodSpec method = MethodSpec.methodBuilder("getPluralRules") .addModifiers(PUBLIC) ...
[ "private", "static", "void", "addPluralRules", "(", "TypeSpec", ".", "Builder", "type", ")", "{", "FieldSpec", "field", "=", "FieldSpec", ".", "builder", "(", "PLURAL_RULES", ",", "\"pluralRules\"", ",", "PRIVATE", ",", "STATIC", ",", "FINAL", ")", ".", "ini...
Add static instance of plural rules and accessor method.
[ "Add", "static", "instance", "of", "plural", "rules", "and", "accessor", "method", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java#L149-L162
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java
CodeGenerator.indexFormatters
private static MethodSpec indexFormatters( String methodName, String registerMethodName, Map<LocaleID, ClassName> dateClasses) { MethodSpec.Builder method = MethodSpec.methodBuilder(methodName) .addModifiers(PRIVATE, STATIC); for (Map.Entry<LocaleID, ClassName> entry : dateClasses.entryS...
java
private static MethodSpec indexFormatters( String methodName, String registerMethodName, Map<LocaleID, ClassName> dateClasses) { MethodSpec.Builder method = MethodSpec.methodBuilder(methodName) .addModifiers(PRIVATE, STATIC); for (Map.Entry<LocaleID, ClassName> entry : dateClasses.entryS...
[ "private", "static", "MethodSpec", "indexFormatters", "(", "String", "methodName", ",", "String", "registerMethodName", ",", "Map", "<", "LocaleID", ",", "ClassName", ">", "dateClasses", ")", "{", "MethodSpec", ".", "Builder", "method", "=", "MethodSpec", ".", "...
Generates a static code block that populates the formatter map.
[ "Generates", "a", "static", "code", "block", "that", "populates", "the", "formatter", "map", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java#L167-L180
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java
CodeGenerator.addLocaleField
private static void addLocaleField(TypeSpec.Builder type, String name, LocaleID locale) { FieldSpec.Builder field = FieldSpec.builder(CLDR_LOCALE_IF, name, PUBLIC, STATIC, FINAL) .initializer("new $T($S, $S, $S, $S)", META_LOCALE, strOrNull(locale.language), strOrNull(lo...
java
private static void addLocaleField(TypeSpec.Builder type, String name, LocaleID locale) { FieldSpec.Builder field = FieldSpec.builder(CLDR_LOCALE_IF, name, PUBLIC, STATIC, FINAL) .initializer("new $T($S, $S, $S, $S)", META_LOCALE, strOrNull(locale.language), strOrNull(lo...
[ "private", "static", "void", "addLocaleField", "(", "TypeSpec", ".", "Builder", "type", ",", "String", "name", ",", "LocaleID", "locale", ")", "{", "FieldSpec", ".", "Builder", "field", "=", "FieldSpec", ".", "builder", "(", "CLDR_LOCALE_IF", ",", "name", ",...
Create a public locale field.
[ "Create", "a", "public", "locale", "field", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java#L297-L306
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java
CodeGenerator.createLanguageAliases
private static void createLanguageAliases(TypeSpec.Builder type, Map<String, String> languageAliases) { MethodSpec.Builder method = MethodSpec.methodBuilder("registerLanguageAliases") .addModifiers(PRIVATE, STATIC); for (Map.Entry<String, String> entry : languageAliases.entrySet()) { method.a...
java
private static void createLanguageAliases(TypeSpec.Builder type, Map<String, String> languageAliases) { MethodSpec.Builder method = MethodSpec.methodBuilder("registerLanguageAliases") .addModifiers(PRIVATE, STATIC); for (Map.Entry<String, String> entry : languageAliases.entrySet()) { method.a...
[ "private", "static", "void", "createLanguageAliases", "(", "TypeSpec", ".", "Builder", "type", ",", "Map", "<", "String", ",", "String", ">", "languageAliases", ")", "{", "MethodSpec", ".", "Builder", "method", "=", "MethodSpec", ".", "methodBuilder", "(", "\"...
Create language alias mapping.
[ "Create", "language", "alias", "mapping", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java#L311-L321
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java
CodeGenerator.createLikelySubtags
private static void createLikelySubtags(TypeSpec.Builder type, Map<String, String> likelySubtags) { MethodSpec.Builder method = MethodSpec.methodBuilder("registerLikelySubtags") .addModifiers(PRIVATE, STATIC); for (Map.Entry<String, String> entry : likelySubtags.entrySet()) { method.addStatem...
java
private static void createLikelySubtags(TypeSpec.Builder type, Map<String, String> likelySubtags) { MethodSpec.Builder method = MethodSpec.methodBuilder("registerLikelySubtags") .addModifiers(PRIVATE, STATIC); for (Map.Entry<String, String> entry : likelySubtags.entrySet()) { method.addStatem...
[ "private", "static", "void", "createLikelySubtags", "(", "TypeSpec", ".", "Builder", "type", ",", "Map", "<", "String", ",", "String", ">", "likelySubtags", ")", "{", "MethodSpec", ".", "Builder", "method", "=", "MethodSpec", ".", "methodBuilder", "(", "\"regi...
Create likely subtags mapping.
[ "Create", "likely", "subtags", "mapping", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java#L338-L348
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java
CodeGenerator.createCurrencies
private static void createCurrencies(TypeSpec.Builder type, List<String> currencies) { TypeSpec.Builder currencyType = TypeSpec.enumBuilder("Currency") .addModifiers(PUBLIC, STATIC); List<String> codes = new ArrayList<>(); codes.addAll(currencies); Collections.sort(codes); StringBuilde...
java
private static void createCurrencies(TypeSpec.Builder type, List<String> currencies) { TypeSpec.Builder currencyType = TypeSpec.enumBuilder("Currency") .addModifiers(PUBLIC, STATIC); List<String> codes = new ArrayList<>(); codes.addAll(currencies); Collections.sort(codes); StringBuilde...
[ "private", "static", "void", "createCurrencies", "(", "TypeSpec", ".", "Builder", "type", ",", "List", "<", "String", ">", "currencies", ")", "{", "TypeSpec", ".", "Builder", "currencyType", "=", "TypeSpec", ".", "enumBuilder", "(", "\"Currency\"", ")", ".", ...
Create top-level container to hold currency constants.
[ "Create", "top", "-", "level", "container", "to", "hold", "currency", "constants", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/CodeGenerator.java#L357-L400
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/MessageArgsUnitParser.java
MessageArgsUnitParser.selectExactUnit
protected static Unit selectExactUnit(String compact, UnitConverter converter) { if (compact != null) { switch (compact) { case "consumption": return converter.consumptionUnit(); case "light": return Unit.LUX; case "speed": return converter.speedUnit(); ...
java
protected static Unit selectExactUnit(String compact, UnitConverter converter) { if (compact != null) { switch (compact) { case "consumption": return converter.consumptionUnit(); case "light": return Unit.LUX; case "speed": return converter.speedUnit(); ...
[ "protected", "static", "Unit", "selectExactUnit", "(", "String", "compact", ",", "UnitConverter", "converter", ")", "{", "if", "(", "compact", "!=", "null", ")", "{", "switch", "(", "compact", ")", "{", "case", "\"consumption\"", ":", "return", "converter", ...
Some categories only have a single possible unit depending the locale.
[ "Some", "categories", "only", "have", "a", "single", "possible", "unit", "depending", "the", "locale", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/MessageArgsUnitParser.java#L93-L110
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/MessageArgsUnitParser.java
MessageArgsUnitParser.inputFromExactUnit
protected static Unit inputFromExactUnit(Unit exact, UnitConverter converter) { switch (exact) { case TERABIT: case GIGABIT: case MEGABIT: case KILOBIT: case BIT: return Unit.BIT; case TERABYTE: case GIGABYTE: case MEGABYTE: case KILOBYTE: case BY...
java
protected static Unit inputFromExactUnit(Unit exact, UnitConverter converter) { switch (exact) { case TERABIT: case GIGABIT: case MEGABIT: case KILOBIT: case BIT: return Unit.BIT; case TERABYTE: case GIGABYTE: case MEGABYTE: case KILOBYTE: case BY...
[ "protected", "static", "Unit", "inputFromExactUnit", "(", "Unit", "exact", ",", "UnitConverter", "converter", ")", "{", "switch", "(", "exact", ")", "{", "case", "TERABIT", ":", "case", "GIGABIT", ":", "case", "MEGABIT", ":", "case", "KILOBIT", ":", "case", ...
Based on the unit we're converting to, guess the input unit. For example, if we're converting to MEGABIT and no input unit was specified, assume BIT.
[ "Based", "on", "the", "unit", "we", "re", "converting", "to", "guess", "the", "input", "unit", ".", "For", "example", "if", "we", "re", "converting", "to", "MEGABIT", "and", "no", "input", "unit", "was", "specified", "assume", "BIT", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/MessageArgsUnitParser.java#L164-L209
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/MessageArgsUnitParser.java
MessageArgsUnitParser.getDefaultFactorSet
protected static UnitFactorSet getDefaultFactorSet(UnitCategory category, UnitConverter converter) { switch (category) { case ANGLE: return UnitFactorSets.ANGLE; case AREA: return converter.areaFactors(); case DURATION: return UnitFactorSets.DURATION; case ELECTRIC: ...
java
protected static UnitFactorSet getDefaultFactorSet(UnitCategory category, UnitConverter converter) { switch (category) { case ANGLE: return UnitFactorSets.ANGLE; case AREA: return converter.areaFactors(); case DURATION: return UnitFactorSets.DURATION; case ELECTRIC: ...
[ "protected", "static", "UnitFactorSet", "getDefaultFactorSet", "(", "UnitCategory", "category", ",", "UnitConverter", "converter", ")", "{", "switch", "(", "category", ")", "{", "case", "ANGLE", ":", "return", "UnitFactorSets", ".", "ANGLE", ";", "case", "AREA", ...
Default conversion factors for each category. Some of these differ based on the locale of the converter.
[ "Default", "conversion", "factors", "for", "each", "category", ".", "Some", "of", "these", "differ", "based", "on", "the", "locale", "of", "the", "converter", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/MessageArgsUnitParser.java#L215-L241
train
Squarespace/cldr
core/src/main/java/com/squarespace/cldr/numbers/NumberPattern.java
NumberPattern.render
public String render() { StringBuilder buf = new StringBuilder(); for (Node node : parsed) { if (node instanceof Symbol) { switch ((Symbol)node) { case MINUS: buf.append('-'); break; case CURRENCY: buf.append(CURRENCY_SYM); break...
java
public String render() { StringBuilder buf = new StringBuilder(); for (Node node : parsed) { if (node instanceof Symbol) { switch ((Symbol)node) { case MINUS: buf.append('-'); break; case CURRENCY: buf.append(CURRENCY_SYM); break...
[ "public", "String", "render", "(", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Node", "node", ":", "parsed", ")", "{", "if", "(", "node", "instanceof", "Symbol", ")", "{", "switch", "(", "(", "Symbol", "...
Render a parseable representation of this pattern.
[ "Render", "a", "parseable", "representation", "of", "this", "pattern", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/core/src/main/java/com/squarespace/cldr/numbers/NumberPattern.java#L38-L81
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/BundleMatcher.java
BundleMatcher.dump
public String dump() { StringBuilder buf = new StringBuilder(); buf.append(" LOCALE MATCHED BUNDLE\n"); buf.append(" ====== ==============\n"); List<MetaLocale> keys = availableBundlesMap.keySet().stream() .map(k -> (MetaLocale)k).collect(Collectors.toList());...
java
public String dump() { StringBuilder buf = new StringBuilder(); buf.append(" LOCALE MATCHED BUNDLE\n"); buf.append(" ====== ==============\n"); List<MetaLocale> keys = availableBundlesMap.keySet().stream() .map(k -> (MetaLocale)k).collect(Collectors.toList());...
[ "public", "String", "dump", "(", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "buf", ".", "append", "(", "\" LOCALE MATCHED BUNDLE\\n\"", ")", ";", "buf", ".", "append", "(", "\" ====== ===========...
Inspect the mapping between permutations of locale fields and bundle identifiers.
[ "Inspect", "the", "mapping", "between", "permutations", "of", "locale", "fields", "and", "bundle", "identifiers", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/BundleMatcher.java#L80-L91
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/BundleMatcher.java
BundleMatcher.buildMap
private void buildMap(List<CLDR.Locale> availableBundles) { // Index all bundles by their original bundle identifier and the maximum // bundle identifier. List<MetaLocale> maxBundleIds = new ArrayList<>(); for (CLDR.Locale locale : availableBundles) { MetaLocale source = (MetaLocale) locale; ...
java
private void buildMap(List<CLDR.Locale> availableBundles) { // Index all bundles by their original bundle identifier and the maximum // bundle identifier. List<MetaLocale> maxBundleIds = new ArrayList<>(); for (CLDR.Locale locale : availableBundles) { MetaLocale source = (MetaLocale) locale; ...
[ "private", "void", "buildMap", "(", "List", "<", "CLDR", ".", "Locale", ">", "availableBundles", ")", "{", "// Index all bundles by their original bundle identifier and the maximum", "// bundle identifier.", "List", "<", "MetaLocale", ">", "maxBundleIds", "=", "new", "Arr...
Iterate over the available bundle identifiers, expand them and index all permutations to enable a fast direct lookup.
[ "Iterate", "over", "the", "available", "bundle", "identifiers", "expand", "them", "and", "index", "all", "permutations", "to", "enable", "a", "fast", "direct", "lookup", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/BundleMatcher.java#L97-L120
train
Squarespace/cldr
runtime/src/main/java/com/squarespace/cldr/BundleMatcher.java
BundleMatcher.indexPermutations
private void indexPermutations(MetaLocale bundleId) { MetaLocale key = bundleId.copy(); for (int flags : LanguageResolver.MATCH_ORDER) { LanguageResolver.set(bundleId, key, flags); MetaLocale maxBundleId = languageResolver.addLikelySubtags(key); MetaLocale source = availableBundlesMap.get(maxB...
java
private void indexPermutations(MetaLocale bundleId) { MetaLocale key = bundleId.copy(); for (int flags : LanguageResolver.MATCH_ORDER) { LanguageResolver.set(bundleId, key, flags); MetaLocale maxBundleId = languageResolver.addLikelySubtags(key); MetaLocale source = availableBundlesMap.get(maxB...
[ "private", "void", "indexPermutations", "(", "MetaLocale", "bundleId", ")", "{", "MetaLocale", "key", "=", "bundleId", ".", "copy", "(", ")", ";", "for", "(", "int", "flags", ":", "LanguageResolver", ".", "MATCH_ORDER", ")", "{", "LanguageResolver", ".", "se...
Index permutations of the given bundle identifier. We iterate over the field permutations and expand each to the maximum bundle identifier, then query to see if that max bundle identifier matches a bundle. Then we index the permutation to that bundle. This creates a static mapping mimicking a dynamic lookup.
[ "Index", "permutations", "of", "the", "given", "bundle", "identifier", ".", "We", "iterate", "over", "the", "field", "permutations", "and", "expand", "each", "to", "the", "maximum", "bundle", "identifier", "then", "query", "to", "see", "if", "that", "max", "...
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/runtime/src/main/java/com/squarespace/cldr/BundleMatcher.java#L128-L144
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/CalendarCodeGenerator.java
CalendarCodeGenerator.generate
public Map<LocaleID, ClassName> generate(Path outputDir, DataReader reader) throws IOException { Map<LocaleID, ClassName> dateClasses = new TreeMap<>(); List<DateTimeData> dateTimeDataList = new ArrayList<>(); for (Map.Entry<LocaleID, DateTimeData> entry : reader.calendars().entrySet()) { Date...
java
public Map<LocaleID, ClassName> generate(Path outputDir, DataReader reader) throws IOException { Map<LocaleID, ClassName> dateClasses = new TreeMap<>(); List<DateTimeData> dateTimeDataList = new ArrayList<>(); for (Map.Entry<LocaleID, DateTimeData> entry : reader.calendars().entrySet()) { Date...
[ "public", "Map", "<", "LocaleID", ",", "ClassName", ">", "generate", "(", "Path", "outputDir", ",", "DataReader", "reader", ")", "throws", "IOException", "{", "Map", "<", "LocaleID", ",", "ClassName", ">", "dateClasses", "=", "new", "TreeMap", "<>", "(", "...
Generates the date-time classes into the given output directory.
[ "Generates", "the", "date", "-", "time", "classes", "into", "the", "given", "output", "directory", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/CalendarCodeGenerator.java#L75-L108
train
Squarespace/cldr
compiler/src/main/java/com/squarespace/cldr/codegen/CalendarCodeGenerator.java
CalendarCodeGenerator.addSkeletonClassifierMethod
private void addSkeletonClassifierMethod(TypeSpec.Builder type, List<DateTimeData> dataList) { Set<String> dates = new LinkedHashSet<>(); Set<String> times = new LinkedHashSet<>(); for (DateTimeData data : dataList) { for (Skeleton skeleton : data.dateTimeSkeletons) { if (isDateSkeleton(skelet...
java
private void addSkeletonClassifierMethod(TypeSpec.Builder type, List<DateTimeData> dataList) { Set<String> dates = new LinkedHashSet<>(); Set<String> times = new LinkedHashSet<>(); for (DateTimeData data : dataList) { for (Skeleton skeleton : data.dateTimeSkeletons) { if (isDateSkeleton(skelet...
[ "private", "void", "addSkeletonClassifierMethod", "(", "TypeSpec", ".", "Builder", "type", ",", "List", "<", "DateTimeData", ">", "dataList", ")", "{", "Set", "<", "String", ">", "dates", "=", "new", "LinkedHashSet", "<>", "(", ")", ";", "Set", "<", "Strin...
Create a helper class to classify skeletons as either DATE or TIME.
[ "Create", "a", "helper", "class", "to", "classify", "skeletons", "as", "either", "DATE", "or", "TIME", "." ]
54b752d4ec2457df56e98461618f9c0eec41e1e1
https://github.com/Squarespace/cldr/blob/54b752d4ec2457df56e98461618f9c0eec41e1e1/compiler/src/main/java/com/squarespace/cldr/codegen/CalendarCodeGenerator.java#L113-L128
train