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