w3c.model.www.pep.bags.PolicyDecl
// ExtDecl.java
// $Id: PolicyDecl.java,v 1.1 1997/07/21 21:55:47 eric Exp $
// (c) COPYRIGHT MIT and INRIA, 1996.
// Please first read the full copyright statement in file COPYRIGHT.html
package w3c.model.www.pep.bags;
import java.util.*;
import w3c.model.www.pep.*;
import w3c.model.www.pep.altlib.*;
public class PolicyDecl extends PEPBag
IdBag id;
ForBag fur;
StrengthBag strength;
MaxAgeBag maxAge;
ParamsBag params;
protected void complete () throws HttpParserException{
if (id == null))
throw MissingElementException("map or unmap", "PolicyDecl");
String mappedURLs[];
if (fur == null)) {
mappedURLs = String[1];
mappedURLs[0] = instanceContext.getMessage().getURI();
} else {
mappedURLs = String[fur.getHeaderWildcards().size()];
Enumeration en = fur.getHeaderWildcards().elements();
for (int i = 0; en.hasMoreElements(); i++))
mappedURLs[i] = (String)en.nextElement();
}
String URI = id.getURI();
boolean must = strength == null ? false : strength.getMust();
String hostURI = instanceContext.getMessage().getURI();
instanceContext.getPepAgent().makeURLExtension(id.getURI(), must, mappedURLs, mappedURLs.length, hostURI);
}
protected final void bufferize ( HttpBuffer buf) {
buf.append((byte) '{');
id.bufferize(buf);
if (fur != null))
fur.bufferize(buf);
if (strength != null))
strength.bufferize(buf);
if (maxAge != null))
maxAge.bufferize(buf);
if (params != null))
params.bufferize(buf);
buf.append((byte) '}');
}
protected HttpRawBag lookupSubBag( String name) throws HttpParserException{
String className;
if ("id".equals(name))) {
if (id != null))
throw NotAllowedException("duplicate id bag", name, "PolicyDecl");
return id = IdBag(name, instanceContext);
} elseif ("for".equals(name))) {
if (fur != null))
throw NotAllowedException("duplicate for bag", name, "PolicyDecl");
return fur = ForBag(name, instanceContext);
} elseif ("strength".equals(name))) {
if (strength != null))
throw NotAllowedException("duplicate strength bag", name, "PolicyDecl");
return strength = StrengthBag(name, instanceContext);
} elseif ("max-age".equals(name))) {
if (maxAge != null))
throw NotAllowedException("duplicate max-age bag", name, "PolicyDecl");
return maxAge = MaxAgeBag(name, instanceContext);
} elseif ("params".equals(name))) {
if (params != null))
throw NotAllowedException("duplicate strength params", name, "PolicyDecl");
return params = ParamsBag(name, instanceContext);
}
return null;
}
public void validate1() {super.validate();} /* public access to BasicValue.validate() */
public void addElement ( String name) throws AtomNotAllowedException{
throw AtomNotAllowedException(name, "PolicyDecl");
}
public IdBag getId() {return id;}
public void setFor( ForBag fur) {this.fur = fur;}
public ForBag getFor() {return fur;}
public void setStrength( StrengthBag strength) {this.strength = strength;}
public StrengthBag getStrength() {return strength;}
public void setMaxAge( MaxAgeBag maxAge) {this.maxAge = maxAge;}
public MaxAgeBag getMaxAge() {return maxAge;}
public PolicyDecl( String name, InstanceContext instanceContext) throws HttpParserException{
super(name, instanceContext);
}
public PolicyDecl ( InstanceContext instanceContext, IdBag idBag) {
super("", instanceContext);
this.id = idBag;
}
public PolicyDecl ( InstanceContext instanceContext, IdBag idBag, ForBag forBag) {
super("", instanceContext);
this.id = idBag;
this.fur = forBag;
}