• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Part类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testHeader

import org.simpleframework.http.Part; //导入依赖的package包/类
public void testHeader() throws Exception {
   PartData list = new PartData();
   PartConsumer consumer = new PartConsumer(new ArrayAllocator(), list, "AaB03x".getBytes("UTF-8"), 8192);
   Cursor cursor = new StreamCursor(SOURCE);
   
   while(!consumer.isFinished()) {
      consumer.consume(cursor);
   }   
   assertEquals(list.getParts().size(), 1);
   assertEquals(list.getParts().get(0).getContentType().getPrimary(), "text");
   assertEquals(list.getParts().get(0).getContentType().getSecondary(), "plain");
   assertEquals(((Part)list.getParts().get(0)).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file1.txt'");         
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:14,代码来源:PartConsumerTest.java


示例2: readMultiPartData

import org.simpleframework.http.Part; //导入依赖的package包/类
private List<BodyPart> readMultiPartData(org.simpleframework.http.Request req) throws IOException {
    List<BodyPart> parts = new ArrayList<>();
    for (Part part : req.getParts()) {
        parts.add(new BodyPart().content(track(part.getInputStream()))
                                .contentType(contentTypeOf(part))
                                .name(part.getName())
                                .filename(part.getFileName()));
    }
    return parts;
}
 
开发者ID:testinfected,项目名称:molecule,代码行数:11,代码来源:SimpleServer.java


示例3: getParts

import org.simpleframework.http.Part; //导入依赖的package包/类
public List<Part> getParts() {
   return list.getParts();
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:4,代码来源:MockBody.java


示例4: getPart

import org.simpleframework.http.Part; //导入依赖的package包/类
public Part getPart(String name) {
   return list.getPart(name);
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:4,代码来源:MockBody.java


示例5: process

import org.simpleframework.http.Part; //导入依赖的package包/类
public void process(Request request, Response response) throws Exception {
   List<Part> list = request.getParts();
   String method = request.getMethod();
   
   if(method.equals("HEAD")) {
      assertEquals(request.getMajor(), 1);
      assertEquals(request.getMinor(), 0);     
      assertEquals(request.getValue("Host"), "some.host.com"); 
   } else if(method.equals("GET")) {      
      assertEquals(request.getMajor(), 1);
      assertEquals(request.getMinor(), 0);     
      assertEquals(request.getValue("Host"), "some.host.com");
      assertEquals(request.getValues("Accept").size(), 4);
      assertEquals(request.getValues("Accept").get(0), "image/gif");
      assertEquals(request.getValues("Accept").get(1), "image/png");
      assertEquals(request.getValues("Accept").get(2), "image/jpeg");
      assertEquals(request.getValues("Accept").get(3), "*"); 
   } else {
      assertEquals(request.getMajor(), 1);
      assertEquals(request.getMinor(), 0);
      assertEquals(request.getContentType().getPrimary(), "multipart");
      assertEquals(request.getContentType().getSecondary(), "form-data");     
      assertEquals(request.getValue("Host"), "some.host.com");
      assertEquals(request.getValues("Accept").size(), 4);
      assertEquals(request.getValues("Accept").get(0), "image/gif");
      assertEquals(request.getValues("Accept").get(1), "image/png");
      assertEquals(request.getValues("Accept").get(2), "image/jpeg");
      assertEquals(request.getValues("Accept").get(3), "*");     
      assertEquals(list.size(), 4);
      assertEquals(list.get(0).getContentType().getPrimary(), "text");
      assertEquals(list.get(0).getContentType().getSecondary(), "plain");
      assertEquals(list.get(0).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file1.txt\"; modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"");
      assertEquals(list.get(0).getName(), "pics");
      assertEquals(list.get(0).getFileName(), "file1.txt");
      assertEquals(list.get(0).isFile(), true);
      assertEquals(list.get(1).getContentType().getPrimary(), "text");
      assertEquals(list.get(1).getContentType().getSecondary(), "plain");
      assertEquals(list.get(1).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file2.txt\"");
      assertEquals(list.get(1).getContentType().getPrimary(), "text");
      assertEquals(list.get(1).getName(), "pics");
      assertEquals(list.get(1).getFileName(), "file2.txt");
      assertEquals(list.get(1).isFile(), true);
      assertEquals(list.get(2).getContentType().getSecondary(), "plain");
      assertEquals(list.get(2).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file3.txt\"");
      assertEquals(list.get(2).getName(), "pics");
      assertEquals(list.get(2).getFileName(), "file3.txt");
      assertEquals(list.get(2).isFile(), true);
      assertEquals(list.get(3).getContentType().getPrimary(), "text");
      assertEquals(list.get(3).getContentType().getSecondary(), "plain");
      assertEquals(list.get(3).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file4.txt\"");
      assertEquals(list.get(3).getName(), "pics");
      assertEquals(list.get(3).getFileName(), "file4.txt");
      assertEquals(list.get(3).isFile(), true);
   }
   StopWatch stopWatch = timers.get(request.getTarget());
   stopWatch.stop();
   finished.offer(stopWatch);
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:59,代码来源:ReactorProcessorTest.java


示例6: testPayload

import org.simpleframework.http.Part; //导入依赖的package包/类
public void testPayload(int dribble) throws Exception {
   Cursor cursor = new DribbleCursor(new StreamCursor(PAYLOAD), 10);
   Channel channel = new MockChannel(cursor);
   MockSelector selector = new MockSelector();
   Collector body = new Collector(new ArrayAllocator(), channel);
   long time = System.currentTimeMillis();
   
   while(!selector.isReady()) {
      body.collect(selector);
   }
   System.err.println("Time taken to parse payload "+(System.currentTimeMillis() - time)+" ms");
   
   Header header = body.getHeader();
   List<Part> list = body.getBody().getParts();
   
   assertEquals(header.getTarget(), "/index.html");
   assertEquals(header.getMethod(), "POST");
   assertEquals(header.getMajor(), 1);
   assertEquals(header.getMinor(), 0);
   assertEquals(header.getContentType().getPrimary(), "multipart");
   assertEquals(header.getContentType().getSecondary(), "form-data");     
   assertEquals(header.getValue("Host"), "some.host.com");
   assertEquals(header.getValues("Accept").size(), 4);
   assertEquals(header.getValues("Accept").get(0), "image/gif");
   assertEquals(header.getValues("Accept").get(1), "image/png");
   assertEquals(header.getValues("Accept").get(2), "image/jpeg");
   assertEquals(header.getValues("Accept").get(3), "*");     
   assertEquals(list.size(), 4);
   assertEquals(list.get(0).getContentType().getPrimary(), "text");
   assertEquals(list.get(0).getContentType().getSecondary(), "plain");
   assertEquals(list.get(0).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file1.txt'");
   assertEquals(list.get(1).getContentType().getPrimary(), "text");
   assertEquals(list.get(1).getContentType().getSecondary(), "plain");
   assertEquals(list.get(1).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file2.txt'");
   assertEquals(list.get(2).getContentType().getPrimary(), "text");
   assertEquals(list.get(2).getContentType().getSecondary(), "plain");
   assertEquals(list.get(2).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file3.txt'");
   assertEquals(list.get(3).getContentType().getPrimary(), "text");
   assertEquals(list.get(3).getContentType().getSecondary(), "plain");
   assertEquals(list.get(3).getHeader("Content-Disposition"), "form-data; name='pics'; filename='file4.txt'");
   assertEquals(cursor.ready(), -1);        
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:43,代码来源:PayloadTest.java


示例7: ready

import org.simpleframework.http.Part; //导入依赖的package包/类
public void ready(Collector collector) throws IOException {
   Entity entity = collector;
   Channel channel = entity.getChannel();
   Cursor cursor = channel.getCursor();
   Header header = entity.getHeader();
   Body body = entity.getBody();
   List<Part> list = body.getParts();
   
   assertEquals(header.getTarget(), "/index.html");
   assertEquals(header.getMethod(), "POST");
   assertEquals(header.getMajor(), 1);
   assertEquals(header.getMinor(), 0);
   assertEquals(header.getContentType().getPrimary(), "multipart");
   assertEquals(header.getContentType().getSecondary(), "form-data");     
   assertEquals(header.getValue("Host"), "some.host.com");
   assertEquals(header.getValues("Accept").size(), 4);
   assertEquals(header.getValues("Accept").get(0), "image/gif");
   assertEquals(header.getValues("Accept").get(1), "image/png");
   assertEquals(header.getValues("Accept").get(2), "image/jpeg");
   assertEquals(header.getValues("Accept").get(3), "*");     
   assertEquals(list.size(), 4);
   assertEquals(list.get(0).getContentType().getPrimary(), "text");
   assertEquals(list.get(0).getContentType().getSecondary(), "plain");
   assertEquals(list.get(0).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file1.txt\"; modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"");
   assertEquals(list.get(0).getName(), "pics");
   assertEquals(list.get(0).getFileName(), "file1.txt");
   assertEquals(list.get(0).isFile(), true);
   assertEquals(list.get(1).getContentType().getPrimary(), "text");
   assertEquals(list.get(1).getContentType().getSecondary(), "plain");
   assertEquals(list.get(1).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file2.txt\"");
   assertEquals(list.get(1).getContentType().getPrimary(), "text");
   assertEquals(list.get(1).getName(), "pics");
   assertEquals(list.get(1).getFileName(), "file2.txt");
   assertEquals(list.get(1).isFile(), true);
   assertEquals(list.get(2).getContentType().getSecondary(), "plain");
   assertEquals(list.get(2).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file3.txt\"");
   assertEquals(list.get(2).getName(), "pics");
   assertEquals(list.get(2).getFileName(), "file3.txt");
   assertEquals(list.get(2).isFile(), true);
   assertEquals(list.get(3).getContentType().getPrimary(), "text");
   assertEquals(list.get(3).getContentType().getSecondary(), "plain");
   assertEquals(list.get(3).getHeader("Content-Disposition"), "file; name=\"pics\"; filename=\"file4.txt\"");
   assertEquals(list.get(3).getName(), "pics");
   assertEquals(list.get(3).getFileName(), "file4.txt");
   assertEquals(list.get(3).isFile(), true);
   assertEquals(cursor.ready(), -1); 
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:48,代码来源:ReactorTest.java


示例8: getPart

import org.simpleframework.http.Part; //导入依赖的package包/类
public Part getPart(String name) {
   return null;
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:4,代码来源:MockRequest.java


示例9: getParts

import org.simpleframework.http.Part; //导入依赖的package包/类
public List<Part> getParts() {
   return Collections.emptyList();
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:4,代码来源:MockRequest.java


示例10: testPayload

import org.simpleframework.http.Part; //导入依赖的package包/类
public void testPayload(int dribble) throws Exception {
   System.out.println("Testing dribbling cursor of "+dribble+" ...");
   Cursor cursor = new StreamCursor(PAYLOAD);
   
   if(dribble < PAYLOAD.length) {
      cursor = new DribbleCursor(cursor, dribble);
   }
   Channel channel = new MockChannel(cursor);
   MockSelector selector = new MockSelector();
   Collector body = new Collector(new ArrayAllocator(), channel);
   
   while(!selector.isReady()) {
      body.collect(selector);
   }   
   Request request = new RequestEntity(body, null);
   List<Part> list = request.getParts();      
   
   assertEquals(request.getParameter("a"), "b");
   assertEquals(request.getParameter("c"), "d");
   assertEquals(request.getParameter("e"), "f");
   assertEquals(request.getParameter("g"), "h");      	
   assertEquals(request.getTarget(), "/index.html?a=b&c=d&e=f&g=h&a=1");
   assertEquals(request.getMethod(), "POST");
   assertEquals(request.getMajor(), 1);
   assertEquals(request.getMinor(), 0);
   assertEquals(request.getContentType().getPrimary(), "multipart");
   assertEquals(request.getContentType().getSecondary(), "form-data");     
   assertEquals(request.getValue("Host"), "some.host.com");
   assertEquals(request.getValues("Accept").size(), 4);
   assertEquals(request.getValues("Accept").get(0), "image/gif");
   assertEquals(request.getValues("Accept").get(1), "image/png");
   assertEquals(request.getValues("Accept").get(2), "image/jpeg");
   assertEquals(request.getValues("Accept").get(3), "*");  
   assertEquals(request.getCookie("UID").getValue(), "1234-5678");
   assertEquals(request.getCookie("UID").getPath(), "/");
   assertEquals(request.getCookie("UID").getDomain(), ".host.com");
   assertEquals(request.getCookie("NAME").getValue(), "Niall Gallagher");
   assertEquals(request.getCookie("NAME").getPath(), "/");
   assertEquals(request.getCookie("NAME").getDomain(), null);
   assertEquals(list.size(), 4);
   assertEquals(list.get(0).getContentType().getPrimary(), "text");
   assertEquals(list.get(0).getContentType().getSecondary(), "plain");
   assertEquals(list.get(0).getHeader("Content-Disposition"), "file; name=\"file1\"; filename=\"file1.txt\"; modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"");
   assertEquals(list.get(0).getName(), "file1");
   assertEquals(list.get(0).getFileName(), "file1.txt");
   assertEquals(list.get(0).isFile(), true);
   assertEquals(list.get(0).getContent(), "example contents of file1.txt");
   assertEquals(request.getPart("file1").getContent(), "example contents of file1.txt");
   assertEquals(list.get(1).getContentType().getPrimary(), "text");
   assertEquals(list.get(1).getContentType().getSecondary(), "plain");
   assertEquals(list.get(1).getHeader("Content-Disposition"), "file; name=\"file2\"; filename=\"file2.txt\"");
   assertEquals(list.get(1).getContentType().getPrimary(), "text");
   assertEquals(list.get(1).getName(), "file2");
   assertEquals(list.get(1).getFileName(), "file2.txt");
   assertEquals(list.get(1).isFile(), true);
   assertEquals(list.get(1).getContent(), "example contents of file2.txt ...");
   assertEquals(request.getPart("file2").getContent(), "example contents of file2.txt ...");
   assertEquals(list.get(2).getContentType().getSecondary(), "plain");
   assertEquals(list.get(2).getHeader("Content-Disposition"), "file; name=\"file3\"; filename=\"file3.txt\"");
   assertEquals(list.get(2).getName(), "file3");
   assertEquals(list.get(2).getFileName(), "file3.txt");
   assertEquals(list.get(2).isFile(), true);
   assertEquals(list.get(2).getContent(), "example contents of file3.txt ...");
   assertEquals(request.getPart("file3").getContent(), "example contents of file3.txt ...");
   assertEquals(list.get(3).getContentType().getPrimary(), "text");
   assertEquals(list.get(3).getContentType().getSecondary(), "plain");
   assertEquals(list.get(3).getHeader("Content-Disposition"), "file; name=\"file4\"; filename=\"file4.txt\"");
   assertEquals(list.get(3).getName(), "file4");
   assertEquals(list.get(3).getFileName(), "file4.txt");
   assertEquals(list.get(3).isFile(), true);
   assertEquals(list.get(3).getContent(), "example contents of file4.txt ...");
   assertEquals(request.getPart("file4").getContent(), "example contents of file4.txt ...");
   assertEquals(cursor.ready(), -1);     
   assertEquals(request.getContent(), BODY);      
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:76,代码来源:RequestTest.java


示例11: contentTypeOf

import org.simpleframework.http.Part; //导入依赖的package包/类
private String contentTypeOf(Part part) {
    return part.getContentType() != null ? part.getContentType().toString() : null;
}
 
开发者ID:testinfected,项目名称:molecule,代码行数:4,代码来源:SimpleServer.java


示例12: addPart

import org.simpleframework.http.Part; //导入依赖的package包/类
/**
 * This is used to add a part to the list. The order the parts are 
 * added to the list is the iteration order. If the part has a name
 * that is not null then it is added to an internal map using that 
 * name. This allows it to be accesses by name at a later time.
 * 
 * @param part this is the part that is to be added to the list
 * 
 * @return returns true if the list has changed due to the add
 */
public boolean addPart(Part part) {
   String name = part.getName();

   if(name != null) {
      map.put(name, part);
   }
   return list.add(part);
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:19,代码来源:PartData.java


示例13: getPart

import org.simpleframework.http.Part; //导入依赖的package包/类
/**
 * This method is used to acquire a <code>Part</code> from the
 * HTTP request using a known name for the part. This is typically 
 * used  when there is a file upload with a multipart POST request.
 * All parts that are not files can be acquired as string values
 * from the attachment object.
 * 
 * @param name this is the name of the part object to acquire
 * 
 * @return the named part or null if the part does not exist
 */ 
public Part getPart(String name) {
   if(series != null) {
      return series.getPart(name);
   }
   return null;
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:18,代码来源:BufferBody.java


示例14: getParts

import org.simpleframework.http.Part; //导入依赖的package包/类
/**
 * This method is used to get all <code>Part</code> objects that
 * are associated with the request. Each attachment contains the 
 * body and headers associated with it. If the request is not a 
 * multipart POST request then this will return an empty list.
 * 
 * @return the list of parts associated with this request
 */     
public List<Part> getParts() {
   if(series != null) {
      return series.getParts();
   }
   return Collections.emptyList();
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:15,代码来源:BufferBody.java


示例15: addPart

import org.simpleframework.http.Part; //导入依赖的package包/类
/**
 * This is used to add a part to the list. The order the parts are added to
 * the list is the iteration order. If the part has a name that is not null
 * then it is added to an internal map using that name. This allows it to be
 * accesses by name at a later time.
 * 
 * @param part
 *            this is the part that is to be added to the list
 * 
 * @return returns true if the list has changed due to the add
 */
@Override
public boolean addPart(Part part) {
    String name = part.getName();

    if (name != null) {
        this.map.put(name, part);
    }
    return this.list.add(part);
}
 
开发者ID:TehSomeLuigi,项目名称:someluigis-peripherals,代码行数:21,代码来源:PartData.java


示例16: getPart

import org.simpleframework.http.Part; //导入依赖的package包/类
/**
 * This is used to acquire the part for this HTTP entity. This
 * will return a part which can be used to read the content of
 * the message, the part created contains the contents of the
 * body and the headers associated with it.
 *  
 * @return the part provided by the HTTP request message
 */
public Part getPart() {
   return new BufferPart(segment, buffer);
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:12,代码来源:ContentConsumer.java


示例17: getParts

import org.simpleframework.http.Part; //导入依赖的package包/类
/**
 * This is used to acquire the attachments associated with this 
 * list. If no parts have been collected by this list then it
 * will return an empty list. The order of the parts in the list
 * are the insertion order for consistency.
 * 
 * @return this returns the parts collected in iteration order
 */
List<Part> getParts();
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:10,代码来源:PartSeries.java


示例18: addPart

import org.simpleframework.http.Part; //导入依赖的package包/类
/**
 * This is used to add a part to the list. The order the parts are 
 * added to the list is the iteration order. If the part has a name
 * that is not null then it is added to an internal map using that 
 * name. This allows it to be accesses by name at a later time.
 * 
 * @param part this is the part that is to be added to the list
 * 
 * @return returns true if the list has changed due to the add
 */
boolean addPart(Part part);
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:12,代码来源:PartSeries.java


示例19: getPart

import org.simpleframework.http.Part; //导入依赖的package包/类
/**
 * This method is used to acquire a <code>Part</code> from the list
 * using a known name for the part. This is a convenient way to 
 * access a part when the name for the part is known.
 * 
 * @param name this is the name of the part to acquire
 * 
 * @return the named part or null if the part does not exist
 */
Part getPart(String name);
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:11,代码来源:PartSeries.java


示例20: PartData

import org.simpleframework.http.Part; //导入依赖的package包/类
/**
 * Constructor for the <code>PartData</code> object. This is used
 * to create an order list of parts that is used by the request 
 * to access the individual parts uploaded with a HTTP body.
 */
public PartData() {
   this.list = new ArrayList<Part>();
   this.map = new KeyMap<Part>();
}
 
开发者ID:blobrobotics,项目名称:bstation,代码行数:10,代码来源:PartData.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WFSException类代码示例发布时间:2022-05-15
下一篇:
Java PersistenceBrokerFactoryIF类代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap