protected String doGetString ( NamespaceRegistry namespaceRegistry , TextEncoder encoder , TextEncoder delimiterEncoder ) { if ( encoder == null ) encoder = DEFAULT_ENCODER ; final String delimiter = delimiterEncoder != null ? delimiterEncoder . encode ( DELIMITER_STR ) : DELIMITER_STR ; // Since the segments are immutable, this code need not be synchronized because concurrent threads // may just compute the same value (with no harm done) StringBuilder sb = new StringBuilder ( ) ; if ( this . isAbsolute ( ) ) sb . append ( delimiter ) ; boolean first = true ; for ( Segment segment : this ) { if ( first ) { first = false ; } else { sb . append ( delimiter ) ; } assert segment != null ; sb . append ( segment . getString ( namespaceRegistry , encoder , delimiterEncoder ) ) ; } String result = sb . toString ( ) ; // Save the result to the internal string if this the default encoder is used. // This is not synchronized, but it's okay return result ; }
Method that creates the string representation . This method works two different ways depending upon whether the namespace registry is provided .