< prev index next >

make/jdk/src/classes/build/tools/cldrconverter/SupplementDataParseHandler.java

Print this page
rev 47734 : imported patch 8190918

*** 1,7 **** /* ! * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 82,138 **** if ("root".equals(id)) { parentLocalesMap.keySet().forEach(key -> { values.put(CLDRConverter.PARENT_LOCALE_PREFIX+key, parentLocalesMap.get(key)); }); ! } else { ! String countryData = getWeekData(id, JAVA_FIRSTDAY, firstDayMap); ! if (countryData != null) { ! values.put(JAVA_FIRSTDAY, countryData); ! } ! String minDaysData = getWeekData(id, JAVA_MINDAY, minDaysMap); ! if (minDaysData != null) { ! values.put(JAVA_MINDAY, minDaysData); ! } } return values.isEmpty() ? null : values; } - /** - * It returns either firstDay or minDays in the JRE format for the country. - * - * @param country territory code of the requested data - * @param jreDataName JAVA_FIRSTDAY or JAVA_MINDAY - * @param dataMap firstDayMap or minDaysMap - * @return the value for the given jreDataName, or null if requested value - * (firstDay/minDays) is not available although that is highly unlikely - * because of the default value for the world (001). - */ - String getWeekData(String country, final String jreDataName, final Map<String, Object> dataMap) { - String countryValue = null; - String defaultWorldValue = null; - for (String key : dataMap.keySet()) { - if (key.contains(country)) { - if (jreDataName.equals(JAVA_FIRSTDAY)) { - countryValue = DAY_OF_WEEK_MAP.get((String) dataMap.get(key)); - } else if (jreDataName.equals(JAVA_MINDAY)) { - countryValue = (String) dataMap.get(key); - } - if (countryValue != null) { - return countryValue; - } - } else if (key.contains(WORLD)) { - if (jreDataName.equals(JAVA_FIRSTDAY)) { - defaultWorldValue = DAY_OF_WEEK_MAP.get((String) dataMap.get(key)); - } else if (jreDataName.equals(JAVA_MINDAY)) { - defaultWorldValue = (String) dataMap.get(key); - } - } - } - return defaultWorldValue; - } - @Override public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException { // avoid HTTP traffic to unicode.org if (systemID.startsWith(CLDRConverter.SPPL_LDML_DTD_SYSTEM_ID)) { return new InputSource((new File(CLDRConverter.LOCAL_SPPL_LDML_DTD)).toURI().toString()); --- 82,103 ---- if ("root".equals(id)) { parentLocalesMap.keySet().forEach(key -> { values.put(CLDRConverter.PARENT_LOCALE_PREFIX+key, parentLocalesMap.get(key)); }); ! firstDayMap.keySet().forEach(key -> { ! values.put(CLDRConverter.CALENDAR_FIRSTDAY_PREFIX+firstDayMap.get(key), ! key); ! }); ! minDaysMap.keySet().forEach(key -> { ! values.put(CLDRConverter.CALENDAR_MINDAYS_PREFIX+minDaysMap.get(key), ! key); ! }); } return values.isEmpty() ? null : values; } @Override public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException { // avoid HTTP traffic to unicode.org if (systemID.startsWith(CLDRConverter.SPPL_LDML_DTD_SYSTEM_ID)) { return new InputSource((new File(CLDRConverter.LOCAL_SPPL_LDML_DTD)).toURI().toString());
*** 150,160 **** public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { // elements we need to actively ignore switch (qName) { case "firstDay": if (!isIgnored(attributes)) { ! firstDayMap.put(attributes.getValue("territories"), attributes.getValue("day")); } break; case "minDays": if (!isIgnored(attributes)) { minDaysMap.put(attributes.getValue("territories"), attributes.getValue("count")); --- 115,151 ---- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { // elements we need to actively ignore switch (qName) { case "firstDay": if (!isIgnored(attributes)) { ! String fd; ! ! switch (attributes.getValue("day")) { ! case "sun": ! fd = "1"; ! break; ! default: ! case "mon": ! fd = "2"; ! break; ! case "tue": ! fd = "3"; ! break; ! case "wed": ! fd = "4"; ! break; ! case "thu": ! fd = "5"; ! break; ! case "fri": ! fd = "6"; ! break; ! case "sat": ! fd = "7"; ! break; ! } ! firstDayMap.put(attributes.getValue("territories"), fd); } break; case "minDays": if (!isIgnored(attributes)) { minDaysMap.put(attributes.getValue("territories"), attributes.getValue("count"));
< prev index next >