001/**************************************************************** 002 * Licensed to the Apache Software Foundation (ASF) under one * 003 * or more contributor license agreements. See the NOTICE file * 004 * distributed with this work for additional information * 005 * regarding copyright ownership. The ASF licenses this file * 006 * to you under the Apache License, Version 2.0 (the * 007 * "License"); you may not use this file except in compliance * 008 * with the License. You may obtain a copy of the License at * 009 * * 010 * http://www.apache.org/licenses/LICENSE-2.0 * 011 * * 012 * Unless required by applicable law or agreed to in writing, * 013 * software distributed under the License is distributed on an * 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * 015 * KIND, either express or implied. See the License for the * 016 * specific language governing permissions and limitations * 017 * under the License. * 018 ****************************************************************/ 019 020package org.apache.james.mime4j.dom.field; 021 022import java.util.Date; 023import java.util.Map; 024 025public interface ContentDispositionField extends ParsedField { 026 027 /** The <code>inline</code> disposition type. */ 028 public static final String DISPOSITION_TYPE_INLINE = "inline"; 029 /** The <code>attachment</code> disposition type. */ 030 public static final String DISPOSITION_TYPE_ATTACHMENT = "attachment"; 031 /** The name of the <code>filename</code> parameter. */ 032 public static final String PARAM_FILENAME = "filename"; 033 /** The name of the <code>creation-date</code> parameter. */ 034 public static final String PARAM_CREATION_DATE = "creation-date"; 035 /** The name of the <code>modification-date</code> parameter. */ 036 public static final String PARAM_MODIFICATION_DATE = "modification-date"; 037 /** The name of the <code>read-date</code> parameter. */ 038 public static final String PARAM_READ_DATE = "read-date"; 039 /** The name of the <code>size</code> parameter. */ 040 public static final String PARAM_SIZE = "size"; 041 042 /** 043 * Gets the disposition type defined in this Content-Disposition field. 044 * 045 * @return the disposition type or an empty string if not set. 046 */ 047 String getDispositionType(); 048 049 /** 050 * Gets the value of a parameter. Parameter names are case-insensitive. 051 * 052 * @param name 053 * the name of the parameter to get. 054 * @return the parameter value or <code>null</code> if not set. 055 */ 056 String getParameter(String name); 057 058 /** 059 * Gets all parameters. 060 * 061 * @return the parameters. 062 */ 063 Map<String, String> getParameters(); 064 065 /** 066 * Determines if the disposition type of this field matches the given one. 067 * 068 * @param dispositionType 069 * the disposition type to match against. 070 * @return <code>true</code> if the disposition type of this field 071 * matches, <code>false</code> otherwise. 072 */ 073 boolean isDispositionType(String dispositionType); 074 075 /** 076 * Return <code>true</code> if the disposition type of this field is 077 * <i>inline</i>, <code>false</code> otherwise. 078 * 079 * @return <code>true</code> if the disposition type of this field is 080 * <i>inline</i>, <code>false</code> otherwise. 081 */ 082 boolean isInline(); 083 084 /** 085 * Return <code>true</code> if the disposition type of this field is 086 * <i>attachment</i>, <code>false</code> otherwise. 087 * 088 * @return <code>true</code> if the disposition type of this field is 089 * <i>attachment</i>, <code>false</code> otherwise. 090 */ 091 boolean isAttachment(); 092 093 /** 094 * Gets the value of the <code>filename</code> parameter if set. 095 * 096 * @return the <code>filename</code> parameter value or <code>null</code> 097 * if not set. 098 */ 099 String getFilename(); 100 101 /** 102 * Gets the value of the <code>creation-date</code> parameter if set and 103 * valid. 104 * 105 * @return the <code>creation-date</code> parameter value or 106 * <code>null</code> if not set or invalid. 107 */ 108 Date getCreationDate(); 109 110 /** 111 * Gets the value of the <code>modification-date</code> parameter if set 112 * and valid. 113 * 114 * @return the <code>modification-date</code> parameter value or 115 * <code>null</code> if not set or invalid. 116 */ 117 Date getModificationDate(); 118 119 /** 120 * Gets the value of the <code>read-date</code> parameter if set and 121 * valid. 122 * 123 * @return the <code>read-date</code> parameter value or <code>null</code> 124 * if not set or invalid. 125 */ 126 Date getReadDate(); 127 128 /** 129 * Gets the value of the <code>size</code> parameter if set and valid. 130 * 131 * @return the <code>size</code> parameter value or <code>-1</code> if 132 * not set or invalid. 133 */ 134 long getSize(); 135 136}