public class AttributeBuilder extends AbstractSAMLObjectBuilder<Attribute>
Attribute
objects.Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_NAME_FORMAT
The default name format for the attribute being built.
|
Constructor and Description |
---|
AttributeBuilder(Attribute template)
Constructor setting up the builder given an attribute template.
|
AttributeBuilder(InputStream resource)
Constructor setting up the builder with a template attribute that is read from an input stream.
|
AttributeBuilder(String name)
Constructor setting the attribute name.
|
Modifier and Type | Method and Description |
---|---|
Attribute |
build()
Returns the
Attribute object that has been built. |
static AttributeBuilder |
builder(Attribute attribute)
Static utility method that creates a
AttributeBuilder given a template attribute. |
static AttributeBuilder |
builder(InputStream resource)
Static utility method that creates a
AttributeBuilder given a template attribute read from an input stream. |
static AttributeBuilder |
builder(String name)
Static utility method that creates a default
AttributeBuilder . |
static <T extends XMLObject> |
createValueObject(Class<T> clazz)
Creates an
AttributeValue object of the given class. |
static <T extends XMLObject> |
createValueObject(QName schemaType,
Class<T> clazz)
Creates an
AttributeValue object of the given class and schema type. |
AttributeBuilder |
friendlyName(String friendlyName)
Assigns the attribute friendly name.
|
protected Class<Attribute> |
getObjectType()
Returns the object type.
|
AttributeBuilder |
name(String name)
Assigns the attribute name.
|
AttributeBuilder |
nameFormat(String nameFormat)
Assigns the attribute name format.
|
AttributeBuilder |
value(List<String> values) |
AttributeBuilder |
value(String... values)
Assigns one (or more) attribute string values.
|
<T extends XMLObject> |
value(T value)
Assigns an attribute value.
|
object
public static final String DEFAULT_NAME_FORMAT
public AttributeBuilder(String name)
name
- the attribute namepublic AttributeBuilder(Attribute template) throws MarshallingException, UnmarshallingException
template
- the attribute templateUnmarshallingException
- for unmarshalling errorsMarshallingException
- for marshalling errorsAbstractSAMLObjectBuilder.AbstractSAMLObjectBuilder(org.opensaml.saml.common.SAMLObject)
public AttributeBuilder(InputStream resource) throws XMLParserException, UnmarshallingException
resource
- the attribute templateUnmarshallingException
- for unmarshalling errorsXMLParserException
- for XML parsing errorsAbstractSAMLObjectBuilder.AbstractSAMLObjectBuilder(InputStream)
public static AttributeBuilder builder(String name)
AttributeBuilder
.name
- the attribute nameAttributeBuilder
instance.AttributeBuilder(String)
public static AttributeBuilder builder(Attribute attribute) throws MarshallingException, UnmarshallingException
AttributeBuilder
given a template attribute.attribute
- the attribute templateUnmarshallingException
- for unmarshalling errorsMarshallingException
- for marshalling errorspublic static AttributeBuilder builder(InputStream resource) throws XMLParserException, UnmarshallingException
AttributeBuilder
given a template attribute read from an input stream.resource
- the attribute templateUnmarshallingException
- for unmarshalling errorsXMLParserException
- for XML parsing errorspublic Attribute build()
Attribute
object that has been built. If the NameFormat
attribute has not been
assigned, the method will inject the default value ("urn:oasis:names:tc:SAML:2.0:attrname-format:uri").build
in interface SAMLObjectBuilder<Attribute>
build
in class AbstractSAMLObjectBuilder<Attribute>
public AttributeBuilder name(String name)
name
- the attribute namepublic AttributeBuilder friendlyName(String friendlyName)
friendlyName
- the friendly namepublic AttributeBuilder nameFormat(String nameFormat)
nameFormat
- the name format URIpublic AttributeBuilder value(String... values)
Note: if null
is passed as a parameter, any previous attribute values are cleared.
values
- the string value(s) to addpublic AttributeBuilder value(List<String> values)
values
- the string value(s) to addvalue(String...)
public <T extends XMLObject> AttributeBuilder value(T value)
T
- the value typevalue
- the value to addpublic static <T extends XMLObject> T createValueObject(Class<T> clazz)
AttributeValue
object of the given class. The type of the attribute value will be the field that
is declared as TYPE_NAME
of the given class.
After the object has been constructed, its setter methods should be called to setup the value object before adding it to the attribute itself.
Note: For attribute having string values, there is no need to explictly create an attribute value. Instead the
value(String...)
method may be used directly.
T
- the typeclazz
- the type of attribute valuecreateValueObject(QName, Class)
public static <T extends XMLObject> T createValueObject(QName schemaType, Class<T> clazz)
AttributeValue
object of the given class and schema type.
After the object has been constructed, its setter methods should be called to setup the value object before adding it to the attribute itself.
Note: For attribute having string values, there is no need to explictly create an attribute value. Instead the
value(String...)
method may be used directly.
T
- the typeschemaType
- the schema type that should be assigned to the attribute value, i.e., xsi:type="ns:ValueType"
clazz
- the type of the attribute valuecreateValueObject(Class)
protected Class<Attribute> getObjectType()
getObjectType
in class AbstractSAMLObjectBuilder<Attribute>
Copyright © 2018 Litsec AB. All rights reserved.