Package org.jpos.iso

Examples of org.jpos.iso.ISOException


            this.xsltfile    = xsltfile;
            this.reread      = reread;
            this.transformer =
                tfactory.newTransformer(new StreamSource(xsltfile));
        } catch (TransformerConfigurationException e) {
            throw new ISOException (e);
        }

    }
View Full Code Here


                    } else if (value instanceof ISOMsg) {
                        ISOMsgTagValue subSequence = (ISOMsgTagValue) tagValue;
                        subField = subSequence.getValue();
                        subField.setFieldNumber(fieldNumber + maxField + 1);
                    } else {
                        throw new ISOException("Unknown TagValue subclass: " + tagValue.getClass());
                    }
                    isoMsg.set(new ISOTaggedField(tagValue.getTag(), subField));
                }
                fieldNumber++;
            }
View Full Code Here

                    } else if (delegate instanceof ISOBinaryField) {
                        tagValue = createBinaryTagValuePair(taggedSubField.getTag(), taggedSubField.getBytes());
                    } else if (delegate instanceof ISOField) {
                        tagValue = createLiteralTagValuePair(taggedSubField.getTag(), taggedSubField.getValue().toString());
                    } else {
                        throw new ISOException("Unknown ISOComponent subclass in ISOTaggedField: " + delegate.getClass());
                    }
                    this.add(tagValue);
                } else {
                    throw new ISOException("Children after first ISOTaggedField should be instance of ISOTaggedField." +
                            " Field " + i + " is not an ISOTaggedField");
                }
            }
        }
View Full Code Here

    public byte[] pack(ISOComponent c) throws ISOException {
        int len;
        byte[] s = c.getBytes();

        if ((len = s.length) > getLength()) {
            throw new ISOException(
                    "Invalid length " + len + " packing IF_FSTBINARY field "
                            + c.getKey() + " max length=" + getLength()
            );
        }
        byte[] b = new byte[s.length + 1];
View Full Code Here

     * @throws org.jpos.iso.ISOException
     */
    public int unpack(ISOComponent c, byte[] b, int offset)
            throws ISOException {
        if (!(c instanceof ISOField))
            throw new ISOException
                    (c.getClass().getName() + " is not an ISOField");
        int length = -1;
        for (int i = 0; i < getMaxPackedLength(); i++) {
            byte dataByte = b[offset + i];
            if (dataByte == terminator) {
                length = i;
                break;
            }
        }
        if (length >= 0) {
            byte[] value = new byte[length];
            System.arraycopy(b, offset, value, 0, length);
            c.setValue(value);
            return length + 1;
        } else {
            throw new ISOException("Terminating Backslash does not exist");
        }
    }
View Full Code Here

    public void unpack(ISOComponent c, InputStream in)
            throws IOException, ISOException {

        if (!(c instanceof ISOField))
            throw new ISOException
                    (c.getClass().getName() + " is not an ISOField");

        boolean endFound = false;
        if (in.markSupported()) {
            in.mark(getMaxPackedLength());
        }
        ByteBuffer buf = ByteBuffer.allocate(getMaxPackedLength());

        for (int i = 0; i < getMaxPackedLength() && in.available() > 0; i++) {
            byte dataByte = (byte) in.read();
            if (dataByte == terminator) {
                endFound = true;
                break;
            } else {
                buf.put(dataByte);
            }
        }
        if (endFound) {
            byte[] data = byteBufferToBytes(buf);
            c.setValue(data);
        } else {
            if (in.markSupported()) {
                in.reset();
            }
            throw new ISOException("Terminating Backslash does not exist");
        }
    }
View Full Code Here

        if (tag ==0)
            return null;

        // Get Length if buffer remains!
        if (!buffer.hasRemaining())
            throw new ISOException(String.format("BAD TLV FORMAT - tag (%x)"
                    + " without length or value",tag));

        int length = getValueLength(buffer);
        if(length >buffer.remaining())
            throw new ISOException(String.format("BAD TLV FORMAT - tag (%x)"
                    + " length (%d) exceeds available data.", tag, length));

        byte[] arrValue= new byte[length];
        buffer.get(arrValue);
View Full Code Here

                                b = new byte[0];
                            } else if (!nested && (i == startIdx || i == endIdx) &&
                                    this.fld.length > i && this.fld[i] != null) {
                                b = this.fld[i].pack(c);
                            } else {
                                throw new ISOException(
                                        "Field: " +
                                                i +
                                                " of type: " +
                                                c.getClass() +
                                                " cannot be packed. Either the object should be of type ISOTagField" +
                                                " OR this should be the first or last sub-field and a packager" +
                                                " should be configured for the same");
                            }
                        }
                        len += b.length;
                        l.add(b);
                    } catch (Exception e) {
                        evt.addMessage("error packing sub-field " + i);
                        evt.addMessage(c);
                        evt.addMessage(e);
                        throw e;
                    }
                }
            }
            int k = 0;
            byte[] d = new byte[len];
            for (byte[] b : l) {
                System.arraycopy(b, 0, d, k, b.length);
                k += b.length;
            }
            if (logger != null) // save a few CPU cycle if no logger available
                evt.addMessage(ISOUtil.hexString(d));
            return d;
        } catch (ISOException e) {
            evt.addMessage(e);
            throw e;
        } catch (Exception e) {
            evt.addMessage(e);
            throw new ISOException(e);
        } finally {
            Logger.log(evt);
        }
    }
View Full Code Here

        final byte[] rawValueBytes;

        try {
            rawValueBytes = packValue(c.getTag(), c);
        } catch (UnknownTagNumberException e) {
            throw new ISOException(e);
        }

        byte[] valueBytes = new byte[valueInterpreter.getPackedLength(rawValueBytes.length)];
        valueInterpreter.interpret(rawValueBytes, valueBytes, 0);
View Full Code Here

    @Override
    public int unpack(ISOComponent m, byte[] b) throws ISOException {
        try {
            return unpack(m, b, false);
        } catch (RuntimeException e) {
            throw new ISOException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.jpos.iso.ISOException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.