Package net.sf.joafip.store.service.binary

Examples of net.sf.joafip.store.service.binary.AbstractConverter


  protected ReferenceLink unmarshallElement(final byte[] binary,
      final int offset) throws HeapRecordableException {
    try {
      int currentOffset = offset;

      AbstractConverter binaryConverter;
      try {
        binaryConverter = helperBinaryConversion.integerConverter;
        binaryConverter.fromBinary(binary, currentOffset);
      } catch (BinaryConverterException exception) {
        throw new HeapRecordableException(exception);
      }
      if (!binaryConverter.valueDefinedFromBinary) {
        throw new HeapRecordableException(
            "number of referencing value must be defined");
      }
      final int numberOfReferencing = (Integer) binaryConverter.objectFromBinary;
      binaryConverter.objectFromBinary = null;// NOPMD
      currentOffset += HelperBinaryConversion.INT_BYTE_SIZE;
      binaryConverter = helperBinaryConversion.referenceConverter;
      binaryConverter.fromBinary(binary, currentOffset);
      final DataRecordIdentifier referenced = (DataRecordIdentifier) binaryConverter.objectFromBinary;
      binaryConverter.objectFromBinary = null;// NOPMD
      currentOffset += HelperBinaryConversion.REFERENCE_BYTE_SIZE;

      final ReferenceLink referenceLink = new ReferenceLink(referenced);
      for (int count = 0; count < numberOfReferencing; count++) {
        binaryConverter = helperBinaryConversion.referenceConverter;
        binaryConverter.fromBinary(binary, currentOffset);
        if (!binaryConverter.valueDefinedFromBinary) {
          throw new HeapRecordableException(
              "referencing data record identifier value must be defined");
        }
        final DataRecordIdentifier referencing = (DataRecordIdentifier)
        /**/binaryConverter.objectFromBinary;
        binaryConverter.objectFromBinary = null;// NOPMD
        currentOffset += HelperBinaryConversion.REFERENCE_BYTE_SIZE;
        try {
          binaryConverter = helperBinaryConversion.integerConverter;
          binaryConverter.fromBinary(binary, currentOffset);
        } catch (BinaryConverterException exception) {
          throw new HeapRecordableException(exception);
        }
        if (!binaryConverter.valueDefinedFromBinary) {
          throw new HeapRecordableException(
View Full Code Here


        true, element);
  }

  protected DataRecordIdentifier unmarshallElement(final byte[] binary,
      final int offset) throws HeapRecordableException {
    AbstractConverter binaryConverter;
    try {
      binaryConverter = helperBinaryConversion.referenceConverter;
      binaryConverter.fromBinary(binary, offset);
    } catch (BinaryConverterException exception) {
      throw new HeapRecordableException(exception);
    }
    if (!binaryConverter.valueDefinedFromBinary) {
      throw new HeapRecordableException(
View Full Code Here

  private Boolean colorFromBinary(
      final HelperBinaryConversion helperBinaryConversion,
      final byte[] binary, final int offset)
      throws HeapRecordableException {
    AbstractConverter binaryConverter;
    try {
      binaryConverter = helperBinaryConversion.booleanConverter;
      binaryConverter.fromBinary(binary, offset);
    } catch (BinaryConverterException exception) {
      throw new HeapRecordableException(exception);
    }
    if (!binaryConverter.valueDefinedFromBinary) {
      throw new HeapRecordableException("color value must be defined");
View Full Code Here

  private Integer numberOfChildFromBinary(
      final HelperBinaryConversion helperBinaryConversion,
      final byte[] binary, final int offset)
      throws HeapRecordableException {
    AbstractConverter binaryConverter;
    try {
      binaryConverter = helperBinaryConversion.integerConverter;
      binaryConverter.fromBinary(binary, offset);
    } catch (BinaryConverterException exception) {
      throw new HeapRecordableException(exception);
    }
    if (!binaryConverter.valueDefinedFromBinary) {
      throw new HeapRecordableException(
View Full Code Here

  private DataRecordIdentifier dataRecordIdentifierFromBinary(
      final HelperBinaryConversion helperBinaryConversion,
      final byte[] binary, final int offset)
      throws HeapRecordableException {
    AbstractConverter binaryConverter;
    try {
      binaryConverter = helperBinaryConversion.nullableAndTypedReferenceConverter;
      binaryConverter.fromBinary(binary, offset);
    } catch (BinaryConverterException exception) {
      throw new HeapRecordableException(exception);
    }
    if (!binaryConverter.valueDefinedFromBinary) {
      throw new HeapRecordableException(
View Full Code Here

  @Override
  public void unmarshall(final byte[] binary) throws HeapRecordableException {
    int offset = 0;

    final AbstractConverter nullableAndTypedReferenceConverter = helperBinaryConversion.nullableAndTypedReferenceConverter;
    final AbstractConverter byteConverter = helperBinaryConversion.byteConverter;
    final AbstractConverter booleanConverter = helperBinaryConversion.booleanConverter;
    try {
      nullableAndTypedReferenceConverter.fromBinary(binary, offset);
      toGarbageRootDataRecordIdentifier =
      /**/(DataRecordIdentifier) nullableAndTypedReferenceConverter.objectFromBinary;
      offset += HelperBinaryConversion.REFERENCE_NULLABLE_BYTE_SIZE;

      nullableAndTypedReferenceConverter.fromBinary(binary, offset);
      assertValueDefined(nullableAndTypedReferenceConverter);
      garbageCandidateRootDataRecordIdentifier =
      /**/(DataRecordIdentifier) nullableAndTypedReferenceConverter.objectFromBinary;
      offset += HelperBinaryConversion.REFERENCE_NULLABLE_BYTE_SIZE;

      nullableAndTypedReferenceConverter.fromBinary(binary, offset);
      assertValueDefined(nullableAndTypedReferenceConverter);
      garbageReferenceLinkRootDataRecordIdentifier =
      /**/(DataRecordIdentifier) nullableAndTypedReferenceConverter.objectFromBinary;
      offset += HelperBinaryConversion.REFERENCE_NULLABLE_BYTE_SIZE;

      nullableAndTypedReferenceConverter.fromBinary(binary, offset);
      assertValueDefined(nullableAndTypedReferenceConverter);
      classNameListRootDataRecordIdentifier =
      /**/(DataRecordIdentifier) nullableAndTypedReferenceConverter.objectFromBinary;
      offset += HelperBinaryConversion.REFERENCE_NULLABLE_BYTE_SIZE;

      nullableAndTypedReferenceConverter.fromBinary(binary, offset);
      assertValueDefined(nullableAndTypedReferenceConverter);
      toVisitByCollectorRootDataRecordIdentifier =
      /**/(DataRecordIdentifier) nullableAndTypedReferenceConverter.objectFromBinary;
      offset += HelperBinaryConversion.REFERENCE_NULLABLE_BYTE_SIZE;

      nullableAndTypedReferenceConverter.fromBinary(binary, offset);
      assertValueDefined(nullableAndTypedReferenceConverter);
      visitedByCollectorRootDataRecordIdentifier =
      /**/(DataRecordIdentifier) nullableAndTypedReferenceConverter.objectFromBinary;
      offset += HelperBinaryConversion.REFERENCE_NULLABLE_BYTE_SIZE;

      nullableAndTypedReferenceConverter.fromBinary(binary, offset);
      assertValueDefined(nullableAndTypedReferenceConverter);
      garbageCandidateInProcess =
      /**/(DataRecordIdentifier) nullableAndTypedReferenceConverter.objectFromBinary;
      offset += HelperBinaryConversion.REFERENCE_NULLABLE_BYTE_SIZE;

      byteConverter.fromBinary(binary, offset);
      assertValueDefined(byteConverter);
      garbageCollectorState =
      /**/(Byte) byteConverter.objectFromBinary;
      offset += HelperBinaryConversion.BYTE_BYTE_SIZE;

      booleanConverter.fromBinary(binary, offset);
      assertValueDefined(booleanConverter);
      garbageManagement = (Boolean) booleanConverter.objectFromBinary;

      nullableAndTypedReferenceConverter.objectFromBinary = null; // NOPMD
      byteConverter.objectFromBinary = null; // NOPMD
View Full Code Here

      final int bodyBeginOffset, final ClassInfo objectClass,
      final DataRecordIdentifier dataRecordIdentifier)
      throws ObjectIOException, ObjectIODataRecordNotFoundException,
      ObjectIODataCorruptedException {
    final ForTestClass read = new ForTestClass();
    AbstractConverter binaryConverter;
    try {
      binaryConverter = helperBinaryConversion.characterConverter;
      binaryConverter.fromBinary(binary, bodyBeginOffset);
    } catch (BinaryConverterException exception) {
      throw new ObjectIOException(exception);
    }
    if (!binaryConverter.valueDefinedFromBinary) {
      throw new ObjectIOException("value must be defined");
View Full Code Here

    System.arraycopy(className, 0, binary, offset, className.length);
  }

  public void unmarshall(final byte[] binary) throws HeapRecordableException {
    int offset = 0;
    AbstractConverter binaryConverter;
    try {
      binaryConverter = helperBinaryConversion.integerConverter;
      binaryConverter.fromBinary(binary, offset);
    } catch (BinaryConverterException exception) {
      throw new HeapRecordableException(exception);
    }
    if (!binaryConverter.valueDefinedFromBinary) {
      throw new HeapRecordableException(
          "class name identifier value must be defined");
    }
    classNameIdentifier = (Integer) binaryConverter.objectFromBinary;
    binaryConverter.objectFromBinary = null;// NOPMD
    offset += HelperBinaryConversion.INT_BYTE_SIZE;
    try {
      binaryConverter = helperBinaryConversion.nullableAndTypedReferenceConverter;
      binaryConverter.fromBinary(binary, offset);
    } catch (BinaryConverterException exception) {
      throw new HeapRecordableException(exception);
    }
    if (!binaryConverter.valueDefinedFromBinary) {
      throw new HeapRecordableException(
View Full Code Here

    final int numberRead = changeFileInputStream.read(data);
    if (numberRead == -1) {
      haveRead = false;
    } else if (numberRead == data.length) {

      AbstractConverter binaryConverter;
      try {
        binaryConverter = helperBinaryConversion.longConverter;
        binaryConverter.fromBinary(data, 0);
      } catch (final BinaryConverterException exception) {
        throw new ObjectIOException(exception);
      }
      if (!binaryConverter.valueDefinedFromBinary) {
        throw new ObjectIOException(
            "data record identifier value must be defined");
      }
      final Long dataRecordIdentifierValue =
      /**/(Long) binaryConverter.objectFromBinary;
      binaryConverter.objectFromBinary = null;// NOPMD
      final DataRecordIdentifier dataRecordIdentifier =
      /**/new DataRecordIdentifier(dataRecordIdentifierValue);

      /* second get data for object length */
      data = new byte[HelperBinaryConversion.INT_BYTE_SIZE];
      readInChangeFileInputStream(changeFileInputStream, data);
      try {
        binaryConverter = helperBinaryConversion.integerConverter;
        binaryConverter.fromBinary(data, 0);
      } catch (final BinaryConverterException exception) {
        throw new ObjectIOException(exception);
      }
      if (!binaryConverter.valueDefinedFromBinary) {
        throw new ObjectIOException("data length value must be defined");
View Full Code Here

  public void read(final byte[] binary,
      final DataRecordIdentifier dataRecordIdentifier)
      throws ObjectIOException, ObjectIOClassNotFoundException {
    int offset = 0;
    AbstractConverter binaryConverter;

    /*
     * first data is class name identifier and flag
     */
    try {
      binaryConverter = helperBinaryConversion.integerConverter;
      binaryConverter.fromBinary(binary, offset);
    } catch (BinaryConverterException exception) {
      throw new ObjectIOException(FOR_DATA_RECORD + dataRecordIdentifier,
          exception);
    }
    if (!binaryConverter.valueDefinedFromBinary) {
      throw new ObjectIOException(
          "class name identifier value must be defined for data record "
              + dataRecordIdentifier);
    }
    offset += HelperBinaryConversion.INT_BYTE_SIZE;
    final int classNameIdentifierAndFormatFlag = ((Integer) binaryConverter.objectFromBinary)
        .intValue();
    binaryConverter.objectFromBinary = null;// NOPMD

    extendedDatarecordFormat = (classNameIdentifierAndFormatFlag & 0x80000000) == 0x80000000;
    if (extendedDatarecordFormat) {

      /*
       * record format identifier
       */
      try {
        binaryConverter = helperBinaryConversion.shortConverter;
        binaryConverter.fromBinary(binary, offset);
      } catch (BinaryConverterException exception) {
        throw new ObjectIOException(FOR_DATA_RECORD
            + dataRecordIdentifier, exception);
      }
      offset += HelperBinaryConversion.SHORT_BYTE_SIZE;
      if (!binaryConverter.valueDefinedFromBinary) {
        throw new ObjectIOException(
            "record format identifier value must be defined for data record "
                + dataRecordIdentifier);
      }
      recordFormatId = ((Short) binaryConverter.objectFromBinary)
          .shortValue();
      binaryConverter.objectFromBinary = null;// NOPMD

      /*
       * joafip release id
       */
      try {
        binaryConverter = helperBinaryConversion.integerConverter;
        binaryConverter.fromBinary(binary, offset);
      } catch (BinaryConverterException exception) {
        throw new ObjectIOException(FOR_DATA_RECORD
            + dataRecordIdentifier, exception);
      }
      if (!binaryConverter.valueDefinedFromBinary) {
        throw new ObjectIOException(
            "joafip release id value must be defined for data record "
                + dataRecordIdentifier);
      }
      offset += HelperBinaryConversion.INT_BYTE_SIZE;
      joafipReleaseId = ((Integer) binaryConverter.objectFromBinary)
          .intValue();
      binaryConverter.objectFromBinary = null;// NOPMD

      /*
       * data model identifier
       */

      try {
        binaryConverter = helperBinaryConversion.integerConverter;
        binaryConverter.fromBinary(binary, offset);
      } catch (BinaryConverterException exception) {
        throw new ObjectIOException(FOR_DATA_RECORD
            + dataRecordIdentifier, exception);
      }
      if (!binaryConverter.valueDefinedFromBinary) {
        throw new ObjectIOException(
            "data model identifier value must be defined for data record "
                + dataRecordIdentifier);
      }
      offset += HelperBinaryConversion.INT_BYTE_SIZE;
      dataModelIdentifier = ((Integer) binaryConverter.objectFromBinary)
          .intValue();
      binaryConverter.objectFromBinary = null;// NOPMD

      /*
       * flags
       */
      if (recordFormatId == RecordFormatIdentifier.ID_FOR_3_0_1_THRU_3_1_0) {

        try {
          binaryConverter = helperBinaryConversion.byteConverter;
          binaryConverter.fromBinary(binary, offset);
        } catch (BinaryConverterException exception) {
          throw new ObjectIOException(FOR_DATA_RECORD
              + dataRecordIdentifier, exception);
        }
        if (!binaryConverter.valueDefinedFromBinary) {
View Full Code Here

TOP

Related Classes of net.sf.joafip.store.service.binary.AbstractConverter

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.