Package org.apache.jdo.model.jdo

Examples of org.apache.jdo.model.jdo.JDOField


    {
        final JDOClass clazz = getJDOClass(classPath);
        if (clazz == null) {
            return null;
        }
        final JDOField field = clazz.getDeclaredField(fieldName);
        affirm(field == null || field.getDeclaringClass() == clazz,
               "field not declared in class: " + classPath + "." + fieldName);
        return field;
    }
View Full Code Here


    private boolean hasFieldModifier(String classPath,
                                     String fieldName,
                                     int fieldModifier)
        throws EnhancerMetaDataUserException, EnhancerMetaDataFatalError
    {
        final JDOField field = getJDOField(classPath, fieldName);
        if (field == null) {
            return false;
        }
        final int pm = field.getPersistenceModifier();
        affirm(pm != PersistenceModifier.UNSPECIFIED,
               "field modifier 'UNSPECIFIED': " + classPath + "." + fieldName);
        return (pm & fieldModifier) != 0;
    }
View Full Code Here

                   "cannot find class file for class: " + classPath);
            JavaField javaField = javaClass.getJavaField(fieldName);
            affirm(javaField != null,
                   "cannot find java field " + classPath + "." + fieldName);
            JavaType fieldType = javaField.getType();
            JDOField field = clazz.getField(fieldName);
            // if field not known by JDOClass (not specified in JDO XML),
            // create the field only if the model's method of default
            // calculation would yield a persistent field.  We must not
            // change the models state by newly created fields with
            // a persistence-modifier "none", because this would lead to
            // in a different annotation by isKnownNonManagedField().
            if (field == null
                && TypeSupport.isPersistenceFieldType(fieldType)) {
                field = clazz.createJDOField(fieldName);
                affirm(field != null,
                       "cannot create JDO field: "
                       + classPath + "." + fieldName);
            }
            field.setJavaField(javaField);
            affirm(fieldType == field.getType());
            affirm(field.getPersistenceModifier()
                   != PersistenceModifier.UNSPECIFIED,
                   "known, unspecified JDO field: " + classPath + "." + fieldName);
        } catch (ModelFatalException ex) {
            throw new EnhancerMetaDataUserException(ex);
        } catch (ModelException ex) {
View Full Code Here

                return true;
            }
           
            // check whether field is managed only if field's
            // persistence-modifier is known by the JDO model
            final JDOField field = clazz.getField(fieldName);
            if (field != null && (field.getPersistenceModifier()
                                  != PersistenceModifier.UNSPECIFIED)) {
                // only field's persistence-modifier known by model
                return !field.isManaged();
            }

            // field not known by JDOClass (not specified in JDO XML)
            // apply model's method of default calculation without
            // changing the model's state
View Full Code Here

     * Tests whether a field of a class is known to be Key.
     */
    public boolean isKeyField(String classPath, String fieldName)
        throws EnhancerMetaDataUserException, EnhancerMetaDataFatalError
    {
        final JDOField field = getJDOField(classPath, fieldName);
        if (field == null) {
            return false;
        }
        return field.isPrimaryKey();
    }
View Full Code Here

     * Default Fetch Group.
     */
    public boolean isDefaultFetchGroupField(String classPath, String fieldName)
        throws EnhancerMetaDataUserException, EnhancerMetaDataFatalError
    {
        final JDOField field = getJDOField(classPath, fieldName);
        if (field == null) {
            return false;
        }
        return field.isDefaultFetchGroup();
    }
View Full Code Here

     * class.
     */
    public int getFieldNumber(String classPath, String fieldName)
        throws EnhancerMetaDataUserException, EnhancerMetaDataFatalError
    {
        final JDOField field = getJDOField(classPath, fieldName);
        if (field == null) {
            return -1;
        }
        return field.getRelativeFieldNumber();
    }
View Full Code Here

        if (skipXMLElements)
            return;
        boolean trace = logger.isTraceEnabled();
        if (trace)
            logger.trace("  <field>"); //NOI18N
        JDOField jdoField = null;
        try {
            // get the current JDOClass from context stack
            JDOClass jdoClass = (JDOClass)context.peek();
            String fieldName = meta.getValue("", "name"); //NOI18N
            jdoField =  jdoClass.createJDOField(fieldName);
            for (int i = 0; i < meta.getLength(); i++ ) {
                String name = meta.getLocalName(i);
                String value = meta.getValue(i);
                if (trace)
                    logger.trace("    " + name + " = " + value); //NOI18N
                if ("name".equals(name)) { //NOI18N
                    // name is already set during create => do nothing
                }
                else if ("persistence-modifier".equals(name)) { //NOI18N
                    int modifier =
                        PersistenceModifier.toPersistenceModifier(value);
                    jdoField.setPersistenceModifier(modifier);
                }
                else if ("primary-key".equals(name)) { //NOI18N
                    jdoField.setPrimaryKey(
                        Boolean.valueOf(value).booleanValue());
                }
                else if ("null-value".equals(name)) { //NOI18N
                    jdoField.setNullValueTreatment(
                        NullValueTreatment.toNullValueTreatment(value));
                }
                else if ("default-fetch-group".equals(name)) { //NOI18N
                    jdoField.setDefaultFetchGroup(
                        Boolean.valueOf(value).booleanValue());
                }
                else if ("embedded".equals(name)) { //NOI18N
                    jdoField.setEmbedded(
                        Boolean.valueOf(value).booleanValue());
                }
                else {
                    /* JDO2 metadata not yet fully supported =>
                       do not throw exception now
View Full Code Here

        if (trace)
            logger.trace("  <collection>"); //NOI18N
        JDOCollection jdoCollection = null;
        try {
            // get the current JDOField from context stack
            JDOField jdoField = (JDOField)context.peek();
            jdoCollection = jdoField.createJDOCollection();
            for (int i = 0; i < meta.getLength(); i++ ) {
                String name = meta.getLocalName(i);
                String value = meta.getValue(i);
                if (trace)
                    logger.trace("    " + name + " = " + value); //NOI18N
View Full Code Here

        if (trace)
            logger.trace("  <array>"); //NOI18N
        JDOArray jdoArray = null;
        try {
            // get the current JDOField from context stack
            JDOField jdoField = (JDOField)context.peek();
            jdoArray = jdoField.createJDOArray();
            for (int i = 0; i < meta.getLength(); i++ ) {
                String name = meta.getLocalName(i);
                String value = meta.getValue(i);
                if (trace)
                    logger.trace("    " + name + " = " + value); //NOI18N
View Full Code Here

TOP

Related Classes of org.apache.jdo.model.jdo.JDOField

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.