View Javadoc

1   /* 
2    * Copyright (c) 2005-2011, Fraunhofer-Gesellschaft
3    * All rights reserved.
4    * 
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are
7    * met:
8    * 
9    * (1) Redistributions of source code must retain the above copyright
10   *     notice, this list of conditions and the disclaimer at the end.
11   *     Redistributions in binary form must reproduce the above copyright
12   *     notice, this list of conditions and the following disclaimer in
13   *     the documentation and/or other materials provided with the
14   *     distribution.
15   * 
16   * (2) Neither the name of Fraunhofer nor the names of its
17   *     contributors may be used to endorse or promote products derived
18   *     from this software without specific prior written permission.
19   * 
20   * DISCLAIMER
21   * 
22   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33   *  
34   */
35  package org.ogf.graap.wsag.api.types;
36  
37  import org.apache.xmlbeans.XmlObject;
38  import org.ogf.graap.wsag.api.AgreementFactory;
39  import org.ogf.schemas.graap.wsAgreement.AgreementFactoryPropertiesType;
40  import org.ogf.schemas.graap.wsAgreement.AgreementTemplateType;
41  
42  /**
43   * AbstractAgreementFactoryType
44   * 
45   * @author Oliver Waeldrich
46   */
47  public abstract class AbstractAgreementFactoryType extends WSAGXmlType implements AgreementFactory
48  {
49  
50      private AgreementFactoryPropertiesType delegateProps = null;
51  
52      /**
53       * Default constructor
54       */
55      public AbstractAgreementFactoryType()
56      {
57          initialize();
58      }
59  
60      /**
61       * initializes the agreement factory properties of this instance
62       */
63      protected void initialize()
64      {
65          delegateProps = AgreementFactoryPropertiesType.Factory.newInstance();
66      }
67  
68      /**
69       * validates the agreement factory properties of this instance
70       * 
71       * {@inheritDoc}
72       */
73      public boolean validate()
74      {
75          return validate( delegateProps );
76      }
77  
78      /**
79       * Adds a new template to the agreement factory properties of this instance
80       * 
81       * @return the new template
82       */
83      public AgreementTemplateType addNewTemplate()
84      {
85          return delegateProps.addNewTemplate();
86      }
87  
88      /**
89       * @return the templates supported by this factory instance
90       */
91      public AgreementTemplateType[] getTemplates()
92      {
93          return delegateProps.getTemplateArray();
94      }
95  
96      /**
97       * @param index
98       *            specifies the template to return
99       * @return the template specified by the index
100      */
101     public AgreementTemplateType getTemplateArray( int index )
102     {
103         return delegateProps.getTemplateArray( index );
104     }
105 
106     /**
107      * Sets the agreement templates for this factory
108      * 
109      * @param templateArray
110      *            the template array to set
111      */
112     public void setTemplateArray( AgreementTemplateType[] templateArray )
113     {
114         delegateProps.setTemplateArray( templateArray );
115     }
116 
117     /**
118      * Updates the template at the position specified by the index parameter.
119      * 
120      * @param index
121      *            the index of the template to set
122      * @param template
123      *            the template top set
124      */
125     public void setTemplateArray( int index, AgreementTemplateType template )
126     {
127         delegateProps.setTemplateArray( index, template );
128     }
129 
130     /**
131      * @return the number of templates exposed by this factory instance
132      */
133     public int sizeOfTemplateArray()
134     {
135         return delegateProps.sizeOfTemplateArray();
136     }
137 
138     /**
139      * @return the XML representation of the agreement factory resource properties
140      */
141     public XmlObject getXMLObject()
142     {
143         return delegateProps;
144     }
145 }