Package net.sf.joafip.store.entity.classinfo

Examples of net.sf.joafip.store.entity.classinfo.ClassInfo


      while (objectToCopy != null) {
        if (forceLoad) {
          forceLoadImpl(objectToCopy);
        }
        addCopied(objectToCopy);
        final ClassInfo objectToCopyClassInfo = proxyManager2
            .classInfoOfObject(objectToCopy);
        createCopy(objectToCopy, objectToCopyClassInfo);
        objectToCopy = objectToCopyQueue.pollFirst();
      }
      final ClassInfo sourceObjectClassInfo = proxyManager2
          .classInfoOfObject(rootSourceObject);
      sourceCopy = getOrCreateObjectCopy(rootSourceObject,
          sourceObjectClassInfo);
      deepCopyDone();
    } catch (ProxyException exception) {
View Full Code Here


      final Object fieldCopyValue;
      if (fieldValue == null || !fieldInfo.isPersisted()) {
        fieldCopyValue = fieldValue;
      } else {
        final Class<?> fieldValueClass = fieldValue.getClass();
        ClassInfo fieldValueClassInfo;
        try {
          fieldValueClassInfo = classInfoFactory
              .getNoProxyClassInfo(fieldValueClass);
        } catch (ClassInfoException exception) {
          throw new CopierException(exception);
        }
        if (fieldValueClass.equals(String.class)) {
          fieldCopyValue = fieldValue;
        } else if (fieldValueClassInfo.isBasicType()) {
          fieldCopyValue = fieldValue;
        } else {
          addObjectToCopyQueue(fieldValue);
          try {
            fieldCopyValue = getOrCreateObjectCopy(fieldValue,
View Full Code Here

  private void arrayCopy(final Object sourceArray, final Object arrayCopy)
      throws CopierException {
    final int arrayLength = Array.getLength(sourceArray);
    final Class<?> componentType = sourceArray.getClass()
        .getComponentType();
    ClassInfo componentTypeClassInfo;
    try {
      componentTypeClassInfo = classInfoFactory
          .getNoProxyClassInfo(componentType);
    } catch (ClassInfoException exception) {
      throw new CopierException(exception);
    }
    if (componentTypeClassInfo.isStringType()
        || componentTypeClassInfo.isBasicType()) {
      for (int index = 0; index < arrayLength; index++) {
        final Object elementObject;
        try {
          elementObject = HELPER_REFLECT.getArrayElement(sourceArray,
              index);
        } catch (ReflectException exception) {
          throw new CopierException("element of "
              + identityString(sourceArray), exception);
        }
        try {
          HELPER_REFLECT.setArrayElement(arrayCopy, index,
              elementObject);
        } catch (ReflectException exception) {
          throw new CopierException(ELEMENT
              + elementObject.getClass() + OF
              + identityString(sourceArray), exception);
        } catch (ReflectFailedSetException exception) {
          throw new CopierException(ELEMENT
              + elementObject.getClass() + OF
              + identityString(sourceArray), exception);
        }
      }
    } else {
      for (int index = 0; index < arrayLength; index++) {
        Object elementObject;
        try {
          elementObject = HELPER_REFLECT.getArrayElement(sourceArray,
              index);
        } catch (ReflectException exception) {
          throw new CopierException("element of " + sourceArray,
              exception);
        }
        addObjectToCopyQueue(elementObject);
        final Object elemetCopy;
        if (elementObject == null) {
          elemetCopy = elementObject;
        } else {
          ClassInfo elementObjectClassInfo;
          try {
            elementObjectClassInfo = classInfoFactory
                .getNoProxyClassInfo(elementObject.getClass());
          } catch (ClassInfoException exception) {
            throw new CopierException(exception);
          }
          if (elementObjectClassInfo.isStringType()
              || elementObjectClassInfo.isBasicType()) {
            elemetCopy = elementObject;
          } else {
            try {
              elemetCopy = getOrCreateObjectCopy(elementObject,
                  elementObjectClassInfo);
View Full Code Here

  @Override
  public PutField putFields() throws IOException {
    if (LOGGER.debugEnabled) {
      LOGGER.debug("putFields");
    }
    final ClassInfo classInfo = objectAndItsClassInfo.objectClassInfo;
    try {
      fieldInfoMap = classInfo.getSerialPersistentFields();
    } catch (ClassInfoException exception) {
      throw new IOException(exception);
    }
    return new PutFieldImpl();
  }
View Full Code Here

  private ObjectClassInfoAndDeclared[] computeCurrentValue()
      throws IOException {
    if (fieldInfoMap == null) {
      throw new NotActiveException("no current PutField object");
    }
    final ClassInfo classInfo = objectAndItsClassInfo.objectClassInfo;
    final FieldInfo[] fieldInfos;
    try {
      fieldInfos = classInfo.getSerialPersistentFieldsInfo();
    } catch (ClassInfoException exception) {
      throw new IOException(exception);
    }
    final ObjectClassInfoAndDeclared[] currentValue =
    /**/new ObjectClassInfoAndDeclared[fieldInfoMap.size()];
    int index = 0;
    for (FieldInfo fieldInfo : fieldInfos) {
      final String fieldName = fieldInfo.getFieldName();
      ClassInfo declaredClassInfo;
      try {
        declaredClassInfo = fieldInfo.getFieldTypeInfo();
      } catch (ClassInfoException exception) {
        throw new RuntimeException(exception);// NOPMD
      }
      final ObjectAndPersistInfo valueAndPersistInfo;
      if (fieldInfo.isPersisted()) {
        final boolean valueDefined = valueMap.containsKey(fieldName);
        if (valueDefined) {
          final Object fieldValue = valueMap.get(fieldName);
          final ClassInfo valueClassInfo = valueClassMap
              .get(fieldName);
          try {
            valueAndPersistInfo = objectIOManager
                .getOrCreateObjectPersistInfoOfObject(
                    fieldValue, null, valueClassInfo,
View Full Code Here

    }
  }

  @Override
  protected void writeObjectOverride(final Object object) throws IOException {
    ClassInfo classInfo;
    try {
      classInfo = proxyManager2.classInfoOfObject(object);

      final ObjectAndPersistInfo toWriteObjectAndItsClassInfo =
      /**/objectIOManager.getOrCreateObjectPersistInfoOfObject(object,
 
View Full Code Here

    try {
      // ASSERTX
      assert fieldName != null : "field name must be set";
      // ASSERTX
      assert fieldTypeName != null : "field class name must be set";
      final ClassInfo fieldType = classInfoFactory
          .getClassInfo(fieldTypeName);
      final ClassInfo declaringClass = classInfoFactory
          .getClassInfo(declaringClassName);
      /* at this point the field value my be undefined */
      /* final ObjectAndPersistInfo value = */valuedFieldList
          .setFieldInformation(declaringClass, fieldName, fieldType,
              staticField, transientField, index);
View Full Code Here

      assert fieldName != null : "field name must be set";
      // ASSERTX
      assert originalFieldTypeName != null : "original field class name must be set";
      // ASSERTX
      assert fieldTypeName != null : "field class name must be set";
      final ClassInfo originalFieldType = classInfoFactory
          .getClassInfo(originalFieldTypeName);
      final ClassInfo originalDeclaringClass = classInfoFactory
          .getClassInfo(originalDeclaringClassName);
      final ClassInfo fieldType = classInfoFactory
          .getClassInfo(fieldTypeName);
      final ClassInfo declaringClass = classInfoFactory
          .getClassInfo(declaringClassName);
      valuedFieldList.changeFieldInformation(originalDeclaringClass,
          originalFieldName, originalFieldType, declaringClass,
          fieldName, fieldType, staticField, transientField);
    } catch (ClassNotFoundException exception) {
View Full Code Here

    final String originalClassName = fieldDefParser.getClassName();
    if (originalClassName == null) {
      throw new ConversionException(
          "bad original class/field definition \"" + elts[1]);
    }
    final ClassInfo originalClass = classForName(originalClassName);
    final String originalFieldName = fieldDefParser.getFieldName();
    final int originalFieldIndex = fieldDefParser.getFieldIndex();
    final String originalFieldClassName = normalizeClassName(fieldDefParser
        .getFieldClassName());
    final String originalFieldDeclaringClassName = fieldDefParser
        .getFieldDeclaringClassName();
    final Boolean originalStaticField = fieldDefParser.getStaticField();
    final Boolean originalTransientField = fieldDefParser
        .getTransientField();

    final ConversionDefEntry conversionDefEntry;

    if ("*".equals(originalFieldName)) {
      /*
       * list of class's fields
       */
      final int toIdentifier = computeIdentifier(elts[2]);
      conversionDefEntry = new ConversionDefEntry(originalClass,
          oldIdentifier, toIdentifier);

      for (int fieldDefIndex = 3; fieldDefIndex < elts.length; fieldDefIndex++) {

        try {
          fieldDefParser.parse(elts[fieldDefIndex]);
        } catch (ConversionException exception) {
          throw new ConversionException("bad field definition \""
              + elts[fieldDefIndex] + "\"", exception);
        }
        if (fieldDefParser.getClassName() != null) {
          throw new ConversionException("bad field definition \""
              + elts[fieldDefIndex] + "\"");
        }

        final String fieldClassName = normalizeClassName(fieldDefParser
            .getFieldClassName());
        final Boolean staticField = fieldDefParser.getStaticField();
        final Boolean transientField = fieldDefParser
            .getTransientField();
        final String declaringClassName = fieldDefParser
            .getFieldDeclaringClassName();
        final String fieldName = fieldDefParser.getFieldName();
        final int fieldIndex = fieldDefParser.getFieldIndex();
        if (fieldIndex != -1) {
          throw new ConversionException(
              "bad field definition, must not have field index declaration \""
                  + elts[fieldDefIndex]);
        }
        final ClassInfo fieldClass = classForName(fieldClassName);
        final ClassInfo declaringClass = classForName(declaringClassName);
        FieldInfo fieldInfo;
        try {
          // FIXMELUC ______known field
          fieldInfo = new FieldInfo(declaringClass, fieldName,// NOPMD
              fieldClass, staticField, transientField);
        } catch (ClassInfoException exception) {
          throw new ConversionException("bad field definition \""
              + elts[fieldDefIndex], exception);
        }
        conversionDefEntry.addToFieldList(fieldInfo);
      }

    } else {
      /*
       * replacement definition
       */
      if (listSize < 3 || listSize > 5) {// NOPMD
        throw new ConversionException("3 thru 5 elements expected for "
            + listSize + " get");
      } else {
        final int toIdentifier = computeIdentifier(elts[2]);
        if (listSize == 3) {
          conversionDefEntry = new ConversionDefEntry(originalClass,
              oldIdentifier, ClassInfo.NULL, toIdentifier,
              ClassInfo.NULL, ClassInfo.NULL);
        } else {
          final ClassInfo converterClass;
          final ClassInfo staticConverterClass;
          if (listSize == 5) {
            final String[] converterClassDef = elts[4].split(":");
            if (converterClassDef.length == 1) {
              converterClass = classForName(converterClassDef[0]);
              staticConverterClass = ClassInfo.NULL;
            } else if (converterClassDef.length == 2
                && "static".equals(converterClassDef[0])) {
              staticConverterClass = classForName(converterClassDef[1]);
              converterClass = ClassInfo.NULL;
            } else {
              throw new ConversionException(
                  "bad conversion class declaration \""
                      + elts[4] + "\"");
            }
          } else {
            converterClass = ClassInfo.NULL;
            staticConverterClass = ClassInfo.NULL;
          }

          try {
            fieldDefParser.parse(elts[3]);
          } catch (ConversionException exception) {
            throw new ConversionException(
                "bad replacemet class/field definition \""
                    + elts[3] + "\"", exception);
          }
          final String replacementClassName = fieldDefParser
              .getClassName();
          if (replacementClassName == null) {
            throw new ConversionException(
                "bad replacement class/field definition \""
                    + elts[3] + "\"");
          }
          final String replacementFieldName = fieldDefParser
              .getFieldName();
          final int replacementFieldIndex = fieldDefParser
              .getFieldIndex();
          final String replacementFieldClassName = normalizeClassName(fieldDefParser
              .getFieldClassName());
          final String replacementFieldDeclaringClassName = fieldDefParser
              .getFieldDeclaringClassName();
          final Boolean replacementStaticField = fieldDefParser
              .getStaticField();
          final Boolean replacementTransientField = fieldDefParser
              .getTransientField();
          final ClassInfo replacementFieldDeclaringClass;
          final ClassInfo replacementClass = classForName(replacementClassName);
          if (replacementFieldDeclaringClassName == null) {
            replacementFieldDeclaringClass = replacementClass;
          } else {
            replacementFieldDeclaringClass = classForName(replacementFieldDeclaringClassName);
          }

          if (originalFieldName == null) {
            conversionDefEntry = new ConversionDefEntry(
                originalClass, oldIdentifier, replacementClass,
                toIdentifier, converterClass,
                staticConverterClass);
          } else {
            final ClassInfo originalFieldDeclaringClass;
            if (originalFieldDeclaringClassName == null) {
              originalFieldDeclaringClass = originalClass;
            } else {
              originalFieldDeclaringClass = classForName(originalFieldDeclaringClassName);
            }
            final ClassInfo originalFieldType;
            if (originalFieldClassName == null) {
              originalFieldType = ClassInfo.NULL;
            } else {
              originalFieldType = classForName(originalFieldClassName);
            }
            final FieldInfo originalFieldInfo;
            try {
              originalFieldInfo = new FieldInfo(
                  originalFieldDeclaringClass,
                  originalFieldName, originalFieldType,
                  originalStaticField, originalTransientField);
            } catch (ClassInfoException exception) {
              throw new ConversionException(
                  "bad replacement class \"" + elts[1] + "\"",
                  exception);
            }
            try {
              final FieldInfo replacementFieldInfo;
              if (replacementFieldName == null) {
                replacementFieldInfo = null;
              } else {
                final ClassInfo replacementFieldType;
                if (replacementFieldClassName == null) {
                  throw new ConversionException(
                      "bad replacement class/field type must be defined \""
                          + elts[3] + "\"");
                } else {
View Full Code Here

   * @throws ConversionException
   */
  private ClassInfo classForName(final String className)
      throws ConversionException {
    try {
      final ClassInfo classForName;
      if (className == null) {
        // classForName = ClassInfo.NULL;
        throw new ConversionException("class name must be defined");
      } else {
        if ("boolean".equals(className)) {
View Full Code Here

TOP

Related Classes of net.sf.joafip.store.entity.classinfo.ClassInfo

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.