Package org.openbel.framework.core.indexer

Examples of org.openbel.framework.core.indexer.JDBMNamespaceLookup


        if (resourceLocation == null) {
            throw new InvalidArgument("resourceLocation", resourceLocation);
        }

        // get opened namespace and lookup namespace parameter encoding
        JDBMNamespaceLookup il = openNamespaces.get(ns.getResourceLocation());
        if (il == null) {
            final String fmt = "Namespace '%s' is not open.";
            final String msg = String.format(fmt, resourceLocation);
            throw new IndexingFailure(resourceLocation, msg);
        }

        String encoding = il.lookup(p.getValue());

        if (encoding == null) {
            String rl = ns.getResourceLocation();
            String pref = ns.getPrefix();
            throw new NamespaceSyntaxWarning(rl, pref, p.getValue());
View Full Code Here


     * @param pattern {@link Pattern}, can not be null
     * @return {@link Set} of {@link String}s containing values that match
     */
    private Set<String> doSearch(String resourceLocation, Pattern pattern) {
        // get opened namespace
        JDBMNamespaceLookup il = openNamespaces.get(resourceLocation);

        Set<String> results = new HashSet<String>();
        for (String value : il.getKeySet()) {
            if (pattern.matcher(value).matches()) {
                results.add(value);
            }
        }

View Full Code Here

        if (resourceLocation == null) {
            throw new InvalidArgument("resourceLocation", resourceLocation);
        }

        // get opened namespace and lookup namespace parameter encoding
        JDBMNamespaceLookup il = openNamespaces.get(ns.getResourceLocation());
        if (il == null) {
            throw new IllegalStateException("namespace index is not open.");
        }

        String encoding = il.lookup(p.getValue());
        if (encoding == null) {
            throw new NamespaceSyntaxWarning(ns.getResourceLocation(),
                    ns.getPrefix(),
                    p.getValue());
        }
View Full Code Here

            String indexPath = asPath(
                    cachedResource.getLocalFile().getAbsolutePath(),
                    NS_INDEX_FILE_NAME);

            JDBMNamespaceLookup il = new JDBMNamespaceLookup(indexPath);
            try {
                il.open();
                il.close();
            } catch (IOException e) {
                return false;
            }

            return true;
View Full Code Here

            throw new IllegalStateException("namespace " + resourceLocation
                    + " is already open.");
        }

        synchronized (resourceLocation) {
            JDBMNamespaceLookup il = new JDBMNamespaceLookup(indexPath);
            try {
                il.open();
            } catch (IOException e) {
                final String fmt = "Failed to open namespace '%s'.";
                final String msg = String.format(fmt, resourceLocation);
                throw new IndexingFailure(resourceLocation, msg, e);
            }
View Full Code Here

    }

    private void closeNamespace(final String resourceLocation)
            throws IndexingFailure {
        synchronized (resourceLocation) {
            JDBMNamespaceLookup jdbmlookup =
                    openNamespaces.get(resourceLocation);
            if (jdbmlookup != null) {
                try {
                    jdbmlookup.close();
                    openNamespaces.remove(resourceLocation);
                } catch (IOException e) {
                    final String fmt = "Failed to close namespace '%s'.";
                    final String msg = String.format(fmt, resourceLocation);
                    throw new IndexingFailure(resourceLocation, msg, e);
View Full Code Here

    }

    @Test
    public void testLookupSuccess() {
        try {
            JDBMNamespaceLookup jdbmLookup =
                    new JDBMNamespaceLookup(indexPath.getAbsolutePath());
            jdbmLookup.open();

            assertEquals(1, jdbmLookup.getRecordCount());
            assertEquals(value, jdbmLookup.lookup("1"));

            jdbmLookup.close();
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
    }
View Full Code Here

    }

    @Test
    public void testLookupFailure() {
        try {
            JDBMNamespaceLookup jdbmLookup =
                    new JDBMNamespaceLookup(indexPath.getAbsolutePath());
            jdbmLookup.open();

            assertEquals(1, jdbmLookup.getRecordCount());
            assertNull(jdbmLookup.lookup("0"));

            jdbmLookup.close();
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
    }
View Full Code Here

    }

    @Test
    public void testInverseLookupSuccess() {
        try {
            JDBMNamespaceLookup jdbmLookup =
                    new JDBMNamespaceLookup(indexPath.getAbsolutePath());
            jdbmLookup.open();

            assertEquals(1, jdbmLookup.getRecordCount());
            assertEquals(key, jdbmLookup.reverseLookup(value));

            jdbmLookup.close();
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
    }
View Full Code Here

    }

    @Test
    public void testInverseLookupFailure() {
        try {
            JDBMNamespaceLookup jdbmLookup =
                    new JDBMNamespaceLookup(indexPath.getAbsolutePath());
            jdbmLookup.open();

            assertEquals(1, jdbmLookup.getRecordCount());
            assertNull(jdbmLookup.reverseLookup("0"));

            jdbmLookup.close();
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
    }
View Full Code Here

TOP

Related Classes of org.openbel.framework.core.indexer.JDBMNamespaceLookup

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.