private object ReadFieldValue(ClassMetadata classMetadata, FieldMetadata field)
		{
			if (!classMetadata.SeekToField(this, field))
			{
				return null;
			}
			return field.Read(this);
		}
Beispiel #2
0
 internal virtual bool CreateChild(QCandidates a_candidates)
 {
     if (!_include)
     {
         return(false);
     }
     if (_fieldMetadata != null)
     {
         ITypeHandler4 handler = _fieldMetadata.GetHandler();
         if (handler != null)
         {
             QueryingReadContext queryingReadContext = new QueryingReadContext(Transaction(),
                                                                               MarshallerFamily().HandlerVersion(), _bytes, _key);
             ITypeHandler4 arrayElementHandler = Handlers4.ArrayElementHandler(handler, queryingReadContext
                                                                               );
             if (arrayElementHandler != null)
             {
                 int  offset   = queryingReadContext.Offset();
                 bool outerRes = true;
                 // The following construct is worse than not ideal.
                 // For each constraint it completely reads the
                 // underlying structure again. The structure could b
                 // kept fairly easy. TODO: Optimize!
                 IEnumerator i = a_candidates.IterateConstraints();
                 while (i.MoveNext())
                 {
                     QCon   qcon = (QCon)i.Current;
                     QField qf   = qcon.GetField();
                     if (qf == null || qf.Name().Equals(_fieldMetadata.GetName()))
                     {
                         QCon tempParent = qcon.Parent();
                         qcon.SetParent(null);
                         QCandidates candidates = new QCandidates(a_candidates.i_trans, null, qf);
                         candidates.AddConstraint(qcon);
                         qcon.SetCandidates(candidates);
                         ReadArrayCandidates(handler, queryingReadContext.Buffer(), arrayElementHandler, candidates
                                             );
                         queryingReadContext.Seek(offset);
                         bool isNot = qcon.IsNot();
                         if (isNot)
                         {
                             qcon.RemoveNot();
                         }
                         candidates.Evaluate();
                         ByRef  pending  = ByRef.NewInstance();
                         bool[] innerRes = new bool[] { isNot };
                         candidates.Traverse(new _IVisitor4_160(innerRes, isNot, pending));
                         // Collect all pending subresults.
                         // We need to change
                         // the
                         // constraint here, so
                         // our
                         // pending collector
                         // uses
                         // the right
                         // comparator.
                         // We only keep one
                         // pending result
                         // for
                         // all array
                         // elements.
                         // and memorize,
                         // whether we had a
                         // true or a false
                         // result.
                         // or both.
                         if (isNot)
                         {
                             qcon.Not();
                         }
                         // In case we had pending subresults, we
                         // need to communicate
                         // them up to our root.
                         if (((Tree)pending.value) != null)
                         {
                             ((Tree)pending.value).Traverse(new _IVisitor4_229(this));
                         }
                         if (!innerRes[0])
                         {
                             // Again this could be double triggering.
                             //
                             // We want to clean up the "No route"
                             // at some stage.
                             qcon.Visit(GetRoot(), qcon.Evaluator().Not(false));
                             outerRes = false;
                         }
                         qcon.SetParent(tempParent);
                     }
                 }
                 return(outerRes);
             }
             // We may get simple types here too, if the YapField was null
             // in the higher level simple evaluation. Evaluate these
             // immediately.
             if (Handlers4.IsQueryLeaf(handler))
             {
                 a_candidates.i_currentConstraint.Visit(this);
                 return(true);
             }
         }
     }
     if (_fieldMetadata == null)
     {
         return(false);
     }
     if (_fieldMetadata is NullFieldMetadata)
     {
         return(false);
     }
     _classMetadata.SeekToField(Transaction(), _bytes, _fieldMetadata);
     Db4objects.Db4o.Internal.Query.Processor.QCandidate candidate = ReadSubCandidate(
         a_candidates);
     if (candidate == null)
     {
         return(false);
     }
     // fast early check for ClassMetadata
     if (a_candidates.i_classMetadata != null && a_candidates.i_classMetadata.IsStronglyTyped
             ())
     {
         ITypeHandler4 handler = _fieldMetadata.GetHandler();
         if (Handlers4.IsUntyped(handler))
         {
             handler = TypeHandlerFor(candidate);
         }
         if (handler == null)
         {
             return(false);
         }
     }
     AddDependant(a_candidates.Add(candidate));
     return(true);
 }
Beispiel #3
0
 /// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception>
 private DatabaseIdentityIDAndUUID ReadDatabaseIdentityIDAndUUID
     (ObjectContainerBase container, ClassMetadata classMetadata, Slot oldSlot, bool
         checkClass)
 {
     if (DTrace.enabled)
     {
         DTrace.RereadOldUuid.LogLength(oldSlot.Address(), oldSlot.Length());
     }
     var reader = container.DecryptedBufferByAddress(oldSlot.Address(), oldSlot
         .Length());
     if (checkClass)
     {
         var realClass = ClassMetadata.ReadClass(container, reader);
         if (realClass != classMetadata)
         {
             return null;
         }
     }
     if (classMetadata.SeekToField(container.Transaction, reader, this) == HandlerVersion
         .Invalid)
     {
         return null;
     }
     return new DatabaseIdentityIDAndUUID(reader.ReadInt(), reader.ReadLong
         ());
 }