com.github.bloodshura.ignitium.cfg.i18n.TranslationUnit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ignitium-cfg Show documentation
Show all versions of ignitium-cfg Show documentation
A collection of configuration and serialization readers and writers, like JSON, internationalization (I18n), and CSV.
package com.github.bloodshura.ignitium.cfg.i18n;
import com.github.bloodshura.ignitium.cfg.props.Properties;
import com.github.bloodshura.ignitium.collection.tuple.Pair;
import com.github.bloodshura.ignitium.resource.Resource;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.io.InputStream;
public class TranslationUnit implements Resource {
private final Dictionary dictionary;
private final Language language;
private boolean loaded;
private final Resource resource;
public TranslationUnit(@Nonnull Language language, @Nonnull Resource resource) {
this.dictionary = new Dictionary<>();
this.language = language;
this.resource = resource;
}
@Nonnull
public Dictionary getDictionary() {
return dictionary;
}
@Nonnull
public Language getLanguage() {
return language;
}
@Nonnull
public Resource getResource() {
return resource;
}
public boolean isLoaded() {
return loaded;
}
public void load() throws IOException {
Properties properties = new Properties();
properties.load(this);
getDictionary().clear();
for (Pair pair : properties) {
getDictionary().set(pair.getLeft(), pair.getRight().toString());
}
this.loaded = true;
}
@Nonnull
@Override
public InputStream newInputStream() throws IOException {
return getResource().newInputStream();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy