/** * Gets the default {@link PropertiesParserRegistry}. * * @return The default registry. */ public static synchronized PropertiesParserRegistry getInstance() { if (defaultRegistry == null) { defaultRegistry = new PropertiesParserRegistry(); } return defaultRegistry; }
@Override protected PropertiesFormat getKey(final PropertiesWriterFactory factory) { return factory.getRDFFormat(); } }
@Override protected PropertiesFormat getKey(PropertiesParserFactory factory) { return factory.getFormat(); } }
resp.setContentType(format.getDefaultMIMEType()); .getInstance().get(format).getWriter(os); writer.write(properties); os.flush(); } finally {
/** * Tries to determine the appropriate file format based on the a MIME * type that describes the content type. * * @param mimeType * A MIME type, e.g. "text/html". * @return An {@link PropertiesFormat} object if the MIME type was recognized, or * <tt>null</tt> otherwise. * @see #forMIMEType(String,PropertiesFormat) * @see #getMIMETypes() */ public static PropertiesFormat forMIMEType(final String mimeType) { return forMIMEType(mimeType, null); }
@Override public Properties parse(final Reader reader) throws IOException { final InputStream in = new ReaderInputStream(reader, getFormat() .getCharset()); try { final Properties p = new Properties(); p.loadFromXML(in); return p; } finally { in.close(); } }
/** * Creates a new {@link PropertiesTextWriter} that will write to the supplied * {@link Writer}. * * @param writer * The {@link Writer} to write the {@link Properties} document * to. */ public PropertiesTextWriter(final Writer writer) { this.os = new WriterOutputStream(writer, PropertiesFormat.TEXT.getCharset()); }
/** * Gets the default {@link PropertiesWriterRegistry}. * * @return The default registry. */ public static synchronized PropertiesWriterRegistry getInstance() { if (defaultRegistry == null) { defaultRegistry = new PropertiesWriterRegistry(); } return defaultRegistry; }
/** * Tries to determine the appropriate file format based on the a MIME * type that describes the content type. The supplied fallback format will be * returned when the MIME type was not recognized. * * @param mimeType * A file name. * @return An {@link PropertiesFormat} that matches the MIME type, or the fallback format if * the extension was not recognized. * @see #forMIMEType(String) * @see #getMIMETypes() */ public static PropertiesFormat forMIMEType(String mimeType, PropertiesFormat fallback) { return matchMIMEType(mimeType, formats/* Iterable<FileFormat> */, fallback); }
resp.setContentType(format.getDefaultMIMEType()); .getInstance().get(format).getWriter(os); writer.write(properties); os.flush(); } finally {
/** * Tries to determine the appropriate file format based on the a MIME * type that describes the content type. * * @param mimeType * A MIME type, e.g. "text/html". * @return An {@link PropertiesFormat} object if the MIME type was recognized, or * <tt>null</tt> otherwise. * @see #forMIMEType(String,PropertiesFormat) * @see #getMIMETypes() */ public static PropertiesFormat forMIMEType(final String mimeType) { return forMIMEType(mimeType, null); }
@Override public Properties parse(final Reader reader) throws IOException { final InputStream in = new ReaderInputStream(reader, getFormat() .getCharset()); try { final Properties p = new Properties(); p.loadFromXML(in); return p; } finally { in.close(); } }
/** * Creates a new {@link PropertiesXMLWriter} that will write to the supplied * {@link Writer}. * * @param writer * The {@link Writer} to write the {@link Properties} document * to. */ public PropertiesXMLWriter(final Writer writer) { this.os = new WriterOutputStream(writer, PropertiesFormat.XML.getCharset()); }
/** * Gets the default {@link PropertiesParserRegistry}. * * @return The default registry. */ public static synchronized PropertiesParserRegistry getInstance() { if (defaultRegistry == null) { defaultRegistry = new PropertiesParserRegistry(); } return defaultRegistry; }
@Override protected PropertiesFormat getKey(final PropertiesWriterFactory factory) { return factory.getRDFFormat(); } }
@Override protected PropertiesFormat getKey(PropertiesParserFactory factory) { return factory.getFormat(); } }
/** * Gets the default {@link PropertiesWriterRegistry}. * * @return The default registry. */ public static synchronized PropertiesWriterRegistry getInstance() { if (defaultRegistry == null) { defaultRegistry = new PropertiesWriterRegistry(); } return defaultRegistry; }
/** * Tries to determine the appropriate file format based on the a MIME * type that describes the content type. The supplied fallback format will be * returned when the MIME type was not recognized. * * @param mimeType * A file name. * @return An {@link PropertiesFormat} that matches the MIME type, or the fallback format if * the extension was not recognized. * @see #forMIMEType(String) * @see #getMIMETypes() */ public static PropertiesFormat forMIMEType(String mimeType, PropertiesFormat fallback) { return matchMIMEType(mimeType, formats/* Iterable<FileFormat> */, fallback); }
/** * Creates a new {@link PropertiesXMLWriter} that will write to the supplied * {@link Writer}. * * @param writer * The {@link Writer} to write the {@link Properties} document * to. */ public PropertiesXMLWriter(final Writer writer) { this.os = new WriterOutputStream(writer, PropertiesFormat.XML.getCharset()); }
/** * Creates a new {@link PropertiesTextWriter} that will write to the supplied * {@link Writer}. * * @param writer * The {@link Writer} to write the {@link Properties} document * to. */ public PropertiesTextWriter(final Writer writer) { this.os = new WriterOutputStream(writer, PropertiesFormat.TEXT.getCharset()); }