protected String generateRelationshipText ( final RelationshipType relationshipType , boolean shortSyntax , final String spacer ) { final StringBuilder retValue ; final List < Relationship > relationships ; // Create the relationship heading if ( relationshipType == RelationshipType . REFER_TO ) { if ( shortSyntax ) { retValue = new StringBuilder ( " [R: " ) ; } else { retValue = new StringBuilder ( "\n" + spacer + "[Refer-to:" ) ; } relationships = getRelatedRelationships ( ) ; } else if ( relationshipType == RelationshipType . PREREQUISITE ) { if ( shortSyntax ) { retValue = new StringBuilder ( " [P: " ) ; } else { retValue = new StringBuilder ( "\n" + spacer + "[Prerequisite:" ) ; } relationships = getPrerequisiteRelationships ( ) ; } else if ( relationshipType == RelationshipType . LINKLIST ) { if ( shortSyntax ) { retValue = new StringBuilder ( " [L: " ) ; } else { retValue = new StringBuilder ( "\n" + spacer + "[Link-List:" ) ; } relationships = getLinkListRelationships ( ) ; } else { throw new IllegalArgumentException ( "Unable to create a text based formation for the " + relationshipType . toString ( ) + " " + "relationship type." ) ; } // Create the list of relationships if ( shortSyntax ) { final List < String > relatedIds = new ArrayList < String > ( ) ; for ( final Relationship related : relationships ) { relatedIds . add ( related . getSecondaryRelationshipId ( ) ) ; } retValue . append ( StringUtilities . buildString ( relatedIds . toArray ( new String [ relatedIds . size ( ) ] ) , ", " ) ) ; } else { boolean first = true ; for ( final Relationship related : relationships ) { if ( first ) { retValue . append ( "\n" ) ; first = false ; } else { retValue . append ( ",\n" ) ; } retValue . append ( spacer ) ; retValue . append ( SPACER ) ; if ( related . getRelationshipTitle ( ) != null && ! related . getRelationshipTitle ( ) . trim ( ) . isEmpty ( ) ) { retValue . append ( ContentSpecUtilities . escapeRelationshipTitle ( related . getRelationshipTitle ( ) ) ) . append ( " " ) ; } retValue . append ( "[" ) ; retValue . append ( related . getSecondaryRelationshipId ( ) ) ; retValue . append ( "]" ) ; } } retValue . append ( "]" ) ; return retValue . toString ( ) ; }
Creates the relationship text to be added to a topic s text .