All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.plantuml.brotli.Dictionary Maven / Gradle / Ivy

There is a newer version: 1.2024.8
Show newest version
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.

package net.sourceforge.plantuml.brotli;

import java.nio.ByteBuffer;

/**
 * Collection of static dictionary words.
 *
 * 

* Dictionary content is loaded from binary resource when {@link #getData()} is * executed for the first time. Consequently, it saves memory and CPU in case * dictionary is not required. * *

* One possible drawback is that multiple threads that need dictionary data may * be blocked (only once in each classworld). To avoid this, it is enough to * call {@link #getData()} proactively. */ public final class Dictionary { private static volatile ByteBuffer data; private static class DataLoader { static final boolean OK; static { boolean ok = true; try { Class.forName(Dictionary.class.getPackage().getName() + ".DictionaryData"); } catch (Throwable ex) { ok = false; } OK = ok; } } public static void setData(ByteBuffer data) { if (!data.isDirect() || !data.isReadOnly()) { throw new BrotliRuntimeException("data must be a direct read-only byte buffer"); } Dictionary.data = data; } public static ByteBuffer getData() { if (data != null) { return data; } if (!DataLoader.OK) { throw new BrotliRuntimeException("brotli dictionary is not set"); } /* Might have been set when {@link DictionaryData} was loaded. */ return data; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy