Пример #1
0
  private void writeValue(
      CDODataOutput out, EClass owner, EStructuralFeature[] features, int i, int referenceChunk)
      throws IOException {
    EStructuralFeature feature = features[i];
    Object value = getValue(i);
    if (value == null) {
      // Feature is NOT set
      out.writeByte(UNSET_OPCODE);
      return;
    }

    // Feature IS set
    if (value == CDORevisionData.NIL) {
      // Feature IS null
      out.writeByte(SET_NULL_OPCODE);
      return;
    }

    // Feature is NOT null
    out.writeByte(SET_NOT_NULL_OPCODE);
    if (feature.isMany()) {
      CDOList list = (CDOList) value;
      out.writeCDOList(owner, feature, list, referenceChunk);
    } else {
      checkNoFeatureMap(feature);
      if (feature instanceof EReference) {
        value = out.getIDProvider().provideCDOID(value);
      }

      if (TRACER.isEnabled()) {
        TRACER.format("Writing feature {0}: {1}", feature.getName(), value);
      }

      out.writeCDOFeatureValue(feature, value);
    }
  }
Пример #2
0
  /** @since 4.1 */
  public void write(CDODataOutput out, int referenceChunk, CDOBranchPoint securityContext)
      throws IOException {
    if (WRITING.isEnabled()) {
      WRITING.start(this);
    }

    writeSystemValues(out);

    CDOPermissionProvider permissionProvider = out.getPermissionProvider();
    CDOPermission permission = permissionProvider.getPermission(this, securityContext);
    out.writeByte(permission.getBits());

    if (permission == CDOPermission.NONE) {
      if (getClassInfo().isResourceNode()) {
        EClass eClass = getEClass();
        EStructuralFeature[] features = getAllPersistentFeatures();
        writeValue(out, eClass, features, RESOURCE_NODE_NAME_INDEX, referenceChunk);

        if (getClassInfo().isResourceFolder()) {
          writeValue(out, eClass, features, RESOURCE_FOLDER_NODES_INDEX, referenceChunk);
        }
      }
    } else {
      if (!isUnchunked() && referenceChunk != 0) {
        CDORevisionUnchunker unchunker = out.getRevisionUnchunker();
        if (unchunker != null) {
          unchunker.ensureChunks(this, referenceChunk);
        }
      }

      writeValues(out, referenceChunk);
    }

    if (WRITING.isEnabled()) {
      WRITING.stop(this);
    }
  }