Package org.apache.stanbol.commons.namespaceprefix

Examples of org.apache.stanbol.commons.namespaceprefix.NamespacePrefixProvider


        super.finalize();
    }
   
    @Override
    public String getNamespace(String prefix) {
        NamespacePrefixProvider npp = cache;
        return npp == null ? null : npp.getNamespace(prefix);
    }
View Full Code Here


        return npp == null ? null : npp.getNamespace(prefix);
    }
   
    @Override
    public String getPrefix(String namespace) {
        NamespacePrefixProvider npp = cache;
        return npp == null ? null : npp.getPrefix(namespace);
    }
View Full Code Here

        NamespacePrefixProvider npp = cache;
        return npp == null ? null : npp.getPrefix(namespace);
    }
    @Override
    public List<String> getPrefixes(String namespace) {
        NamespacePrefixProvider npp = cache;
        return npp == null ? null : npp.getPrefixes(namespace);
    }
View Full Code Here

        Assert.assertTrue(mappingFile.isFile());
    }

    @Test
    public void testReadingFromFile() throws IOException {
        NamespacePrefixProvider provider = new NamespacePrefixProviderImpl(
            new FileInputStream(mappingFile));
        //this tests the namespaces defined in namespaceprefix.mappings file
        Assert.assertEquals("http://www.example.org/test#", provider.getNamespace("test"));
        Assert.assertEquals("http://www.example.org/test-1/",provider.getNamespace("test-1"));
        Assert.assertEquals("urn:example.text:",provider.getNamespace("urn_test"));
        List<String> prefixes = provider.getPrefixes("http://www.example.org/test#");
        Assert.assertEquals(2, prefixes.size());
        Assert.assertEquals("test",prefixes.get(0));
        Assert.assertEquals("test2",prefixes.get(1));
        Assert.assertEquals("http://www.example.org/test#", provider.getNamespace("test"));
        Assert.assertEquals("http://www.example.org/test#", provider.getNamespace("test2"));
    }
View Full Code Here

        mappings.put("test2","http://www.example.org/test#");
        //add some invalid mappings
        mappings.put("test:3","http://www.example.org/test#");
        mappings.put("test3","http://www.example.org/test");
       
        NamespacePrefixProvider provider = new NamespacePrefixProviderImpl(mappings);
        //this tests the namespaces defined in namespaceprefix.mappings file
        Assert.assertEquals("http://www.example.org/test#", provider.getNamespace("test"));
        Assert.assertEquals("http://www.example.org/test-1/",provider.getNamespace("test-1"));
        Assert.assertEquals("urn:example.text:",provider.getNamespace("urn_test"));
        List<String> prefixes = provider.getPrefixes("http://www.example.org/test#");
        Assert.assertEquals(2, prefixes.size());
        Assert.assertEquals("test",prefixes.get(0));
        Assert.assertEquals("test2",prefixes.get(1));
        Assert.assertEquals("http://www.example.org/test#", provider.getNamespace("test"));
        Assert.assertEquals("http://www.example.org/test#", provider.getNamespace("test2"));
       
        //test that illegal mappings are not imported
        Assert.assertNull(provider.getNamespace("test:3"));
        Assert.assertNull(provider.getNamespace("test3"));
       
    }
View Full Code Here

            mappingsLock.readLock().unlock();
        }
        if(namespace == null){
            ServiceReference[] refs = getSortedProviderReferences();
            for(int i=0;namespace == null && i<refs.length;i++){
                NamespacePrefixProvider provider = getService(refs[i]);
                if(provider != null){
                    namespace = provider.getNamespace(prefix);
                }
            }
        }
        return namespace;
    }
View Full Code Here

            mappingsLock.readLock().unlock();
        }
        if(prefixes == null){
            ServiceReference[] refs = getSortedProviderReferences();
            for(int i=0;prefixes == null && i<refs.length;i++){
                NamespacePrefixProvider provider = getService(refs[i]);
                if(provider != null){
                    prefixes = provider.getPrefixes(namespace);
                }
            }
        }
        return prefixes == null ? Collections.EMPTY_LIST:prefixes;
    }
View Full Code Here

        super.finalize();
    }
   
    @Override
    public String getNamespace(String prefix) {
        NamespacePrefixProvider npp = cache;
        return npp == null ? null : npp.getNamespace(prefix);
    }
View Full Code Here

        return npp == null ? null : npp.getNamespace(prefix);
    }
   
    @Override
    public String getPrefix(String namespace) {
        NamespacePrefixProvider npp = cache;
        return npp == null ? null : npp.getPrefix(namespace);
    }
View Full Code Here

        NamespacePrefixProvider npp = cache;
        return npp == null ? null : npp.getPrefix(namespace);
    }
    @Override
    public List<String> getPrefixes(String namespace) {
        NamespacePrefixProvider npp = cache;
        return npp == null ? null : npp.getPrefixes(namespace);
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.commons.namespaceprefix.NamespacePrefixProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.