001: /*
002: * ContentType.java February 2001
003: *
004: * Copyright (C) 2001, Niall Gallagher <niallg@users.sf.net>
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013: * GNU Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General
016: * Public License along with this library; if not, write to the
017: * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
018: * Boston, MA 02111-1307 USA
019: */
020:
021: package simple.util.net;
022:
023: /**
024: * This provides access to the MIME type parts, that is the type
025: * subtype and an optional <code>charset</code> parameter. The
026: * <code>charset</code> parameter is one of many parameters that
027: * can be assiciated with a MIME type. This however only provides
028: * access to the <code>charset</code> value.
029: * <p>
030: * The <code>getCharset</code> will return <code>val</code> if the
031: * MIME type represented is type/subtype; charset=val. The type and
032: * subtype are set to the <code>String</code> value <code>null</code>
033: * if the <code>setPrimary</code> or <code>setSecondary</code> are
034: * given a <code>null</code> <code>String</code>.
035: *
036: * @author Niall Gallagher
037: */
038: public interface ContentType {
039:
040: /**
041: * This sets the type to whatever value is in the <code>String</code>
042: * object. If the <code>String</code> object is <code>null</code> the
043: * this object's <code>toString</code> method will contain the value
044: * <code>null</code>.
045: * <p>
046: * If type is <code>null</code> then the <code>toString</code> method
047: * will be null/subtype;param=value. If the type is non-null this will
048: * contain the value of the <code>String</code>.
049: *
050: * @param type the type to add to the MIME type
051: */
052: public void setPrimary(String type);
053:
054: /**
055: * This is used to retrive the type of this MIME type. The type
056: * part within the MIME type defines the generic type. For example
057: * <code>type/subtype;param1=value1</code>. This will return the
058: * value of the type part. If there is no type part then this will
059: * return <code>null</code> otherwise the type <code>String</code>.
060: *
061: * @return the type part of the MIME type
062: */
063: public String getPrimary();
064:
065: /**
066: * Sets the subtype to whatever value is in the <code>String</code>
067: * object. If the <code>String</code> object is <code>null</code>
068: * the this object's <code>toString</code> method will contain the
069: * value <code>null</code>.
070: * <p>
071: * If subtype is <code>null</code> then the <code>toString</code>
072: * method will be <code>type/null;param=value</code>. If the type
073: * is non-null this will contain the value of the <code>String</code>.
074: *
075: * @param type the type to add to the MIME type
076: */
077: public void setSecondary(String type);
078:
079: /**
080: * This is used to retrive the subtype of this MIME type. The
081: * subtype part within the MIME type defines the specific type.
082: * For example <code>type/subtype;param1=value1</code>. This will
083: * return the value of the subtype part. If there is no subtype
084: * part then this will return <code>null</code> otherwise the type
085: * <code>String</code>.
086: *
087: * @return the subtype part of the MIME type
088: */
089: public String getSecondary();
090:
091: /**
092: * This will set the <code>charset</code> to whatever value is
093: * in the <code>String</code> object. If the <code>String</code>
094: * object is <code>null</code> then this <code>toString</code>
095: * method will not contain the <code>charset</code>.
096: * <p>
097: * If <code>charset</code> is <code>null</code> then the
098: * <code>toString</code> method will be type/subtype. If the
099: * <code>charset</code> value is non-null this will contain
100: * the <code>charset</code> parameter with that value.
101: *
102: * @param charset the value to add to the MIME type
103: */
104: public void setCharset(String charset);
105:
106: /**
107: * This is used to retrive the <code>charset</code> of this MIME
108: * type. The <code>charset</code> part within the MIME type is an
109: * optional parameter. For example <code>type/subtype;charset=value
110: * </code>. This will return the value of the <code>charset</code>
111: * value. If there is no <code>charset</code> param then this will
112: * return <code>null</code> otherwise the type <code>String</code>.
113: *
114: * @return the <code>charset</code> value for the MIME type
115: */
116: public String getCharset();
117:
118: /**
119: * This will return the <code>String</code> value of the MIME
120: * type. This will return the MIME type with the type, subtype
121: * and if there is a <code>charset</code> value specified then
122: * a <code>charset</code> parameter.
123: * <p>
124: * The <code>charset</code> parameter is an optional parameter
125: * to the MIME type. An example a MIME type is <code>type/subtype;
126: * charset=value<code>. If the type or subtype is <code>null</code>
127: * then the MIME type will be wither null/subtype, type/null or if
128: * both are <code>null</code> null/null.
129: *
130: * @return the <code>String</code> representation of the MIME type
131: */
132: public String toString();
133: }
|