PageRenderTime 78ms CodeModel.GetById 63ms RepoModel.GetById 0ms app.codeStats 1ms

/protocols/ss7/hardware/dialogic/java/src/main/java/org/mobicents/ss7/hardware/dialogic/oam/DialogicLinksetFactory.java

http://mobicents.googlecode.com/
Java | 100 lines | 46 code | 22 blank | 32 comment | 14 complexity | 141ff1e4542e995d1f13ae7f66296ad8 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 org.mobicents.ss7.hardware.dialogic.oam;
  23. import org.mobicents.ss7.linkset.oam.LinkOAMMessages;
  24. import org.mobicents.ss7.linkset.oam.Linkset;
  25. import org.mobicents.ss7.linkset.oam.LinksetFactory;
  26. /**
  27. * <p>
  28. * Factory for creating <tt>dialogic</tt> based {@link Linkset}
  29. * </p>
  30. *
  31. * @author amit bhayani
  32. *
  33. */
  34. public class DialogicLinksetFactory extends LinksetFactory {
  35. private static final String NAME = "dialogic";
  36. public DialogicLinksetFactory() {
  37. super();
  38. }
  39. @Override
  40. public String getName() {
  41. return NAME;
  42. }
  43. @Override
  44. public Linkset createLinkset(String[] options) throws Exception {
  45. // the expected command is "linkset create dialogic opc 1 apc 2 ni 3
  46. // srcmod 61 dstmod 34 linkset1". We know length is 14
  47. if (options.length != 14) {
  48. throw new Exception(LinkOAMMessages.INVALID_COMMAND);
  49. }
  50. String option = options[3];
  51. // If first option is not OPC
  52. if (option.compareTo("opc") != 0) {
  53. return null;
  54. }
  55. int opc = Integer.parseInt(options[4]);
  56. if (options[5].compareTo("apc") != 0) {
  57. throw new Exception(LinkOAMMessages.INVALID_COMMAND);
  58. }
  59. int dpc = Integer.parseInt(options[6]);
  60. if (options[7].compareTo("ni") != 0) {
  61. throw new Exception(LinkOAMMessages.INVALID_COMMAND);
  62. }
  63. int ni = Integer.parseInt(options[8]);
  64. if (options[9].compareTo("srcmod") != 0) {
  65. throw new Exception(LinkOAMMessages.INVALID_COMMAND);
  66. }
  67. int srcmod = Integer.parseInt(options[10]);
  68. if (options[11].compareTo("dstmod") != 0) {
  69. throw new Exception(LinkOAMMessages.INVALID_COMMAND);
  70. }
  71. int dstmod = Integer.parseInt(options[12]);
  72. String name = options[13];
  73. if (name == null) {
  74. throw new Exception(LinkOAMMessages.INVALID_COMMAND);
  75. }
  76. return new DialogicLinkset(name, opc, dpc, ni, srcmod, dstmod);
  77. }
  78. }