コード例 #1
0
public class ReceivedConstructor extends DescribedTypeConstructor<Received> {
  private static final Object[] DESCRIPTORS = {
    Symbol.valueOf("amqp:received:list"), UnsignedLong.valueOf(0x0000000000000023L),
  };

  private static final ReceivedConstructor INSTANCE = new ReceivedConstructor();

  public static void register(DescribedTypeConstructorRegistry registry) {
    for (Object descriptor : DESCRIPTORS) {
      registry.register(descriptor, INSTANCE);
    }
  }

  public Received construct(Object underlying) {
    if (underlying instanceof List) {
      List list = (List) underlying;
      Received obj = new Received();
      int position = 0;
      final int size = list.size();

      if (position < size) {
        Object val = list.get(position);
        position++;

        if (val != null) {

          try {
            obj.setSectionNumber((UnsignedInteger) val);
          } catch (ClassCastException e) {

            // TODO Error
          }
        }

      } else {
        return obj;
      }

      if (position < size) {
        Object val = list.get(position);
        position++;

        if (val != null) {

          try {
            obj.setSectionOffset((UnsignedLong) val);
          } catch (ClassCastException e) {

            // TODO Error
          }
        }

      } else {
        return obj;
      }

      return obj;
    } else {
      // TODO - error
      return null;
    }
  }
}
コード例 #2
0
ファイル: SourceConstructor.java プロジェクト: ncdc/qpid
public class SourceConstructor extends DescribedTypeConstructor<Source> {
  private static final Object[] DESCRIPTORS = {
    Symbol.valueOf("amqp:source:list"), UnsignedLong.valueOf(0x0000000000000028L),
  };

  private static final SourceConstructor INSTANCE = new SourceConstructor();

  public static void register(DescribedTypeConstructorRegistry registry) {
    for (Object descriptor : DESCRIPTORS) {
      registry.register(descriptor, INSTANCE);
    }
  }

  public Source construct(Object underlying) {
    if (underlying instanceof List) {
      List list = (List) underlying;
      Source obj = new Source();
      int position = 0;
      final int size = list.size();

      if (position < size) {
        Object val = list.get(position);
        position++;

        if (val != null) {

          try {
            obj.setAddress((String) val);
          } catch (ClassCastException e) {

            // TODO Error
          }
        }

      } else {
        return obj;
      }

      if (position < size) {
        Object val = list.get(position);
        position++;

        if (val != null) {

          try {
            obj.setDurable(TerminusDurability.valueOf(val));
          } catch (ClassCastException e) {

            // TODO Error
          }
        }

      } else {
        return obj;
      }

      if (position < size) {
        Object val = list.get(position);
        position++;

        if (val != null) {

          try {
            obj.setExpiryPolicy(TerminusExpiryPolicy.valueOf(val));
          } catch (ClassCastException e) {

            // TODO Error
          }
        }

      } else {
        return obj;
      }

      if (position < size) {
        Object val = list.get(position);
        position++;

        if (val != null) {

          try {
            obj.setTimeout((UnsignedInteger) val);
          } catch (ClassCastException e) {

            // TODO Error
          }
        }

      } else {
        return obj;
      }

      if (position < size) {
        Object val = list.get(position);
        position++;

        if (val != null) {

          try {
            obj.setDynamic((Boolean) val);
          } catch (ClassCastException e) {

            // TODO Error
          }
        }

      } else {
        return obj;
      }

      if (position < size) {
        Object val = list.get(position);
        position++;

        if (val != null) {

          try {
            obj.setDynamicNodeProperties((Map) val);
          } catch (ClassCastException e) {

            // TODO Error
          }
        }

      } else {
        return obj;
      }

      if (position < size) {
        Object val = list.get(position);
        position++;

        if (val != null) {

          try {
            obj.setDistributionMode((DistributionMode) val);
          } catch (ClassCastException e) {

            // TODO Error
          }
        }

      } else {
        return obj;
      }

      if (position < size) {
        Object val = list.get(position);
        position++;

        if (val != null) {

          try {
            obj.setFilter((Map) val);
          } catch (ClassCastException e) {

            // TODO Error
          }
        }

      } else {
        return obj;
      }

      if (position < size) {
        Object val = list.get(position);
        position++;

        if (val != null) {

          try {
            obj.setDefaultOutcome((Outcome) val);
          } catch (ClassCastException e) {

            // TODO Error
          }
        }

      } else {
        return obj;
      }

      if (position < size) {
        Object val = list.get(position);
        position++;

        if (val != null) {

          if (val instanceof Symbol[]) {
            obj.setOutcomes((Symbol[]) val);
          } else {
            try {
              obj.setOutcomes(new Symbol[] {(Symbol) val});
            } catch (ClassCastException e) {
              // TODO Error
            }
          }
        }

      } else {
        return obj;
      }

      if (position < size) {
        Object val = list.get(position);
        position++;

        if (val != null) {

          if (val instanceof Symbol[]) {
            obj.setCapabilities((Symbol[]) val);
          } else {
            try {
              obj.setCapabilities(new Symbol[] {(Symbol) val});
            } catch (ClassCastException e) {
              // TODO Error
            }
          }
        }

      } else {
        return obj;
      }

      return obj;
    } else {
      // TODO - error
      return null;
    }
  }
}