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;
        }
      }
    }
  }
예제 #2
0
 /**
  * The name of the character set.
  *
  * @param characterSetName The name of the character set.
  * @return Returns a reference to this object so that method calls can be chained together.
  */
 public CharacterSet withCharacterSetName(String characterSetName) {
   setCharacterSetName(characterSetName);
   return this;
 }