diff options
author | Florian Reimair <florian.reimair@iaik.tugraz.at> | 2015-08-10 16:35:14 +0200 |
---|---|---|
committer | Florian Reimair <florian.reimair@iaik.tugraz.at> | 2015-08-10 16:45:26 +0200 |
commit | 496ba9bb6e150ad67c5c628c1c97f30d6da81dfb (patch) | |
tree | 1dbe494358ab717b2bf94bae9fd3c3f90f4dbd58 /id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java | |
parent | f71531346c6be197957311712ba093e024545e37 (diff) | |
download | moa-id-spss-496ba9bb6e150ad67c5c628c1c97f30d6da81dfb.tar.gz moa-id-spss-496ba9bb6e150ad67c5c628c1c97f30d6da81dfb.tar.bz2 moa-id-spss-496ba9bb6e150ad67c5c628c1c97f30d6da81dfb.zip |
approved changes
Diffstat (limited to 'id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java')
-rw-r--r-- | id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java | 57 |
1 files changed, 51 insertions, 6 deletions
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 index 49ea3e695..8d1482f05 100644 --- 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 @@ -18,7 +18,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; +import java.util.Vector; import org.apache.log4j.Logger; @@ -60,7 +60,7 @@ public final class PersonalAttribute implements Serializable, Cloneable { /** * Complex values of the personal attribute. */ - private Map<String, String> complexValue = new ConcurrentHashMap<String, String>(); + private List<Map<String, String>> complexValue = new Vector<Map<String, String>>(); /** * Is the personal attribute mandatory? @@ -138,8 +138,7 @@ public final class PersonalAttribute implements Serializable, Cloneable { personalAttr.setValue(val); } if (!isEmptyComplexValue()) { - final Map<String, String> complexVal = (Map<String, String>) ((HashMap<String, String>) this.getComplexValue()).clone(); - personalAttr.setComplexValue(complexVal); + personalAttr.addComplexValues(this.getComplexValues()); } return personalAttr; } catch (final CloneNotSupportedException e) { @@ -209,6 +208,18 @@ public final class PersonalAttribute implements Serializable, Cloneable { } /** + * Add new value to list of values. + * + * @param attrValue + * The personal attribute value. + */ + public void addValue(final String attrValue) { + if (attrValue != null) { + this.value.add(attrValue); + } + } + + /** * Getter for the type value. * * @return The name value. @@ -252,6 +263,19 @@ public final class PersonalAttribute implements Serializable, Cloneable { * @return The complex value. */ public Map<String, String> getComplexValue() { + if (complexValue.size() > 0) { + return complexValue.get(0); + } else { + return new HashMap<String, String>(); + } + } + + /** + * Getter for the complex values. + * + * @return The complex value. + */ + public List<Map<String, String>> getComplexValues() { return complexValue; } @@ -263,11 +287,21 @@ public final class PersonalAttribute implements Serializable, Cloneable { */ public void setComplexValue(final Map<String, String> complexVal) { if (complexVal != null) { - this.complexValue = complexVal; + this.complexValue.add(complexVal); } } /** + * Setter for the complex values. + * + * @param complexVal + * The personal attribute Complex values. + */ + public void addComplexValues(final List<Map<String, String>> complexVals) { + this.complexValue.addAll(complexVals); + } + + /** * Getter for the personal's friendly name. * * @return The personal's friendly name value. @@ -301,7 +335,7 @@ public final class PersonalAttribute implements Serializable, Cloneable { * @return True if the Complex Value is empty; */ public boolean isEmptyComplexValue() { - return complexValue.isEmpty(); + return complexValue.isEmpty() || complexValue.get(0).isEmpty(); } /** @@ -343,4 +377,15 @@ public final class PersonalAttribute implements Serializable, Cloneable { return strBuild.toString(); } + /** + * Empties the Value or ComplexValue field of a PersonalAttribute + */ + public void setEmptyValue() { + if (this.isEmptyValue()) { + this.complexValue = new Vector<Map<String, String>>(); + } else { + this.value = new ArrayList<String>(); + } + } + } |