Package com.dgwave.osrs.jaxb

Examples of com.dgwave.osrs.jaxb.Item


    DtAssoc dt = (DtAssoc) resp.getBody().getDataBlock().getDtAass().get(0);
    List<Object> items = dt.getDtAassi();
    for (Iterator<Object> iterator = items.iterator(); iterator.hasNext();) {
      Object object = (Object) iterator.next();
      if (object instanceof Item) {
        Item item = (Item) object;
        if ("action".equals(item.getKey())) {
          response.setAction(item.getStringValue());
        } else if ("object".equals(item.getKey())) {
          response.setObject(item.getStringValue());
        } else if ("response_text".equals(item.getKey())) {
          response.setErrorMessage(item.getStringValue());
        } else if ("response_code".equals(item.getKey())) {
          try {
            response.setErrorCode(Integer.parseInt(item.getStringValue()));
          } catch (NumberFormatException e) {
            response.setErrorCode(999);
          }
        } else if ("is_success".equals(item.getKey())) {
          int tf = Integer.parseInt(item.getStringValue());
          response.setError(tf==1?false:true);
        } else if ("protocol".equals(item.getKey())) {
          response.setProtocol(item.getStringValue());
        }else  {
          populate(response, item);
        }
      }
    }
View Full Code Here


    cleanList(items);
    Map<String,String> assocValues = new HashMap<String, String>();
    for (Iterator<Object> it3 = items.iterator(); it3.hasNext();) {
      Object obj3 = (Object) it3.next();
      if (obj3 instanceof Item) {
        Item item = (Item)obj3;
        String value = item.getStringValue();
        if (value != null) { // simple item value
          assocValues.put(item.getKey(), value);
        } else { // this is an element in one type of item
          processContainerList(response, item.getDtAass(),item.getKey());
        }
      }
    }
    return assocValues; 
  }
View Full Code Here

      OPSEnvelope opsEnvelope = objFactory.createOPSEnvelope();
      Header header = objFactory.createHeader();
      header.setVersion("0.9");
      opsEnvelope.setHeader(header);
     
      Item domain = objFactory.createItem();
      domain.setKey("domain");
      domain.setStringValue("dgwave.com");
     
      DtAssoc attrs = objFactory.createDtAssoc();
      attrs.addItem(domain);
      Item attributes = objFactory.createItem();
      attributes.setKey("attributes");
      attributes.addDtAssoc(attrs);
     
     
      Item protocol = objFactory.createItem();
      protocol.setKey("protocol");
      protocol.setStringValue("XCP");
      Item action = objFactory.createItem();
      action.setKey("action");
      action.setStringValue("belongs_to_rsp");
      Item obj = objFactory.createItem();
      obj.setKey("object");
      obj.setStringValue("domain");
     
      DtAssoc top = objFactory.createDtAssoc();
      top.addItem(protocol);
      top.addItem(action);
      top.addItem(obj);
View Full Code Here

      "</body>\n" +
      "</OPS_envelope>\n";
      OPSEnvelope evp  = client.createEnvelope(sampleResponse);
      assertNotNull(evp);
      assertEquals("Version ", "0.9", evp.getHeader().getVersion());
      Item item = (Item)((DtAssoc)evp.getBody().getDataBlock().getDtAass().get(0)).getDtAassi().get(5);
      assertEquals("Simple ", "is_success", item.getKey());
      assertNotNull(item.getStringValue());
      assertEquals("Value ", "1", item.getStringValue());
     
    } catch (OsrsException e) {
      e.printStackTrace();
      fail ("Error while creating envelope from string");
    }
View Full Code Here

 
  protected String getString(OsrsRequest request) throws OsrsException {
    OPSEnvelope envelope = getEmptyEnvelope();
    Map<String, Object> attrs = request.getAttributes();

    Item pro = oj.createItem();
    pro.setKey("protocol");
    pro.setStringValue(this.protocol);
    Item obj = oj.createItem();
    obj.setKey("object");
    obj.setStringValue(request.getObject());
    Item act = oj.createItem();
    act.setKey("action");
    act.setStringValue(request.getAction());
    Item att = oj.createItem();
    att.setKey("attributes");
    att.addDtAssoc(processAttrs(attrs));
   
    DtAssoc c = oj.createDtAssoc();
    c.addItem(pro);
    c.addItem(act);
    c.addItem(obj);
View Full Code Here

  private DtAssoc processAttrs(Map<String, Object> attrs) {
    DtAssoc dt = oj.createDtAssoc();
    for (Iterator<String> iter = attrs.keySet().iterator(); iter.hasNext();) {
      String key = (String) iter.next();
      if (attrs.get(key) instanceof String) {
        Item one = oj.createItem();
        one.setKey(key);
        one.setStringValue((String)attrs.get(key));
        dt.addItem(one);
      }
    }
    return dt;
  }
View Full Code Here

TOP

Related Classes of com.dgwave.osrs.jaxb.Item

Copyright © 2018 www.massapicom. 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.