public void simple3() {
        //the following line works inside process(Document, Arguments, Processing) in a DocumentProcessor
        AnnotationTypeRegistry atr = processing.getService().getDocumentTypeManager().getAnnotationTypeRegistry();

        StringFieldValue text = new StringFieldValue("<html><head><title>Diary</title></head><body>I live in San Francisco</body></html>");
                                                    //012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789

        SpanList root = new SpanList();
        SpanTree tree = new SpanTree("html", root);

        AnnotationType textType = atr.getType("text");
        AnnotationType beginTag = atr.getType("begintag");
        AnnotationType endTag = atr.getType("endtag");
        AnnotationType bodyType = atr.getType("body");
        AnnotationType headerType = atr.getType("header");

        SpanList header = new SpanList();
        {
            Span span1 = new Span(6, 6);
            Span span2 = new Span(12, 7);
            Span span3 = new Span(19, 5);
            Span span4 = new Span(24, 8);
            Span span5 = new Span(32, 7);
            header.add(span1)
                    .add(span2)
                    .add(span3)
                    .add(span4)
                    .add(span5);
            tree.annotate(span1, beginTag)
                    .annotate(span2, beginTag)
                    .annotate(span3, textType)
                    .annotate(span4, endTag)
                    .annotate(span5, endTag)
                    .annotate(header, headerType);
        }

        SpanList body = new SpanList();
        {
            Span span1 = new Span(39, 6);
            Span span2 = new Span(45, 23);
            Span span3 = new Span(68, 7);
            body.add(span1)
                    .add(span2)
                    .add(span3);
            tree.annotate(span1, beginTag)
                    .annotate(span2, textType)
                    .annotate(span3, endTag)
                    .annotate(body, bodyType);
        }

        {
            Span span1 = new Span(0, 6);
            Span span2 = new Span(75, 7);
            root.add(span1)
                    .add(header)
                    .add(body)
                    .add(span2);
            tree.annotate(span1, beginTag)
                    .annotate(span2, endTag);
        }

        text.setSpanTree(tree);
    }
Contains code snippets that are used in the documentation. Not really a test case.

@author Einar M R Rosenvinge
document/src/test/java/com/yahoo/document/annotation/DocTestCase.java