示例#1
0
  public void generateHC() {
    System.out.println("Hashcode test of String:");
    String str = "sri";
    System.out.println(str.hashCode());
    str = str + "ram";
    System.out.println(str.hashCode());

    System.out.println("Hashcode test of StringBuffer:");
    StringBuffer sb = new StringBuffer("sri");
    System.out.println(sb.hashCode());
    sb.append("ram");
    System.out.println(sb.hashCode());
  }
  private String addLocationElement(
      Document parentDocument, PersonElementWrapper person, Element rapSheet) {
    StringBuffer fullAddress = new StringBuffer(1024);
    fullAddress
        .append(person.streetAddress)
        .append(" ")
        .append(person.city)
        .append(", ")
        .append(person.state)
        .append(" ")
        .append(person.zipCode);
    String id = "L" + String.valueOf(fullAddress.hashCode());
    Element location = appendElement(rapSheet, OjbcNamespaceContext.NS_NC, "Location");
    XmlUtils.addAttribute(location, OjbcNamespaceContext.NS_STRUCTURES, "id", id);

    Element e = appendElement(location, OjbcNamespaceContext.NS_NC, "LocationAddress");
    e = appendElement(e, OjbcNamespaceContext.NS_NC, "AddressFullText");
    e.setTextContent(fullAddress.toString());

    return id;
  }