/**
   * Creates the id entity by a xml.
   *
   * @param xml the xml string
   * @return the instance of NeteaseIDEntity
   */
  private NeteaseIDEntity createEntity(String xml) {
    if (xml == null || xml.equals("")) {
      return null;
    }

    Document document = null;
    try {
      document = Dom4JReader.getDocument(xml);
    } catch (DocumentException e) {
      e.printStackTrace();
    }
    Element rootElement = document.getRootElement();
    Element productElement = rootElement.element("product");

    NeteaseIDEntity idEntity = new NeteaseIDEntity();

    Element codeElement = productElement.element("code");
    idEntity.setCode(codeElement.getText());

    Element locationElement = productElement.element("location");
    idEntity.setLocation(locationElement.getText());

    Element birthdayElement = productElement.element("birthday");
    String birthday = birthdayElement.getText();
    birthday =
        birthday.substring(0, 4) + "-" + birthday.substring(4, 6) + "-" + birthday.substring(6);
    idEntity.setBirthday(birthday);

    Element genderElement = productElement.element("gender");
    String gender = genderElement.getText();
    if (gender.equals("m")) {
      gender = UtilityLocale.getString("male");
    } else if (gender.equals("f")) {
      gender = UtilityLocale.getString("femal");
    } else {
      gender = UtilityLocale.getString("unknown");
    }
    idEntity.setGender(gender);

    return idEntity;
  }
示例#2
0
  public ElementNode parse(InputStream inputStream) throws DocumentException, IOException {
    Document document = Dom4JReader.getDocument(inputStream);

    return parse(document);
  }
示例#3
0
  public ElementNode parseFormat(File file)
      throws DocumentException, IOException, UnsupportedEncodingException {
    Document document = Dom4JReader.getFormatDocument(file);

    return parse(document);
  }
示例#4
0
  public ElementNode parse(File file) throws DocumentException, IOException {
    Document document = Dom4JReader.getDocument(file);

    return parse(document);
  }
示例#5
0
  public ElementNode parseFormat(String text)
      throws DocumentException, UnsupportedEncodingException {
    Document document = Dom4JReader.getFormatDocument(text);

    return parse(document);
  }
示例#6
0
  public ElementNode parse(String text) throws DocumentException {
    Document document = Dom4JReader.getDocument(text);

    return parse(document);
  }
示例#7
0
  public ElementNode parseFormat(InputStream inputStream)
      throws DocumentException, IOException, UnsupportedEncodingException {
    Document document = Dom4JReader.getFormatDocument(inputStream);

    return parse(document);
  }