edu.internet2.middleware.grouper.subj
Class SubjectHelper

java.lang.Object
  extended by edu.internet2.middleware.grouper.subj.SubjectHelper

public class SubjectHelper
extends Object

Subject utility helper class.

Version:
$Id: SubjectHelper.java,v 1.7 2009-12-28 06:08:37 mchyzer Exp $
Author:
blair christensen.

Constructor Summary
SubjectHelper()
           
 
Method Summary
static org.apache.commons.collections.keyvalue.MultiKey convertToMultiKey(edu.internet2.middleware.subject.Subject subject)
          if keeping the subjects in a map where the subject is the key, this multikey will identify the subject
static boolean eq(Object a, Object b)
           
static boolean eqSource(Object a, Object b)
           
static edu.internet2.middleware.subject.Subject findInList(Collection<edu.internet2.middleware.subject.Subject> collection, String sourceId, String subjectId, boolean exceptionIfNotFound)
          see if a subject is in a list, if so return it
static String getPretty(Member _m)
           
static String getPretty(edu.internet2.middleware.subject.Subject subj)
           
static String getPrettyComplete(edu.internet2.middleware.subject.Subject subj)
           
static int hashcode(edu.internet2.middleware.subject.Subject subject)
          hashcode for subject
static boolean inList(Collection<edu.internet2.middleware.subject.Subject> collection, String sourceId, String subjectId)
          see if a subject is in a list
static boolean inList(Collection<edu.internet2.middleware.subject.Subject> collection, edu.internet2.middleware.subject.Subject subject)
          see if a subject is in a list
static boolean inSourceList(Collection<edu.internet2.middleware.subject.Source> collection, edu.internet2.middleware.subject.Source source)
          see if a source is in a list
static Set<edu.internet2.middleware.subject.Source> nonGroupSources()
           
static void removeDuplicates(Collection<edu.internet2.middleware.subject.Subject> subjects)
          remove duplicates from a set
static void sortByDescription(Collection<edu.internet2.middleware.subject.Subject> subjects)
          sort a set or list by subject description
static Set<edu.internet2.middleware.subject.Subject> sortSetForSearch(Collection<edu.internet2.middleware.subject.Subject> subjectsIn, String searchTerm)
          sort a set of subjects for a search, match id's and identifiers at top
static Set<edu.internet2.middleware.subject.Subject> sortSetForSearch(Collection<edu.internet2.middleware.subject.Subject> subjectsIn, String searchTerm, Set<edu.internet2.middleware.subject.Subject> idOrIdentifierMatches)
          sort a set of subjects for a search, match id's and identifiers at top
static String sourcesToIdsString(Collection<edu.internet2.middleware.subject.Source> sources)
          convert sources to id's comma separated
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubjectHelper

public SubjectHelper()
Method Detail

sourcesToIdsString

public static String sourcesToIdsString(Collection<edu.internet2.middleware.subject.Source> sources)
convert sources to id's comma separated

Parameters:
sources -
Returns:
the string or null if none

convertToMultiKey

public static org.apache.commons.collections.keyvalue.MultiKey convertToMultiKey(edu.internet2.middleware.subject.Subject subject)
if keeping the subjects in a map where the subject is the key, this multikey will identify the subject

Parameters:
subject -
Returns:
the multikey of source id and subject id

sortByDescription

public static void sortByDescription(Collection<edu.internet2.middleware.subject.Subject> subjects)
sort a set or list by subject description

Parameters:
subjects -

nonGroupSources

public static Set<edu.internet2.middleware.subject.Source> nonGroupSources()
Returns:
the sources that are non group

sortSetForSearch

public static Set<edu.internet2.middleware.subject.Subject> sortSetForSearch(Collection<edu.internet2.middleware.subject.Subject> subjectsIn,
                                                                             String searchTerm)
sort a set of subjects for a search, match id's and identifiers at top

Parameters:
subjectsIn -
searchTerm -
Returns:
the set with close matches at top

sortSetForSearch

public static Set<edu.internet2.middleware.subject.Subject> sortSetForSearch(Collection<edu.internet2.middleware.subject.Subject> subjectsIn,
                                                                             String searchTerm,
                                                                             Set<edu.internet2.middleware.subject.Subject> idOrIdentifierMatches)
sort a set of subjects for a search, match id's and identifiers at top

Parameters:
subjectsIn -
searchTerm -
idOrIdentifierMatches - null if not known, but if you know of some, pass that in here
Returns:
the set with close matches at top

hashcode

public static int hashcode(edu.internet2.middleware.subject.Subject subject)
hashcode for subject

Parameters:
subject -
Returns:
the hashcode

eq

public static boolean eq(Object a,
                         Object b)
Parameters:
a -
b -
Returns:
True if both objects are Subjects and equal.
Since:
1.2.1

eqSource

public static boolean eqSource(Object a,
                               Object b)
Parameters:
a -
b -
Returns:
True if both objects are Sources and equal.
Since:
2.0.2

getPretty

public static String getPretty(Member _m)
Parameters:
_m -
Returns:
string

getPretty

public static String getPretty(edu.internet2.middleware.subject.Subject subj)
Parameters:
subj -
Returns:
string

getPrettyComplete

public static String getPrettyComplete(edu.internet2.middleware.subject.Subject subj)
Parameters:
subj -
Returns:
string

removeDuplicates

public static void removeDuplicates(Collection<edu.internet2.middleware.subject.Subject> subjects)
remove duplicates from a set

Parameters:
subjects -

inList

public static boolean inList(Collection<edu.internet2.middleware.subject.Subject> collection,
                             edu.internet2.middleware.subject.Subject subject)
see if a subject is in a list

Parameters:
collection -
subject -
Returns:
true if in list

inList

public static boolean inList(Collection<edu.internet2.middleware.subject.Subject> collection,
                             String sourceId,
                             String subjectId)
see if a subject is in a list

Parameters:
collection -
sourceId -
subjectId -
Returns:
true if in list

findInList

public static edu.internet2.middleware.subject.Subject findInList(Collection<edu.internet2.middleware.subject.Subject> collection,
                                                                  String sourceId,
                                                                  String subjectId,
                                                                  boolean exceptionIfNotFound)
see if a subject is in a list, if so return it

Parameters:
collection -
sourceId -
subjectId -
exceptionIfNotFound - true if an exception should be thrown if not found
Returns:
subject or null if not found or exception

inSourceList

public static boolean inSourceList(Collection<edu.internet2.middleware.subject.Source> collection,
                                   edu.internet2.middleware.subject.Source source)
see if a source is in a list

Parameters:
collection -
source -
Returns:
true if in list