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

How to use
ByteChunk
in
org.glassfish.grizzly.http.util

Best Java code snippets using org.glassfish.grizzly.http.util.ByteChunk (Showing top 20 results out of 315)

origin: org.glassfish.grizzly/grizzly-websockets-server

/**
 * Unescapes any double quotes in the given cookie value.
 *
 * @param bc The cookie value to modify
 */
public static void unescapeDoubleQuotes(final ByteChunk bc) {
  if (bc == null || bc.getLength() == 0) {
    return;
  }
  int src = bc.getStart();
  int end = bc.getEnd();
  int dest = src;
  final byte[] buffer = bc.getBuffer();
  while (src < end) {
    if (buffer[src] == '\\' && src < end && buffer[src + 1] == '"') {
      src++;
    }
    buffer[dest] = buffer[src];
    dest++;
    src++;
  }
  bc.setEnd(dest);
}
origin: javaee/grizzly

/** Create a converter
 */
public C2BConverter(String encoding) throws IOException {
  this( new ByteChunk(1024), encoding );
}
origin: javaee/grizzly

public void append( ByteChunk src ) throws IOException {
  append( src.getBytes(), src.getStart(), src.getLength());
}
origin: javaee/grizzly

public boolean equals( ByteChunk bb ) {
  return equals( bb.getBytes(), bb.getStart(), bb.getLength());
}
origin: org.glassfish.grizzly/grizzly-http-server-core

/**
 * Compares the message data to the specified ByteChunk.
 * @param byteChunkToCheck the ByteChunk to compare
 * @return true if the comparison succeeded, false otherwise
 */
public boolean equals(final ByteChunk byteChunkToCheck) {
  return equals(byteChunkToCheck.getBuffer(), byteChunkToCheck.getStart(),
      byteChunkToCheck.getLength());
}
origin: javaee/grizzly

public static SettingsFrame fromBase64Uri(final DataChunk src) {
  if (src.getType() == DataChunk.Type.Bytes) {
    final ByteChunk bc = src.getByteChunk();
    return parseBase64Uri(bc.getBuffer(), bc.getStart(), bc.getEnd());
  } else if (src.getType() == DataChunk.Type.Buffer) {
    final BufferChunk bc = src.getBufferChunk();
    return parseBase64Uri(bc.getBuffer(), bc.getStart(), bc.getEnd());
  }
  
  return parseBase64Uri(src.toString());
}

origin: org.glassfish.grizzly/grizzly-http

/** Generate the bytes using the specified encoding
 */
public void convert(char c[], int off, int len) throws IOException {
  CharBuffer cb = CharBuffer.wrap(c, off, len);
  byte[] barr = bb.getBuffer();
  int boff = bb.getEnd();
  ByteBuffer tmp = ByteBuffer.wrap(barr, boff, barr.length - boff);
  CoderResult cr = encoder.encode(cb, tmp, true);
  bb.setEnd(tmp.position());
  while (cr == CoderResult.OVERFLOW) {
  if (!bb.canGrow())
      bb.flushBuffer();
  boff = bb.getEnd();
  barr = bb.getBuffer();
    tmp = ByteBuffer.wrap(barr, boff, barr.length - boff);
    cr = encoder.encode(cb, tmp, true);
    bb.setEnd(tmp.position());
  }
  if (cr != CoderResult.UNDERFLOW) {
    throw new IOException("Encoding error");
}
}
origin: javaee/grizzly

/** Unimplemented yet. Do a char->byte conversion.
 */
public void toBytes() {
  if( ! byteC.isNull() ) {
    type=T_BYTES;
    return;
  }
  toString();
  type=T_BYTES;
  byte bb[] = strValue.getBytes(byteC.getCharset());
  byteC.setBytes(bb, 0, bb.length);
}
origin: javaee/grizzly

/**
 * Returns true if the message bytes starts with the specified string.
 * @param c the character
 * @param starting The start position
 */
public int indexOf(char c, int starting) {
  int ret = indexOf( buff, start+starting, end, c);
  return (ret >= start) ? ret - start : -1;
}
origin: org.glassfish.grizzly/grizzly-websockets-server

private void setBytesInternal(final byte[] array,
                final int position,
                final int limit) {
  byteChunk.setBytes(array, position, limit - position);
  switchToByteChunk();
}
origin: org.glassfish.grizzly/grizzly-http

/**
 * Returns the <tt>DataChunk</tt> end position.
 *
 * @return the <tt>DataChunk</tt> end position.
 */
@Override
public int getEnd() {
  switch (type) {
    case Bytes:
      return byteChunk.getEnd();
    case Buffer:
      return bufferChunk.getEnd();
    case Chars:
      return charChunk.getEnd();
    default:
      return stringValue.length();
  }
}
origin: javaee/grizzly

public void append( char c ) throws IOException {
  append( (byte)c);
}
origin: javaee/grizzly

/**
 * Sets the <tt>DataChunk</tt> end position.
 *
 * @param end the <tt>DataChunk</tt> end position.
 */
@Override
public void setEnd(int end) {
  switch (type) {
    case Bytes:
      byteChunk.setEnd(end);
      break;
    case Buffer:
      bufferChunk.setEnd(end);
      break;
    case Chars:
      charChunk.setEnd(end);
      break;
    default:
      break;
  }
}
origin: javaee/grizzly

/**
 * Compares the message data to the specified ByteChunk.
 * @param byteChunkToCheck the ByteChunk to compare
 * @return true if the comparison succeeded, false otherwise
 */
public boolean equals(final ByteChunk byteChunkToCheck) {
  return equals(byteChunkToCheck.getBuffer(), byteChunkToCheck.getStart(),
      byteChunkToCheck.getLength());
}
origin: javaee/grizzly

public static SettingsFrame fromBase64Uri(final DataChunk src) {
  if (src.getType() == DataChunk.Type.Bytes) {
    final ByteChunk bc = src.getByteChunk();
    return parseBase64Uri(bc.getBuffer(), bc.getStart(), bc.getEnd());
  } else if (src.getType() == DataChunk.Type.Buffer) {
    final BufferChunk bc = src.getBufferChunk();
    return parseBase64Uri(bc.getBuffer(), bc.getStart(), bc.getEnd());
  }
  
  return parseBase64Uri(src.toString());
}

origin: javaee/grizzly

/** Generate the bytes using the specified encoding
 */
public void convert(char c[], int off, int len) throws IOException {
  CharBuffer cb = CharBuffer.wrap(c, off, len);
  byte[] barr = bb.getBuffer();
  int boff = bb.getEnd();
  ByteBuffer tmp = ByteBuffer.wrap(barr, boff, barr.length - boff);
  CoderResult cr = encoder.encode(cb, tmp, true);
  bb.setEnd(tmp.position());
  while (cr == CoderResult.OVERFLOW) {
  if (!bb.canGrow())
      bb.flushBuffer();
  boff = bb.getEnd();
  barr = bb.getBuffer();
    tmp = ByteBuffer.wrap(barr, boff, barr.length - boff);
    cr = encoder.encode(cb, tmp, true);
    bb.setEnd(tmp.position());
  }
  if (cr != CoderResult.UNDERFLOW) {
    throw new IOException("Encoding error");
}
}
origin: javaee/grizzly

public boolean equals( ByteChunk bb ) {
  return equals( bb.getBytes(), bb.getStart(), bb.getLength());
}
origin: javaee/grizzly

/** Unimplemented yet. Do a char->byte conversion.
 */
public void toBytes() {
  if( ! byteC.isNull() ) {
    type=T_BYTES;
    return;
  }
  toString();
  type=T_BYTES;
  byte bb[] = strValue.getBytes(byteC.getCharset());
  byteC.setBytes(bb, 0, bb.length);
}
origin: javaee/grizzly

/**
 * Returns true if the message bytes starts with the specified string.
 * @param c the character
 * @param starting The start position
 */
public int indexOf(char c, int starting) {
  int ret = indexOf( buff, start+starting, end, c);
  return (ret >= start) ? ret - start : -1;
}
origin: javaee/grizzly

private void setBytesInternal(final byte[] array,
                final int position,
                final int limit) {
  byteChunk.setBytes(array, position, limit - position);
  switchToByteChunk();
}
org.glassfish.grizzly.http.utilByteChunk

Javadoc

This class is used to represent a chunk of bytes, and utilities to manipulate byte[]. The buffer can be modified and used for both input and output.

Most used methods

  • getBuffer
    Returns the message bytes.
  • getEnd
  • getStart
    Returns the start offset of the bytes. For output this is the end of the buffer.
  • <init>
  • append
    Add data to the buffer
  • getBytes
    Returns the message bytes.
  • getLength
    Returns the length of the bytes. XXX need to clean this up
  • indexOf
  • setBytes
    Sets the message bytes to the specified sub-array of bytes.
  • setEnd
  • toString
  • allocate
  • toString,
  • allocate,
  • canGrow,
  • delete,
  • equals,
  • equalsIgnoreCase,
  • equalsIgnoreCaseLowerCase,
  • flushBuffer,
  • getCharset,
  • getInt

Popular in Java

  • Start an intent from android
  • onRequestPermissionsResult (Fragment)
  • requestLocationUpdates (LocationManager)
  • setRequestProperty (URLConnection)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Option (scala)
  • Best plugins for Eclipse
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