Package com.orientechnologies.orient.core.serialization

Examples of com.orientechnologies.orient.core.serialization.OSerializableStream


  public Object fromStream(final ODatabaseComplex<?> iDatabase, final String iStream) {
    if (iStream == null || iStream.length() == 0)
      // NULL VALUE
      return null;

    OSerializableStream instance = null;

    int propertyPos = iStream.indexOf(':');
    int pos = iStream.indexOf(OStreamSerializerHelper.SEPARATOR);
    if (pos < 0 || pos > propertyPos) {
      instance = new ODocument((ODatabaseRecord) iDatabase);
      pos = -1;
    } else {
      final String className = iStream.substring(0, pos);
      try {
        final Class<?> clazz = Class.forName(className);
        instance = (OSerializableStream) clazz.newInstance();
      } catch (Exception e) {
        OLogManager.instance().error(this, "Error on unmarshalling content. Class: " + className, e, OSerializationException.class);
      }
    }

    instance.fromStream(OBinaryProtocol.string2bytes(iStream.substring(pos + 1)));
    return instance;
  }
View Full Code Here


  public StringBuilder toStream(final ODatabaseComplex<?> iDatabase, final StringBuilder iOutput, Object iValue) {
    if (iValue != null) {
      if (!(iValue instanceof OSerializableStream))
        throw new OSerializationException("Can't serialize the object since it's not implements the OSerializableStream interface");

      OSerializableStream stream = (OSerializableStream) iValue;
      iOutput.append(iValue.getClass().getName());
      iOutput.append(OStreamSerializerHelper.SEPARATOR);
      iOutput.append(OBinaryProtocol.bytes2string(stream.toStream()));
    }
    return iOutput;
  }
View Full Code Here

    checkConnection();

    if (!(iCommand instanceof OSerializableStream))
      throw new OCommandExecutionException("Can't serialize the command to being executed to the server side.");

    OSerializableStream command = iCommand;
    Object result = null;

    do {
      OStorageRemoteThreadLocal.INSTANCE.get().commandExecuting = true;
View Full Code Here

    checkConnection();

    if (!(iCommand instanceof OSerializableStream))
      throw new OCommandExecutionException("Can't serialize the command to being executed to the server side.");

    OSerializableStream command = iCommand;

    Object result = null;

    do {
View Full Code Here

    checkConnection();

    if (!(iCommand instanceof OSerializableStream))
      throw new OCommandExecutionException("Can't serialize the command to being executed to the server side.");

    OSerializableStream command = iCommand;

    Object result = null;

    do {
View Full Code Here

  public Object fromStream(final ODatabaseComplex<?> iDatabase, final String iStream) {
    if (iStream == null || iStream.length() == 0)
      // NULL VALUE
      return null;

    OSerializableStream instance = null;

    int propertyPos = iStream.indexOf(':');
    int pos = iStream.indexOf(OStreamSerializerHelper.SEPARATOR);
    if (pos < 0 || pos > propertyPos) {
      instance = new ODocument((ODatabaseRecord) iDatabase);
      pos = -1;
    } else {
      final String className = iStream.substring(0, pos);
      try {
        final Class<?> clazz = Class.forName(className);
        instance = (OSerializableStream) clazz.newInstance();
      } catch (Exception e) {
        OLogManager.instance().error(this, "Error on unmarshalling content. Class: " + className, e, OSerializationException.class);
      }
    }

    instance.fromStream(OBinaryProtocol.string2bytes(iStream.substring(pos + 1)));
    return instance;
  }
View Full Code Here

   *
   * @param iValue
   */
  public StringBuilder toStream(final ODatabaseComplex<?> iDatabase, final StringBuilder iOutput, Object iValue) {
    if (iValue != null) {
      OSerializableStream stream = (OSerializableStream) iValue;

      if (!(iValue instanceof OSerializableStream))
        throw new OSerializationException("Can't serialize the object since it's not implements the OSerializableStream interface");

      iOutput.append(iValue.getClass().getName());
      iOutput.append(OStreamSerializerHelper.SEPARATOR);
      iOutput.append(OBinaryProtocol.bytes2string(stream.toStream()));
    }
    return iOutput;
  }
View Full Code Here

    try {
      Class<?> clazz = Class.forName(className);

      // CREATE THE OBJECT BY INVOKING THE EMPTY CONSTRUCTOR
      OSerializableStream stream = (OSerializableStream) clazz.newInstance();

      return stream.fromStream(OArrays.copyOfRange(iStream, 4 + classNameSize, iStream.length));

    } catch (Exception e) {
      OLogManager.instance().error(this, "Error on unmarshalling content. Class: " + className, e, OSerializationException.class);
    }
    return null;
View Full Code Here

    if (!(iObject instanceof OSerializableStream))
      throw new OSerializationException("Can't serialize the object [" + iObject.getClass() + ":" + iObject
          + "] since it not implements the OSerializableStream interface");

    OSerializableStream stream = (OSerializableStream) iObject;

    // SERIALIZE THE CLASS NAME
    byte[] className = OBinaryProtocol.string2bytes(iObject.getClass().getName());
   
    // SERIALIZE THE OBJECT CONTENT
    byte[] objectContent = stream.toStream();

    byte[] result = new byte[4 + className.length + objectContent.length];

    // COPY THE CLASS NAME SIZE + CLASS NAME + OBJECT CONTENT
    System.arraycopy(OBinaryProtocol.int2bytes(className.length), 0, result, 0, 4);
View Full Code Here

  public Object fromStream(final ODatabaseComplex<?> iDatabase, final String iStream) {
    if (iStream == null || iStream.length() == 0)
      // NULL VALUE
      return null;

    OSerializableStream instance = null;

    int propertyPos = iStream.indexOf(':');
    int pos = iStream.indexOf(OStreamSerializerHelper.SEPARATOR);
    if (pos < 0 || pos > propertyPos) {
      instance = new ODocument((ODatabaseRecord) iDatabase);
      pos = -1;
    } else {
      final String className = iStream.substring(0, pos);
      try {
        final Class<?> clazz = Class.forName(className);
        instance = (OSerializableStream) clazz.newInstance();
      } catch (Exception e) {
        OLogManager.instance().error(this, "Error on unmarshalling content. Class: " + className, e, OSerializationException.class);
      }
    }

    instance.fromStream(OBinaryProtocol.string2bytes(iStream.substring(pos + 1)));
    return instance;
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.serialization.OSerializableStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.