PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/servers/jain-slee/resources/diameter-base/common/ratype/src/main/java/net/java/slee/resource/diameter/base/DiameterAvpFactory.java

http://mobicents.googlecode.com/
Java | 395 lines | 49 code | 41 blank | 305 comment | 0 complexity | 30d3681d6f6fa109e3300e85c07634ad MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
  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 net.java.slee.resource.diameter.base;
  23. import java.util.Date;
  24. import net.java.slee.resource.diameter.base.events.DiameterCommand;
  25. import net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException;
  26. import net.java.slee.resource.diameter.base.events.avp.DiameterAvp;
  27. import net.java.slee.resource.diameter.base.events.avp.DiameterAvpType;
  28. import net.java.slee.resource.diameter.base.events.avp.DiameterIdentity;
  29. import net.java.slee.resource.diameter.base.events.avp.ExperimentalResultAvp;
  30. import net.java.slee.resource.diameter.base.events.avp.FailedAvp;
  31. import net.java.slee.resource.diameter.base.events.avp.ProxyInfoAvp;
  32. import net.java.slee.resource.diameter.base.events.avp.VendorSpecificApplicationIdAvp;
  33. /**
  34. *
  35. * Factory to create instances of {@link DiameterAvp}.
  36. * <p/>
  37. * An implementation of this class should be returned by the
  38. * {@link DiameterProvider#getDiameterAvpFactory()} method.
  39. *
  40. * @author <a href="mailto:brainslog@gmail.com"> Alexandre Mendonca </a>
  41. * @author <a href="mailto:baranowb@gmail.com"> Bartosz Baranowski </a>
  42. */
  43. public interface DiameterAvpFactory {
  44. /**
  45. * Create a value for a Grouped AVP. Type will always be
  46. * {@link DiameterAvpType#GROUPED}
  47. *
  48. * @param avpCode the code for the AVP
  49. * @param avps an array of DiameterAvp objects
  50. * @return an implementation of the DiameterAvp interface
  51. */
  52. DiameterAvp createAvp(int avpCode, DiameterAvp[] avps) throws NoSuchAvpException, AvpNotAllowedException;
  53. /**
  54. * Create a value for a vendor-specific Grouped AVP. Type will always be
  55. * {@link DiameterAvpType#GROUPED}
  56. *
  57. * @param vendorID the IANA-assigned enterprise number of the vendor that specified the AVP (eg. 10415 for 3GPP).
  58. * @param avpCode the code for the AVP
  59. * @param avps an array of DiameterAvp objects
  60. * @return an implementation of the DiameterAvp interface
  61. */
  62. DiameterAvp createAvp(int vendorID, int avpCode, DiameterAvp[] avps) throws NoSuchAvpException, AvpNotAllowedException;
  63. /**
  64. * Create an AVP containing a DiameterAvpValue from the byte[] value provided. The
  65. * AVP type will be determined from the AVP code.
  66. *
  67. * @param avpCode the code for the AVP
  68. * @param value the value itself
  69. * @return an implementation of the DiameterAvp interface
  70. */
  71. DiameterAvp createAvp(int avpCode, byte[] value) throws NoSuchAvpException;
  72. /**
  73. * Create a vendor-specific AVP containing a DiameterAvpValue from the byte[] value provided.
  74. * The AVP type will be determined from the AVP code.
  75. *
  76. * @param vendorID the IANA-assigned enterprise number of the vendor that specified the AVP (eg. 10415 for 3GPP).
  77. * @param avpCode the code for the AVP
  78. * @param value the value itself
  79. * @return an implementation of the DiameterAvp interface
  80. */
  81. DiameterAvp createAvp(int vendorID, int avpCode, byte[] value) throws NoSuchAvpException;
  82. /**
  83. * Create an AVP containing a DiameterAvpValue from the int value provided. The
  84. * AVP type will be determined from the AVP code.
  85. *
  86. * @param avpCode the code for the AVP
  87. * @param value the value itself
  88. * @return an implementation of the DiameterAvp interface
  89. */
  90. DiameterAvp createAvp(int avpCode, int value) throws NoSuchAvpException;
  91. /**
  92. * Create a vendor-specific AVP containing a DiameterAvpValue from the int value provided.
  93. * The AVP type will be determined from the AVP code.
  94. *
  95. * @param vendorID the IANA-assigned enterprise number of the vendor that specified the AVP (eg. 10415 for 3GPP).
  96. * @param avpCode the code for the AVP
  97. * @param value the value itself
  98. * @return an implementation of the DiameterAvp interface
  99. */
  100. DiameterAvp createAvp(int vendorID, int avpCode, int value) throws NoSuchAvpException;
  101. /**
  102. * Create an AVP containing a DiameterAvpValue from the long value provided. The
  103. * AVP type will be determined from the AVP code.
  104. *
  105. * @param avpCode the code for the AVP
  106. * @param value the value itself
  107. * @return an implementation of the DiameterAvp interface
  108. */
  109. DiameterAvp createAvp(int avpCode, long value) throws NoSuchAvpException;
  110. /**
  111. * Create a vendor-specific AVP containing a DiameterAvpValue from the long value provided.
  112. * The AVP type will be determined from the AVP code.
  113. *
  114. * @param vendorID the IANA-assigned enterprise number of the vendor that specified the AVP (eg. 10415 for 3GPP).
  115. * @param avpCode the code for the AVP
  116. * @param value the value itself
  117. * @return an implementation of the DiameterAvp interface
  118. */
  119. DiameterAvp createAvp(int vendorID, int avpCode, long value) throws NoSuchAvpException;
  120. /**
  121. * Create an AVP containing a DiameterAvpValue from the float value provided. The
  122. * AVP type will be determined from the AVP code.
  123. *
  124. * @param avpCode the code for the AVP
  125. * @param value the value itself
  126. * @return an implementation of the DiameterAvp interface
  127. */
  128. DiameterAvp createAvp(int avpCode, float value) throws NoSuchAvpException;
  129. /**
  130. * Create a vendor-specific AVP containing a DiameterAvpValue from the float value provided.
  131. * The AVP type will be determined from the AVP code.
  132. *
  133. * @param vendorID the IANA-assigned enterprise number of the vendor that specified the AVP (eg. 10415 for 3GPP).
  134. * @param avpCode the code for the AVP
  135. * @param value the value itself
  136. * @return an implementation of the DiameterAvp interface
  137. */
  138. DiameterAvp createAvp(int vendorID, int avpCode, float value) throws NoSuchAvpException;
  139. /**
  140. * Create an AVP containing a DiameterAvpValue from the double value provided. The
  141. * AVP type will be determined from the AVP code.
  142. *
  143. * @param avpCode the code for the AVP
  144. * @param value the value itself
  145. * @return an implementation of the DiameterAvp interface
  146. */
  147. DiameterAvp createAvp(int avpCode, double value) throws NoSuchAvpException;
  148. /**
  149. * Create a vendor-specific AVP containing a DiameterAvpValue from the double value provided.
  150. * The AVP type will be determined from the AVP code.
  151. *
  152. * @param vendorID the IANA-assigned enterprise number of the vendor that specified the AVP (eg. 10415 for 3GPP).
  153. * @param avpCode the code for the AVP
  154. * @param value the value itself
  155. * @return an implementation of the DiameterAvp interface
  156. */
  157. DiameterAvp createAvp(int vendorID, int avpCode, double value) throws NoSuchAvpException;
  158. /**
  159. * Create an AVP containing a DiameterAvpValue from the java.net.InetAddress value provided. The
  160. * AVP type will be determined from the AVP code.
  161. *
  162. * @param avpCode the code for the AVP
  163. * @param value the value itself
  164. * @return an implementation of the DiameterAvp interface
  165. */
  166. DiameterAvp createAvp(int avpCode, java.net.InetAddress value) throws NoSuchAvpException;
  167. /**
  168. * Create a vendor-specific AVP containing a DiameterAvpValue from the java.net.InetAddress value provided.
  169. * The AVP type will be determined from the AVP code.
  170. *
  171. * @param vendorID the IANA-assigned enterprise number of the vendor that specified the AVP (eg. 10415 for 3GPP).
  172. * @param avpCode the code for the AVP
  173. * @param value the value itself
  174. * @return an implementation of the DiameterAvp interface
  175. */
  176. DiameterAvp createAvp(int vendorID, int avpCode, java.net.InetAddress value) throws NoSuchAvpException;
  177. /**
  178. * Create an AVP containing a DiameterAvpValue from the Date value provided. The
  179. * AVP type will be determined from the AVP code.
  180. *
  181. * @param avpCode the code for the AVP
  182. * @param value the value itself
  183. * @return an implementation of the DiameterAvp interface
  184. */
  185. DiameterAvp createAvp(int avpCode, Date value) throws NoSuchAvpException;
  186. /**
  187. * Create a vendor-specific AVP containing a DiameterAvpValue from the Date value provided.
  188. * The AVP type will be determined from the AVP code.
  189. *
  190. * @param vendorID the IANA-assigned enterprise number of the vendor that specified the AVP (eg. 10415 for 3GPP).
  191. * @param avpCode the code for the AVP
  192. * @param value the value itself
  193. * @return an implementation of the DiameterAvp interface
  194. */
  195. DiameterAvp createAvp(int vendorID, int avpCode, Date value) throws NoSuchAvpException;
  196. /**
  197. * Create an AVP containing a DiameterAvpValue from the java.lang.String value provided. The
  198. * AVP type will be determined from the AVP code.
  199. *
  200. * @param avpCode the code for the AVP
  201. * @param value the value itself
  202. * @return an implementation of the DiameterAvp interface
  203. */
  204. DiameterAvp createAvp(int avpCode, java.lang.String value) throws NoSuchAvpException;
  205. /**
  206. * Create a vendor-specific AVP containing a DiameterAvpValue from the java.lang.String value provided.
  207. * The AVP type will be determined from the AVP code.
  208. *
  209. * @param vendorID the IANA-assigned enterprise number of the vendor that specified the AVP (eg. 10415 for 3GPP).
  210. * @param avpCode the code for the AVP
  211. * @param value the value itself
  212. * @return an implementation of the DiameterAvp interface
  213. */
  214. DiameterAvp createAvp(int vendorID, int avpCode, java.lang.String value) throws NoSuchAvpException;
  215. /**
  216. * Create an AVP containing a DiameterAvpValue from the net.java.slee.resource.diameter.base.types.Enumerated value provided. The
  217. * AVP type will be determined from the AVP code.
  218. *
  219. * @param avpCode the code for the AVP
  220. * @param value the value itself
  221. * @return an implementation of the DiameterAvp interface
  222. */
  223. DiameterAvp createAvp(int avpCode, net.java.slee.resource.diameter.base.events.avp.Enumerated value) throws NoSuchAvpException;
  224. /**
  225. * Create a vendor-specific AVP containing a DiameterAvpValue from the net.java.slee.resource.diameter.base.types.Enumerated value provided.
  226. * The AVP type will be determined from the AVP code.
  227. *
  228. * @param vendorID the IANA-assigned enterprise number of the vendor that specified the AVP (eg. 10415 for 3GPP).
  229. * @param avpCode the code for the AVP
  230. * @param value the value itself
  231. * @return an implementation of the DiameterAvp interface
  232. */
  233. DiameterAvp createAvp(int vendorID, int avpCode, net.java.slee.resource.diameter.base.events.avp.Enumerated value) throws NoSuchAvpException;
  234. /**
  235. * Create an instance of a DiameterCommand concrete implementation using
  236. * the given arguments.
  237. *
  238. * @param commandCode the command code of the command
  239. * @param applicationId the application ID of the command
  240. * @param shortName the short name of the command, e.g., "CER"
  241. * @param longName the long name of the command, e.g., "Capabilities-Exchange-Request"
  242. * @param isRequest true if this command represents a request (not answer)
  243. * @param isProxiable true if this command may be proxied
  244. * @return a complete and correct DiameterCommand object to be passed to
  245. * {@link #createMessage(DiameterCommand, DiameterAvp[] avps)}.
  246. */
  247. DiameterCommand createCommand(int commandCode, int applicationId, String shortName, String longName, boolean isRequest, boolean isProxiable);
  248. /**
  249. * Create a ProxyInfo (Grouped AVP) instance using required AVP values.
  250. *
  251. * @param proxyHost
  252. * @param proxyState
  253. * @return
  254. */
  255. ProxyInfoAvp createProxyInfo(DiameterIdentity proxyHost, byte[] proxyState);
  256. /**
  257. * Create an empty ProxyInfo (Grouped AVP) instance.
  258. *
  259. * @return
  260. */
  261. ProxyInfoAvp createProxyInfo();
  262. /**
  263. * Create a ProxyInfo (Grouped AVP) instance, populating one AVP.
  264. *
  265. * @param avp
  266. * @return
  267. */
  268. ProxyInfoAvp createProxyInfo(DiameterAvp avp);
  269. /**
  270. * Create a ProxyInfo (Grouped AVP) instance using the given array to populate the AVPs.
  271. *
  272. * @param avps
  273. * @return
  274. */
  275. ProxyInfoAvp createProxyInfo(DiameterAvp[] avps);
  276. /**
  277. * Create a VendorSpecificApplicationId (Grouped AVP) instance using required AVP values.
  278. *
  279. * @param vendorId
  280. * @return
  281. */
  282. VendorSpecificApplicationIdAvp createVendorSpecificApplicationId(long vendorId);
  283. /**
  284. * Create an empty VendorSpecificApplicationId (Grouped AVP) instance.
  285. *
  286. * @return
  287. */
  288. VendorSpecificApplicationIdAvp createVendorSpecificApplicationId();
  289. /**
  290. * Create a VendorSpecificApplicationId (Grouped AVP) instance, populating one AVP.
  291. *
  292. * @param avp
  293. * @return
  294. * @throws AvpNotAllowedException
  295. */
  296. VendorSpecificApplicationIdAvp createVendorSpecificApplicationId(DiameterAvp avp) throws AvpNotAllowedException;
  297. /**
  298. * Create a VendorSpecificApplicationId (Grouped AVP) instance using the given array to populate the AVPs.
  299. *
  300. * @param avps
  301. * @return
  302. * @throws AvpNotAllowedException
  303. */
  304. VendorSpecificApplicationIdAvp createVendorSpecificApplicationId(DiameterAvp[] avps) throws AvpNotAllowedException;
  305. /**
  306. * Create an empty FailedAvp (Grouped AVP) instance.
  307. *
  308. * @return
  309. */
  310. FailedAvp createFailedAvp();
  311. /**
  312. * Create a FailedAvp (Grouped AVP) instance, populating one AVP.
  313. *
  314. * @param avp
  315. * @return
  316. */
  317. FailedAvp createFailedAvp(DiameterAvp avp);
  318. /**
  319. * Create a FailedAvp (Grouped AVP) instance using the given array to populate the AVPs.
  320. *
  321. * @param avps
  322. * @return
  323. */
  324. FailedAvp createFailedAvp(DiameterAvp[] avps);
  325. /**
  326. * Create a ExperimentalResult (Grouped AVP) instance using required AVP values.
  327. * @param vendorId
  328. * @param experimentalResultCode
  329. * @return
  330. */
  331. ExperimentalResultAvp createExperimentalResult(long vendorId, long experimentalResultCode);
  332. /**
  333. * Create an empty ExperimentalResult (Grouped AVP) instance.
  334. *
  335. * @return
  336. */
  337. ExperimentalResultAvp createExperimentalResult();
  338. /**
  339. * Create a ExperimentalResult (Grouped AVP) instance, populating one AVP.
  340. *
  341. * @param avp
  342. * @return
  343. * @throws AvpNotAllowedException
  344. */
  345. ExperimentalResultAvp createExperimentalResult(DiameterAvp avp) throws AvpNotAllowedException;
  346. /**
  347. * Create a ExperimentalResult (Grouped AVP) instance using the given array to populate the AVPs.
  348. *
  349. * @param avps
  350. * @return
  351. * @throws AvpNotAllowedException
  352. */
  353. ExperimentalResultAvp createExperimentalResult(DiameterAvp[] avps) throws AvpNotAllowedException;
  354. }