Package com.mobixess.jodb.core.transaction.JODBSession

Examples of com.mobixess.jodb.core.transaction.JODBSession.ClassDescriptor


    }

    public Object composeInstance(Class type,
            ObjectDataContainer persistentDataContainer, JODBSession session) throws IOException
    {
        ClassDescriptor classDescriptor;

        classDescriptor = session.getDescriptorForClass(type);


        if (persistentDataContainer.isArray()) {
            return Array.newInstance(type, persistentDataContainer.getActiveFieldsIterator().getRemainingInCurrentCategory());
        }
           
        try {
            return classDescriptor.newInstance();
        } catch (IllegalClassTypeException e) {
            throw new JodbIOException(e);
        }
    }
View Full Code Here


            return objectsAreEqual(value1, value2, context, fieldsToIgnore);
        }
    }
   
    private boolean objectsAreEqual(Object value1, Object value2, JODBOperationContext context, Field[] fieldsToIgnore) {
        ClassDescriptor classDescriptor = context.getSession().getDescriptorForClass(value1.getClass());

        FieldAndIDRecord[] fields = classDescriptor.getAllFields();
        for (int i = 0; i < fields.length; i++) {
            Field field = fields[i]._field;
            if(ArrayUtils.indexOf(fieldsToIgnore, field)!=-1 ){
                continue;
            }
View Full Code Here

    }

    public boolean equals(Object value1, ObjectDataContainer value2,
            JODBOperationContext context, Field[] fieldsToIgnore) throws IOException
    {
        ClassDescriptor desc;
        try {
            desc = context.getSession().getDescriptorForClass(value1.getClass());
            if (desc.isArray()) {
                return checkActiveArrayObjectUnchanged(context, value1, value2, desc);
            }
        } catch (IllegalClassTypeException e) {
            e.printStackTrace();
            throw new JodbIOException(e);
View Full Code Here

        }
    }


    private static void fillObject(JODBSession session, boolean delayedActivation, ObjectDataContainer objectDataContainer,  Object instance, int remainingDepth) throws IOException{
        ClassDescriptor classDescriptor = session.getDescriptorForClass(instance.getClass());

        IOBase base = session.getBase();
        FieldsIterator fieldsIterator = objectDataContainer.getActiveFieldsIterator();
        if(fieldsIterator == null){
            return;
        }
        BitSet processedFieldMask = new BitSet();
        FieldRecord record = objectDataContainer.getRecordCache();
        for (int i = 0; fieldsIterator.hasNext(); i++) {
            fieldsIterator.next(record, base);
            Field field = classDescriptor.getFieldForID(record._fieldID, processedFieldMask);
            if (field == null) {
                continue;
            }
            if (field.getType().isPrimitive() && !delayedActivation) {
                try {
                    field.set(instance, record._value);
                } catch (Exception e) {
                    setDefaultValue(instance, field);
                    //TODO add debug level output
                }
                continue;
            }
            if (remainingDepth < 1) {
                continue;
            }
            Object child = TransactionUtils.launchObject(session, record._objectOffset, null, remainingDepth - 1);
            try {
                if(child!=null || JODBConfig.isAllowNullInReflectionSet()){
                    field.set(instance, child);
                }
            } catch (Exception e) {
                setDefaultValue(instance, field);
                //TODO add debug level output
                continue;
            }
        }
        if (!delayedActivation) {
            FieldAndIDRecord[] fields = classDescriptor.getAllFields();
            for (int i = 0; i < fields.length; i++) {//set default values for remaining fields
                if (processedFieldMask.get(i)) {
                    continue;
                }
                setDefaultValue(instance, fields[i]._field);
View Full Code Here

        FieldsIterator fieldsIterator = objectDataContainer.getActiveFieldsIterator();
        if(fieldsIterator == null){
            return;
        }
        FieldRecord record = objectDataContainer.getRecordCache();
        ClassDescriptor arrayTypeDescriptor;

        arrayTypeDescriptor = session.getDescriptorForClass(instance.getClass().getComponentType());

        if (arrayTypeDescriptor.isPrimitive()) {
            for (int i = 0; fieldsIterator.hasNext(); i++) {
                fieldsIterator.next(record, base);
                Array.set(instance, i, record._value);
            }
        } else {
View Full Code Here

            }
           
            if(typeConstraint != null){
                //boolean useIndexDataFromIterator = false;
                JODBIndexingRootAgent indexingRootAgent = _session.getIndexingRootAgent();
                ClassDescriptor classDescriptor = _session.getDescriptorForClass((Class)typeConstraint.getObject());
                JODBIndexingAgent indexingAgent = null;
                if(sortDataCache!=null){
                    //lookup indexing data to optimize query
                    SortNodeRecord[] sortRecords = sortDataCache.getSortNodes();
                    int fieldId = classDescriptor.getFieldIDForName(sortRecords[0]._fullPath);
                    if(fieldId!=-1){
                        indexingAgent = indexingRootAgent.getIndexingAgent(fieldId, base);
                        if(indexingAgent!=null){
                            indexIterator = indexingAgent.getIndexIterator(sortRecords[0]._orderAscending);
                            indexedNode = _descendants.get(sortRecords[0]._fullPath);
                            skipConventionalSorting = sortRecords.length == 1;
                        }
                    }
                }
                if(indexIterator == null){
                    //search first index
                    Iterator<String> descendants = _descendants.keySet().iterator();
                    while (descendants.hasNext() && indexIterator == null) {
                        String next = descendants.next();
                        Field field = classDescriptor.getFieldForName(next);
                        if(field==null){
                            continue;
                        }
                        indexingAgent = indexingRootAgent.getIndexingAgent(field, base);
                        if(indexingAgent!=null){
                            indexIterator = indexingAgent.getIndexIterator(true);
                            indexedNode = _descendants.get(next);
                        }
                    }
                }
                if(indexingAgent!=null && indexedNode != null){
                    Field field = classDescriptor.getFieldForID(indexingAgent.getFieldId(), null);
                    Class fieldType = field.getType();                       
                    if(fieldType.isPrimitive()){
                        indexDataIteratorFieldRecord = new FieldRecord();
                        indexDataIteratorFieldRecord._fieldID = indexingAgent.getFieldId();
                        indexDataIteratorFieldRecord._category = FIELD_CATEGORIES.PRIMITIVE;
View Full Code Here

                }
            }           
        }else if(object == null){
            return getCumulativeStatus();
        }
        ClassDescriptor classDescriptor;
        classDescriptor = _session.getDescriptorForClass(object!=null?object.getClass():field.getType());
        Iterator<QueryNode> iterator = _descendants.values().iterator();
        while (iterator.hasNext()) {
            QueryNode descendant = iterator.next();
            Field descendantField = classDescriptor.getFieldForName(descendant._name);
            if (descendantField != null) {
                descendant.analize(object, descendantField, context);
            }
        }
        return getCumulativeStatus();
View Full Code Here

    private CONSTRAINT_EVALUATION_STATUS analize(long objectOffset, FieldRecord fieldRecord, JODBOperationContext context) throws IOException{
        if(context.isServerMode() && context.isExcludedObjectId(objectOffset)){
            _constraints.setStatus(CONSTRAINT_EVALUATION_STATUS.EXCLUDED);
            return CONSTRAINT_EVALUATION_STATUS.EXCLUDED;
        }
        ClassDescriptor classDescriptor = null;
        if( fieldRecord!=null ){
            try {
                classDescriptor = _session.getDescriptorForClass(fieldRecord._fieldTypeID);
            } catch (Exception e) {
                e.printStackTrace();
View Full Code Here

       
        return getCumulativeStatus();
    }
   
    private void assembleForPattern(Object pattern, Collection defaultIgnoreValues){
        ClassDescriptor classDescriptor = _session.getDescriptorForClass(pattern.getClass());
        constrain(pattern.getClass());
        FieldAndIDRecord[] fields = classDescriptor.getAllFields();
        for (int i = 0; i < fields.length; i++) {
            Field descendant = fields[i]._field;
            Object descendantValue;
            try {
                descendantValue = descendant.get(pattern);
View Full Code Here

        if(activeObject!=null){
            Enumeration<QueryNode> descendants = _descendants.elements();
            while (descendants.hasMoreElements()) {
                QueryNode descendantQueryNode = descendants.nextElement();
                if(descendantQueryNode.hasSortInstructions()){
                    ClassDescriptor classDescriptor = context.getSession().getDescriptorForClass(activeObject.getClass());
                    Field descendantField = classDescriptor.getFieldForName(descendantQueryNode._name);
                    if(descendantField!=null){
                        descendantQueryNode.readSortData(activeObject, descendantField, sortDataCache, context);
                    }
                }
            }
View Full Code Here

TOP

Related Classes of com.mobixess.jodb.core.transaction.JODBSession.ClassDescriptor

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.