gluu
公開メンバ関数 | 関数 | 非公開メンバ関数 | 静的非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.gluu.oxtrust.model.scim2.CustomAttributes クラス
org.gluu.oxtrust.model.scim2.CustomAttributes 連携図
Collaboration graph

公開メンバ関数

 CustomAttributes (String uri)
 
String getUri ()
 
Set< String > getAttributeNames ()
 
void remove (String name)
 
void setAttribute (String name, String value)
 
void setAttribute (String name, Boolean value)
 
void setAttribute (String name, Double value)
 
void setAttribute (String name, Integer value)
 
void setAttribute (String name, DateTime value)
 
void setAttribute (String name, Date value)
 
void setAttribute (String name, List<?> values)
 

関数

 CustomAttributes (String uri, Map< String, Object > attributeMap)
 
Map< String, Object > getAttributeMap ()
 
public< T > List< T > getValues (String name, Class< T > cls)
 
public< T > T getValue (String name, Class< T > cls)
 

非公開メンバ関数

void set (String name, Object value)
 

静的非公開メンバ関数

static< T > T getTypedValue (Object val, Class< T > cls)
 

非公開変数類

Map< String, Object > attributeMap
 
String uri
 

詳解

A class used to store the values of custom attributes associated to a resource extension. This class is mainly targeted at users of Java SCIM-Client in order to specify/retrieve custom attributes.

Use the setAttribute methods to associate one (or several) values to an attribute, and use the getValue/getValues methods to retrive those values when coming directly from service invocations.

For both kind of operations (set/get) the data types used should ideally be consistent with the previously configured custom attributes at Gluu Server. This allows your custom data to be successfully validated when sent to server, or to be correctly retrieved when reading a response.

For photo or text, you may use String, for numeric sensible choices are Integer or Double, for boolean use Boolean, and for date you may use Date or DateTime from Joda-Time library.

Remember that custom attributes can be managed via Gluu Server oxTrust admin web console. For instructions, please see the SCIM docs page.

See also: BaseScimResource#addCustomAttributes(CustomAttributes) and BaseScimResource#getCustomAttributes(String).

構築子と解体子

◆ CustomAttributes() [1/2]

org.gluu.oxtrust.model.scim2.CustomAttributes.CustomAttributes ( String  uri)
inline

Constructs an instance of this class to store the attribute values associated to an extension whose URI is supplied.

引数
uriA string denoting the URI of an existing extension
47  {
48  this.uri=uri;
49  attributeMap=new HashMap<String, Object>();
50  }
String uri
Definition: CustomAttributes.java:40
Map< String, Object > attributeMap
Definition: CustomAttributes.java:39

◆ CustomAttributes() [2/2]

org.gluu.oxtrust.model.scim2.CustomAttributes.CustomAttributes ( String  uri,
Map< String, Object >  attributeMap 
)
inlinepackage
52  {
53  this.uri=uri;
55 
56  }
String uri
Definition: CustomAttributes.java:40
Map< String, Object > attributeMap
Definition: CustomAttributes.java:39

関数詳解

◆ getAttributeMap()

Map<String, Object> org.gluu.oxtrust.model.scim2.CustomAttributes.getAttributeMap ( )
inlinepackage
64  {
65  return attributeMap;
66  }
Map< String, Object > attributeMap
Definition: CustomAttributes.java:39

◆ getAttributeNames()

Set<String> org.gluu.oxtrust.model.scim2.CustomAttributes.getAttributeNames ( )
inline

Returns the names of all attributes currently part of this instance object.

戻り値
A Set of Strings
80  {
81  return attributeMap.keySet();
82  }
Map< String, Object > attributeMap
Definition: CustomAttributes.java:39

◆ getTypedValue()

static <T> T org.gluu.oxtrust.model.scim2.CustomAttributes.getTypedValue ( Object  val,
Class< T >  cls 
)
inlinestaticprivate
224  {
225 
226  if (val!=null) {
227  Class classOfVal=val.getClass();
228 
229  if (IntrospectUtil.isCollection(classOfVal)){
230  //Return only the 1st
231  Collection coll=(Collection) val;
232  Iterator<?> iterator=coll.iterator();
233  if (iterator.hasNext()) {
234  val = iterator.next();
235  classOfVal=val.getClass();
236  }
237  else { //it's an empty collection
238  val = null;
239  classOfVal=NullType.class;
240  }
241  }
242 
243  if (val!=null) {
244  if (DateTime.class.equals(cls) || Date.class.equals(cls)) {
245  try{
246  val=new DateTime(val.toString());
247  if (Date.class.equals(cls))
248  val=((DateTime)val).toDate();
249  }
250  catch (Exception e){
251  val = null;
252  }
253  }
254  else
255  if (String.class.equals(cls))
256  val = val.toString();
257  else
258  if (!classOfVal.equals(cls))
259  val = null;
260  }
261  }
262 
263  try {
264  return cls.cast(val);
265  }
266  catch (Exception e){
267  return null;
268  }
269 
270  }

◆ getUri()

String org.gluu.oxtrust.model.scim2.CustomAttributes.getUri ( )
inline

Retrieves the URI to which this CustomAttributes instance is tied.

戻り値
The URI as a String
72  {
73  return uri;
74  }
String uri
Definition: CustomAttributes.java:40

◆ getValue()

public<T> T org.gluu.oxtrust.model.scim2.CustomAttributes.getValue ( String  name,
Class< T >  cls 
)
inlinepackage

Returns the value of a custom attribute as an instance of the specified type. If you are not sure about the data type of the attribute, use String for type parameter T: in this case toString is used to generate a representation.

引数
nameThe name of the custom attribute
clsSpecifies the type utilized to read the attribute value
<T>Type parameter for cls
戻り値
null if the attribute is not known to this object, or if it was not possible to read its value using the type provided. Otherwise, the value associated to the attribute is returned (when the attribute is multivalued, only the first value found is taken into account: use getValues to get all values).
214  {
215 
216  if (!IntrospectUtil.isCollection(cls)){
217  Object val=attributeMap.get(name);
218  return getTypedValue(val, cls);
219  }
220  else
221  return null;
222  }
static< T > T getTypedValue(Object val, Class< T > cls)
Definition: CustomAttributes.java:224
Map< String, Object > attributeMap
Definition: CustomAttributes.java:39

◆ getValues()

public<T> List<T> org.gluu.oxtrust.model.scim2.CustomAttributes.getValues ( String  name,
Class< T >  cls 
)
inlinepackage

Returns the values of a multi-valued custom attribute as a List of objects of the specified type. If you are not sure about the data type of the attribute, use String for type parameter T: in this case toString is used to generate a representation.

引数
nameThe name of the custom attribute
clsSpecifies the type utilized to read the attribute values
<T>Type parameter for cls
戻り値
null if the attribute is not known to this object, or if it was not possible to read any of its values using the type provided. Otherwise, a list of values associated to the attribute is returned (when the attribute is not multivalued, a singleton list is returned: use getValue to get atomic values instead).
170  {
171 
172  Object val=attributeMap.get(name);
173  List<T> list=null;
174 
175  if (val!=null){
176 
177  if (IntrospectUtil.isCollection(val.getClass())) {
178  list = new ArrayList<T>();
179 
180  for (Object item : (Collection) val){
181  T aValue=getTypedValue(item, cls);
182 
183  if (aValue==null){
184  list=null;
185  break;
186  }
187  else
188  list.add(aValue);
189  }
190  if (list!=null && list.size()==0)
191  list=null;
192  }
193  else { //Create a list with one element
194  T aValue=getTypedValue(val, cls);
195  list= aValue==null ? null : Collections.singletonList(aValue);
196  }
197  }
198 
199  return list;
200  }
static< T > T getTypedValue(Object val, Class< T > cls)
Definition: CustomAttributes.java:224
Map< String, Object > attributeMap
Definition: CustomAttributes.java:39

◆ remove()

void org.gluu.oxtrust.model.scim2.CustomAttributes.remove ( String  name)
inline

Removes an attribute (and associated value) from this object

引数
nameThe name of the attribute to remove. Use the exactly the same String as when the attribute was set
88  {
89  attributeMap.remove(name);
90  }
Map< String, Object > attributeMap
Definition: CustomAttributes.java:39

◆ set()

void org.gluu.oxtrust.model.scim2.CustomAttributes.set ( String  name,
Object  value 
)
inlineprivate
58  {
59  if (StringUtils.isNotEmpty(name) && value!=null){
60  attributeMap.put(name, value);
61  }
62  }
Map< String, Object > attributeMap
Definition: CustomAttributes.java:39

◆ setAttribute() [1/7]

void org.gluu.oxtrust.model.scim2.CustomAttributes.setAttribute ( String  name,
String  value 
)
inline

Sets the value of an attribute using a String.

引数
nameName of attribute
valueA String object. Must be non-null, or else it won't be stored
97  {
98  set(name, value);
99  }

◆ setAttribute() [2/7]

void org.gluu.oxtrust.model.scim2.CustomAttributes.setAttribute ( String  name,
Boolean  value 
)
inline

Sets the value of an attribute using a Boolean.

引数
nameName of attribute
valueA Boolean object. Must be non-null, or else it won't be stored
106  {
107  set(name, value);
108  }

◆ setAttribute() [3/7]

void org.gluu.oxtrust.model.scim2.CustomAttributes.setAttribute ( String  name,
Double  value 
)
inline

Sets the value of an attribute using a Double.

引数
nameName of attribute
valueA Double object. Must be non-null, or else it won't be stored
115  {
116  set(name, value);
117  }

◆ setAttribute() [4/7]

void org.gluu.oxtrust.model.scim2.CustomAttributes.setAttribute ( String  name,
Integer  value 
)
inline

Sets the value of an attribute using an Integer.

引数
nameName of attribute
valueAn Integer object. Must be non-null, or else it won't be stored
124  {
125  set(name, value);
126  }

◆ setAttribute() [5/7]

void org.gluu.oxtrust.model.scim2.CustomAttributes.setAttribute ( String  name,
DateTime  value 
)
inline

Sets the value of an attribute using a Joda DateTime.

引数
nameName of attribute
valueA DateTime object. Must be non-null, or else it won't be stored
133  {
134  if (value!=null)
135  setAttribute(name, ISODateTimeFormat.dateTime().print(value));
136  }
void setAttribute(String name, String value)
Definition: CustomAttributes.java:97

◆ setAttribute() [6/7]

void org.gluu.oxtrust.model.scim2.CustomAttributes.setAttribute ( String  name,
Date  value 
)
inline

Sets the value of an attribute using a JDK Date.

引数
nameName of attribute
valueA Date object. Must be non-null, or else it won't be stored
143  {
144  if (value!=null)
145  setAttribute(name, ISODateTimeFormat.dateTime().print(new DateTime(value)));
146  }
void setAttribute(String name, String value)
Definition: CustomAttributes.java:97

◆ setAttribute() [7/7]

void org.gluu.oxtrust.model.scim2.CustomAttributes.setAttribute ( String  name,
List<?>  values 
)
inline

Sets the value of an attribute using a List of objects.

引数
nameName of attribute
valuesA non-empty, non-null list of values.
153  {
154  if (values!=null && values.size()>0)
155  set(name, values);
156  }

メンバ詳解

◆ attributeMap

Map<String, Object> org.gluu.oxtrust.model.scim2.CustomAttributes.attributeMap
private

◆ uri

String org.gluu.oxtrust.model.scim2.CustomAttributes.uri
private

このクラス詳解は次のファイルから抽出されました: