Examples of ClassMapping


Examples of org.apache.openjpa.jdbc.meta.ClassMapping

        return ((Comparable) v1).compareTo(v2);
    }

    public void map(boolean adapt) {
        ClassMapping cls = vers.getClassMapping();
        if (cls.getJoinablePCSuperclassMapping() != null
            || cls.getEmbeddingMetaData() != null)
            throw new MetaDataException(_loc.get("not-base-vers", cls));

        VersionMappingInfo info = vers.getMappingInfo();
        info.assertNoJoin(vers, true);
        info.assertNoForeignKey(vers, !adapt);
View Full Code Here

Examples of org.compass.core.mapping.osem.ClassMapping

            CompassMapping mapping = (CompassMapping) new FieldInvoker(CompassConfiguration.class, "mapping").prepare().get(compassConfiguration);
            AliasMapping[] mappings = mapping.getMappings();
            for (int i = 0; i < mappings.length; i++) {
                AliasMapping am = mappings[i];
                if (am instanceof ClassMapping) {
                    ClassMapping cm = (ClassMapping) am;
                    CompassClassMapping dummyMapping = new CompassClassMapping();
                    dummyMapping.setAlias(cm.getAlias());
                    dummyMapping.setMappedClass(cm.getClazz());
                    tempClassMappings.add(dummyMapping);
                }
            }
        } catch (Exception e) {
            throw new IllegalStateException("Failed to get Compass mapping: " + e);
View Full Code Here

Examples of org.exolab.castor.mapping.xml.ClassMapping

            throw new MappingException("mapping.classNotConstructable", cls.getName());
        }

        XMLClassDescriptor xmlClass;
        FieldDescriptor[] fields;
        ClassMapping classMap;
        FieldMapping fieldMap;

        boolean introspected = false;
        try {
            if (_forceIntrospection) {
                xmlClass = _internalContext.getIntrospector().generateClassDescriptor(cls);
                introspected = true;
            } else {
                xmlClass = (XMLClassDescriptor) _internalContext.getXMLClassDescriptorResolver().resolve(cls);
                introspected = _internalContext.getIntrospector().introspected(xmlClass);
            }
        } catch (Exception except) {
            throw new MappingException(except);
        }
        classMap = new ClassMapping();
        classMap.setName(cls.getName());
        classMap.setDescription("Default mapping for class " + cls.getName());

        // -- prevent default access from showing up in the mapping
        classMap.setAccess(null);

        // -- map-to
        MapTo mapTo = new MapTo();
        mapTo.setXml(xmlClass.getXMLName());
        mapTo.setNsUri(xmlClass.getNameSpaceURI());
        mapTo.setNsPrefix(xmlClass.getNameSpacePrefix());
        classMap.setMapTo(mapTo);

        // -- add mapping to hashtable before processing
        // -- fields so we can do recursive processing
        _mappings.put(cls, classMap);

        fields = xmlClass.getFields();
        for (int i = 0; i < fields.length; ++i) {
            FieldDescriptor fdesc = fields[i];

            String fieldName = fdesc.getFieldName();

            boolean isContainer = false;
            // -- check for collection wrapper
            if (introspected && fieldName.startsWith("##container")) {
                fdesc = fdesc.getClassDescriptor().getFields()[0];
                fieldName = fdesc.getFieldName();
                isContainer = true;
            }

            Class fieldType = fdesc.getFieldType();

            // -- check to make sure we can find the accessors...
            // -- if we used introspection we don't need to
            // -- enter this block...only when descriptors
            // -- were generated using the source code generator
            // -- or by hand.
            if ((!introspected) && fieldName.startsWith(UNDERSCORE)) {
                // -- check to see if we need to remove underscore
                if (!_mappingLoader.canFindAccessors(cls, fieldName, fieldType)) {
                    fieldName = fieldName.substring(1);
                }

                // -- check to see if we need to remove "List" prefix
                // -- used by generated source code
                if (!_mappingLoader.canFindAccessors(cls, fieldName, fieldType)) {
                    if (fieldName.endsWith("List")) {
                        int len = fieldName.length() - 4;
                        String tmpName = fieldName.substring(0, len);
                        if (_mappingLoader.canFindAccessors(cls, tmpName, fieldType)) {
                            fieldName = tmpName;
                        }
                    }
                }
            }

            fieldMap = new FieldMapping();
            fieldMap.setName(fieldName);

            // -- unwrap arrays of objects
            boolean isArray = fieldType.isArray();
            while (fieldType.isArray()) {
                fieldType = fieldType.getComponentType();
            }

            // -- To prevent outputing of optional fields...check
            // -- for value first before setting
            if (fdesc.isRequired()) {
                fieldMap.setRequired(true);
            }
            if (fdesc.isTransient()) {
                fieldMap.setTransient(true);
            }
            if (fdesc.isMultivalued()) {
                // -- special case for collections
                if (isContainer) {
                    // -- backwards than what you'd expect, but
                    // -- if the collection had a "container" wrapper
                    // -- then we specify container="false" in the
                    // -- mapping file.
                    fieldMap.setContainer(false);
                }

                // -- try to guess collection type
                if (isArray) {
                    fieldMap.setCollection(FieldMappingCollectionType.ARRAY);
                } else {
                    // -- if the fieldType is the collection, then set
                    // appropriate
                    // -- collection type
                    String colName = CollectionHandlers.getCollectionName(fieldType);
                    if (colName != null) {
                        fieldMap.setCollection(FieldMappingCollectionType.valueOf(colName));
                        fieldType = Object.class;
                    } else if (_mappingLoader.returnsArray(cls, fieldName, fieldType)) {
                        // -- help maintain compatibility with generated
                        // descriptors
                        fieldMap.setCollection(FieldMappingCollectionType.ARRAY);
                    } else {
                        fieldMap.setCollection(FieldMappingCollectionType.ENUMERATE);
                    }
                }
            }

            // -- fieldType
            fieldMap.setType(fieldType.getName());

            // -- handle XML Specific information
            fieldMap.setBindXml(new BindXml());
            fieldMap.getBindXml().setName(((XMLFieldDescriptor) fdesc).getXMLName());
            fieldMap.getBindXml().setNode(
                    BindXmlNodeType.valueOf(((XMLFieldDescriptor) fields[i]).getNodeType()
                            .toString()));
            if (classMap.getClassChoice() == null) {
                classMap.setClassChoice(new ClassChoice());
            }
            classMap.getClassChoice().addFieldMapping(fieldMap);

            if (deep) {
                if (_mappings.get(fieldType) != null) {
                    continue;
                }
View Full Code Here

Examples of org.objectweb.jorm.metainfo.api.ClassMapping

                                    String projectName,
                                    String mapperName,
                          JormMIMappingBuilder mb)
          throws SpeedoException, PException {
    Class clazz = sc.jormclass;
    ClassMapping cm = clazz.getClassProject(projectName)
        .getMapping(mapperName).getClassMapping();
        logger.log(BasicLevel.DEBUG, "Generate the Jorm MI for the class "
                + clazz.getFQName());
        for (Iterator fieldsIt = sc.fields.values().iterator();fieldsIt.hasNext();) {
            SpeedoField sp = (SpeedoField) fieldsIt.next();
View Full Code Here

Examples of org.xorm.ClassMapping

     * and sets the Type field to the correct class.
     */
    public boolean visitFieldAccess(Expression.FieldAccess exp) {
  if (exp == Expression.FieldAccess.THIS) { return true; }
        Expression owner = exp.getOwner();
        ClassMapping mapping;
        if (owner != Expression.FieldAccess.THIS) {
            owner.accept(this);
            mapping = getModelMapping()
                .getClassMapping(exp.getOwner().getType());
        } else {
            mapping = getModelMapping()
                .getClassMapping(query.getCandidateClass());
        }
        //System.out.println("Setting type of field " + exp.getName() + " to " + mapping.getFieldDescriptor(exp.getName()).type + " using mapping for " + mapping.getMappedClass());
        exp.setType(mapping.getFieldDescriptor(exp.getName()).type);
        return true;
    }
View Full Code Here

Examples of st.gravel.support.compiler.ast.ClassMapping

    } );
  }

  public static ClassDescriptionMirror getClassMirror(
      Class<? extends Object> aClass) {
    ClassMapping classMapping = ImageBootstrapper.systemMapping
        .classMappingForJavaClass_(aClass);
    return ClassDescriptionMirror.forReference(classMapping.reference());
  }
View Full Code Here

Examples of st.gravel.support.compiler.ast.ClassMapping

        .classMappingForJavaClass_(aClass);
    return ClassDescriptionMirror.forReference(classMapping.reference());
  }

  public static ClassDescriptionMirror getNilClassMirror() {
    ClassMapping classMapping = ImageBootstrapper.systemMapping
        .nilClassMapping();
    return ClassDescriptionMirror.forReference(classMapping.reference());
  }
View Full Code Here

Examples of st.gravel.support.compiler.ast.ClassMapping

    }
    return receiver;
  }

  public static boolean inheritsFrom_(ObjectClass receiver, Object arg) {
    ClassMapping cm = ImageBootstrapper.systemMapping
        .classMappingForJavaClass_(receiver.getClass());
    ClassMapping other = ImageBootstrapper.systemMapping
        .classMappingForJavaClass_(arg.getClass());
    AbstractClassMapping sm = cm;
    while (sm != null) {
      sm = sm.superclassMappingIn_(ImageBootstrapper.systemMapping);
      if (sm == other)
View Full Code Here

Examples of st.gravel.support.compiler.ast.ClassMapping

  public static boolean identityEquals_(Object receiver, Object other) {
    return (receiver == null && other == null) || (receiver == other);
  }

  public static String classTitle(ObjectClass receiver) {
    ClassMapping cm = ImageBootstrapper.systemMapping
        .classMappingForJavaClass_(receiver.getClass());
    return cm.reference().nonmeta().toString();
  }
View Full Code Here

Examples of st.gravel.support.compiler.ast.ClassMapping

    }
  }

  public SystemMappingUpdater executeUpdateClassDescriptorDiff_reference_(final UpdateClassDescriptorDiff _anUpdateClassDescriptorDiff, final Reference _aReference) {
    final ExtensionClassPartMapping _ecm;
    ClassMapping _cm;
    final ClassDescriptionNode _ncn;
    final MethodNode[] _methods;
    _cm = ((ClassMapping) _systemMapping.classMappingAtReference_(_aReference));
    _cm = ((ClassMapping) st.gravel.support.jvm.ArrayExtensions.inject_into_(_anUpdateClassDescriptorDiff.updatedMethodNodes(), _cm, ((st.gravel.support.jvm.Block2<ClassMapping, ClassMapping, MethodNode>) (new st.gravel.support.jvm.Block2<ClassMapping, ClassMapping, MethodNode>() {

      @Override
      public ClassMapping value_value_(final ClassMapping _classMapping, final MethodNode _methodNode) {
        return (ClassMapping) _classMapping.withoutMethodMapping_(_methodNode.selector());
      }
    }))));
    _cm = ((ClassMapping) st.gravel.support.jvm.ArrayExtensions.inject_into_(_anUpdateClassDescriptorDiff.deletedSelectors(), _cm, ((st.gravel.support.jvm.Block2<ClassMapping, ClassMapping, String>) (new st.gravel.support.jvm.Block2<ClassMapping, ClassMapping, String>() {

      @Override
      public ClassMapping value_value_(final ClassMapping _classMapping, final String _selector) {
        return (ClassMapping) _classMapping.withoutMethodMapping_(_selector);
      }
    }))));
    _ncn = _anUpdateClassDescriptorDiff.applyOnClassNode_(_cm.classNode());
    _methods = st.gravel.support.jvm.ArrayExtensions.copyWithAll_(_anUpdateClassDescriptorDiff.methodNodes(), _anUpdateClassDescriptorDiff.updatedMethodNodes());
    _ecm = this.compileExtensionClassPartMapping_methods_identityClass_instVars_sourceFile_(_ncn, _methods, _cm.identityClass(), _cm.classNode().boundInstVars(), this.findSourceFile_(_anUpdateClassDescriptorDiff.methodNodes()));
    _systemMapping.addClassMapping_(_cm.withClassNode_(_ncn).withExtension_(_ecm));
    return this;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.