Parser createSld11Parser( Object input, ResourceLocator resourceLocator, EntityResolver entityResolver) { if (resourceLocator == null && input instanceof File) { // setup for resolution of relative paths final java.net.URL surl = URLs.fileToUrl((File) input); DefaultResourceLocator defResourceLocator = new DefaultResourceLocator(); defResourceLocator.setSourceUrl(surl); resourceLocator = defResourceLocator; } final ResourceLocator locator = resourceLocator; SLDConfiguration sld; if (locator != null) { sld = new SLDConfiguration() { protected void configureContext( org.picocontainer.MutablePicoContainer container) { container.registerComponentInstance(ResourceLocator.class, locator); }; }; } else { sld = new SLDConfiguration(); } Parser parser = new Parser(sld); if (entityResolver != null) { parser.setEntityResolver(entityResolver); } return parser; }
public SLDParser(StyleFactory factory, FilterFactory filterFactory) { this.factory = factory; this.ff = filterFactory; this.onlineResourceLocator = new DefaultResourceLocator(); }
@Test public void testParseStyleTwiceLock() throws Exception { StyleInfo style = getCatalog().getStyles().get(0); FileSystemResourceStore store = (FileSystemResourceStore) getDataDirectory().getResourceStore(); store.setLockProvider(new MemoryLockProvider()); // parse twice to check we are not locking on it Resource resource = getDataDirectory().style(style); Styles.handler(style.getFormat()) .parse(resource, style.getFormatVersion(), new DefaultResourceLocator(), null); Styles.handler(style.getFormat()) .parse(resource, style.getFormatVersion(), new DefaultResourceLocator(), null); }
@Override protected void configureContext(MutablePicoContainer container) { super.configureContext(container); container.registerComponentImplementation(StyleFactory.class, StyleFactoryImpl.class); container.registerComponentInstance(ResourceLocator.class, new DefaultResourceLocator()); }
/** * Configures the sld context. * * <p>The following factories are registered: * * <ul> * <li>{@link StyleFactoryImpl} under {@link StyleFactory} * </ul> */ protected void configureContext(MutablePicoContainer container) { super.configureContext(container); container.registerComponentImplementation(StyleFactory.class, StyleFactoryImpl.class); container.registerComponentInstance(ResourceLocator.class, new DefaultResourceLocator()); }
protected void configureContext( org.picocontainer.MutablePicoContainer container) { DefaultResourceLocator locator = new DefaultResourceLocator(); locator.setSourceUrl(surl); container.registerComponentInstance(ResourceLocator.class, locator); }; };
public void testPreserveURLQueryWithColors() throws Exception { DefaultResourceLocator locator = new DefaultResourceLocator(); locator.setSourceUrl(getClass().getResource("test-data/blob.gif")); // Confirm still able to resolve to a File URL url = locator.locateResource("blob.gif?fill=#ff0000&stroke=#000000"); final String external = url.toExternalForm(); assertTrue(external.indexOf('?') > 0); assertEquals("fill=#ff0000&stroke=#000000", external.split("\\?")[1]); File file = URLs.urlToFile(url); assertTrue(file.exists()); }
public void testPreserveURLQuery() throws Exception { DefaultResourceLocator locator = new DefaultResourceLocator(); locator.setSourceUrl(getClass().getResource("test-data/blob.gif")); // Confirm still able to resolve to a File URL url = locator.locateResource("blob.gif?query=parameter"); assertEquals("query=parameter", url.getQuery()); File file = URLs.urlToFile(url); assertTrue(file.exists()); }
public void testInvalidPath() throws Exception { DefaultResourceLocator locator = new DefaultResourceLocator(); URL testURL = new URL(
public SLDParser(StyleFactory factory, FilterFactory filterFactory) { this.factory = factory; this.ff = filterFactory; this.onlineResourceLocator = new DefaultResourceLocator(); }
public void testRelativeFileURL() throws Exception { DefaultResourceLocator locator = new DefaultResourceLocator(); locator.setSourceUrl(getClass().getResource("test-data/blob.gif")); checkURL(locator.locateResource("blob.gif")); checkURL(locator.locateResource("file:blob.gif")); checkURL(locator.locateResource("file://blob.gif")); checkURL(locator.locateResource("file://./blob.gif")); }
/** * Sets the resource locator so that relative external graphic files can be found. * * @param styleReader the new resource locator * @param url the url */ public static void setResourcelocator(SLDParser styleReader, URL url) { DefaultResourceLocator resourceLocator = new DefaultResourceLocator(); resourceLocator.setSourceUrl(url); styleReader.setOnLineResourceLocator(resourceLocator); }
@Override public StyledLayerDescriptor parse(Object input, Version version, @Nullable ResourceLocator resourceLocator, EntityResolver entityResolver) throws IOException { if (resourceLocator == null && input instanceof File) { resourceLocator = new DefaultResourceLocator(); ((DefaultResourceLocator)resourceLocator).setSourceUrl(DataUtilities.fileToURL((File) input)); } return Ysld.parse(toReader(input), Collections.singletonList(zoomFinder), resourceLocator, uomMapper); }
@Override protected void configureContext(MutablePicoContainer container) { super.configureContext(container); container.registerComponentImplementation(StyleFactory.class, StyleFactoryImpl.class); container.registerComponentInstance(ResourceLocator.class, new DefaultResourceLocator()); }
/** * Configures the sld context. * <p> * The following factories are registered: * <ul> * <li>{@link StyleFactoryImpl.class} under {@link StyleFactory.class} * </ul> * </p> */ protected void configureContext(MutablePicoContainer container) { super.configureContext(container); container.registerComponentImplementation(StyleFactory.class, StyleFactoryImpl.class); container.registerComponentInstance(ResourceLocator.class, new DefaultResourceLocator()); }
private Parser createSld11Parser(Object input, ResourceLocator resourceLocator, EntityResolver entityResolver) { if (resourceLocator == null && input instanceof File) { // setup for resolution of relative paths final java.net.URL surl = DataUtilities.fileToURL((File) input); DefaultResourceLocator defResourceLocator = new DefaultResourceLocator(); defResourceLocator.setSourceUrl(surl); resourceLocator = defResourceLocator; } final ResourceLocator locator = resourceLocator; SLDConfiguration sld; if (locator != null) { sld = new SLDConfiguration() { protected void configureContext(org.picocontainer.MutablePicoContainer container) { container.registerComponentInstance(ResourceLocator.class, locator); } ; } ; } else { sld = new SLDConfiguration(); } Parser parser = new Parser(sld); if (entityResolver != null) { parser.setEntityResolver(entityResolver); } return parser; }