public Object fromStream(final String iStream) {
    if (iStream == null || iStream.length() == 0)
      // NULL VALUE
      return null;

    final ODocument instance = new ODocument();
    try {
      ORecordSerializerSchemaAware2CSV.INSTANCE.fromStream(iStream.getBytes("UTF-8"), instance, null);
    } catch (UnsupportedEncodingException e) {
      throw OException.wrapException(new OSerializationException("Error decoding string"), e);
    }

    final String className = instance.field(ODocumentSerializable.CLASS_NAME);
    if (className == null)
      return instance;

    Class<?> clazz = null;
    try {
      clazz = Class.forName(className);
    } catch (ClassNotFoundException e) {
      OLogManager.instance().debug(this, "Class name provided in embedded document " + className + " does not exist.", e);
    }

    if (clazz == null)
      return instance;

    if (ODocumentSerializable.class.isAssignableFrom(clazz)) {
      try {
        final ODocumentSerializable documentSerializable = (ODocumentSerializable) clazz.newInstance();
        final ODocument docClone = new ODocument();
        instance.copyTo(docClone);
        docClone.removeField(ODocumentSerializable.CLASS_NAME);
        documentSerializable.fromDocument(docClone);

        return documentSerializable;
      } catch (InstantiationException e) {
        throw OException.wrapException(new OSerializationException("Cannot serialize the object"), e);
      } catch (IllegalAccessException e) {
        throw OException.wrapException(new OSerializationException("Cannot serialize the object"), e);
      }
    }

    return instance;
  }
public Object fromStream ( final String iStream ) { if ( iStream == null || iStream . length ( ) == 0 ) return null ; final ODocument instance = new ODocument ( ) ; try { ORecordSerializerSchemaAware2CSV . INSTANCE . fromStream ( iStream . getBytes ( "UTF-8" ) , instance , null ) ; } catch ( UnsupportedEncodingException e ) { throw OException . wrapException ( new OSerializationException ( "Error decoding string" ) , e ) ; } final String className = instance . field ( ODocumentSerializable . CLASS_NAME ) ; if ( className == null ) return instance ; Class < ? > clazz = null ; try { clazz = Class . forName ( className ) ; } catch ( ClassNotFoundException e ) { OLogManager . instance ( ) . debug ( this , "Class name provided in embedded document " + className + " does not exist." , e ) ; } if ( clazz == null ) return instance ; if ( ODocumentSerializable . class . isAssignableFrom ( clazz ) ) { try { final ODocumentSerializable documentSerializable = ( ODocumentSerializable ) clazz . newInstance ( ) ; final ODocument docClone = new ODocument ( ) ; instance . copyTo ( docClone ) ; docClone . removeField ( ODocumentSerializable . CLASS_NAME ) ; documentSerializable . fromDocument ( docClone ) ; return documentSerializable ; } catch ( InstantiationException e ) { throw OException . wrapException ( new OSerializationException ( "Cannot serialize the object" ) , e ) ; } catch ( IllegalAccessException e ) { throw OException . wrapException ( new OSerializationException ( "Cannot serialize the object" ) , e ) ; } } return instance ; }
Re-Create any object if the class has a public constructor that accepts a String as unique parameter.