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


Java QueryStringDecoder类代码示例

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


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

示例1: decode

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
@Override
protected Object decode(
        Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {

    HttpRequest request = (HttpRequest) msg;
    QueryStringDecoder decoder = new QueryStringDecoder(request.getUri());

    DeviceSession deviceSession = getDeviceSession(
            channel, remoteAddress, decoder.getParameters().get("UserName").get(0));
    if (deviceSession == null) {
        return null;
    }

    Parser parser = new Parser(PATTERN, decoder.getParameters().get("LOC").get(0));
    if (!parser.matches()) {
        return null;
    }

    Position position = new Position();
    position.setProtocol(getProtocolName());
    position.setDeviceId(deviceSession.getDeviceId());

    position.setTime(parser.nextDateTime(Parser.DateTimeFormat.DMY_HMS));

    position.setValid(true);
    position.setLatitude(parser.nextDouble(0));
    position.setLongitude(parser.nextDouble(0));
    position.setAltitude(parser.nextDouble(0));
    position.setSpeed(parser.nextDouble(0));
    position.setCourse(parser.nextDouble(0));

    if (channel != null) {
        HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
        channel.write(response).addListener(ChannelFutureListener.CLOSE);
    }

    return position;
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:39,代码来源:PathAwayProtocolDecoder.java

示例2: doPost

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
private void doPost(ChannelHandlerContext ctx, MessageEvent e, HttpRequest req)
        throws IOException {

  final QueryStringDecoder decoded = new QueryStringDecoder(req.getUri());
  if (!decoded.getPath().equalsIgnoreCase("/write")) {
    writeResponseAndClose(e,
            new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.NOT_FOUND));
    return;
  }

  try {
    metricParser.parse(req);
  } catch (IllegalArgumentException iae) {
    logger.warn("Metric parser failed: " + iae.getMessage());
  }

  HttpResponse response = new DefaultHttpResponse(
          HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
  response.setContent(ChannelBuffers.copiedBuffer(
          ("Seen events").getBytes()
  ));
  writeResponseAndClose(e, response);
}
 
开发者ID:yandex,项目名称:opentsdb-flume,代码行数:24,代码来源:LegacyHttpSource.java

示例3: messageReceived

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
@Override
public final void messageReceived(ChannelHandlerContext context, MessageEvent event) throws Exception {
  if (!(event.getMessage() instanceof HttpRequest)) {
    context.sendUpstream(event);
    return;
  }

  HttpRequest request = (HttpRequest)event.getMessage();
  //if (BuiltInServer.LOG.isDebugEnabled()) {
  //BuiltInServer.LOG.debug(request.toString());
  //}

  if (!process(context, request, new QueryStringDecoder(request.getUri()))) {
    Responses.sendStatus(request, context, NOT_FOUND);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:DelegatingHttpRequestHandlerBase.java

示例4: returnRegeditPage

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
/**
 * return login page,if user & password is error.return error tips!
 * */
private HttpResponse returnRegeditPage(ChannelHandlerContext ctx, QueryStringDecoder content,String tips) {
	HttpResponse response;
	String responseContent = ReadAll.readAll("web/regedit.html", "utf-8");
	responseContent = responseContent.replaceAll("<<param.gw_address>>",HttpParameterHelper.getParameters(content, "gw_address"));
	responseContent = responseContent.replaceAll("<<param.gw_port>>",HttpParameterHelper.getParameters(content, "gw_port"));
	responseContent = responseContent.replaceAll("<<param.gw_id>>",HttpParameterHelper.getParameters(content, "gw_id"));
	responseContent = responseContent.replaceAll("<<param.url>>",HttpParameterHelper.getParameters(content, "url"));
	
	if(tips==null){
		responseContent = responseContent.replaceAll("<<showtips>>","");
	}else{
		responseContent = responseContent.replaceAll("<<showtips>>","<input type='button' onclick='return;' class='get_btn' value='"+tips+"'>");
	}
	
	response = sendPrepare(ctx, responseContent);
	return response;
}
 
开发者ID:violetgo,项目名称:wifidogAuthServer,代码行数:21,代码来源:HttpHandler.java

示例5: returnLoginPage

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
/**
 * return login page,if user & password is error.return error tips!
 * */
private HttpResponse returnLoginPage(ChannelHandlerContext ctx, QueryStringDecoder content,String tips) {
	HttpResponse response;
	String responseContent = ReadAll.readAll("web/login.html", "utf-8");
	responseContent = responseContent.replaceAll("<<param.gw_address>>",HttpParameterHelper.getParameters(content, "gw_address"));
	responseContent = responseContent.replaceAll("<<param.gw_port>>",HttpParameterHelper.getParameters(content, "gw_port"));
	responseContent = responseContent.replaceAll("<<param.gw_id>>",HttpParameterHelper.getParameters(content, "gw_id"));
	responseContent = responseContent.replaceAll("<<param.url>>",HttpParameterHelper.getParameters(content, "url"));
	
	if(tips==null){
		responseContent = responseContent.replaceAll("<<showtips>>","");
	}else{
		responseContent = responseContent.replaceAll("<<showtips>>","<input type='button' onclick='return;' class='get_btn' value='"+tips+"'>");
	}
	
	response = sendPrepare(ctx, responseContent);
	return response;
}
 
开发者ID:violetgo,项目名称:wifidogAuthServer,代码行数:21,代码来源:HttpHandler.java

示例6: getParameters

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
/**
 * get Parameter from URI
 * */
public static String getParameters(QueryStringDecoder content,String query){
	List<String> list = content.getParameters().get(query);
	if(list==null){
		return "";
	}
	
	StringBuilder respone = new StringBuilder();
	for(int i=0;i<list.size();i++){
		if(i==list.size()-1){
			respone.append(list.get(i));
		}else{
			respone.append(list.get(i)+",");
		}
	}
	return respone.toString();
}
 
开发者ID:violetgo,项目名称:wifidogAuthServer,代码行数:20,代码来源:HttpParameterHelper.java

示例7: parseQueryParameters

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
private QueryParams parseQueryParameters(QueryStringDecoder decoded) {
  final Map<String, List<String>> parameters = decoded.getParameters();
  return new QueryParams(
          safeOneValue(parameters, "type"),
          safeOneValue(parameters, "key"),
          Long.parseLong(safeOneValue(parameters, "from")),
          Long.parseLong(safeOneValue(parameters, "to"))
  );
}
 
开发者ID:yandex,项目名称:opentsdb-flume,代码行数:10,代码来源:LegacyHttpSource.java

示例8: traversalDecoder

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
private void traversalDecoder(QueryStringDecoder decoder) {
    try {
        for (Map.Entry<String, List<String>> entry : decoder.getParameters().entrySet()) {
            params.put(entry.getKey(), entry.getValue().get(0));
        }
    } catch (JSONException e) {
        throw NaviUtil.transferToNaviSysException(e);
    }
}
 
开发者ID:sunguangran,项目名称:navi,代码行数:10,代码来源:NaviHttpRequest.java

示例9: getPath

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
private static String getPath(QueryStringDecoder decoder)
        throws FileNotFoundException {
  String path = decoder.getPath();
  if (path.startsWith("/webhdfs/v1/")) {
    return path.substring(11);
  } else {
    throw new FileNotFoundException("Path: " + path + " should " +
            "start with \"/webhdfs/v1/\"");
  }
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:11,代码来源:FSImageHandler.java

示例10: apply

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
public Future<HttpResponse> apply(HttpRequest req) {
    // Parse URL parameters
    String bannerSize = null;
    String opt = null;
    QueryStringDecoder decoder = new QueryStringDecoder(req.getUri());
    Map <String, List<String>> params = decoder.getParameters();
    if (params.containsKey("bsize")) {
        bannerSize = params.get("bsize").get(0);
        opt = params.get("opt").get(0);
    }

    // Parse cookie
    Cookie cookie = null;
    String value = req.getHeader("Cookie");
    if (value != null) {
        Set<Cookie> cookies = new CookieDecoder().decode(value);
        for (Cookie c : cookies) {
            if (c.getName().equals(COOKIE_NAME)) {
                cookie = c;
            }
        }
    }
    String vizid = null;
    if (cookie != null) {
        vizid = cookie.getValue();
    } else {
        vizid = UUID.randomUUID().toString();
        // TODO Skip cache access
    }

    // Get data from redis cache
    Future<scala.collection.immutable.Set<ChannelBuffer>> udResponse = redisCache.sMembers(vizid);

    Future<HttpResponse> response = udResponse.flatMap(new ProcessResponse(req, vizid, 
            bannerSize, opt, redisCache));
    System.out.println("[CookieServer] Returning response Future");
    return response;
}
 
开发者ID:eternalthinker,项目名称:finagle-6.x-java-example,代码行数:39,代码来源:CookieServerSingle.java

示例11: testCreateHashFetchURL

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
@Test
public void testCreateHashFetchURL() throws Exception {
  QueryId q1 = TestTajoIds.createQueryId(1315890136000l, 2);
  String hostName = "tajo1";
  int port = 1234;
  ExecutionBlockId sid = new ExecutionBlockId(q1, 2);
  int partitionId = 2;

  List<QueryUnit.IntermediateEntry> intermediateEntries = TUtil.newList();
  for (int i = 0; i < 1000; i++) {
    intermediateEntries.add(new QueryUnit.IntermediateEntry(i, 0, partitionId, hostName, port));
  }

  Collection<URI> uris = Repartitioner.
      createHashFetchURL(hostName + ":" + port, sid, partitionId,
              TajoWorkerProtocol.ShuffleType.HASH_SHUFFLE, intermediateEntries);

  List<String> taList = TUtil.newList();
  for (URI uri : uris) {
    final Map<String, List<String>> params =
        new QueryStringDecoder(uri).getParameters();
    taList.addAll(splitMaps(params.get("ta")));
  }

  int checkTaskId = 0;
  for (String ta : taList) {
    assertEquals(checkTaskId++, Integer.parseInt(ta.split("_")[0]));
  }
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:30,代码来源:TestRepartitioner.java

示例12: handle

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
public ComposableFuture<Map<String, String>> handle(final HttpRequest request) {
  final QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri());
  final Map<String,List<String>> params = queryStringDecoder.getParameters();
  final Map<String, String> res = new HashMap<>();
  for (final String key: params.keySet()) {
    res.put(key, params.get(key).get(0));
  }

  return ComposableFutures.fromValue(res);
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:11,代码来源:ParamsService.java

示例13: process

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
@Override
protected boolean process(ChannelHandlerContext context, HttpRequest request, QueryStringDecoder urlDecoder) throws IOException, ImageWriteException {
  HttpRequestHandler connectedHandler = (HttpRequestHandler)context.getAttachment();
  if (connectedHandler != null) {
    if (connectedHandler.isSupported(request) && connectedHandler.process(urlDecoder, request, context)) {
      return true;
    }
    // prev cached connectedHandler is not suitable for this request, so, let's find it again
    context.setAttachment(null);
  }

  if (urlDecoder.getPath().equals("/favicon.ico")) {
    Icon icon = IconLoader.findIcon(ApplicationInfoEx.getInstanceEx().getSmallIconUrl());
    if (icon != null) {
      BufferedImage image = UIUtil.createImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
      icon.paintIcon(null, image.getGraphics(), 0, 0);
      byte[] icoBytes = Sanselan.writeImageToBytes(image, ImageFormat.IMAGE_FORMAT_ICO, null);
      Responses.send(icoBytes, FileResponses.createResponse(urlDecoder.getPath()), request, context);
      return true;
    }
  }

  for (HttpRequestHandler handler : BuiltInServerManager.EP_NAME.getExtensions()) {
    try {
      if (handler.isSupported(request) && handler.process(urlDecoder, request, context)) {
        if (context.getAttachment() == null) {
          context.setAttachment(handler);
        }
        return true;
      }
    }
    catch (Throwable e) {
      BuiltInServer.LOG.error(e);
    }
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:38,代码来源:DelegatingHttpRequestHandler.java

示例14: parseGet

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
private void parseGet(ChannelHandlerContext ctx, MessageEvent e, HttpRequest request)  {
	QueryStringDecoder decoder = new QueryStringDecoder(request.getUri());
	String path = decoder.getPath();
	HttpResponse response = null;;
	LogHelper.info("got get request "+path);
	if(path.equals("/ewifi/ping/")){
		response = parsePing(ctx, decoder);
	}else if(path.equals("/ewifi/auth/")){
		response = parseAuth(ctx, decoder);
	}else if(path.equals("/ewifi/login/")){
		response = parseLogin(ctx, decoder);
	}else if(path.equals("/ewifi/portal/")){
		response = parsePortal(ctx, decoder);
	}else if(path.equals("/ewifi/regedit/")){
		response = parseRegedit(ctx, decoder);
	}else if(path.equals("/ewifi/querymac/")){
		response = parseQuery(ctx, decoder);
	}else{
		response = parseStatic(ctx, decoder);
	}

	Channel ch = e.getChannel();
	if (ch.isConnected()) {
		ch.write(response).addListener(ChannelFutureListener.CLOSE);
	}

}
 
开发者ID:violetgo,项目名称:wifidogAuthServer,代码行数:28,代码来源:HttpHandler.java

示例15: parsePortal

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入依赖的package包/类
private HttpResponse parsePortal(ChannelHandlerContext ctx, QueryStringDecoder content) {
	HttpResponse response = null;
	String html = ReadAll.readAll("web/portal/"+HttpParameterHelper.getParameters(content, "gw_id")+".html", "utf-8");
	if(html!=null && !html.isEmpty()){
		response = sendPrepare(ctx,html);
	}else{
		response = sendPrepare(ctx,"欢迎你连接"+HttpParameterHelper.getParameters(content, "gw_id")+",你现在可以正常上网了!");
	}
	
	return response;
}
 
开发者ID:violetgo,项目名称:wifidogAuthServer,代码行数:12,代码来源:HttpHandler.java


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