Package org.apache.mina.codec.delimited.ints

Examples of org.apache.mina.codec.delimited.ints.VarInt$Encoder


  {
    CommandMessage commandMessage = new CommandMessage();
    commandMessage.setOperation( CommandMessage.LOGIN_OPERATION );

    String credString = username + ":" + password;
    Encoder encoder = new Encoder( credString.length() );
    encoder.encode( credString.getBytes() );

    commandMessage.setBody( encoder.drain() );
    commandMessage.setDestination( DESTINATION );
    return commandMessage;
  }
View Full Code Here


    private CommandMessage createLoginCommandMessage() {
        CommandMessage commandMessage = new CommandMessage();
        commandMessage.setOperation(CommandMessage.LOGIN_OPERATION);

        String credString = username + ":" + password;
        Encoder encoder = new Encoder(credString.length());
        encoder.encode(credString.getBytes());

        commandMessage.setBody(encoder.drain());
        commandMessage.setDestination(DESTINATION);
        return commandMessage;
    }
View Full Code Here

    public static <L extends GeneratedMessage> ProtobufEncoder<L> newInstance(Class<L> clazz) {
        return new ProtobufEncoder<L>(clazz);
    }

    public ProtobufEncoder(Class<INPUT> clazz) {
        super(new VarInt().getEncoder(), ProtobufMessageEncoder.newInstance(clazz));
    }
View Full Code Here

    return newInstance(clazz, ExtensionRegistryLite.getEmptyRegistry());
  }

  public ProtobufDecoder(Class<OUTPUT> clazz, ExtensionRegistryLite registry)
      throws NoSuchMethodException {
    super(new VarInt().getDecoder(), ProtobufMessageDecoder.newInstance(
        clazz, registry));
  }
View Full Code Here

    public static <L extends GeneratedMessage> ProtobufDynamicDecoder newInstance() throws NoSuchMethodException {
        return new ProtobufDynamicDecoder();
    }

    public ProtobufDynamicDecoder() throws NoSuchMethodException {
        super(new VarInt().getDecoder(), ProtobufDynamicMessageDecoder.newInstance());
    }
View Full Code Here

      throws NoSuchMethodException {
    return new ThriftDynamicDecoder();
  }

  public ThriftDynamicDecoder() throws NoSuchMethodException {
    super(new VarInt().getDecoder(), new ThriftDynamicMessageDecoder());
  }
View Full Code Here

     * Construct an Avro Decoder
     *
     * @param schema            Avro Schema to be used
     */
    public AvroDecoder(Schema schema) {
        super(new VarInt().getDecoder(), new AvroMessageDecoder<T>(schema));
    }
View Full Code Here

    /**
     * Intializes the Avro Encoder
     * Default Encoder are VarInt encoder for Size and {@link AvroEncoder} for Avro encoding
     */
    public AvroEncoder() {
        super(new VarInt().getEncoder(), new AvroMessageEncoder<T>());
    }
View Full Code Here

    pHandler.startElement("", VALUE_TAG, VALUE_TAG, ZERO_ATTRIBUTES);
    pHandler.startElement("", BASE_64_TAG, BASE_64_TAG, ZERO_ATTRIBUTES);
    byte[] buffer = (byte[]) pObject;
    if (buffer.length > 0) {
      char[] charBuffer = new char[buffer.length >= 1024 ? 1024 : ((buffer.length+3)/4)*4];
      Encoder encoder = new Base64.SAXEncoder(charBuffer, 0, null, pHandler);
      try {
        encoder.write(buffer, 0, buffer.length);
        encoder.flush();
      } catch (Base64.SAXIOException e) {
        throw e.getSAXException();
      } catch (IOException e) {
        throw new SAXException(e);
      }
View Full Code Here

  public void write(final ContentHandler pHandler, Object pObject) throws SAXException {
    pHandler.startElement("", VALUE_TAG, VALUE_TAG, ZERO_ATTRIBUTES);
    pHandler.startElement("", SERIALIZABLE_TAG, EX_SERIALIZABLE_TAG, ZERO_ATTRIBUTES);
    char[] buffer = new char[1024];
    Encoder encoder = new Base64.SAXEncoder(buffer, 0, null, pHandler);
    try {
      OutputStream ostream = new EncoderOutputStream(encoder);
      ObjectOutputStream oos = new ObjectOutputStream(ostream);
      oos.writeObject(pObject);
      oos.close();
View Full Code Here

TOP

Related Classes of org.apache.mina.codec.delimited.ints.VarInt$Encoder

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.