Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.codehaus.xfire.jaxb2;
 
 
 
    private MessageContext context;
    public AttachmentUnmarshaller(MessageContext context)
    {
        this. = context;
    }
    @Override
    public byte[] getAttachmentAsByteArray(String cid)
    {
        Attachment a = AttachmentUtil.getAttachment(cid.getOutMessage());
        if (a == null)
            throw new IllegalArgumentException("Attachment " + cid + " was not found.");
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try
        {
            copy(a.getDataHandler().getInputStream(), bos);
        }
        catch (IOException e)
        {
            throw new XFireRuntimeException("Could not read attachment."e);
        }
        return bos.toByteArray();
    }
    public static void copy(InputStream inputOutputStream outputthrows IOException
    {
        try
        {
            final byte[] buffer = new byte[8096];
            int n = 0;
            while (-1 != (n = input.read(buffer)))
            {
                output.write(buffer, 0, n);
            }
        }
        finally
        {
            output.close();
            input.close();
        }
    }
    @Override
    {
        Attachment a = AttachmentUtil.getAttachment(cid.getInMessage());
        if (a == null)
            throw new IllegalArgumentException("Attachment " + cid + " was not found.");
        return a.getDataHandler();
    }
    @Override
    public boolean isXOPPackage()
    {
        if (mtomEnabled == nullreturn false;
        
        return Boolean.valueOf(mtomEnabled).booleanValue();
    }
New to GrepCode? Check out our FAQ X