Package net.sourceforge.yagsbook.encyclopedia.indexing

Examples of net.sourceforge.yagsbook.encyclopedia.indexing.Reference


            String      uri = e.getUri();
            set.add(uri);
        }

        while (links.hasNext()) {
            Reference   reference = (Reference)links.next();
            String      uri = reference.getUri();
            if (!set.contains(uri)) {
                String  warning = entry.getSubject().getUri() + " references <i>"+uri+"</i>";
                missing.add(warning);
            }
        }
View Full Code Here


                    Node    node = list.item(i);

                    String  uri = getTextNode(node, "@uri");
                    String  name = getTextNode(node);

                    references.add(new Reference(uri, name, true));
                }

                // Now add all soft refereces (those in the article body).
                list = getNodeList("/article/body//qv");
                for (int i=0; i < list.getLength(); i++) {
                    Node    node = list.item(i);

                    String  uri = getTextNode(node, "@uri");
                    String  name = getTextNode(node);

                    references.add(new Reference(uri, name, false));
                }
            } catch (XMLException e) {
            }

            return references;
View Full Code Here

       
        MockArticle     mock = new MockArticle();
       
        Reference[]     hard = new Reference[HARD];
        for (int i=0; i < HARD; i++) {
            hard[i] = new Reference("hard-"+URI+i, NAME+i, true);
        }
        mock.setReferences(hard);
        Reference[]     soft = new Reference[HARD];
        for (int i=0; i < SOFT; i++) {
            soft[i] = new Reference("hard-"+URI+i, NAME+i, false);
        }
       
        StringBuffer    body = new StringBuffer();
        body.append("<sect1><title>Reference test</title>");
        for (int i=0; i < SOFT; i++) {
            body.append("<para>This is a ");
            body.append("<qv uri=\""+soft[i].getUri()+"\">");
            body.append(soft[i].getName()+"</qv>");
            body.append("</para>");
        }
        body.append("</sect1>");
        mock.setBody(body.toString());
       
        try {
            Article     article = new Article("test", mock.toXML());
            Iterator    iter = article.getReferences();
           
            if (!iter.hasNext()) {
                fail("Did not find any references");
            }
           
            for (int i = 0; i < HARD; i++) {
                if (!iter.hasNext()) {
                    fail("Failed to find all hard references");
                }
                Reference   reference = (Reference) iter.next();
               
                assertEquals("Hard reference uri "+i+" was wrong",
                             hard[i].getUri(), reference.getUri());
                assertEquals("Hard reference name "+i+" was wrong",
                             hard[i].getName(), reference.getName());
                assertEquals("Hard reference uri "+i+" was soft",
                             true, reference.isHard());
            }
           
            if (!iter.hasNext()) {
                fail("Did not find any soft references");
            }
            for (int i = 0; i < SOFT; i++) {
                if (!iter.hasNext()) {
                    fail("Failed to find all soft references");
                }
                Reference   reference = (Reference) iter.next();
               
                assertEquals("Soft reference uri "+i+" was wrong",
                             soft[i].getUri(), reference.getUri());
                assertEquals("Soft reference name "+i+" was wrong",
                             soft[i].getName(), reference.getName());
                assertEquals("Soft reference uri "+i+" was hard",
                             false, reference.isHard());
            }
            if (iter.hasNext()) {
                fail("Too many references returned");
            }
        } catch (IOException e) {
View Full Code Here

TOP

Related Classes of net.sourceforge.yagsbook.encyclopedia.indexing.Reference

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.