make/jdk/src/classes/build/tools/cldrconverter/LDMLParseHandler.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 52869 c5c0db0b7c2f
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   506         //
   506         //
   507         case "decimalFormatLength":
   507         case "decimalFormatLength":
   508             String type = attributes.getValue("type");
   508             String type = attributes.getValue("type");
   509             if (null == type) {
   509             if (null == type) {
   510                 // format data for decimal number format
   510                 // format data for decimal number format
   511                 pushStringEntry(qName, attributes, "NumberPatterns/decimal");
   511                 pushStringEntry(qName, attributes,
       
   512                     currentNumberingSystem + "NumberPatterns/decimal");
   512                 currentStyle = type;
   513                 currentStyle = type;
   513             } else {
   514             } else {
   514                 switch (type) {
   515                 switch (type) {
   515                     case "short":
   516                     case "short":
   516                     case "long":
   517                     case "long":
   584                 }
   585                 }
   585             } else {
   586             } else {
   586                 pushContainer(qName, attributes);
   587                 pushContainer(qName, attributes);
   587             }
   588             }
   588             break;
   589             break;
       
   590         case "currencyFormats":
       
   591         case "decimalFormats":
       
   592         case "percentFormats":
       
   593             {
       
   594                 String script = attributes.getValue("numberSystem");
       
   595                 if (script != null) {
       
   596                     addNumberingScript(script);
       
   597                     currentNumberingSystem = script + ".";
       
   598                 }
       
   599                 pushContainer(qName, attributes);
       
   600             }
       
   601             break;
   589         case "currencyFormatLength":
   602         case "currencyFormatLength":
   590             if (attributes.getValue("type") == null) {
   603             if (attributes.getValue("type") == null) {
   591                 // skipping type="short" data
   604                 // skipping type="short" data
   592                 // for FormatData
   605                 // for FormatData
   593                 pushContainer(qName, attributes);
   606                 pushContainer(qName, attributes);
   594             } else {
   607             } else {
   595                 pushIgnoredContainer(qName);
   608                 pushIgnoredContainer(qName);
   596             }
   609             }
   597             break;
   610             break;
   598         case "currencyFormat":
   611         case "currencyFormat":
       
   612             {
       
   613                 // for FormatData
       
   614                 // copy string for later assembly into NumberPatterns
       
   615                 String cfStyle = attributes.getValue("type");
       
   616                 if (cfStyle.equals("standard")) {
       
   617                     pushStringEntry(qName, attributes,
       
   618                         currentNumberingSystem + "NumberPatterns/currency");
       
   619                 } else if (cfStyle.equals("accounting")) {
       
   620                     pushStringEntry(qName, attributes,
       
   621                         currentNumberingSystem + "NumberPatterns/accounting");
       
   622                 } else {
       
   623                     pushIgnoredContainer(qName);
       
   624                 }
       
   625             }
       
   626             break;
       
   627         case "percentFormat":
   599             // for FormatData
   628             // for FormatData
   600             // copy string for later assembly into NumberPatterns
   629             // copy string for later assembly into NumberPatterns
   601             if (attributes.getValue("type").equals("standard")) {
   630             if (attributes.getValue("type").equals("standard")) {
   602             pushStringEntry(qName, attributes, "NumberPatterns/currency");
   631                 pushStringEntry(qName, attributes,
   603             } else {
   632                     currentNumberingSystem + "NumberPatterns/percent");
   604                 pushIgnoredContainer(qName);
       
   605             }
       
   606             break;
       
   607         case "percentFormat":
       
   608             // for FormatData
       
   609             // copy string for later assembly into NumberPatterns
       
   610             if (attributes.getValue("type").equals("standard")) {
       
   611             pushStringEntry(qName, attributes, "NumberPatterns/percent");
       
   612             } else {
   633             } else {
   613                 pushIgnoredContainer(qName);
   634                 pushIgnoredContainer(qName);
   614             }
   635             }
   615             break;
   636             break;
   616         case "defaultNumberingSystem":
   637         case "defaultNumberingSystem":
   634                 if (digits == null) {
   655                 if (digits == null) {
   635                     pushIgnoredContainer(qName);
   656                     pushIgnoredContainer(qName);
   636                     break;
   657                     break;
   637                 }
   658                 }
   638 
   659 
   639                 @SuppressWarnings("unchecked")
   660                 addNumberingScript(script);
   640                 List<String> numberingScripts = (List<String>) get("numberingScripts");
       
   641                 if (numberingScripts == null) {
       
   642                     numberingScripts = new ArrayList<>();
       
   643                     put("numberingScripts", numberingScripts);
       
   644                 }
       
   645                 numberingScripts.add(script);
       
   646                 put(currentNumberingSystem + "NumberElements/zero", digits.substring(0, 1));
   661                 put(currentNumberingSystem + "NumberElements/zero", digits.substring(0, 1));
   647                 pushContainer(qName, attributes);
   662                 pushContainer(qName, attributes);
   648             }
   663             }
   649             break;
   664             break;
   650         case "decimal":
   665         case "decimal":
  1011             putIfEntry();
  1026             putIfEntry();
  1012             break;
  1027             break;
  1013         case "decimalFormatLength":
  1028         case "decimalFormatLength":
  1014             currentStyle = "";
  1029             currentStyle = "";
  1015             compactCount = "";
  1030             compactCount = "";
       
  1031             putIfEntry();
       
  1032             break;
       
  1033         case "currencyFormats":
       
  1034         case "decimalFormats":
       
  1035         case "percentFormats":
       
  1036         case "symbols":
       
  1037             currentNumberingSystem = "";
  1016             putIfEntry();
  1038             putIfEntry();
  1017             break;
  1039             break;
  1018         default:
  1040         default:
  1019             putIfEntry();
  1041             putIfEntry();
  1020         }
  1042         }
  1079                 return "tz";
  1101                 return "tz";
  1080             default:
  1102             default:
  1081                 return key;
  1103                 return key;
  1082         }
  1104         }
  1083     }
  1105     }
       
  1106 
       
  1107     private void addNumberingScript(String script) {
       
  1108         @SuppressWarnings("unchecked")
       
  1109         List<String> numberingScripts = (List<String>) get("numberingScripts");
       
  1110         if (numberingScripts == null) {
       
  1111             numberingScripts = new ArrayList<>();
       
  1112             put("numberingScripts", numberingScripts);
       
  1113         }
       
  1114         if (!numberingScripts.contains(script)) {
       
  1115             numberingScripts.add(script);
       
  1116         }
       
  1117     }
  1084 }
  1118 }