protected int buildProtoNetwork(ProtoNetwork pn,
            Statement statement, Map<String, Annotation> annotationMap) {
        // build new list of annotations from statement group + individual
        // statement
        Map<String, Annotation> localAnnotationMap =
                new HashMap<String, Annotation>(
                        annotationMap);
        handleAnnotationGroup(pn, localAnnotationMap,
                statement.getAnnotationGroup());

        // assembly annotation definitions and values up to this point
        Set<AnnotationPair> annotationPairs = buildAnnotationPairs(
                pn, localAnnotationMap);

        // handle statement subject and object
        int subjectTerm = buildProtoNetwork(pn, statement.getSubject());

        // compiling only one document, so index is 0
        final int did = 0;
        final int sid;
        final StatementTable st = pn.getStatementTable();

        if (statement.getObject() == null) {
            // definitional statement
            sid =
                    st.addStatement(new TableStatement(subjectTerm), statement,
                            did);
        } else if (statement.getObject().getStatement() == null) {
            // simple statement
            int objectTerm = buildProtoNetwork(pn, statement.getObject()
                    .getTerm());
            sid = st.addStatement(new TableStatement(subjectTerm, statement
                    .getRelationshipType().getDisplayValue(),
                    objectTerm), statement, did);
        } else {
            // nested statement
            final Statement nested = statement.getObject().getStatement();
            int nestedSubject = buildProtoNetwork(pn, nested.getSubject());
            int nestedObject = buildProtoNetwork(pn, nested.getObject()
                    .getTerm());
            sid = st.addStatement(
                    new TableStatement(subjectTerm, statement
                            .getRelationshipType().getDisplayValue(),
                            nestedSubject, nested.getRelationshipType()
                                    .getDisplayValue(), nestedObject),
                    statement, did);
        }

        // associate annotations to new statement
        StatementAnnotationMapTable samt = pn.getStatementAnnotationMapTable();
        if (hasItems(annotationPairs)) {
            samt.addStatementAnnotation(sid, annotationPairs);
        }

        return sid;
    }
protected int buildProtoNetwork ( ProtoNetwork pn , Statement statement , Map < String , Annotation > annotationMap ) { Map < String , Annotation > localAnnotationMap = new HashMap < String , Annotation > ( annotationMap ) ; handleAnnotationGroup ( pn , localAnnotationMap , statement . getAnnotationGroup ( ) ) ; Set < AnnotationPair > annotationPairs = buildAnnotationPairs ( pn , localAnnotationMap ) ; int subjectTerm = buildProtoNetwork ( pn , statement . getSubject ( ) ) ; final int did = 0 ; final int sid ; final StatementTable st = pn . getStatementTable ( ) ; if ( statement . getObject ( ) == null ) { sid = st . addStatement ( new TableStatement ( subjectTerm ) , statement , did ) ; } else if ( statement . getObject ( ) . getStatement ( ) == null ) { int objectTerm = buildProtoNetwork ( pn , statement . getObject ( ) . getTerm ( ) ) ; sid = st . addStatement ( new TableStatement ( subjectTerm , statement . getRelationshipType ( ) . getDisplayValue ( ) , objectTerm ) , statement , did ) ; } else { final Statement nested = statement . getObject ( ) . getStatement ( ) ; int nestedSubject = buildProtoNetwork ( pn , nested . getSubject ( ) ) ; int nestedObject = buildProtoNetwork ( pn , nested . getObject ( ) . getTerm ( ) ) ; sid = st . addStatement ( new TableStatement ( subjectTerm , statement . getRelationshipType ( ) . getDisplayValue ( ) , nestedSubject , nested . getRelationshipType ( ) . getDisplayValue ( ) , nestedObject ) , statement , did ) ; } StatementAnnotationMapTable samt = pn . getStatementAnnotationMapTable ( ) ; if ( hasItems ( annotationPairs ) ) { samt . addStatementAnnotation ( sid , annotationPairs ) ; } return sid ; }
Builds the {@link ProtoNetwork} at the {@link Statement} level.

@param pn {@link ProtoNetwork}, the proto network
@param statement {@link Statement}, the statement to evaluate
@param annotationMap {@link Map}, the parent statement group annotations
accumulated to this point
@return {@code int[]}, the statement indexes in the
{@link StatementTable}