/servers/jain-slee/resources/diameter-cca/common/events/src/main/java/org/mobicents/slee/resource/diameter/cca/events/CreditControlAnswerImpl.java

http://mobicents.googlecode.com/ · Java · 262 lines · 123 code · 32 blank · 107 comment · 0 complexity · b027660ff070e781c388a2fb70c794af MD5 · raw file

  1. /*
  2. * JBoss, Home of Professional Open Source
  3. * Copyright 2011, Red Hat, Inc. and individual contributors
  4. * by the @authors tag. See the copyright.txt in the distribution for a
  5. * full listing of individual contributors.
  6. *
  7. * This is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation; either version 2.1 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This software is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this software; if not, write to the Free
  19. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21. */
  22. package org.mobicents.slee.resource.diameter.cca.events;
  23. import net.java.slee.resource.diameter.cca.events.CreditControlAnswer;
  24. import net.java.slee.resource.diameter.cca.events.avp.CcSessionFailoverType;
  25. import net.java.slee.resource.diameter.cca.events.avp.CheckBalanceResultType;
  26. import net.java.slee.resource.diameter.cca.events.avp.CostInformationAvp;
  27. import net.java.slee.resource.diameter.cca.events.avp.CreditControlAVPCodes;
  28. import net.java.slee.resource.diameter.cca.events.avp.CreditControlFailureHandlingType;
  29. import net.java.slee.resource.diameter.cca.events.avp.DirectDebitingFailureHandlingType;
  30. import net.java.slee.resource.diameter.cca.events.avp.FinalUnitIndicationAvp;
  31. import net.java.slee.resource.diameter.cca.events.avp.GrantedServiceUnitAvp;
  32. import org.jdiameter.api.Message;
  33. import org.mobicents.slee.resource.diameter.cca.events.avp.CostInformationAvpImpl;
  34. import org.mobicents.slee.resource.diameter.cca.events.avp.FinalUnitIndicationAvpImpl;
  35. import org.mobicents.slee.resource.diameter.cca.events.avp.GrantedServiceUnitAvpImpl;
  36. /**
  37. * CCA Credit-Control-Answer message implementation.<br>
  38. * <br>
  39. *
  40. * Start time:15:49:22 2008-11-11<br>
  41. * Project: mobicents-diameter-parent<br>
  42. *
  43. * @author <a href="mailto:baranowb@gmail.com"> Bartosz Baranowski </a>
  44. * @author <a href="mailto:brainslog@gmail.com"> Alexandre Mendonca </a>
  45. */
  46. public class CreditControlAnswerImpl extends CreditControlMessageImpl implements CreditControlAnswer {
  47. /**
  48. * Constructor.
  49. * @param message the message to construct the Answer
  50. */
  51. public CreditControlAnswerImpl(Message message) {
  52. super(message);
  53. }
  54. @Override
  55. public String getLongName() {
  56. return "Credit-Control-Answer";
  57. }
  58. @Override
  59. public String getShortName() {
  60. return "CCA";
  61. }
  62. /* (non-Javadoc)
  63. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#getCcSessionFailover()
  64. */
  65. public CcSessionFailoverType getCcSessionFailover()
  66. {
  67. return (CcSessionFailoverType) getAvpAsEnumerated(CreditControlAVPCodes.CC_Session_Failover, CcSessionFailoverType.class);
  68. }
  69. /* (non-Javadoc)
  70. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#getCheckBalanceResult()
  71. */
  72. public CheckBalanceResultType getCheckBalanceResult()
  73. {
  74. return (CheckBalanceResultType) getAvpAsEnumerated(CreditControlAVPCodes.Check_Balance_Result, CheckBalanceResultType.class);
  75. }
  76. /* (non-Javadoc)
  77. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#getCostInformation()
  78. */
  79. public CostInformationAvp getCostInformation()
  80. {
  81. return (CostInformationAvp) getAvpAsCustom(CreditControlAVPCodes.Cost_Information, CostInformationAvpImpl.class);
  82. }
  83. /* (non-Javadoc)
  84. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#getCreditControlFailureHandling()
  85. */
  86. public CreditControlFailureHandlingType getCreditControlFailureHandling()
  87. {
  88. return (CreditControlFailureHandlingType) getAvpAsEnumerated(CreditControlAVPCodes.Credit_Control_Failure_Handling, CreditControlFailureHandlingType.class);
  89. }
  90. /* (non-Javadoc)
  91. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#getDirectDebitingFailureHandling()
  92. */
  93. public DirectDebitingFailureHandlingType getDirectDebitingFailureHandling()
  94. {
  95. return (DirectDebitingFailureHandlingType) getAvpAsEnumerated(CreditControlAVPCodes.Direct_Debiting_Failure_Handling, DirectDebitingFailureHandlingType.class);
  96. }
  97. /* (non-Javadoc)
  98. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#getFinalUnitIndication()
  99. */
  100. public FinalUnitIndicationAvp getFinalUnitIndication()
  101. {
  102. return (FinalUnitIndicationAvp) getAvpAsCustom(CreditControlAVPCodes.Final_Unit_Indication, FinalUnitIndicationAvpImpl.class);
  103. }
  104. /* (non-Javadoc)
  105. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#getGrantedServiceUnit()
  106. */
  107. public GrantedServiceUnitAvp getGrantedServiceUnit()
  108. {
  109. return (GrantedServiceUnitAvp) getAvpAsCustom(CreditControlAVPCodes.Granted_Service_Unit, GrantedServiceUnitAvpImpl.class);
  110. }
  111. /* (non-Javadoc)
  112. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#getValidityTime()
  113. */
  114. public long getValidityTime()
  115. {
  116. return getAvpAsUnsigned32(CreditControlAVPCodes.Validity_Time);
  117. }
  118. /* (non-Javadoc)
  119. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#hasCcSessionFailover()
  120. */
  121. public boolean hasCcSessionFailover()
  122. {
  123. return hasAvp(CreditControlAVPCodes.CC_Session_Failover);
  124. }
  125. /* (non-Javadoc)
  126. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#hasCheckBalanceResult()
  127. */
  128. public boolean hasCheckBalanceResult()
  129. {
  130. return hasAvp(CreditControlAVPCodes.Check_Balance_Result);
  131. }
  132. /* (non-Javadoc)
  133. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#hasCostInformation()
  134. */
  135. public boolean hasCostInformation()
  136. {
  137. return hasAvp(CreditControlAVPCodes.Cost_Information);
  138. }
  139. /* (non-Javadoc)
  140. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#hasCreditControlFailureHandling()
  141. */
  142. public boolean hasCreditControlFailureHandling()
  143. {
  144. return hasAvp(CreditControlAVPCodes.Credit_Control_Failure_Handling);
  145. }
  146. /* (non-Javadoc)
  147. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#hasDirectDebitingFailureHandling()
  148. */
  149. public boolean hasDirectDebitingFailureHandling()
  150. {
  151. return hasAvp(CreditControlAVPCodes.Direct_Debiting_Failure_Handling);
  152. }
  153. /* (non-Javadoc)
  154. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#hasFinalUnitIndication()
  155. */
  156. public boolean hasFinalUnitIndication()
  157. {
  158. return hasAvp(CreditControlAVPCodes.Final_Unit_Indication);
  159. }
  160. /* (non-Javadoc)
  161. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#hasGrantedServiceUnit()
  162. */
  163. public boolean hasGrantedServiceUnit()
  164. {
  165. return hasAvp(CreditControlAVPCodes.Granted_Service_Unit);
  166. }
  167. /* (non-Javadoc)
  168. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#hasValidityTime()
  169. */
  170. public boolean hasValidityTime()
  171. {
  172. return hasAvp(CreditControlAVPCodes.Validity_Time);
  173. }
  174. /* (non-Javadoc)
  175. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#setCcSessionFailover(net.java.slee.resource.diameter.cca.events.avp.CcSessionFailoverType)
  176. */
  177. public void setCcSessionFailover(CcSessionFailoverType ccSessionFailover) throws IllegalStateException
  178. {
  179. addAvp(CreditControlAVPCodes.CC_Session_Failover, ccSessionFailover.getValue());
  180. }
  181. /* (non-Javadoc)
  182. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#setCheckBalanceResult(net.java.slee.resource.diameter.cca.events.avp.CheckBalanceResultType)
  183. */
  184. public void setCheckBalanceResult(CheckBalanceResultType checkBalanceResult) throws IllegalStateException
  185. {
  186. addAvp(CreditControlAVPCodes.Check_Balance_Result, checkBalanceResult.getValue());
  187. }
  188. /* (non-Javadoc)
  189. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#setCostInformation(net.java.slee.resource.diameter.cca.events.avp.CostInformationAvp)
  190. */
  191. public void setCostInformation(CostInformationAvp costInformation) throws IllegalStateException
  192. {
  193. addAvp(CreditControlAVPCodes.Cost_Information, costInformation.byteArrayValue());
  194. }
  195. /* (non-Javadoc)
  196. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#setCreditControlFailureHandling(net.java.slee.resource.diameter.cca.events.avp.CreditControlFailureHandlingType)
  197. */
  198. public void setCreditControlFailureHandling(CreditControlFailureHandlingType creditControlFailureHandling) throws IllegalStateException
  199. {
  200. addAvp(CreditControlAVPCodes.Credit_Control_Failure_Handling, creditControlFailureHandling.getValue());
  201. }
  202. /* (non-Javadoc)
  203. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#setDirectDebitingFailureHandling(net.java.slee.resource.diameter.cca.events.avp.DirectDebitingFailureHandlingType)
  204. */
  205. public void setDirectDebitingFailureHandling(DirectDebitingFailureHandlingType directDebitingFailureHandling) throws IllegalStateException
  206. {
  207. addAvp(CreditControlAVPCodes.Direct_Debiting_Failure_Handling, directDebitingFailureHandling.getValue());
  208. }
  209. /* (non-Javadoc)
  210. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#setFinalUnitIndication(net.java.slee.resource.diameter.cca.events.avp.FinalUnitIndicationAvp)
  211. */
  212. public void setFinalUnitIndication(FinalUnitIndicationAvp finalUnitIndication) throws IllegalStateException
  213. {
  214. addAvp(CreditControlAVPCodes.Final_Unit_Indication, finalUnitIndication.byteArrayValue());
  215. }
  216. /* (non-Javadoc)
  217. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#setGrantedServiceUnit(net.java.slee.resource.diameter.cca.events.avp.GrantedServiceUnitAvp)
  218. */
  219. public void setGrantedServiceUnit(GrantedServiceUnitAvp grantedServiceUnit) throws IllegalStateException
  220. {
  221. addAvp(CreditControlAVPCodes.Granted_Service_Unit, grantedServiceUnit.byteArrayValue());
  222. }
  223. /* (non-Javadoc)
  224. * @see net.java.slee.resource.diameter.cca.events.CreditControlAnswer#setValidityTime(long)
  225. */
  226. public void setValidityTime(long validityTime) throws IllegalStateException
  227. {
  228. addAvp(CreditControlAVPCodes.Validity_Time, validityTime);
  229. }
  230. }