/protocols/ss7/map/map-impl/src/main/java/org/mobicents/protocols/ss7/map/primitives/ISDNAddressStringImpl.java

http://mobicents.googlecode.com/ · Java · 87 lines · 45 code · 13 blank · 29 comment · 4 complexity · 3b0ed1de96ec8aba765c44d1fb38427a 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.protocols.ss7.map.primitives;
  23. import javolution.xml.XMLFormat;
  24. import javolution.xml.stream.XMLStreamException;
  25. import org.mobicents.protocols.ss7.map.api.MAPException;
  26. import org.mobicents.protocols.ss7.map.api.MAPParsingComponentException;
  27. import org.mobicents.protocols.ss7.map.api.MAPParsingComponentExceptionReason;
  28. import org.mobicents.protocols.ss7.map.api.primitives.AddressNature;
  29. import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString;
  30. import org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan;
  31. /**
  32. *
  33. * @author sergey vetyutnev
  34. *
  35. */
  36. public class ISDNAddressStringImpl extends AddressStringImpl implements ISDNAddressString {
  37. public ISDNAddressStringImpl() {
  38. }
  39. public ISDNAddressStringImpl(AddressNature addressNature, NumberingPlan numberingPlan, String address) {
  40. super(addressNature, numberingPlan, address);
  41. }
  42. @Override
  43. protected void _testLengthDecode(int length) throws MAPParsingComponentException {
  44. if (length > 9)
  45. throw new MAPParsingComponentException("Error when decoding FTNAddressString: mesage length must not exceed 9",
  46. MAPParsingComponentExceptionReason.MistypedParameter);
  47. }
  48. @Override
  49. protected void _testLengthEncode() throws MAPException {
  50. if (this.address == null && this.address.length() > 16)
  51. throw new MAPException("Error when encoding ISDNAddressString: address length must not exceed 16 digits");
  52. }
  53. @Override
  54. public String toString() {
  55. return "ISDNAddressString[AddressNature=" + this.addressNature + ", NumberingPlan=" + this.numberingPlan + ", Address="
  56. + this.address + "]";
  57. }
  58. /**
  59. * XML Serialization/Deserialization
  60. */
  61. protected static final XMLFormat<ISDNAddressStringImpl> ISDN_ADDRESS_STRING_XML = new XMLFormat<ISDNAddressStringImpl>(
  62. ISDNAddressStringImpl.class) {
  63. @Override
  64. public void read(javolution.xml.XMLFormat.InputElement xml, ISDNAddressStringImpl isdnAddressStringImpl)
  65. throws XMLStreamException {
  66. ADDRESS_STRING_XML.read(xml, isdnAddressStringImpl);
  67. }
  68. @Override
  69. public void write(ISDNAddressStringImpl isdnAddressStringImpl, javolution.xml.XMLFormat.OutputElement xml)
  70. throws XMLStreamException {
  71. ADDRESS_STRING_XML.write(isdnAddressStringImpl, xml);
  72. }
  73. };
  74. }