📄 contenttype.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: ContentType.java
package org.lazybug.mime;
// Referenced classes of package javax.mail.internet:
// HeaderTokenizer, ParameterList, ParseException
public class ContentType
{
private String primaryType;
private String subType;
private ParameterList list;
public ContentType()
{
}
public ContentType(String primaryType, String subType, ParameterList parameterlist)
{
this.primaryType = primaryType;
this.subType = subType;
list = parameterlist;
}
public ContentType(String s) throws ParseException
{
HeaderTokenizer headertokenizer = new HeaderTokenizer(s, "()<>@,;:\\\"\t []/?=");
HeaderTokenizer.Token token = headertokenizer.next();
if(token.getType() != -1)
throw new ParseException();
primaryType = token.getValue();
token = headertokenizer.next();
if((char)token.getType() != '/')
throw new ParseException();
token = headertokenizer.next();
if(token.getType() != -1)
throw new ParseException();
subType = token.getValue();
String s1 = headertokenizer.getRemainder();
if(s1 != null) list = new ParameterList(s1);
}
public String getPrimaryType()
{
return primaryType;
}
public String getSubType()
{
return subType;
}
public String getBaseType()
{
return primaryType + '/' + subType;
}
public String getParameter(String s)
{
if(list == null)
return null;
else
return list.get(s);
}
public ParameterList getParameterList()
{
return list;
}
public void setPrimaryType(String s)
{
primaryType = s;
}
public void setSubType(String s)
{
subType = s;
}
public void setParameter(String token, String value)
{
if(list == null) list = new ParameterList();
if( value != null ) list.set(token, value);
}
public void setParameterList(ParameterList parameterlist)
{
list = parameterlist;
}
public String toString()
{
if(primaryType == null || subType == null)
return "";
StringBuffer stringbuffer = new StringBuffer();
stringbuffer.append(primaryType).append('/').append(subType);
if(list != null)
{
stringbuffer.append(list.toString(stringbuffer.length() + 14));
}
return stringbuffer.toString();
}
public boolean match(ContentType contenttype)
{
if(!primaryType.equalsIgnoreCase(contenttype.getPrimaryType()))
return false;
String s = contenttype.getSubType();
if(subType.charAt(0) == '*' || s.charAt(0) == '*')
return true;
return subType.equalsIgnoreCase(s);
}
public boolean match(String s)
{
try
{
return match(new ContentType(s));
}
catch(ParseException _ex)
{
return false;
}
}
public static void main(String[] args)
{
try
{
ContentType ct = new ContentType("multipart/related;type=\"applicatoin/smil\";start=\"<sddd>\"");
System.out.println(ct.getParameter("type"));
}
catch(ParseException e)
{
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -