public String getCanonicalForm() {
        StringBuilder buf = new StringBuilder();

        for ( PathElement pe : elements ) {
            buf.append( "." ).append( pe.getCanonicalForm() );
        }

        return buf.substring( 1 ); // strip the leading "."
    }
public String getCanonicalForm ( ) { StringBuilder buf = new StringBuilder ( ) ; for ( PathElement pe : elements ) { buf . append ( "." ) . append ( pe . getCanonicalForm ( ) ) ; } return buf . substring ( 1 ) ; }
Testing method.