예제 #1
0
 public Object construct(final ByteBuffer in, ValueHandler handler) throws AmqpErrorException {
   if (in.hasRemaining()) {
     byte b = in.get();
     return UnsignedLong.valueOf(((long) b) & 0xffL);
   } else {
     Error error = new Error();
     error.setCondition(ConnectionError.FRAMING_ERROR);
     error.setDescription("Cannot construct ulong: insufficient input data");
     throw new AmqpErrorException(error);
   }
 }
예제 #2
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;
    }
  }
}
예제 #3
0
public class OpenConstructor extends DescribedTypeConstructor<Open> {
  private static final Object[] DESCRIPTORS = {
    Symbol.valueOf("amqp:open:list"), UnsignedLong.valueOf(0x0000000000000010L),
  };

  private static final OpenConstructor INSTANCE = new OpenConstructor();

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

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

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

        if (val != null) {

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

            // TODO Error
          }
        }

      } else {
        return obj;
      }

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

        if (val != null) {

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

            // TODO Error
          }
        }

      } else {
        return obj;
      }

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

        if (val != null) {

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

            // TODO Error
          }
        }

      } else {
        return obj;
      }

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

        if (val != null) {

          try {
            obj.setChannelMax((UnsignedShort) val);
          } catch (ClassCastException e) {

            // TODO Error
          }
        }

      } else {
        return obj;
      }

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

        if (val != null) {

          try {
            obj.setIdleTimeOut((UnsignedInteger) 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.setOutgoingLocales((Symbol[]) val);
          } else {
            try {
              obj.setOutgoingLocales(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.setIncomingLocales((Symbol[]) val);
          } else {
            try {
              obj.setIncomingLocales(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.setOfferedCapabilities((Symbol[]) val);
          } else {
            try {
              obj.setOfferedCapabilities(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.setDesiredCapabilities((Symbol[]) val);
          } else {
            try {
              obj.setDesiredCapabilities(new Symbol[] {(Symbol) val});
            } catch (ClassCastException e) {
              // TODO Error
            }
          }
        }

      } else {
        return obj;
      }

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

        if (val != null) {

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

            // TODO Error
          }
        }

      } else {
        return obj;
      }

      return obj;
    } else {
      // TODO - error
      return null;
    }
  }
}
예제 #4
0
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;
    }
  }
}