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;
        }
      }
    }
  }
Exemplo n.º 2
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;

    if (obj instanceof CharacterSet == false) return false;
    CharacterSet other = (CharacterSet) obj;
    if (other.getCharacterSetName() == null ^ this.getCharacterSetName() == null) return false;
    if (other.getCharacterSetName() != null
        && other.getCharacterSetName().equals(this.getCharacterSetName()) == false) return false;
    if (other.getCharacterSetDescription() == null ^ this.getCharacterSetDescription() == null)
      return false;
    if (other.getCharacterSetDescription() != null
        && other.getCharacterSetDescription().equals(this.getCharacterSetDescription()) == false)
      return false;
    return true;
  }