当前位置: 首页>>代码示例>>Java>>正文


Java Allocator类代码示例

本文整理汇总了Java中org.simpleframework.util.buffer.Allocator的典型用法代码示例。如果您正苦于以下问题:Java Allocator类的具体用法?Java Allocator怎么用?Java Allocator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Allocator类属于org.simpleframework.util.buffer包,在下文中一共展示了Allocator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNoFinalCRLF

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
public void testNoFinalCRLF() throws Exception {
   byte[] data = SOURCE.getBytes("UTF-8");
   byte[] boundary = "mxvercagiykxaqsdvrfabfhfpaseejrg".getBytes("UTF-8");
   Allocator allocator = new ArrayAllocator();
   FileUploadConsumer consumer = new FileUploadConsumer(allocator, boundary, data.length);      
   Cursor cursor = new StreamCursor(data);
   
   while(!consumer.isFinished()) {
      consumer.consume(cursor);
   }  
   assertEquals(consumer.getBody().getContent(), SOURCE);
   assertEquals(consumer.getBody().getParts().size(), 6); 
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:14,代码来源:FileUploadConsumerTest.java

示例2: testNoFinalCRLSWithDribble

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
public void testNoFinalCRLSWithDribble() throws Exception {
   byte[] data = SOURCE.getBytes("UTF-8");
   byte[] boundary = "mxvercagiykxaqsdvrfabfhfpaseejrg".getBytes("UTF-8");
   Allocator allocator = new ArrayAllocator();
   FileUploadConsumer consumer = new FileUploadConsumer(allocator, boundary, data.length);      
   Cursor cursor = new StreamCursor(data);
   DribbleCursor dribble = new DribbleCursor(cursor, 1);
   
   while(!consumer.isFinished()) {
      consumer.consume(dribble);
   }  
   assertEquals(consumer.getBody().getContent(), SOURCE);
   assertEquals(consumer.getBody().getParts().size(), 6); 
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:15,代码来源:FileUploadConsumerTest.java

示例3: testNoFinalCRLSWithDribble3

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
public void testNoFinalCRLSWithDribble3() throws Exception {
   byte[] data = SOURCE.getBytes("UTF-8");
   byte[] boundary = "mxvercagiykxaqsdvrfabfhfpaseejrg".getBytes("UTF-8");
   Allocator allocator = new ArrayAllocator();
   FileUploadConsumer consumer = new FileUploadConsumer(allocator, boundary, data.length);      
   Cursor cursor = new StreamCursor(data);
   DribbleCursor dribble = new DribbleCursor(cursor, 3);
   
   while(!consumer.isFinished()) {
      consumer.consume(dribble);
   }  
   assertEquals(consumer.getBody().getContent(), SOURCE);
   assertEquals(consumer.getBody().getParts().size(), 6); 
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:15,代码来源:FileUploadConsumerTest.java

示例4: testTokenConsumer

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
public void testTokenConsumer() throws IOException {
   Allocator allocator = new ArrayAllocator();
   TokenConsumer consumer = new TokenConsumer(allocator, "\r\n".getBytes());
   Cursor cursor = new StreamCursor("\r\n");
   
   consumer.consume(cursor);
   
   assertEquals(cursor.ready(), -1);
   assertTrue(consumer.isFinished());  
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:11,代码来源:TokenConsumerTest.java

示例5: testTokenConsumerException

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
public void testTokenConsumerException() throws IOException {
   Allocator allocator = new ArrayAllocator();
   TokenConsumer consumer = new TokenConsumer(allocator, "\r\n".getBytes());
   Cursor cursor = new StreamCursor("--\r\n");
   boolean exception = false;
   
   try {
      consumer.consume(cursor);
   } catch(Exception e) {
      exception = true;
   }
   assertTrue("Exception not thrown for invalid token", exception); 
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:14,代码来源:TokenConsumerTest.java

示例6: testTokenConsumerDribble

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
public void testTokenConsumerDribble() throws IOException {
   Allocator allocator = new ArrayAllocator();
   TokenConsumer consumer = new TokenConsumer(allocator, "This is a large token to be consumed\r\n".getBytes());
   DribbleCursor cursor = new DribbleCursor(new StreamCursor("This is a large token to be consumed\r\n0123456789"), 1);

   consumer.consume(cursor);
   
   assertEquals(cursor.ready(), 1);
   assertTrue(consumer.isFinished()); 
   assertEquals(cursor.read(), '0');
   assertEquals(cursor.read(), '1');
   assertEquals(cursor.read(), '2');
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:14,代码来源:TokenConsumerTest.java

示例7: PingServer

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
public PingServer(int port, String message) throws Exception {
   Allocator allocator = new FileAllocator();
   Processor processor  = new ContainerProcessor(this, allocator, 5);
   Server server = new ProcessorServer(processor);
   DebugServer debug = new DebugServer(server);
   
   this.connection = new SocketConnection(debug);
   this.address = new InetSocketAddress(port);
   this.message = message;
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:11,代码来源:ConnectionTest.java

示例8: MockRenegotiationServer

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
public MockRenegotiationServer(SSLContext context, boolean certRequired, int port) throws IOException {
   Allocator allocator = new FileAllocator();
   ContainerProcessor processor = new ContainerProcessor(this, allocator, 4);
   TransportGrabber grabber = new TransportGrabber(processor);
   ProcessorServer processorServer = new ProcessorServer(grabber);
   
   this.server = new ConfigurableCertificateServer(processorServer, certRequired);  
   this.agent = new ConsoleAgent();
   this.connection = new SocketConnection(server, agent);
   this.address = new InetSocketAddress(port);
   this.context = context;
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:13,代码来源:MockRenegotiationServer.java

示例9: ContentConsumer

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
/**
 * Constructor for the <code>ContentConsumer</code> object. This 
 * is used to create a consumer that reads the body of a part in
 * a multipart request body. The terminal token must be provided
 * so that the end of the part body can be determined.
 *
 * @param allocator this is used to allocate the internal buffer
 * @param segment this represents the headers for the part body
 * @param series this is the part list that this body belongs in
 * @param boundary this is the message boundary for the body part
 */  
public ContentConsumer(Allocator allocator, Segment segment, PartSeries series, byte[] boundary) {
   this.allocator = allocator;
   this.boundary = boundary; 
   this.segment = segment;      
   this.series = series;
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:18,代码来源:ContentConsumer.java

示例10: PartConsumer

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
/**
 * Constructor for the <code>PartConsumer</code> object. This is
 * used to create a consumer used to read the contents of a part
 * and the boundary that terminates the content. Any parts that
 * are created by this are added to the provided part list.
 *
 * @param allocator this is the allocator used to creat buffers
 * @param series this is the part list used to store the parts
 * @param terminal this is the terminal token for the part
 * @param length this is the length of the parent part series    
 */
public PartConsumer(Allocator allocator, PartSeries series, byte[] terminal, long length) {
   this.header = new PartHeaderConsumer(allocator);
   this.factory = new PartFactory(allocator, header, length);      
   this.terminal = terminal;
   this.current = header;
   this.series = series;
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:19,代码来源:PartConsumer.java

示例11: PartSeriesConsumer

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
/**
 * Constructor for the <code>PartSeriesConsumer</code> object. This 
 * will create a consumer that is capable of breaking an upload in
 * to individual parts so that they can be accessed and used by
 * the receiver of the HTTP request message.
 *
 * @param allocator this is used to allocate the internal buffer
 * @param series this is the part list used to accumulate the parts   
 * @param boundary this is the boundary used for the upload
 * @param length this is the number of bytes the upload should be   
 */    
public PartSeriesConsumer(Allocator allocator, PartSeries series, byte[] boundary, long length) {
   this.buffer = new BufferAllocator(allocator, length);
   this.consumer = new PartEntryConsumer(buffer, series, boundary, length);
   this.factory = new PartEntryFactory(buffer, series, boundary, length);
   this.series = series;
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:18,代码来源:PartSeriesConsumer.java

示例12: EntityConsumer

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
/**
 * Constructor for the <code>EntityConsumer</code> object. This
 * is used to build an entity from the constituent parts. Once
 * all of the parts have been consumed they are available from
 * the exposed methods of this consumed instance.
 * 
 * @param allocator this is used to allocate the memory used
 * @param channel this is the channel used to send a response
 */
public EntityConsumer(Allocator allocator, Channel channel) {
   this.header = new RequestConsumer();
   this.expect = new Expectation(channel);
   this.factory = new ConsumerFactory(allocator, header);
   this.sequence = header.getHeader();
   this.trace = channel.getTrace();
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:17,代码来源:EntityConsumer.java

示例13: TokenConsumer

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
/**
 * The <code>TokenConsumer</code> object is used to read a token
 * from the cursor. This tracks the bytes read from the cursor, 
 * when it has fully read the token bytes correctly it will 
 * finish and append the consumed bytes to a buffer.
 * 
 * @param allocator the allocator used to create a buffer
 * @param token this is the token that is to be consumed
 */
public TokenConsumer(Allocator allocator, byte[] token) {
   this.allocator = allocator;
   this.length = token.length;
   this.token = token;
   this.chunk = length;
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:16,代码来源:TokenConsumer.java

示例14: PartEntryFactory

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
/**
 * Constructor for the <code>PartEntryFactory</code> object.
 * This is used to create a factory for entry consumers that
 * can be used to read an entry from a part list.
 * 
 * @param allocator this is the allocator used for buffers
 * @param series this is the list of parts that are extracted
 * @param terminal this is the terminal buffer to be used
 * @param length this is the length of the parent part series     
 */
public PartEntryFactory(Allocator allocator, PartSeries series, byte[] terminal, long length) {
   this.allocator = allocator;
   this.terminal = terminal;
   this.series = series;
   this.length = length;
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:17,代码来源:PartEntryFactory.java

示例15: Collector

import org.simpleframework.util.buffer.Allocator; //导入依赖的package包/类
/**
 * The <code>Collector</code> object used to collect the data from
 * the underlying transport. In order to collect a body this must
 * be given an <code>Allocator</code> which is used to create an
 * internal buffer to store the consumed body.
 * 
 * @param allocator this is the allocator used to buffer data
 * @param tracker this is the tracker used to create sessions
 * @param channel this is the channel used to read the data
 */
public Collector(Allocator allocator, Channel channel) { 
   this.entity = new EntityConsumer(allocator, channel);
   this.timer = new Timer(MILLISECONDS);
   this.cursor = channel.getCursor();     
   this.trace = channel.getTrace();
   this.channel = channel;
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:18,代码来源:Collector.java


注:本文中的org.simpleframework.util.buffer.Allocator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。