question: private static Attributes encodeReference ( char separator , Reference ref , Attributes attrs , Object orig ) throws NamingException { if ( ref == null ) return attrs ; String s ; if ( ( s = ref . getClassName ( ) ) != null ) { attrs . put ( new BasicAttribute ( JAVA_ATTRIBUTES [ CLASSNAME ] , s ) ) ; } if ( ( s = ref . getFactoryClassName ( ) ) != null ) { attrs . put ( new BasicAttribute ( JAVA_ATTRIBUTES [ FACTORY ] , s ) ) ; } if ( ( s = ref . getFactoryClassLocation ( ) ) != null ) { attrs . put ( new BasicAttribute ( JAVA_ATTRIBUTES [ CODEBASE ] , s ) ) ; } if ( orig != null && attrs . get ( JAVA_ATTRIBUTES [ TYPENAME ] ) != null ) { Attribute tAttr = LdapCtxFactory . createTypeNameAttr ( orig . getClass ( ) ) ; if ( tAttr != null ) { attrs . put ( tAttr ) ; } } int count = ref . size ( ) ; if ( count > 0 ) { Attribute refAttr = new BasicAttribute ( JAVA_ATTRIBUTES [ REF_ADDR ] ) ; RefAddr refAddr ; BASE64Encoder encoder = null ; for ( int i = 0 ; i < count ; i ++ ) { refAddr = ref . get ( i ) ; if ( refAddr instanceof StringRefAddr ) { refAttr . add ( "" + separator + i + separator + refAddr . getType ( ) + separator + refAddr . getContent ( ) ) ; } else { if ( encoder == null ) encoder = new BASE64Encoder ( ) ; refAttr . add ( "" + separator + i + separator + refAddr . getType ( ) + separator + separator + encoder . encodeBuffer ( serializeObject ( refAddr ) ) ) ; } } attrs . put ( refAttr ) ; } return attrs ; }
target:  Convert a Reference object into several LDAP attributes. A Reference is stored as into the following attributes: javaClassName value: Reference.getClassName(); javaFactory value: Reference.getFactoryClassName(); javaCodeBase value: Reference.getFactoryClassLocation(); javaReferenceAddress value: #0#typeA#valA value: #1#typeB#valB value: #2#typeC##[serialized RefAddr C] value: #3#typeD#valD where -  the first character denotes the separator -  the number following the first separator denotes the position of the RefAddr within the Reference -  "typeA" is RefAddr.getType() -  ## denotes that the Base64-encoded form of the non-StringRefAddr is to follow; otherwise the value that follows is StringRefAddr.getContents() The default separator is the hash character (#). May provide property for this in future.