View Javadoc

    1   /*
    2    *  soapUI, copyright (C) 2004-2007 eviware.com
    3    *
    4    *  soapUI is free software; you can redistribute it and/or modify it under the
    5    *  terms of version 2.1 of the GNU Lesser General Public License as published by
    6    *  the Free Software Foundation.
    7    *
    8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
    9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    10   *  See the GNU Lesser General Public License for more details at gnu.org.
    11   */
    12
    13  package com.eviware.soapui.impl.wsdl;
    14
    15  import java.util.ArrayList;
    16  import java.util.List;
    17
    18  import com.eviware.soapui.model.iface.Attachment;
    19  import com.eviware.soapui.model.iface.MessagePart;
    20
    21  /***
    22   * Descriptor for attachments
    23   *
    24   * @author Ole.Matzura
    25   */
    26
    27  public final class WsdlAttachmentPart extends MessagePart.AttachmentPart
    28  {
    29  	public static final String ANONYMOUS_NAME = "<anonymous>";
    30  	private String name;
    31  	private List<String> contentTypes = new ArrayList<String>();
    32  	private Attachment.AttachmentType type;
    33  	private boolean anonymous;
    34
    35  	public WsdlAttachmentPart()
    36  	{
    37  		anonymous = true;
    38  		name = ANONYMOUS_NAME;
    39  	}
    40
    41  	public WsdlAttachmentPart(String name, List<String> types )
    42  	{
    43  		super();
    44  		this.name = name;
    45
    46  		if( types != null )
    47  			contentTypes.addAll( types );
    48  	}
    49
    50  	public WsdlAttachmentPart( String name, String type )
    51  	{
    52  		this.name = name;
    53  		if( type != null )
    54  			contentTypes.add( type );
    55  	}
    56
    57  	public String[] getContentTypes()
    58  	{
    59  		return contentTypes.toArray( new String[contentTypes.size()] );
    60  	}
    61
    62  	public String getName()
    63  	{
    64  		return name;
    65  	}
    66
    67  	public void addContentType( String contentType )
    68  	{
    69  		contentTypes.add( contentType );
    70  	}
    71
    72  	public Attachment.AttachmentType getAttachmentType()
    73  	{
    74  		return type;
    75  	}
    76
    77  	public void setType(Attachment.AttachmentType type)
    78  	{
    79  		this.type = type;
    80  	}
    81
    82  	public String getDescription()
    83  	{
    84  		return name + " attachment; [" + getContentTypes() + "]";
    85  	}
    86
    87  	public boolean isAnonymous()
    88  	{
    89  		return anonymous;
    90  	};
    91  }