View Javadoc

1   /*
2    * Copyright [2005] [University Corporation for Advanced Internet Development, Inc.]
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  /**
18   * 
19   */
20  
21  package org.opensaml.saml2.metadata.impl;
22  
23  import java.util.ArrayList;
24  import java.util.List;
25  
26  import org.opensaml.common.impl.AbstractSAMLObject;
27  import org.opensaml.saml2.common.Extensions;
28  import org.opensaml.saml2.metadata.Company;
29  import org.opensaml.saml2.metadata.ContactPerson;
30  import org.opensaml.saml2.metadata.ContactPersonTypeEnumeration;
31  import org.opensaml.saml2.metadata.EmailAddress;
32  import org.opensaml.saml2.metadata.GivenName;
33  import org.opensaml.saml2.metadata.SurName;
34  import org.opensaml.saml2.metadata.TelephoneNumber;
35  import org.opensaml.xml.XMLObject;
36  import org.opensaml.xml.util.AttributeMap;
37  import org.opensaml.xml.util.XMLObjectChildrenList;
38  
39  /**
40   * Concrete implementation of {@link org.opensaml.saml2.metadata.ContactPerson}
41   */
42  public class ContactPersonImpl extends AbstractSAMLObject implements ContactPerson {
43  
44      /** Contact person type */
45      private ContactPersonTypeEnumeration type;
46  
47      /** Extensions child object */
48      private Extensions extensions;
49  
50      /** Company child element */
51      private Company company;
52  
53      /** GivenName child objectobject */
54      private GivenName givenName;
55  
56      /** SurName child object */
57      private SurName surName;
58      
59      /** "anyAttribute" attributes */
60      private final AttributeMap unknownAttributes;
61  
62      /** Child email address */
63      private final XMLObjectChildrenList<EmailAddress> emailAddresses;
64  
65      /** Child telephone numbers */
66      private final XMLObjectChildrenList<TelephoneNumber> telephoneNumbers;
67  
68      /**
69       * Constructor
70       * 
71       * @param namespaceURI
72       * @param elementLocalName
73       * @param namespacePrefix
74       */
75      protected ContactPersonImpl(String namespaceURI, String elementLocalName, String namespacePrefix) {
76          super(namespaceURI, elementLocalName, namespacePrefix);
77          unknownAttributes = new AttributeMap(this);
78          emailAddresses = new XMLObjectChildrenList<EmailAddress>(this);
79          telephoneNumbers = new XMLObjectChildrenList<TelephoneNumber>(this);
80      }
81  
82      /** {@inheritDoc} */
83      public ContactPersonTypeEnumeration getType() {
84          return type;
85      }
86  
87      /** {@inheritDoc} */
88      public void setType(ContactPersonTypeEnumeration type) {
89          this.type = prepareForAssignment(this.type, type);
90      }
91  
92      /** {@inheritDoc} */
93      public Extensions getExtensions() {
94          return extensions;
95      }
96  
97      /** {@inheritDoc} */
98      public void setExtensions(Extensions extensions) throws IllegalArgumentException {
99          this.extensions = prepareForAssignment(this.extensions, extensions);
100     }
101 
102     /** {@inheritDoc} */
103     public Company getCompany() {
104         return company;
105     }
106 
107     /** {@inheritDoc} */
108     public void setCompany(Company company) {
109         this.company = prepareForAssignment(this.company, company);
110     }
111 
112     /** {@inheritDoc} */
113     public GivenName getGivenName() {
114         return givenName;
115     }
116 
117     /** {@inheritDoc} */
118     public void setGivenName(GivenName name) {
119         givenName = prepareForAssignment(givenName, name);
120     }
121 
122     /** {@inheritDoc} */
123     public SurName getSurName() {
124         return surName;
125     }
126 
127     /** {@inheritDoc} */
128     public void setSurName(SurName name) {
129         surName = prepareForAssignment(surName, name);
130     }
131 
132     /** {@inheritDoc} */
133     public List<EmailAddress> getEmailAddresses() {
134         return emailAddresses;
135     }
136 
137     /** {@inheritDoc} */
138     public List<TelephoneNumber> getTelephoneNumbers() {
139         return telephoneNumbers;
140     }
141     
142     /**
143      * {@inheritDoc}
144      */
145     public AttributeMap getUnknownAttributes() {
146         return unknownAttributes;
147     }
148 
149     /** {@inheritDoc} */
150     public List<XMLObject> getOrderedChildren() {
151         ArrayList<XMLObject> children = new ArrayList<XMLObject>();
152 
153         children.add(extensions);
154         children.add(company);
155         children.add(givenName);
156         children.add(surName);
157         children.addAll(emailAddresses);
158         children.addAll(telephoneNumbers);
159 
160         return children;
161     }
162 }