From 0236a88fb454682608c28f7c21716d9288b56bec Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Mon, 3 Mar 2014 09:38:27 +0100 Subject: added tweaked stork2-commons source --- .../stork/peps/auth/commons/PersonalAttribute.java | 348 +++++++++++++++++++++ 1 file changed, 348 insertions(+) create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java (limited to 'id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java') diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java new file mode 100644 index 000000000..5d8281445 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java @@ -0,0 +1,348 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.log4j.Logger; + +import eu.stork.peps.auth.commons.exceptions.InternalErrorPEPSException; + +/** + * This class is a bean used to store the information relative to the + * PersonalAttribute. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.22 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class PersonalAttribute implements Serializable, Cloneable { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 2612951678412632174L; + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(PersonalAttribute.class + .getName()); + + /** + * Name of the personal attribute. + */ + private String name; + + /** + * Values of the personal attribute. + */ + private List value = new ArrayList(); + + /** + * Type of the personal attribute. + */ + private String type; + + /** + * Complex values of the personal attribute. + */ + private Map complexValue = new ConcurrentHashMap(); + + /** + * Is the personal attribute mandatory? + */ + private transient boolean required; + + /** + * Returned status of the attribute from the IdP. + */ + private String status; + + /** + * Name of the personal attribute. + */ + private String friendlyName; + + /** + * Empty Constructor. + */ + public PersonalAttribute() { + super(); + } + + /** + * PersonalAttribute Constructor for complex values. + * + * @param attrName The attribute name. + * @param attrIsRequired The attribute type value. + * @param attrComplexValue The attribute's value. + * @param attrStatus The attribute's status value. + */ + public PersonalAttribute(final String attrName, final boolean attrIsRequired, + final List attrComplexValue, final String attrStatus) { + this.setName(attrName); + this.setIsRequired(attrIsRequired); + this.setValue(attrComplexValue); + this.setStatus(attrStatus); + } + + /** + * PersonalAttribute Constructor for complex values. + * + * @param attrName The attribute name. + * @param attrIsRequired The attribute type value. + * @param attrComplexValue The attribute's complex value. + * @param attrStatus The attribute's status value. + */ + public PersonalAttribute(final String attrName, final boolean attrIsRequired, + final Map attrComplexValue, final String attrStatus) { + this.setName(attrName); + this.setIsRequired(attrIsRequired); + this.setComplexValue(attrComplexValue); + this.setStatus(attrStatus); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public Object clone() { + + try { + final PersonalAttribute personalAttr = (PersonalAttribute) super.clone(); + personalAttr.setIsRequired(this.isRequired()); + personalAttr.setName(this.getName()); + personalAttr.setStatus(this.getStatus()); + if (!isEmptyValue()) { + final List val = + (List) ((ArrayList) this.getValue()).clone(); + personalAttr.setValue(val); + } + if (!isEmptyComplexValue()) { + final Map complexVal = + (Map) ((HashMap) this + .getComplexValue()).clone(); + personalAttr.setComplexValue(complexVal); + } + return personalAttr; + } catch (final CloneNotSupportedException e) { + // assert false; + LOG.trace("Nothing to do."); + throw new InternalErrorPEPSException( + PEPSUtil.getConfig(PEPSErrors.INTERNAL_ERROR.errorCode()), + PEPSUtil.getConfig(PEPSErrors.INTERNAL_ERROR.errorMessage()), e); + } + } + + /** + * Getter for the required value. + * + * @return The required value. + */ + public boolean isRequired() { + return required; + } + + /** + * Setter for the required value. + * + * @param attrIsRequired this attribute? + */ + public void setIsRequired(final boolean attrIsRequired) { + this.required = attrIsRequired; + } + + /** + * Getter for the name value. + * + * @return The name value. + */ + public String getName() { + return name; + } + + /** + * Setter for the name value. + * + * @param attrName The personal attribute name. + */ + public void setName(final String attrName) { + this.name = attrName; + } + + /** + * Getter for the value. + * + * @return The list of values. + */ + public List getValue() { + return value; + } + + /** + * Setter for the list of values. + * + * @param attrValue The personal attribute value. + */ + public void setValue(final List attrValue) { + if (attrValue != null) { + this.value = attrValue; + } + } + + + /** + * Getter for the type value. + * + * @return The name value. + */ + public String getType() { + return type; + } + + /** + * Setter for the type value. + * + * @param attrName The personal attribute type. + */ + public void setType(final String attrType) { + this.type = attrType; + } + + /** + * Getter for the status. + * + * @return The status value. + */ + public String getStatus() { + return status; + } + + /** + * Setter for the status value. + * + * @param attrStatus The personal attribute status. + */ + public void setStatus(final String attrStatus) { + this.status = attrStatus; + } + + /** + * Getter for the complex value. + * + * @return The complex value. + */ + public Map getComplexValue() { + return complexValue; + } + + /** + * Setter for the complex value. + * + * @param complexVal The personal attribute Complex value. + */ + public void setComplexValue(final Map complexVal) { + if (complexVal != null) { + this.complexValue = complexVal; + } + } + + /** + * Getter for the personal's friendly name. + * + * @return The personal's friendly name value. + */ + public String getFriendlyName() { + return friendlyName; + } + + /** + * Setter for the personal's friendly name. + * + * @param fName The personal's friendly name. + */ + public void setFriendlyName(final String fName) { + this.friendlyName = fName; + } + + /** + * Return true the value is empty. + * + * @return True if the value is empty "[]"; + */ + public boolean isEmptyValue() { + return value.isEmpty() || (value.size() == 1 && value.get(0).length() == 0); + } + + /** + * Returns true if the Complex Value is empty. + * + * @return True if the Complex Value is empty; + */ + public boolean isEmptyComplexValue() { + return complexValue.isEmpty(); + } + + /** + * Returns true if the Status is empty. + * + * @return True if the Status is empty; + */ + public boolean isEmptyStatus() { + return (status == null || status.length() == 0); + } + + /** + * Prints the PersonalAttribute in the following format. + * name:required:[v,a,l,u,e,s]|[v=a,l=u,e=s]:status; + * + * @return The PersonalAttribute as a string. + */ + public String toString() { + final StringBuilder strBuild = new StringBuilder(); + + AttributeUtil.appendIfNotNull(strBuild, getName()); + strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); + AttributeUtil.appendIfNotNull(strBuild, String.valueOf(isRequired())); + strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); + strBuild.append('['); + + if (isEmptyValue()) { + if (!isEmptyComplexValue()) { + AttributeUtil.appendIfNotNull(strBuild, AttributeUtil.mapToString( + getComplexValue(), PEPSValues.ATTRIBUTE_VALUE_SEP.toString())); + } + } else { + AttributeUtil.appendIfNotNull( + strBuild, + AttributeUtil.listToString(getValue(), + PEPSValues.ATTRIBUTE_VALUE_SEP.toString())); + } + + strBuild.append(']'); + strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); + AttributeUtil.appendIfNotNull(strBuild, getStatus()); + strBuild.append(PEPSValues.ATTRIBUTE_SEP.toString()); + + return strBuild.toString(); + } + +} -- cgit v1.2.3 From 0b3249e37b26e029c576127654dca31bff4a5a63 Mon Sep 17 00:00:00 2001 From: Bojan Suzic Date: Mon, 17 Mar 2014 18:23:52 +0100 Subject: removing old samlengine and storkcommons --- .../stork/peps/auth/commons/PersonalAttribute.java | 348 --------------------- 1 file changed, 348 deletions(-) delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java (limited to 'id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java') diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java deleted file mode 100644 index 5d8281445..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java +++ /dev/null @@ -1,348 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.log4j.Logger; - -import eu.stork.peps.auth.commons.exceptions.InternalErrorPEPSException; - -/** - * This class is a bean used to store the information relative to the - * PersonalAttribute. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.22 $, $Date: 2010-11-17 05:15:28 $ - */ -public final class PersonalAttribute implements Serializable, Cloneable { - - /** - * Unique identifier. - */ - private static final long serialVersionUID = 2612951678412632174L; - - /** - * Logger object. - */ - private static final Logger LOG = Logger.getLogger(PersonalAttribute.class - .getName()); - - /** - * Name of the personal attribute. - */ - private String name; - - /** - * Values of the personal attribute. - */ - private List value = new ArrayList(); - - /** - * Type of the personal attribute. - */ - private String type; - - /** - * Complex values of the personal attribute. - */ - private Map complexValue = new ConcurrentHashMap(); - - /** - * Is the personal attribute mandatory? - */ - private transient boolean required; - - /** - * Returned status of the attribute from the IdP. - */ - private String status; - - /** - * Name of the personal attribute. - */ - private String friendlyName; - - /** - * Empty Constructor. - */ - public PersonalAttribute() { - super(); - } - - /** - * PersonalAttribute Constructor for complex values. - * - * @param attrName The attribute name. - * @param attrIsRequired The attribute type value. - * @param attrComplexValue The attribute's value. - * @param attrStatus The attribute's status value. - */ - public PersonalAttribute(final String attrName, final boolean attrIsRequired, - final List attrComplexValue, final String attrStatus) { - this.setName(attrName); - this.setIsRequired(attrIsRequired); - this.setValue(attrComplexValue); - this.setStatus(attrStatus); - } - - /** - * PersonalAttribute Constructor for complex values. - * - * @param attrName The attribute name. - * @param attrIsRequired The attribute type value. - * @param attrComplexValue The attribute's complex value. - * @param attrStatus The attribute's status value. - */ - public PersonalAttribute(final String attrName, final boolean attrIsRequired, - final Map attrComplexValue, final String attrStatus) { - this.setName(attrName); - this.setIsRequired(attrIsRequired); - this.setComplexValue(attrComplexValue); - this.setStatus(attrStatus); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public Object clone() { - - try { - final PersonalAttribute personalAttr = (PersonalAttribute) super.clone(); - personalAttr.setIsRequired(this.isRequired()); - personalAttr.setName(this.getName()); - personalAttr.setStatus(this.getStatus()); - if (!isEmptyValue()) { - final List val = - (List) ((ArrayList) this.getValue()).clone(); - personalAttr.setValue(val); - } - if (!isEmptyComplexValue()) { - final Map complexVal = - (Map) ((HashMap) this - .getComplexValue()).clone(); - personalAttr.setComplexValue(complexVal); - } - return personalAttr; - } catch (final CloneNotSupportedException e) { - // assert false; - LOG.trace("Nothing to do."); - throw new InternalErrorPEPSException( - PEPSUtil.getConfig(PEPSErrors.INTERNAL_ERROR.errorCode()), - PEPSUtil.getConfig(PEPSErrors.INTERNAL_ERROR.errorMessage()), e); - } - } - - /** - * Getter for the required value. - * - * @return The required value. - */ - public boolean isRequired() { - return required; - } - - /** - * Setter for the required value. - * - * @param attrIsRequired this attribute? - */ - public void setIsRequired(final boolean attrIsRequired) { - this.required = attrIsRequired; - } - - /** - * Getter for the name value. - * - * @return The name value. - */ - public String getName() { - return name; - } - - /** - * Setter for the name value. - * - * @param attrName The personal attribute name. - */ - public void setName(final String attrName) { - this.name = attrName; - } - - /** - * Getter for the value. - * - * @return The list of values. - */ - public List getValue() { - return value; - } - - /** - * Setter for the list of values. - * - * @param attrValue The personal attribute value. - */ - public void setValue(final List attrValue) { - if (attrValue != null) { - this.value = attrValue; - } - } - - - /** - * Getter for the type value. - * - * @return The name value. - */ - public String getType() { - return type; - } - - /** - * Setter for the type value. - * - * @param attrName The personal attribute type. - */ - public void setType(final String attrType) { - this.type = attrType; - } - - /** - * Getter for the status. - * - * @return The status value. - */ - public String getStatus() { - return status; - } - - /** - * Setter for the status value. - * - * @param attrStatus The personal attribute status. - */ - public void setStatus(final String attrStatus) { - this.status = attrStatus; - } - - /** - * Getter for the complex value. - * - * @return The complex value. - */ - public Map getComplexValue() { - return complexValue; - } - - /** - * Setter for the complex value. - * - * @param complexVal The personal attribute Complex value. - */ - public void setComplexValue(final Map complexVal) { - if (complexVal != null) { - this.complexValue = complexVal; - } - } - - /** - * Getter for the personal's friendly name. - * - * @return The personal's friendly name value. - */ - public String getFriendlyName() { - return friendlyName; - } - - /** - * Setter for the personal's friendly name. - * - * @param fName The personal's friendly name. - */ - public void setFriendlyName(final String fName) { - this.friendlyName = fName; - } - - /** - * Return true the value is empty. - * - * @return True if the value is empty "[]"; - */ - public boolean isEmptyValue() { - return value.isEmpty() || (value.size() == 1 && value.get(0).length() == 0); - } - - /** - * Returns true if the Complex Value is empty. - * - * @return True if the Complex Value is empty; - */ - public boolean isEmptyComplexValue() { - return complexValue.isEmpty(); - } - - /** - * Returns true if the Status is empty. - * - * @return True if the Status is empty; - */ - public boolean isEmptyStatus() { - return (status == null || status.length() == 0); - } - - /** - * Prints the PersonalAttribute in the following format. - * name:required:[v,a,l,u,e,s]|[v=a,l=u,e=s]:status; - * - * @return The PersonalAttribute as a string. - */ - public String toString() { - final StringBuilder strBuild = new StringBuilder(); - - AttributeUtil.appendIfNotNull(strBuild, getName()); - strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); - AttributeUtil.appendIfNotNull(strBuild, String.valueOf(isRequired())); - strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); - strBuild.append('['); - - if (isEmptyValue()) { - if (!isEmptyComplexValue()) { - AttributeUtil.appendIfNotNull(strBuild, AttributeUtil.mapToString( - getComplexValue(), PEPSValues.ATTRIBUTE_VALUE_SEP.toString())); - } - } else { - AttributeUtil.appendIfNotNull( - strBuild, - AttributeUtil.listToString(getValue(), - PEPSValues.ATTRIBUTE_VALUE_SEP.toString())); - } - - strBuild.append(']'); - strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); - AttributeUtil.appendIfNotNull(strBuild, getStatus()); - strBuild.append(PEPSValues.ATTRIBUTE_SEP.toString()); - - return strBuild.toString(); - } - -} -- cgit v1.2.3 From e6144cfe09bb148638911660eeb492fee7ab8079 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Thu, 20 Mar 2014 11:43:22 +0100 Subject: fixed serializable issues in stork2-commons --- .../stork/peps/auth/commons/PersonalAttribute.java | 348 +++++++++++++++++++++ 1 file changed, 348 insertions(+) create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java (limited to 'id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java') diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java new file mode 100644 index 000000000..5d8281445 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java @@ -0,0 +1,348 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.log4j.Logger; + +import eu.stork.peps.auth.commons.exceptions.InternalErrorPEPSException; + +/** + * This class is a bean used to store the information relative to the + * PersonalAttribute. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.22 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class PersonalAttribute implements Serializable, Cloneable { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 2612951678412632174L; + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(PersonalAttribute.class + .getName()); + + /** + * Name of the personal attribute. + */ + private String name; + + /** + * Values of the personal attribute. + */ + private List value = new ArrayList(); + + /** + * Type of the personal attribute. + */ + private String type; + + /** + * Complex values of the personal attribute. + */ + private Map complexValue = new ConcurrentHashMap(); + + /** + * Is the personal attribute mandatory? + */ + private transient boolean required; + + /** + * Returned status of the attribute from the IdP. + */ + private String status; + + /** + * Name of the personal attribute. + */ + private String friendlyName; + + /** + * Empty Constructor. + */ + public PersonalAttribute() { + super(); + } + + /** + * PersonalAttribute Constructor for complex values. + * + * @param attrName The attribute name. + * @param attrIsRequired The attribute type value. + * @param attrComplexValue The attribute's value. + * @param attrStatus The attribute's status value. + */ + public PersonalAttribute(final String attrName, final boolean attrIsRequired, + final List attrComplexValue, final String attrStatus) { + this.setName(attrName); + this.setIsRequired(attrIsRequired); + this.setValue(attrComplexValue); + this.setStatus(attrStatus); + } + + /** + * PersonalAttribute Constructor for complex values. + * + * @param attrName The attribute name. + * @param attrIsRequired The attribute type value. + * @param attrComplexValue The attribute's complex value. + * @param attrStatus The attribute's status value. + */ + public PersonalAttribute(final String attrName, final boolean attrIsRequired, + final Map attrComplexValue, final String attrStatus) { + this.setName(attrName); + this.setIsRequired(attrIsRequired); + this.setComplexValue(attrComplexValue); + this.setStatus(attrStatus); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public Object clone() { + + try { + final PersonalAttribute personalAttr = (PersonalAttribute) super.clone(); + personalAttr.setIsRequired(this.isRequired()); + personalAttr.setName(this.getName()); + personalAttr.setStatus(this.getStatus()); + if (!isEmptyValue()) { + final List val = + (List) ((ArrayList) this.getValue()).clone(); + personalAttr.setValue(val); + } + if (!isEmptyComplexValue()) { + final Map complexVal = + (Map) ((HashMap) this + .getComplexValue()).clone(); + personalAttr.setComplexValue(complexVal); + } + return personalAttr; + } catch (final CloneNotSupportedException e) { + // assert false; + LOG.trace("Nothing to do."); + throw new InternalErrorPEPSException( + PEPSUtil.getConfig(PEPSErrors.INTERNAL_ERROR.errorCode()), + PEPSUtil.getConfig(PEPSErrors.INTERNAL_ERROR.errorMessage()), e); + } + } + + /** + * Getter for the required value. + * + * @return The required value. + */ + public boolean isRequired() { + return required; + } + + /** + * Setter for the required value. + * + * @param attrIsRequired this attribute? + */ + public void setIsRequired(final boolean attrIsRequired) { + this.required = attrIsRequired; + } + + /** + * Getter for the name value. + * + * @return The name value. + */ + public String getName() { + return name; + } + + /** + * Setter for the name value. + * + * @param attrName The personal attribute name. + */ + public void setName(final String attrName) { + this.name = attrName; + } + + /** + * Getter for the value. + * + * @return The list of values. + */ + public List getValue() { + return value; + } + + /** + * Setter for the list of values. + * + * @param attrValue The personal attribute value. + */ + public void setValue(final List attrValue) { + if (attrValue != null) { + this.value = attrValue; + } + } + + + /** + * Getter for the type value. + * + * @return The name value. + */ + public String getType() { + return type; + } + + /** + * Setter for the type value. + * + * @param attrName The personal attribute type. + */ + public void setType(final String attrType) { + this.type = attrType; + } + + /** + * Getter for the status. + * + * @return The status value. + */ + public String getStatus() { + return status; + } + + /** + * Setter for the status value. + * + * @param attrStatus The personal attribute status. + */ + public void setStatus(final String attrStatus) { + this.status = attrStatus; + } + + /** + * Getter for the complex value. + * + * @return The complex value. + */ + public Map getComplexValue() { + return complexValue; + } + + /** + * Setter for the complex value. + * + * @param complexVal The personal attribute Complex value. + */ + public void setComplexValue(final Map complexVal) { + if (complexVal != null) { + this.complexValue = complexVal; + } + } + + /** + * Getter for the personal's friendly name. + * + * @return The personal's friendly name value. + */ + public String getFriendlyName() { + return friendlyName; + } + + /** + * Setter for the personal's friendly name. + * + * @param fName The personal's friendly name. + */ + public void setFriendlyName(final String fName) { + this.friendlyName = fName; + } + + /** + * Return true the value is empty. + * + * @return True if the value is empty "[]"; + */ + public boolean isEmptyValue() { + return value.isEmpty() || (value.size() == 1 && value.get(0).length() == 0); + } + + /** + * Returns true if the Complex Value is empty. + * + * @return True if the Complex Value is empty; + */ + public boolean isEmptyComplexValue() { + return complexValue.isEmpty(); + } + + /** + * Returns true if the Status is empty. + * + * @return True if the Status is empty; + */ + public boolean isEmptyStatus() { + return (status == null || status.length() == 0); + } + + /** + * Prints the PersonalAttribute in the following format. + * name:required:[v,a,l,u,e,s]|[v=a,l=u,e=s]:status; + * + * @return The PersonalAttribute as a string. + */ + public String toString() { + final StringBuilder strBuild = new StringBuilder(); + + AttributeUtil.appendIfNotNull(strBuild, getName()); + strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); + AttributeUtil.appendIfNotNull(strBuild, String.valueOf(isRequired())); + strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); + strBuild.append('['); + + if (isEmptyValue()) { + if (!isEmptyComplexValue()) { + AttributeUtil.appendIfNotNull(strBuild, AttributeUtil.mapToString( + getComplexValue(), PEPSValues.ATTRIBUTE_VALUE_SEP.toString())); + } + } else { + AttributeUtil.appendIfNotNull( + strBuild, + AttributeUtil.listToString(getValue(), + PEPSValues.ATTRIBUTE_VALUE_SEP.toString())); + } + + strBuild.append(']'); + strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); + AttributeUtil.appendIfNotNull(strBuild, getStatus()); + strBuild.append(PEPSValues.ATTRIBUTE_SEP.toString()); + + return strBuild.toString(); + } + +} -- cgit v1.2.3