Package net.sf.joafip.store.entity.conversion.input

Examples of net.sf.joafip.store.entity.conversion.input.ConversionDefEntry


    /**/classInfoForA/* declaringClass */,
    /**/VALUE,
    /**/fieldType,
    /**/false, false);

    final ConversionDefEntry conversionDefEntry = new ConversionDefEntry(
        classInfoForA, version0, version1);
    conversionDefEntry.addToFieldList(fieldInfo);

    final ReplacementDefMap replacementDefMap =
    /**/new ReplacementDefMap();
    replacementDefMap.add(conversionDefEntry);

View Full Code Here


    /**/new ReplacementDefMap();

    final ClassInfo classInfoFor0 = classInfoFactory.getClassInfo("0");
    final ClassInfo classInfoFor1 = classInfoFactory.getClassInfo("1");

    ConversionDefEntry conversionDefEntry = new ConversionDefEntry(
        classInfoFor0, version0, classInfoFor1, version1,
        ClassInfo.NULL, ClassInfo.NULL);

    replacementDefMap.add(conversionDefEntry);

    final ClassInfo classInfoForA = classInfoFactory.getClassInfo("a");
    final FieldInfo fieldInfo = new FieldInfo(classInfoForA, VALUE,
        fieldType, false, false);

    conversionDefEntry = new ConversionDefEntry(classInfoForA, version0,
        version1);
    conversionDefEntry.addToFieldList(fieldInfo);

    replacementDefMap.add(conversionDefEntry);

    // check class "0"
    Deque<ClassReplacementDef> replacementDef = replacementDefMap
View Full Code Here

    final FieldInfo fieldInfo = new FieldInfo(
    /**/classInfoForA/* declaring class */,
    /**/VALUE,
    /**/fieldType,
    /**/false, false);
    ConversionDefEntry conversionDefEntry = new ConversionDefEntry(
        classInfoForA, version0, version1);
    conversionDefEntry.addToFieldList(fieldInfo);

    replacementDefMap.add(conversionDefEntry);

    final ClassInfo classInfoForB = classInfoFactory.getClassInfo("b");
    conversionDefEntry = new ConversionDefEntry(classInfoForA, version0,
        classInfoForB, version1, ClassInfo.NULL, ClassInfo.NULL);
    replacementDefMap.add(conversionDefEntry);

    final Deque<ClassReplacementDef> replacementDef = replacementDefMap
        .replacementClassDef(version0, version1, classInfoForA);
View Full Code Here

    /**/new ReplacementDefMap();

    final ClassInfo classInfoForA = classInfoFactory.getClassInfo("a");
    final ClassInfo classInfoForB = classInfoFactory.getClassInfo("b");

    ConversionDefEntry conversionDefEntry = new ConversionDefEntry(
        classInfoForA, version0, classInfoForB, version1,
        ClassInfo.NULL, ClassInfo.NULL);
    replacementDefMap.add(conversionDefEntry);

    final FieldInfo fieldInfo = new FieldInfo(classInfoForA, VALUE,
        fieldType, false, false);
    conversionDefEntry = new ConversionDefEntry(classInfoForA, version0,
        version1);
    conversionDefEntry.addToFieldList(fieldInfo);
    replacementDefMap.add(conversionDefEntry);

    final Deque<ClassReplacementDef> replacementDef = replacementDefMap
        .replacementClassDef(version1, Version.releaseId("0.0.2"),
            classInfoForA);
View Full Code Here

    } else {
      converterClass = classInfoFactory.getClassInfo(strings[6]);
    }
    // create the conversion definition

    final ConversionDefEntry conversionDefEntry;
    if (originalField == null) {
      assertNull("replacement field must not be defined",
          replacementField);
      conversionDefEntry = new ConversionDefEntry(originalClass,
          oldIdentifier, replacementClass, newIdentifier,
          converterClass, ClassInfo.NULL);
    } else {
      assertNotNull("replacement field must be defined", replacementField);
      conversionDefEntry = new ConversionDefEntry(originalClass,
          oldIdentifier, replacementClass, newIdentifier,
          originalField, -1, replacementField, -1);
    }
    replacementDefMap.add(conversionDefEntry);
  }
View Full Code Here

    final InputStreamAndSource convertionDefinitionInputStreamAndSource =
    /**/new InputStreamAndSource(convertionDefinitionInputStream, "");
    final ConversionDefinitionIdStrReader convertionDefinitionReader =
    /**/new ConversionDefinitionIdStrReader(
        convertionDefinitionInputStreamAndSource, classInfoFactory);
    ConversionDefEntry def;

    def = convertionDefinitionReader.read();
    assertDefOk(def);
    def = convertionDefinitionReader.read();
    assertDefOk(def);
View Full Code Here

    /**/new InputStreamAndSource(convertionDefinitionInputStream, "");
    final ConversionDefinitionIdStrReader convertionDefinitionReader =
    /**/new ConversionDefinitionIdStrReader(
        convertionDefinitionInputStreamAndSource, classInfoFactory);

    ConversionDefEntry def;

    def = convertionDefinitionReader.read();
    assertNotNull("must have definition", def);
    // old identifier
    assertEquals("bad old identifier", Version.releaseId("0.0.0"),
        def.getIdentifier());
    // new identifier
    assertEquals("bad new identifier", Version.releaseId("0.0.1"),
        def.getToIdentifier());
    // original class name
    assertEquals("bad original class name", "net.sf.joafip.a", def
        .getClassInfo().getName());
    // replacement class name
    assertEquals("bad replacement class name", "net.sf.joafip.b", def
        .getReplacementClass().getName());
    // original declaring class
    assertEquals("bad original declaring class", "net.sf.joafip.AbstractA",
        def.getOriginalFieldInfo().getDeclaringClassName());
    // replacement declaring class
    assertEquals("bad replacement declaring class",
        "net.sf.joafip.AbstractB", def.getReplacementFieldInfo()
            .getDeclaringClassName());
    // original field type
    assertEquals("bad original field type", "java.lang.Integer", def
        .getOriginalFieldInfo().getFieldTypeName());
    // replacement field type
    assertEquals("bad replacement field type", "java.lang.Integer", def
        .getReplacementFieldInfo().getFieldTypeName());
    // original field name
    assertEquals("bad original field name", "a", def.getOriginalFieldInfo()
        .getFieldName());
    // replacement field name
    assertEquals("bad replacement field name", "b", def
        .getReplacementFieldInfo().getFieldName());
    // only one definition
    def = convertionDefinitionReader.read();
    assertNull("must not have more definition", def);
    convertionDefinitionReader.close();
View Full Code Here

    try {
      final ConversionDefinitionIdStrReader conversionDefinitionIdStrReader =
      /**/new ConversionDefinitionIdStrReader(
          new ConversionDefInputStream(classLoaderProvider),
          classInfoFactory);
      ConversionDefEntry conversionDefStr;
      while ((conversionDefStr = conversionDefinitionIdStrReader.read()) != null) {// NOPMD
        joafipReplacementDefMap.add(conversionDefStr);
      }
      conversionDefinitionIdStrReader.close();

      if (inputStream != null) {
        final ConversionDefinitionIdIntReader conversionDefinitionIdIntReader =
        /**/new ConversionDefinitionIdIntReader(inputStream,
            classInfoFactory);
        ConversionDefEntry conversionDefInt;
        while ((conversionDefInt = conversionDefinitionIdIntReader// NOPMD
            .read()) != null) {
          dataModelReplacementDefMap.add(conversionDefInt);
        }
        conversionDefinitionIdIntReader.close();
View Full Code Here

   */
  public ConversionDefEntry read() throws ConversionException {

    final List<String> list = extractList();

    final ConversionDefEntry conversionDefEntry;
    if (list.isEmpty()) {
      conversionDefEntry = null;
    } else {
      try {
        conversionDefEntry = conversionDefFromList(list);
View Full Code Here

        .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 {
                  replacementFieldType = classForName(replacementFieldClassName);
                }
                replacementFieldInfo = new FieldInfo(
                    replacementFieldDeclaringClass,
                    replacementFieldName,
                    replacementFieldType,
                    replacementStaticField,
                    replacementTransientField);
              }
              conversionDefEntry = new ConversionDefEntry(
                  originalClass, oldIdentifier,
                  replacementClass, toIdentifier,
                  originalFieldInfo, originalFieldIndex,
                  replacementFieldInfo, replacementFieldIndex);
            } catch (ClassInfoException exception) {
View Full Code Here

TOP

Related Classes of net.sf.joafip.store.entity.conversion.input.ConversionDefEntry

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.