// Path: retired/cldr-data/src/main/java/org/javamoney/data/AbstractXmlResourceLoaderListener.java
// public abstract class AbstractXmlResourceLoaderListener implements
//         LoaderListener {
// 
//     private DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
//             .newInstance();
// 
//     private Document document;
// 
//     /**
//      * Constructor.
//      */
//     public AbstractXmlResourceLoaderListener() {
//         docBuilderFactory.setIgnoringComments(true);
//         docBuilderFactory.setIgnoringElementContentWhitespace(true);
//         docBuilderFactory.setValidating(false);
//     }
// 
//     @Override
//     public void newDataLoaded(String dataId, InputStream is) {
//         try {
//             InputSource inputSource = new InputSource(is);
//             docBuilderFactory.setValidating(false);
//             DocumentBuilder builder = docBuilderFactory.newDocumentBuilder();
//             builder.setEntityResolver((publicId, systemId) -> new InputSource(new ByteArrayInputStream(
//                     "<?xml version='1.0' encoding='UTF-8'?>"
//                             .getBytes())));
//             document = builder.parse(inputSource);
//             document.normalize();
//             loadDocument(document);
//         } catch (Exception e) {
//             Logger.getLogger(getClass().getName()).log(Level.SEVERE,
//                     "Failed to parse resource " + dataId, e);
//         } finally {
//             if (is != null) {
//                 try {
//                     is.close();
//                 } catch (Exception e) {
//                     Logger.getLogger(getClass().getName()).log(Level.SEVERE,
//                             "Error closing input stream from " + dataId, e);
//                 }
//             }
//         }
//     }
// 
//     /**
//      * Access the underlying XML document, last read.
//      *
//      * @return the underlying document.
//      */
//     public Document getDocument() {
//         return this.document;
//     }
// 
//     /**
//      * Method to be implemented to load the document data.
//      *
//      * @param document the document, not null.
//      */
//     protected abstract void loadDocument(Document document);
// 
// }


import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.money.spi.Bootstrap;
import org.javamoney.moneta.spi.LoaderService;
import org.javamoney.moneta.spi.LoaderService.UpdatePolicy;
import org.javamoney.data.AbstractXmlResourceLoaderListener;
/*
 *  Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.javamoney.data.icu4j;





public final class CLDRTranslations {

    private static final CLDRTranslations INSTANCE = new CLDRTranslations();

    private Map<String, LanguageTranslations> translations = new ConcurrentHashMap<>();

    private CLDRTranslations() {
    }

    // @Produces
    public static CLDRTranslations getInstance() {
        return INSTANCE;
    }

    public static LanguageTranslations getInstance(String language) {
        LanguageTranslations transl = INSTANCE.translations.get(language);
        if (transl == null) {
            try {
                transl = new LanguageTranslations(language);
            } catch (Exception e) {
                throw new IllegalArgumentException("Unsupported language.", e);
            }
            INSTANCE.translations.put(language, transl);
        }
        return transl;
    }

    public static LanguageTranslations getInstance(Locale locale) {
        return getInstance(locale.getLanguage());
    }

    public static final class LanguageTranslations extends
// Path: retired/cldr-data/src/main/java/org/javamoney/data/AbstractXmlResourceLoaderListener.java
// public abstract class AbstractXmlResourceLoaderListener implements
//         LoaderListener {
// 
//     private DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
//             .newInstance();
// 
//     private Document document;
// 
//     /**
//      * Constructor.
//      */
//     public AbstractXmlResourceLoaderListener() {
//         docBuilderFactory.setIgnoringComments(true);
//         docBuilderFactory.setIgnoringElementContentWhitespace(true);
//         docBuilderFactory.setValidating(false);
//     }
// 
//     @Override
//     public void newDataLoaded(String dataId, InputStream is) {
//         try {
//             InputSource inputSource = new InputSource(is);
//             docBuilderFactory.setValidating(false);
//             DocumentBuilder builder = docBuilderFactory.newDocumentBuilder();
//             builder.setEntityResolver((publicId, systemId) -> new InputSource(new ByteArrayInputStream(
//                     "<?xml version='1.0' encoding='UTF-8'?>"
//                             .getBytes())));
//             document = builder.parse(inputSource);
//             document.normalize();
//             loadDocument(document);
//         } catch (Exception e) {
//             Logger.getLogger(getClass().getName()).log(Level.SEVERE,
//                     "Failed to parse resource " + dataId, e);
//         } finally {
//             if (is != null) {
//                 try {
//                     is.close();
//                 } catch (Exception e) {
//                     Logger.getLogger(getClass().getName()).log(Level.SEVERE,
//                             "Error closing input stream from " + dataId, e);
//                 }
//             }
//         }
//     }
// 
//     /**
//      * Access the underlying XML document, last read.
//      *
//      * @return the underlying document.
//      */
//     public Document getDocument() {
//         return this.document;
//     }
// 
//     /**
//      * Method to be implemented to load the document data.
//      *
//      * @param document the document, not null.
//      */
//     protected abstract void loadDocument(Document document);
// 
// }


// Path: retired/cldr-data/src/main/java/org/javamoney/data/icu4j/CLDRTranslations.java
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.money.spi.Bootstrap;
import org.javamoney.moneta.spi.LoaderService;
import org.javamoney.moneta.spi.LoaderService.UpdatePolicy;
import org.javamoney.data.AbstractXmlResourceLoaderListener;

/*
 *  Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.javamoney.data.icu4j;





public final class CLDRTranslations {

    private static final CLDRTranslations INSTANCE = new CLDRTranslations();

    private Map<String, LanguageTranslations> translations = new ConcurrentHashMap<>();

    private CLDRTranslations() {
    }

    // @Produces
    public static CLDRTranslations getInstance() {
        return INSTANCE;
    }

    public static LanguageTranslations getInstance(String language) {
        LanguageTranslations transl = INSTANCE.translations.get(language);
        if (transl == null) {
            try {
                transl = new LanguageTranslations(language);
            } catch (Exception e) {
                throw new IllegalArgumentException("Unsupported language.", e);
            }
            INSTANCE.translations.put(language, transl);
        }
        return transl;
    }

    public static LanguageTranslations getInstance(Locale locale) {
        return getInstance(locale.getLanguage());
    }

    public static final class LanguageTranslations extends
            AbstractXmlResourceLoaderListener {