@Override public Properties create() throws IOException { return new ContextPropertiesFactory(STTemplateWorker.class) .withProperties(getProperties()).fromResource(PROPERTIES_URL); }
private synchronized void loadProperties() { try { ContextPropertiesFactory p = new ContextPropertiesFactory(context) .withProperties(System.getProperties()); if (defaultProperties != null) { p.withDefaultProperties(defaultProperties); } properties = p.fromResource(resource); } catch (IOException e) { throw new ProvisionException(format(LOAD_MESSAGE, resource), e); } }
/** * Creates the converter with default properties. * * @param appendable * the {@link Appendable} to append the converted string. * * @return the {@link MapToTableString}. */ public static MapToTableString withDefaults(Appendable appendable) { try { return new MapToTableString( new ContextPropertiesFactory(MapToTableString.class) .fromResource(PROPERTIES_RESOURCE).withReplacements( System.getProperties()), appendable); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Loads the properties from a resource with a default character set. * * @param resource * the resource {@link URI}. * * @return the {@link ContextProperties}. * * @throws IOException * if there was an error loading the resource. */ public ContextProperties fromResource(URI resource) throws IOException { return fromResource(resource, DEFAULT_CHARSET); }
URL userResource = getUserResourceURL(fileKey, urlKey); return fromResource(userResource == null ? resource : userResource);
public ContextPropertiesFactory create(String context) { return new ContextPropertiesFactory(context); }
/** * Loads the properties from a resource with a specified character set. * * @param url * the resource {@link URL}. * * @param charset * the {@link Charset} of the resource. * * @return the {@link ContextProperties}. * * @throws IOException * if there was an error loading the resource. */ public ContextProperties fromResource(URL url, Charset charset) throws IOException { InputStream resource = new BufferedInputStream(url.openStream()); Properties properties = loadProperties(resource, charset); return new ContextProperties(context, properties); }
/** * Loads the properties from a resource with a default character set. * * @param resource * the resource {@link File}. * * @return the {@link ContextProperties}. * * @throws IOException * if there was an error loading the resource. */ public ContextProperties fromResource(File resource) throws IOException { return fromResource(resource, DEFAULT_CHARSET); }
public ContextPropertiesFactory create(Object context) { return new ContextPropertiesFactory(context); }
/** * Loads the properties from a resource with a specified character set. * * @param file * the resource {@link File}. * * @param charset * the {@link Charset} of the resource. * * @return the {@link ContextProperties}. * * @throws IOException * if there was an error loading the resource. * * @since 1.1 */ public ContextProperties fromResource(File file, Charset charset) throws IOException { FileInputStream resource = new FileInputStream(file); Properties properties = loadProperties(resource, charset); return new ContextProperties(context, properties); }
/** * Loads the properties from a resource with a default character set. * * @param resource * the resource {@link URL}. * * @return the {@link ContextProperties}. * * @throws IOException * if there was an error loading the resource. */ public ContextProperties fromResource(URL resource) throws IOException { return fromResource(resource, DEFAULT_CHARSET); }
public ContextPropertiesFactory create(Class<?> context) { return new ContextPropertiesFactory(context); }
/** * Loads the properties from a resource with a specified character set. * * @param resource * the resource {@link URI}. * * @param charset * the {@link Charset} of the resource. * * @return the {@link ContextProperties}. * * @throws IOException * if there was an error loading the resource. * * @since 1.1 */ public ContextProperties fromResource(URI resource, Charset charset) throws IOException { return fromResource(new File(resource), charset); }