class AmdJsResource extends ResourceFilter {

    @Override
    public void write(OutputStream outStream, LanguageBundle languageBundle,
            FilterOptions options) throws IOException, ResourceFilterException {
        try (OutputStreamWriter writer = new OutputStreamWriter(new BufferedOutputStream(outStream), StandardCharsets.UTF_8)) {
            writer.write("define({\n");
            boolean first = true;
            final Character quote = '"';
            for (ResourceString res : languageBundle.getSortedResourceStrings()) {
                if (first) {
                    first = false;
                } else {
                    writer.write(",\n");
                }
                writer.write(quote + escapeString(res.getKey(), quote) + quote + ": ");
                writer.write(quote + escapeString(res.getValue(), quote) + quote);
            }
            writer.write("\n});\n");
        }
    }

}