edu.internet2.middleware.subject.provider
Class SubjectImpl

java.lang.Object
  extended by edu.internet2.middleware.subject.provider.SubjectImpl
All Implemented Interfaces:
Subject, Serializable
Direct Known Subclasses:
GrouperSubject, JNDISubject, SubjectWrapper, UnresolvableSubject

public class SubjectImpl
extends Object
implements Subject

Base Subject implementation. Subclass this to change behavior

See Also:
Serialized Form

Constructor Summary
SubjectImpl(String id1, String name1, String description1, String typeName1, String sourceId1)
          Constructor called by SourceManager.
SubjectImpl(String id1, String name1, String description1, String typeName1, String sourceId1, Map<String,Set<String>> attributes1)
          Constructor called by SourceManager.
 
Method Summary
static String attributeValueOrCommaSeparated(Subject subject, String attributeName)
           
 boolean equals(Object obj)
           
static boolean equalsStatic(Subject subject, Object obj)
           
 Map<String,Set<String>> getAttributes()
          Gets a map attribute names and values.
 String getAttributeValue(String name1)
          Returns the value of a single-valued attribute.
 String getAttributeValueOrCommaSeparated(String attributeName)
           Returns the attribute value if single-valued, or if multi-valued, returns the values comma separated (with a space too).
 Set<String> getAttributeValues(String name1)
          Returns the values of a multi-valued attribute, or a set of size one for a single valued attribute.
 String getAttributeValueSingleValued(String attributeName)
          Returns the attribute value if single-valued, or if multi-valued, throws an exception.
 String getDescription()
          Gets this Subject's description.
 String getId()
          Gets this Subject's ID.
 String getName()
          Gets this Subject's name.
 Source getSource()
          Returns the Source of this Subject.
 String getSourceId()
          sourceId
 SubjectType getType()
          Gets this Subject's type.
 String getTypeName()
          get the type name
 int hashCode()
           
static int hashcodeStatic(Subject subject)
           
static void initVirtualAttributes(Subject subject)
          make sure the virtual attributes are setup for the subject
 void setAttributes(Map<String,Set<String>> attributes1)
           
 void setDescription(String description1)
           
 void setId(String id1)
           
 void setName(String name1)
           
 void setSourceId(String sourceId1)
          sourceId
 void setTypeName(String typeName1)
           
static Map<String,Set<String>> toAttributeMap(String... strings)
          turn some strings into a map, every other is a name or value of attribute
 String toString()
           
static String toStringStatic(Subject subject)
          toString
static Map<String,String> virtualAttributesForSource(Source source)
          get the ordered list of virtual attributes for a source
static Map<String,String> virtualAttributeVariablesForSource(Source source)
          get the ordered list of virtual attributes for a source
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SubjectImpl

public SubjectImpl(String id1,
                   String name1,
                   String description1,
                   String typeName1,
                   String sourceId1)
Constructor called by SourceManager. Will create an empty map for attributes

Parameters:
id1 -
name1 -
description1 -
typeName1 -
sourceId1 -

SubjectImpl

public SubjectImpl(String id1,
                   String name1,
                   String description1,
                   String typeName1,
                   String sourceId1,
                   Map<String,Set<String>> attributes1)
Constructor called by SourceManager.

Parameters:
id1 -
name1 -
description1 -
typeName1 -
sourceId1 -
attributes1 -
Method Detail

toAttributeMap

public static Map<String,Set<String>> toAttributeMap(String... strings)
turn some strings into a map, every other is a name or value of attribute

Parameters:
strings -
Returns:
the map (never null)

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

toStringStatic

public static String toStringStatic(Subject subject)
toString

Parameters:
subject -
Returns:
string

getSourceId

public String getSourceId()
sourceId

Specified by:
getSourceId in interface Subject
Returns:
the sourceId

setSourceId

public void setSourceId(String sourceId1)
sourceId

Parameters:
sourceId1 - the sourceId to set

getId

public String getId()
Gets this Subject's ID.

Specified by:
getId in interface Subject
Returns:
string

getType

public SubjectType getType()
Gets this Subject's type.

Specified by:
getType in interface Subject
Returns:
subject type

getName

public String getName()
Gets this Subject's name.

Specified by:
getName in interface Subject
Returns:
name or null if not there

getDescription

public String getDescription()
Gets this Subject's description.

Specified by:
getDescription in interface Subject
Returns:
description or null if not there

getAttributeValue

public String getAttributeValue(String name1)
Returns the value of a single-valued attribute. If multivalued, this returns the first value

Specified by:
getAttributeValue in interface Subject
Returns:
value or null if not found

getAttributeValues

public Set<String> getAttributeValues(String name1)
Returns the values of a multi-valued attribute, or a set of size one for a single valued attribute. Note the returned set should not be changed.

Specified by:
getAttributeValues in interface Subject
Returns:
set or empty set or null if not there

initVirtualAttributes

public static void initVirtualAttributes(Subject subject)
make sure the virtual attributes are setup for the subject

Parameters:
subject -

virtualAttributeVariablesForSource

public static Map<String,String> virtualAttributeVariablesForSource(Source source)
get the ordered list of virtual attributes for a source

Parameters:
source -
Returns:
the ordered list

virtualAttributesForSource

public static Map<String,String> virtualAttributesForSource(Source source)
get the ordered list of virtual attributes for a source

Parameters:
source -
Returns:
the ordered list

getAttributes

public Map<String,Set<String>> getAttributes()
Gets a map attribute names and values. The map's key contains the attribute name and the map's value contains a Set of attribute value(s). The returned Map can be augmented or changed

Specified by:
getAttributes in interface Subject
Returns:
map or empty map or null if not there

getSource

public Source getSource()
Returns the Source of this Subject.

Specified by:
getSource in interface Subject
Returns:
source

setAttributes

public void setAttributes(Map<String,Set<String>> attributes1)
Parameters:
attributes1 -

getTypeName

public String getTypeName()
Description copied from interface: Subject
get the type name

Specified by:
getTypeName in interface Subject
Returns:
the type name
See Also:
Subject.getTypeName()

setId

public void setId(String id1)
Parameters:
id1 - the id to set

setName

public void setName(String name1)
Parameters:
name1 - the name to set

setDescription

public void setDescription(String description1)
Parameters:
description1 - the description to set

setTypeName

public void setTypeName(String typeName1)
Parameters:
typeName1 - the typeName to set

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

equalsStatic

public static boolean equalsStatic(Subject subject,
                                   Object obj)
Parameters:
subject -
obj -
Returns:
true if equal

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

hashcodeStatic

public static int hashcodeStatic(Subject subject)
Parameters:
subject -
Returns:
hash code

getAttributeValueOrCommaSeparated

public String getAttributeValueOrCommaSeparated(String attributeName)
Description copied from interface: Subject
 Returns the attribute value if single-valued, or
 if multi-valued, returns the values comma separated (with a space too).
 So if the values are: a b c; this would return the string: "a, b, c"
 Implementors can use the static helper in SubjectImpl
 

Specified by:
getAttributeValueOrCommaSeparated in interface Subject
Returns:
value or values or null if not there
See Also:
Subject.getAttributeValueOrCommaSeparated(java.lang.String)

attributeValueOrCommaSeparated

public static String attributeValueOrCommaSeparated(Subject subject,
                                                    String attributeName)
Parameters:
subject - shouldnt be null
attributeName -
Returns:
the string
See Also:
Subject.getAttributeValueOrCommaSeparated(String)

getAttributeValueSingleValued

public String getAttributeValueSingleValued(String attributeName)
Description copied from interface: Subject
Returns the attribute value if single-valued, or if multi-valued, throws an exception. Implementors can use the static helper in SubjectImpl

Specified by:
getAttributeValueSingleValued in interface Subject
Returns:
value or null if not there
See Also:
Subject.getAttributeValueSingleValued(java.lang.String)