Examples of DataParser


Examples of ch.ethz.inf.vs.californium.network.serialization.DataParser

     * The endpoint's executor executes this method to convert the raw bytes
     * into a message, look for an associated exchange and forward it to
     * the stack of layers.
     */
    private void receiveMessage(RawData raw) {
      DataParser parser = new DataParser(raw.getBytes());
     
      if (parser.isRequest()) {
        // This is a request
        Request request;
        try {
          request = parser.parseRequest();
        } catch (IllegalStateException e) {
          String log = "message format error caused by " + raw.getInetSocketAddress();
          if (!parser.isReply()) {
            // manually build RST from raw information
            EmptyMessage rst = new EmptyMessage(Type.RST);
            rst.setDestination(raw.getAddress());
            rst.setDestinationPort(raw.getPort());
            rst.setMID(parser.getMID());
            for (MessageInterceptor interceptor:interceptors)
              interceptor.sendEmptyMessage(rst);
            connector.send(serializer.serialize(rst));
            log += " and reseted";
          }
          LOGGER.info(log);
          return;
        }
        request.setSource(raw.getAddress());
        request.setSourcePort(raw.getPort());

        /*
         * Logging here causes significant performance loss.
         * If necessary, add an interceptor that logs the messages,
         * e.g., the MessageTracer.
         */
       
        for (MessageInterceptor interceptor:interceptors)
          interceptor.receiveRequest(request);

        // MessageInterceptor might have canceled
        if (!request.isCanceled()) {
          Exchange exchange = matcher.receiveRequest(request);
          if (exchange != null) {
            exchange.setEndpoint(CoAPEndpoint.this);
            coapstack.receiveRequest(exchange, request);
          }
        }
       
      } else if (parser.isResponse()) {
        // This is a response
        Response response = parser.parseResponse();
        response.setSource(raw.getAddress());
        response.setSourcePort(raw.getPort());

        /*
         * Logging here causes significant performance loss.
         * If necessary, add an interceptor that logs the messages,
         * e.g., the MessageTracer.
         */
       
        for (MessageInterceptor interceptor:interceptors)
          interceptor.receiveResponse(response);

        // MessageInterceptor might have canceled
        if (!response.isCanceled()) {
          Exchange exchange = matcher.receiveResponse(response);
          if (exchange != null) {
            exchange.setEndpoint(CoAPEndpoint.this);
            response.setRTT(System.currentTimeMillis() - exchange.getTimestamp());
            coapstack.receiveResponse(exchange, response);
          }
        }
       
      } else if (parser.isEmpty()) {
        // This is an empty message
        EmptyMessage message = parser.parseEmptyMessage();
        message.setSource(raw.getAddress());
        message.setSourcePort(raw.getPort());
       
        /*
         * Logging here causes significant performance loss.
View Full Code Here

Examples of org.apache.axiom.c14n.DataParser

    public static void main(String[] args) {
        TestRunner.run(suite());
    }

    public void setUp() throws Exception {
        dp = new DataParser("/sample1.xml");
        dp.init();
        // get e5
        OMElement e5 = dp.omDocEle.getFirstChildWithName(new QName("http://example.org", "e5"));
        // get the wrapped element of e5
        Element e = (Element) dp.fac.getNode(e5);
View Full Code Here

Examples of org.apache.axiom.c14n.DataParser

    public static void main(String[] args) {
        TestRunner.run(suite());
    }

    public void setUp() throws Exception{
        dp = new DataParser("/sample1.xml");
        dp.init();
    }
View Full Code Here

Examples of org.apache.axiom.c14n.DataParser

            "   <normId id=\"' &#xD;&#xA;&#x9; '\"></normId>\n" +
            "</doc>";

    public void setUp() throws Exception {
        // parse data of sample2.xml
        dp = new DataParser("/sample2.xml");
        // get canonicalizer with comment
        c14n = Canonicalizer.getInstance(
                "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments");
    }
View Full Code Here

Examples of org.apache.axiom.c14n.DataParser

    private String sample6Result = "<doc>©</doc>";

    public void setUp() throws Exception {
        // parse data of sample5.xml
        dp = new DataParser("/sample5.xml");
        // get canonicalizer which omits comments
        c14n = Canonicalizer.getInstance(
                "http://www.w3.org/TR/2001/REC-xml-c14n-20010315");
    }
View Full Code Here

Examples of org.apache.axiom.c14n.DataParser

    public static void main(String[] args) {
        TestRunner.run(suite());
    }

    public void setUp() throws Exception{
        dp = new DataParser("/sample1.xml");
        dp.init();
        // get e5
        OMElement e5 = dp.omDocEle.getFirstChildWithName(new QName("http://example.org","e5"));
        // get the wrapped element of e5
        Element e = (Element)dp.fac.getNode(e5);
View Full Code Here

Examples of org.apache.axiom.c14n.DataParser

    public static void main(String[] args) {
        TestRunner.run(suite());
    }

    public void setUp() throws Exception{
        dp = new DataParser("/sample1.xml");
        dp.init();
    }
View Full Code Here

Examples of org.apache.axiom.c14n.DataParser

    public static void main(String[] args) {
        TestRunner.run(suite());
    }

    public void setUp() throws Exception{
        dp = new DataParser("/sample1.xml");
        dp.init();
        // <!-- Comment 2 -->
        comment = (Comment)dp.doc.getFirstChild().getNextSibling();
    }
View Full Code Here

Examples of org.apache.axiom.c14n.DataParser

    public static void main(String[] args) {
        TestRunner.run(suite());
    }

    public void setUp() throws Exception{
        dp = new DataParser("/sample1.xml");
        dp.init();
        NodeList nl = dp.docEle.getChildNodes();
        n = null;
        for (int i = 0; i < nl.getLength(); i++) {
            n = nl.item(i);
View Full Code Here

Examples of org.apache.axiom.c14n.DataParser

    public static void main(String[] args) {
        TestRunner.run(suite());
    }

    public void setUp() throws Exception{
        dp = new DataParser("/sample1.xml");
        dp.init();
        nl = dp.docEle.getChildNodes();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.