Tabnine Logo
LineDelimiter
Code IndexAdd Tabnine to your IDE (free)

How to use
LineDelimiter
in
org.apache.mina.filter.codec.textline

Best Java code snippets using org.apache.mina.filter.codec.textline.LineDelimiter (Showing top 20 results out of 315)

origin: org.apache.mina/mina-core

/**
 * Creates a new instance with the specified <tt>charset</tt>
 * and the specified <tt>delimiter</tt>.
 * 
 * @param charset The {@link Charset} to use
 * @param delimiter The line delimiter to use
 */
public TextLineEncoder(Charset charset, String delimiter) {
  this(charset, new LineDelimiter(delimiter));
}
origin: org.apache.mina/mina-core

/**
 * Creates a new instance with the specified <tt>charset</tt>
 * and the specified <tt>delimiter</tt>.
 * 
 * @param charset The {@link Charset} to use
 * @param delimiter The line delimiter to use
 */
public TextLineDecoder(Charset charset, LineDelimiter delimiter) {
  if (charset == null) {
    throw new IllegalArgumentException("charset parameter shuld not be null");
  }
  if (delimiter == null) {
    throw new IllegalArgumentException("delimiter parameter should not be null");
  }
  this.charset = charset;
  this.delimiter = delimiter;
  // Convert delimiter to ByteBuffer if not done yet.
  if (delimBuf == null) {
    IoBuffer tmp = IoBuffer.allocate(2).setAutoExpand(true);
    try {
      tmp.putString(delimiter.getValue(), charset.newEncoder());
    } catch (CharacterCodingException cce) {
    }
    tmp.flip();
    delimBuf = tmp;
  }
}
origin: org.apache.directory.mina/mina-core

public TextLineEncoder( Charset charset, LineDelimiter delimiter )
{
  if( charset == null )
  {
    throw new NullPointerException( "charset" );
  }
  if( delimiter == null )
  {
    throw new NullPointerException( "delimiter" );
  }
  if( LineDelimiter.AUTO.equals( delimiter ) )
  {
    throw new IllegalArgumentException( "AUTO delimiter is not allowed for encoder." );
  }
  
  
  this.charset = charset;
  this.delimiter = delimiter;
}

origin: org.apache.directory.api/api-ldap-client-all

/**
 * Creates a new instance with the specified <tt>charset</tt>
 * and the specified <tt>delimiter</tt>.
 * 
 * @param charset The {@link Charset} to use
 * @param delimiter The line delimiter to use
 */
public TextLineDecoder(Charset charset, LineDelimiter delimiter) {
  if (charset == null) {
    throw new IllegalArgumentException("charset parameter shuld not be null");
  }
  if (delimiter == null) {
    throw new IllegalArgumentException("delimiter parameter should not be null");
  }
  this.charset = charset;
  this.delimiter = delimiter;
  // Convert delimiter to ByteBuffer if not done yet.
  if (delimBuf == null) {
    IoBuffer tmp = IoBuffer.allocate(2).setAutoExpand(true);
    try {
      tmp.putString(delimiter.getValue(), charset.newEncoder());
    } catch (CharacterCodingException cce) {
    }
    tmp.flip();
    delimBuf = tmp;
  }
}
origin: org.apache.mina/mina-core

/**
 * Creates a new instance with the specified <tt>charset</tt>
 * and the specified <tt>delimiter</tt>.
 * 
 * @param charset The {@link Charset} to use
 * @param delimiter The line delimiter to use
 */
public TextLineEncoder(Charset charset, LineDelimiter delimiter) {
  if (charset == null) {
    throw new IllegalArgumentException("charset");
  }
  if (delimiter == null) {
    throw new IllegalArgumentException("delimiter");
  }
  if (LineDelimiter.AUTO.equals(delimiter)) {
    throw new IllegalArgumentException("AUTO delimiter is not allowed for encoder.");
  }
  this.charset = charset;
  this.delimiter = delimiter;
}
origin: org.apache.mina/mina-core

/**
 * {@inheritDoc}
 */
@Override
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
  CharsetEncoder encoder = (CharsetEncoder) session.getAttribute(ENCODER);
  if (encoder == null) {
    encoder = charset.newEncoder();
    session.setAttribute(ENCODER, encoder);
  }
  String value = message == null ? "" : message.toString();
  IoBuffer buf = IoBuffer.allocate(value.length()).setAutoExpand(true);
  buf.putString(value, encoder);
  if (buf.position() > maxLineLength) {
    throw new IllegalArgumentException("Line length: " + buf.position());
  }
  buf.putString(delimiter.getValue(), encoder);
  buf.flip();
  out.write(buf);
}
origin: org.parallelj/parallelj-launching

/**
 * Creates a new instance with the spcified <tt>charset</tt>
 * and the specified <tt>delimiter</tt>.
 */
public TcpIpTextLineEncoder(final Charset charset, final LineDelimiter delimiter) {
  if (charset == null) {
    throw new IllegalArgumentException("charset");
  }
  if (delimiter == null) {
    throw new IllegalArgumentException("delimiter");
  }
  if (LineDelimiter.AUTO.equals(delimiter)) {
    throw new IllegalArgumentException(
        "AUTO delimiter is not allowed for encoder.");
  }
  this.charset = charset;
  //this.delimiter = delimiter;
}
origin: org.apache.mina/mina-core

/**
 * Creates a new instance with the current default {@link Charset}
 * and the specified <tt>delimiter</tt>.
 * 
 * @param delimiter The line delimiter to use
 */
public TextLineDecoder(String delimiter) {
  this(new LineDelimiter(delimiter));
}
origin: kaazing/gateway

public void encode(IoSession session, Object message,
    ProtocolEncoderOutput out) throws Exception {
  CharsetEncoder encoder = (CharsetEncoder) session.getAttribute(ENCODER);
  if (encoder == null) {
    encoder = charset.newEncoder();
    session.setAttribute(ENCODER, encoder);
  }
  String value = message.toString();
  IoBuffer buf = IoBuffer.allocate(value.length())
      .setAutoExpand(true);
  buf.putString(value, encoder);
  if (buf.position() > maxLineLength) {
    throw new IllegalArgumentException("Line length: " + buf.position());
  }
  buf.putString(delimiter.getValue(), encoder);
  buf.flip();
  out.write(buf);
}
origin: kaazing/gateway

/**
 * Creates a new instance with the spcified <tt>charset</tt>
 * and the specified <tt>delimiter</tt>.
 */
public TextLineEncoder(Charset charset, LineDelimiter delimiter) {
  if (charset == null) {
    throw new NullPointerException("charset");
  }
  if (delimiter == null) {
    throw new NullPointerException("delimiter");
  }
  if (LineDelimiter.AUTO.equals(delimiter)) {
    throw new IllegalArgumentException(
        "AUTO delimiter is not allowed for encoder.");
  }
  this.charset = charset;
  this.delimiter = delimiter;
}
origin: org.apache.directory.api/api-ldap-client-all

/**
 * Creates a new instance with the current default {@link Charset}
 * and the specified <tt>delimiter</tt>.
 * 
 * @param delimiter The line delimiter to use
 */
public TextLineDecoder(String delimiter) {
  this(new LineDelimiter(delimiter));
}
origin: org.apache.directory.api/api-ldap-client-all

/**
 * {@inheritDoc}
 */
@Override
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
  CharsetEncoder encoder = (CharsetEncoder) session.getAttribute(ENCODER);
  if (encoder == null) {
    encoder = charset.newEncoder();
    session.setAttribute(ENCODER, encoder);
  }
  String value = message == null ? "" : message.toString();
  IoBuffer buf = IoBuffer.allocate(value.length()).setAutoExpand(true);
  buf.putString(value, encoder);
  if (buf.position() > maxLineLength) {
    throw new IllegalArgumentException("Line length: " + buf.position());
  }
  buf.putString(delimiter.getValue(), encoder);
  buf.flip();
  out.write(buf);
}
origin: org.apache.directory.api/api-ldap-client-all

/**
 * Creates a new instance with the specified <tt>charset</tt>
 * and the specified <tt>delimiter</tt>.
 * 
 * @param charset The {@link Charset} to use
 * @param delimiter The line delimiter to use
 */
public TextLineEncoder(Charset charset, LineDelimiter delimiter) {
  if (charset == null) {
    throw new IllegalArgumentException("charset");
  }
  if (delimiter == null) {
    throw new IllegalArgumentException("delimiter");
  }
  if (LineDelimiter.AUTO.equals(delimiter)) {
    throw new IllegalArgumentException("AUTO delimiter is not allowed for encoder.");
  }
  this.charset = charset;
  this.delimiter = delimiter;
}
origin: org.apache.mina/mina-core

/**
 * Creates a new instance with the current default {@link Charset}
 * and the specified <tt>delimiter</tt>.
 * 
 * @param delimiter The line delimiter to use
 */
public TextLineEncoder(String delimiter) {
  this(new LineDelimiter(delimiter));
}
origin: org.apache.directory.mina/mina-core

public void encode( IoSession session, Object message,
          ProtocolEncoderOutput out )
    throws Exception
{
  CharsetEncoder encoder = ( CharsetEncoder ) session.getAttribute( ENCODER );
  if( encoder == null )
  {
    encoder = charset.newEncoder();
    session.setAttribute( ENCODER, encoder );
  }
  
  String value = message.toString();
  ByteBuffer buf = ByteBuffer.allocate( value.length() ).setAutoExpand( true );
  buf.putString( value, encoder );
  if( buf.position() > maxLineLength )
  {
    throw new IllegalArgumentException( "Line length: " + buf.position() );
  }
  buf.putString( delimiter.getValue(), encoder );
  buf.flip();
  out.write( buf );
}
origin: org.apache.mina/mina-core

/**
 * {@inheritDoc}
 */
@Override
public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
  Context ctx = getContext(session);
  if (LineDelimiter.AUTO.equals(delimiter)) {
    decodeAuto(ctx, session, in, out);
  } else {
    decodeNormal(ctx, session, in, out);
  }
}
origin: org.apache.mina/mina-core

/**
 * Creates a new instance with the spcified <tt>charset</tt>
 * and the specified <tt>delimiter</tt>.
 * 
 * @param charset The {@link Charset} to use
 * @param delimiter The line delimiter to use
 */
public TextLineDecoder(Charset charset, String delimiter) {
  this(charset, new LineDelimiter(delimiter));
}
origin: r17171709/android_demo

private PushManager() {
  connector=new NioSocketConnector();
  connector.setConnectTimeoutMillis(Params.CONNECT_TIMEOUT);
  //为接收器设置管理服务
  connector.setHandler(new ClientSessionHandler());
  //设置过滤器(使用Mina提供的文本换行符编解码器)
  connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("UTF-8"), LineDelimiter.WINDOWS.getValue(),LineDelimiter.WINDOWS.getValue())));
  //读写通道5秒内无操作进入空闲状态
  connector.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, Params.REQUEST_TIMEOUT);
  //设置读取数据的缓冲区大小
  connector.getSessionConfig().setReadBufferSize(2048);
  //设置心跳
  KeepAliveMessageFactory heartBeatFactory = new ClientKeepAliveMessageFactoryImp();
  KeepAliveRequestTimeoutHandler heartBeatHandler = new ClientKeepAliveMessageTimeoutFactoryImp();
  KeepAliveFilter heartBeat = new KeepAliveFilter(heartBeatFactory, IdleStatus.BOTH_IDLE, heartBeatHandler);
  //是否回发
  heartBeat.setForwardEvent(true);
  //心跳发送频率
  heartBeat.setRequestInterval(Params.REQUEST_INTERVAL);
  connector.getSessionConfig().setKeepAlive(true);
  connector.getFilterChain().addLast("keepalive", heartBeat);
}
origin: org.apache.directory.api/api-ldap-client-all

/**
 * {@inheritDoc}
 */
@Override
public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
  Context ctx = getContext(session);
  if (LineDelimiter.AUTO.equals(delimiter)) {
    decodeAuto(ctx, session, in, out);
  } else {
    decodeNormal(ctx, session, in, out);
  }
}
origin: org.apache.directory.api/api-ldap-client-all

/**
 * Creates a new instance with the current default {@link Charset}
 * and the specified <tt>delimiter</tt>.
 * 
 * @param delimiter The line delimiter to use
 */
public TextLineEncoder(String delimiter) {
  this(new LineDelimiter(delimiter));
}
org.apache.mina.filter.codec.textlineLineDelimiter

Javadoc

A delimiter which is appended to the end of a text line, such as CR/LF.

Most used methods

  • getValue
  • equals
  • <init>
    Creates a new line delimiter with the specified value.

Popular in Java

  • Reading from database using SQL prepared statement
  • onRequestPermissionsResult (Fragment)
  • setRequestProperty (URLConnection)
  • addToBackStack (FragmentTransaction)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now