public PolicyAttributeDescription unmarshall(StaxUnmarshallerContext context) throws Exception {
    PolicyAttributeDescription policyAttributeDescription = new PolicyAttributeDescription();

    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

    if (context.isStartOfDocument()) targetDepth += 2;

    while (true) {
      int xmlEvent = context.nextEvent();
      if (xmlEvent == XmlPullParser.END_DOCUMENT) break;

      if (xmlEvent == XmlPullParser.START_TAG) {
        if (context.testExpression("AttributeName", targetDepth)) {
          policyAttributeDescription.setAttributeName(
              StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
        if (context.testExpression("AttributeValue", targetDepth)) {
          policyAttributeDescription.setAttributeValue(
              StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
      } else if (xmlEvent == XmlPullParser.END_TAG) {
        if (context.getCurrentDepth() < originalDepth) {
          break;
        }
      }
    }
    return policyAttributeDescription;
  }
コード例 #2
0
  public InstanceState unmarshall(StaxUnmarshallerContext context) throws Exception {
    InstanceState instanceState = new InstanceState();
    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

    if (context.isStartOfDocument()) targetDepth += 2;

    while (true) {
      XMLEvent xmlEvent = context.nextEvent();
      if (xmlEvent.isEndDocument()) return instanceState;

      if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {
        if (context.testExpression("InstanceId", targetDepth)) {
          instanceState.setInstanceId(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
        if (context.testExpression("State", targetDepth)) {
          instanceState.setState(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
        if (context.testExpression("ReasonCode", targetDepth)) {
          instanceState.setReasonCode(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
        if (context.testExpression("Description", targetDepth)) {
          instanceState.setDescription(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
      } else if (xmlEvent.isEndElement()) {
        if (context.getCurrentDepth() < originalDepth) {
          return instanceState;
        }
      }
    }
  }
コード例 #3
0
  public ListenerDescription unmarshall(StaxUnmarshallerContext context) throws Exception {
    ListenerDescription listenerDescription = new ListenerDescription();
    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

    if (context.isStartOfDocument()) targetDepth += 2;

    while (true) {
      XMLEvent xmlEvent = context.nextEvent();
      if (xmlEvent.isEndDocument()) return listenerDescription;

      if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {
        if (context.testExpression("Listener", targetDepth)) {
          listenerDescription.setListener(
              ListenerStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
        if (context.testExpression("PolicyNames/member", targetDepth)) {
          listenerDescription
              .getPolicyNames()
              .add(StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
      } else if (xmlEvent.isEndElement()) {
        if (context.getCurrentDepth() < originalDepth) {
          return listenerDescription;
        }
      }
    }
  }