protected ParseTemplate getCachedOrNewTemplate()

in java/main/src/main/java/com/epam/deltix/hdtime/Parsers.java [422:448]


        protected ParseTemplate getCachedOrNewTemplate(final String fmt, final HashMap<String, ParseTemplate> local) {
            ParseTemplate f;
            final HashMap<String, ParseTemplate> global = globalTemplateCache;
            // Try to find in the global formatter cache
            synchronized (global) {
                f = global.get(fmt);
            }

            if (null == f) {
                builder.clear();
                parseFormat(fmt);
                f = builder.get();
                synchronized (global) {
                    ParseTemplate tmp = global.get(fmt);
                    if (null == tmp)
                        global.put(fmt, f);
                    else
                        f = tmp;
                }

                assert (null != f);
            }

            // Copy the reference to local cache
            local.put(fmt, f);
            return f;
        }