slieb.blendercss.utilities.CssRenameMapParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of blender-css Show documentation
Show all versions of blender-css Show documentation
BlenderCss provides a java toolset that compiles css from
different supersets of css together.
The newest version!
package slieb.blendercss.utilities;
import com.google.common.io.Files;
import com.google.inject.Inject;
import org.codehaus.jackson.map.ObjectMapper;
import javax.annotation.Nonnull;
import javax.inject.Singleton;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static java.nio.charset.Charset.defaultCharset;
@Singleton
public class CssRenameMapParser {
public final ObjectMapper objectMapper;
@Inject
public CssRenameMapParser(@Nonnull ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
private String getJsonContent(String content) {
return content.substring(content.indexOf('{'), content.lastIndexOf('}') + 1);
}
public void parse(String content, Map map) throws IOException {
map.putAll((Map) objectMapper.readValue(getJsonContent(content), HashMap.class));
}
public RenamingMap parse(String content) throws IOException {
RenamingMap map = new RenamingMap();
parse(content, map);
return map;
}
public RenamingMap parse(File file) throws IOException {
return parse(Files.toString(file, defaultCharset()));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy