public CharacterSet unmarshall(StaxUnmarshallerContext context) throws Exception {
    CharacterSet characterSet = new CharacterSet();
    int originalDepth = context.getCurrentDepth();
    int targetDepth = originalDepth + 1;

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

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

      if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) {

        if (context.testExpression("CharacterSetName", targetDepth)) {
          characterSet.setCharacterSetName(
              StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }

        if (context.testExpression("CharacterSetDescription", targetDepth)) {
          characterSet.setCharacterSetDescription(
              StringStaxUnmarshaller.getInstance().unmarshall(context));
          continue;
        }
      } else if (xmlEvent.isEndElement()) {
        if (context.getCurrentDepth() < originalDepth) {
          return characterSet;
        }
      }
    }
  }
Ejemplo n.º 2
0
 /**
  * The description of the character set.
  *
  * @param characterSetDescription The description of the character set.
  * @return Returns a reference to this object so that method calls can be chained together.
  */
 public CharacterSet withCharacterSetDescription(String characterSetDescription) {
   setCharacterSetDescription(characterSetDescription);
   return this;
 }