Logo Search packages:      
Sourcecode: uimaj version File versions  Download package

int org::apache::uima::resource::metadata::impl::MetaDataObject_impl::hashCode (  ) [inline, inherited]

Gets the hash code for this object. The hash codes of two NameClassPairs x and y must be equal if x.equals(y) returns true;

Returns:
the hash code for this object

Reimplemented in org::apache::uima::resource::metadata::impl::LanguagePrecondition_impl.

Definition at line 495 of file MetaDataObject_impl.java.

                        {
    int hashCode = 0;

    // add the hash codes of all attributes
    List<NameClassPair> attrs = listAttributes();
    Iterator<NameClassPair> i = attrs.iterator();
    while (i.hasNext()) {
      String attrName = ((NameClassPair) i.next()).getName();
      Object val = getAttributeValue(attrName);
      if (val != null) {
        if (val instanceof Object[]) {
          Object[] arr = (Object[]) val;
          for (int j = 0; j < arr.length; j++) {
            if (arr[j] != null) {
              hashCode += arr[j].hashCode();
            }
          }
        } else if (val instanceof Map) // only need to do this to handle Maps w/ array vals
        {
          Set entrySet = ((Map) val).entrySet();
          Iterator it = entrySet.iterator();
          while (it.hasNext()) {
            Map.Entry entry = (Map.Entry) it.next();
            hashCode += entry.getKey().hashCode();
            Object subval = entry.getValue();
            if (subval instanceof Object[]) {
              Object[] arr = (Object[]) subval;
              for (int j = 0; j < arr.length; j++) {
                if (arr[j] != null) {
                  hashCode += arr[j].hashCode();
                }
              }
            } else {
              hashCode += subval.hashCode();
            }
          }
        } else {
          hashCode += val.hashCode();
        }
      }
    }
    return hashCode;
  }

Generated by  Doxygen 1.6.0   Back to index