コード例 #1
0
ファイル: RecordInput.java プロジェクト: lzimm/qluster
 /** @see EntityInput#skipField */
 public void skipField(Format declaredFormat) {
   if (declaredFormat != null && declaredFormat.isPrimitive()) {
     declaredFormat.skipContents(this);
   } else {
     int formatId = readPackedInt();
     if (formatId > 0) {
       Format format = catalog.getFormat(formatId, true /*expectStored*/);
       format.skipContents(this);
     }
   }
 }
コード例 #2
0
ファイル: RecordInput.java プロジェクト: lzimm/qluster
 /**
  * Called when copying secondary keys, for an input that is positioned on the secondary key field.
  * Handles references to previously occurring objects, returning a different RecordInput than this
  * one if appropriate.
  */
 KeyLocation getKeyLocation(Format fieldFormat) {
   RecordInput input = this;
   if (!fieldFormat.isPrimitive()) {
     int formatId = input.readPackedInt();
     if (formatId == Format.ID_NULL) {
       /* Key field is null. */
       return null;
     }
     if (formatId < 0) {
       int offset = (-(formatId + 1));
       if (offset == RecordInput.PRI_KEY_VISITED_OFFSET) {
         assert priKeyEntry != null && priKeyFormatId > 0;
         input = new RecordInput(this, priKeyEntry);
         formatId = priKeyFormatId;
       } else {
         input = new RecordInput(this, offset);
         formatId = input.readPackedInt();
       }
     }
     fieldFormat = catalog.getFormat(formatId, true /*expectStored*/);
   }
   /* Key field is non-null. */
   return new KeyLocation(input, fieldFormat);
 }
コード例 #3
0
 Object checkAndConvert(Object o, Format declaredFormat) {
   if (o == null) {
     if (declaredFormat.isPrimitive()) {
       throw new IllegalArgumentException(
           "A primitive type may not be null or missing: " + declaredFormat.getClassName());
     }
   } else if (declaredFormat.isSimple()) {
     if (declaredFormat.isPrimitive()) {
       if (o.getClass() != declaredFormat.getWrapperFormat().getType()) {
         throw new IllegalArgumentException(
             "Raw value class: "
                 + o.getClass().getName()
                 + " must be the wrapper class for a primitive type: "
                 + declaredFormat.getClassName());
       }
     } else {
       if (o.getClass() != declaredFormat.getType()) {
         throw new IllegalArgumentException(
             "Raw value class: "
                 + o.getClass().getName()
                 + " must be the declared class for a simple type: "
                 + declaredFormat.getClassName());
       }
     }
   } else {
     if (o instanceof RawObject) {
       Object o2 = null;
       if (!rawAccess) {
         if (converted != null) {
           o2 = converted.get(o);
         } else {
           converted = new IdentityHashMap();
         }
       }
       if (o2 != null) {
         o = o2;
       } else {
         if (!rawAccess) {
           o = catalog.convertRawObject((RawObject) o, converted);
         }
       }
     } else {
       if (!SimpleCatalog.isSimpleType(o.getClass())) {
         throw new IllegalArgumentException(
             "Raw value class: " + o.getClass().getName() + " must be RawObject a simple type");
       }
     }
     if (rawAccess) {
       checkRawType(catalog, o, declaredFormat);
     } else {
       if (!declaredFormat.getType().isAssignableFrom(o.getClass())) {
         throw new IllegalArgumentException(
             "Raw value class: "
                 + o.getClass().getName()
                 + " is not assignable to type: "
                 + declaredFormat.getClassName());
       }
     }
   }
   return o;
 }