/** * To check if a checksum does have a specific method * @param checksum the checksum * @param methodId the checksum MI identifier * @param methodName the checksum method name * @return true if the checksum has the method with given name/identifier */ public static boolean doesChecksumHaveMethod(Checksum checksum, String methodId, String methodName){ if (checksum == null || (methodName == null && methodId == null)){ return false; } CvTerm method = checksum.getMethod(); // we can compare identifiers if (methodId != null && method.getMIIdentifier() != null){ // we have the same method id return method.getMIIdentifier().equals(methodId); } // we need to compare methodNames else if (methodName != null) { return methodName.equalsIgnoreCase(method.getShortName()); } return false; }
/** * * @param checksum * @return the hashcode consistent with the equals method for this comparator */ public static int hashCode(Checksum checksum){ if (unambiguousChecksumComparator == null){ unambiguousChecksumComparator = new UnambiguousChecksumComparator(); } if (checksum == null){ return 0; } int hashcode = 31; CvTerm method = checksum.getMethod(); hashcode = 31*hashcode + UnambiguousCvTermComparator.hashCode(method); String value = checksum.getValue(); hashcode = 31*hashcode + value.hashCode(); return hashcode; } }
public void writeChecksum(Checksum checksum) throws IOException { if (checksum != null){ // first method escapeAndWriteString(checksum.getMethod().getShortName()); getWriter().write(MitabUtils.XREF_SEPARATOR); // then value escapeAndWriteString(checksum.getValue()); } }
CvTerm method = checksum.getMethod();
final OntologyAccess access = ontologyManager.getOntologyAccess("MI"); CvTerm method = checksum.getMethod();