org.apache.tomcat.util.buf.B2CConverter.convert()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中org.apache.tomcat.util.buf.B2CConverter.convert()方法的一些代码示例,展示了B2CConverter.convert()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。B2CConverter.convert()方法的具体详情如下:
包路径:org.apache.tomcat.util.buf.B2CConverter
类名称:B2CConverter
方法名:convert

B2CConverter.convert介绍

[英]Convert the given bytes to characters.
[中]将给定的字节转换为字符。

代码示例

代码示例来源:origin: org.apache.coyote.springsource/com.springsource.org.apache.coyote.springsource

/** Convert a buffer of bytes into a chars
 * @deprecated
 */
public  void convert( ByteChunk bb, CharChunk cb )
  throws IOException
{
  // Set the ByteChunk as input to the Intermediate reader
  convert(bb, cb, cb.getBuffer().length - cb.getEnd());
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

public int realReadChars() throws IOException {
  checkConverter();
  boolean eof = false;
  if (bb.remaining() <= 0) {
    int nRead = realReadBytes();
    if (nRead < 0) {
      eof = true;
    }
  }
  if (markPos == -1) {
    clear(cb);
  } else {
    // Make sure there's enough space in the worst case
    makeSpace(bb.remaining());
    if ((cb.capacity() - cb.limit()) == 0 && bb.remaining() != 0) {
      // We went over the limit
      clear(cb);
      markPos = -1;
    }
  }
  state = CHAR_STATE;
  conv.convert(bb, cb, this, eof);
  if (cb.remaining() == 0 && eof) {
    return -1;
  } else {
    return cb.remaining();
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

public int realReadChars() throws IOException {
  checkConverter();
  boolean eof = false;
  if (bb.remaining() <= 0) {
    int nRead = realReadBytes();
    if (nRead < 0) {
      eof = true;
    }
  }
  if (markPos == -1) {
    clear(cb);
  } else {
    // Make sure there's enough space in the worst case
    makeSpace(bb.remaining());
    if ((cb.capacity() - cb.limit()) == 0 && bb.remaining() != 0) {
      // We went over the limit
      clear(cb);
      markPos = -1;
    }
  }
  state = CHAR_STATE;
  conv.convert(bb, cb, this, eof);
  if (cb.remaining() == 0 && eof) {
    return -1;
  } else {
    return cb.remaining();
  }
}

代码示例来源:origin: jboss.remoting/jboss-remoting

public int realReadChars(char cbuf[], int off, int len)
   throws IOException
{
 if(!gotEnc)
 {
   setConverter();
 }
 if(bb.getLength() <= 0)
 {
   int nRead = realReadBytes(bb.getBytes(), 0, bb.getBytes().length);
   if(nRead < 0)
   {
    return -1;
   }
 }
 if(markPos == -1)
 {
   cb.setOffset(0);
   cb.setEnd(0);
 }
 conv.convert(bb, cb);
 bb.setOffset(bb.getEnd());
 state = CHAR_STATE;
 return cb.getLength();
}

代码示例来源:origin: org.osivia.portal.core/osivia-portal-jbossas-jbossweb-lib

/* 588 */           conv.convert(bc, cc);

代码示例来源:origin: jboss.web/jbossweb

conv.convert(bc, cc);
uri.setChars(cc.getBuffer(), cc.getStart(), 
       cc.getLength());

代码示例来源:origin: tomcat/catalina

public int realReadChars(char cbuf[], int off, int len)
  throws IOException {
  if (!gotEnc)
    setConverter();
  if (bb.getLength() <= 0) {
    int nRead = realReadBytes(bb.getBytes(), 0, bb.getBytes().length);
    if (nRead < 0) {
      return -1;
    }
  }
  if (markPos == -1) {
    cb.setOffset(0);
    cb.setEnd(0);
  }
  int limit = bb.getLength()+cb.getStart();
  if( cb.getLimit() < limit ) 
    cb.setLimit(limit);
  conv.convert(bb, cb);
  bb.setOffset(bb.getEnd());
  state = CHAR_STATE;
  return cb.getLength();
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

public int realReadChars(char cbuf[], int off, int len)
  throws IOException {
  if (!gotEnc)
    setConverter();
  if (bb.getLength() <= 0) {
    int nRead = realReadBytes(bb.getBytes(), 0, bb.getBytes().length);
    if (nRead < 0) {
      return -1;
    }
  }
  if (markPos == -1) {
    cb.setOffset(0);
    cb.setEnd(0);
  }
  int limit = bb.getLength()+cb.getStart();
  if ( cb.getLimit() < limit )
    cb.setLimit(limit);
  state = CHAR_STATE;
  conv.convert(bb, cb, bb.getLength());
  bb.setOffset(bb.getEnd());
  return cb.getLength();
}

代码示例来源:origin: jboss.web/jbossweb

public int realReadChars(char cbuf[], int off, int len)
  throws IOException {
  if (!gotEnc)
    setConverter();
  if (bb.getLength() <= 0) {
    if (realReadBytes(bb.getBytes(), 0, bb.getBytes().length) < 0) {
      return -1;
    }
  }
  if (markPos == -1) {
    cb.setOffset(0);
    cb.setEnd(0);
  } else {
    // Make sure there's enough space in the worst case
    cb.makeSpace(bb.getLength());
    if ((cb.getBuffer().length - cb.getEnd()) == 0) {
      // We went over the limit
      cb.setOffset(0);
      cb.setEnd(0);
      markPos = -1;
    }
  }
  state = CHAR_STATE;
  conv.convert(bb, cb);
  return cb.getLength();
}

代码示例来源:origin: org.jboss.web/jbossweb

public int realReadChars(char cbuf[], int off, int len)
  throws IOException {
  if (!gotEnc)
    setConverter();
  if (bb.getLength() <= 0) {
    if (realReadBytes(bb.getBytes(), 0, bb.getBytes().length) < 0) {
      return -1;
    }
  }
  if (markPos == -1) {
    cb.setOffset(0);
    cb.setEnd(0);
  } else {
    // Make sure there's enough space in the worst case
    cb.makeSpace(bb.getLength());
    if ((cb.getBuffer().length - cb.getEnd()) == 0) {
      // We went over the limit
      cb.setOffset(0);
      cb.setEnd(0);
      markPos = -1;
    }
  }
  state = CHAR_STATE;
  conv.convert(bb, cb);
  return cb.getLength();
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

public int realReadChars(char cbuf[], int off, int len)
  throws IOException {
  if (!gotEnc)
    setConverter();
  if (bb.getLength() <= 0) {
    int nRead = realReadBytes(bb.getBytes(), 0, bb.getBytes().length);
    if (nRead < 0) {
      return -1;
    }
  }
  if (markPos == -1) {
    cb.setOffset(0);
    cb.setEnd(0);
  }
  int limit = bb.getLength()+cb.getStart();
  if ( cb.getLimit() < limit )
    cb.setLimit(limit);
  state = CHAR_STATE;
  conv.convert(bb, cb, bb.getLength());
  bb.setOffset(bb.getEnd());
  return cb.getLength();
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

public int realReadChars(char cbuf[], int off, int len)
  throws IOException {
  if (!gotEnc)
    setConverter();
  if (bb.getLength() <= 0) {
    int nRead = realReadBytes(bb.getBytes(), 0, bb.getBytes().length);
    if (nRead < 0) {
      return -1;
    }
  }
  if (markPos == -1) {
    cb.setOffset(0);
    cb.setEnd(0);
  }
  int limit = bb.getLength()+cb.getStart();
  if ( cb.getLimit() < limit )
    cb.setLimit(limit);
  state = CHAR_STATE;
  conv.convert(bb, cb, bb.getLength());
  bb.setOffset(bb.getEnd());
  return cb.getLength();
}

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

@Override
public int realReadChars(char cbuf[], int off, int len)
  throws IOException {
  if (!gotEnc) {
    setConverter();
  }
  if (bb.getLength() <= 0) {
    int nRead = realReadBytes(bb.getBytes(), 0, bb.getBytes().length);
    if (nRead < 0) {
      return -1;
    }
  }
  if (markPos == -1) {
    cb.setOffset(0);
    cb.setEnd(0);
  }
  int limit = bb.getLength()+cb.getStart();
  if ( cb.getLimit() < limit ) {
    cb.setLimit(limit);
  }
  state = CHAR_STATE;
  conv.convert(bb, cb, bb.getLength());
  bb.setOffset(bb.getEnd());
  return cb.getLength();
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

/**
 * Character conversion of the URI.
 *
 * @param uri MessageBytes object containing the URI
 * @param request The Servlet request object
 * @throws IOException if a IO exception occurs sending an error to the client
 */
protected void convertURI(MessageBytes uri, Request request) throws IOException {
  ByteChunk bc = uri.getByteChunk();
  int length = bc.getLength();
  CharChunk cc = uri.getCharChunk();
  cc.allocate(length, -1);
  Charset charset = connector.getURICharset();
  B2CConverter conv = request.getURIConverter();
  if (conv == null) {
    conv = new B2CConverter(charset, true);
    request.setURIConverter(conv);
  } else {
    conv.recycle();
  }
  try {
    conv.convert(bc, cc, true);
    uri.setChars(cc.getBuffer(), cc.getStart(), cc.getLength());
  } catch (IOException ioe) {
    // Should never happen as B2CConverter should replace
    // problematic characters
    request.getResponse().sendError(HttpServletResponse.SC_BAD_REQUEST);
  }
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

/**
 * Character conversion of the URI.
 *
 * @param uri MessageBytes object containing the URI
 * @param request The Servlet request object
 * @throws IOException if a IO exception occurs sending an error to the client
 */
protected void convertURI(MessageBytes uri, Request request) throws IOException {
  ByteChunk bc = uri.getByteChunk();
  int length = bc.getLength();
  CharChunk cc = uri.getCharChunk();
  cc.allocate(length, -1);
  Charset charset = connector.getURICharset();
  B2CConverter conv = request.getURIConverter();
  if (conv == null) {
    conv = new B2CConverter(charset, true);
    request.setURIConverter(conv);
  } else {
    conv.recycle();
  }
  try {
    conv.convert(bc, cc, true);
    uri.setChars(cc.getBuffer(), cc.getStart(), cc.getLength());
  } catch (IOException ioe) {
    // Should never happen as B2CConverter should replace
    // problematic characters
    request.getResponse().sendError(HttpServletResponse.SC_BAD_REQUEST);
  }
}

代码示例来源:origin: codefollower/Tomcat-Research

conv.convert(bb, cb, eof);

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

conv.convert(bb, cb, eof);

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

conv.convert(bc, cc, cc.getBuffer().length - cc.getEnd());
uri.setChars(cc.getBuffer(), cc.getStart(), 
       cc.getLength());

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

conv.convert(bc, cc, cc.getBuffer().length - cc.getEnd());
uri.setChars(cc.getBuffer(), cc.getStart(),
       cc.getLength());

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

conv.convert(bc, cc, cc.getBuffer().length - cc.getEnd());
uri.setChars(cc.getBuffer(), cc.getStart(), 
       cc.getLength());

相关文章

微信公众号

最新文章

更多