📄 cookie.java
字号:
// IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
//
// This class must only be used for TINI until all of the stuff
// required by javax.servlet.http.Cookie is supported by TINI.
//
// The missing elements are:
//
// java.text.MessageFormat
//
// Cookie.java - TINI version of javax.servlet.http.Cookie.
//
// Copyright (C) 1999-2002 Smart Software Consulting
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// Smart Software Consulting
// 1688 Silverwood Court
// Danville, CA 94526-3079
// USA
//
// http://www.smartsc.com
//
package javax.servlet.http;
public class Cookie
implements Cloneable
{
public Cookie(String s, String s1)
{
maxAge = -1;
version = 0;
if(!isToken(s) || s.equalsIgnoreCase("Comment") || s.equalsIgnoreCase("Discard") || s.equalsIgnoreCase("Domain") || s.equalsIgnoreCase("Expires") || s.equalsIgnoreCase("Max-Age") || s.equalsIgnoreCase("Path") || s.equalsIgnoreCase("Secure") || s.equalsIgnoreCase("Version"))
{
throw new IllegalArgumentException( "Cookie name " + s + " is a reserved token");
}
else
{
name = s;
value = s1;
return;
}
}
public Object clone()
{
try
{
return super.clone();
}
catch(CloneNotSupportedException clonenotsupportedexception)
{
throw new RuntimeException(clonenotsupportedexception.getMessage());
}
}
public String getComment()
{
return comment;
}
public String getDomain()
{
return domain;
}
public int getMaxAge()
{
return maxAge;
}
public String getName()
{
return name;
}
public String getPath()
{
return path;
}
public boolean getSecure()
{
return secure;
}
public String getValue()
{
return value;
}
public int getVersion()
{
return version;
}
private boolean isToken(String s)
{
int i = s.length();
for(int j = 0; j < i; j++)
{
char c = s.charAt(j);
if(c < ' ' || c >= '\177' || ",;".indexOf(c) != -1)
return false;
}
return true;
}
public void setComment(String s)
{
comment = s;
}
public void setDomain(String s)
{
domain = s.toLowerCase();
}
public void setMaxAge(int i)
{
maxAge = i;
}
public void setPath(String s)
{
path = s;
}
public void setSecure(boolean flag)
{
secure = flag;
}
public void setValue(String s)
{
value = s;
}
public void setVersion(int i)
{
version = i;
}
private String name;
private String value;
private String comment;
private String domain;
private int maxAge;
private String path;
private boolean secure;
private int version;
private static final String tspecials = ",;";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -