* @param output a stream into which the XML-encoded data is written
* @param indenter an object that creates indentation strings
*/
public void encode(OutputStream output, Indenter indenter) {
if (! getParameters().isEmpty()) {
AbstractPolicy policy = getPolicy();
// FIXME: This is ugly and happens in several places...maybe this
// should get folded into the AbstractPolicy API?
if (policy instanceof Policy) {
encodeParamaters(output, indenter, "Policy",
policy.getId().toString());
} else if (policy instanceof PolicySet) {
encodeParamaters(output, indenter, "PolicySet",
policy.getId().toString());
} else {
PolicyReference ref = (PolicyReference)policy;
if (ref.getReferenceType() == PolicyReference.POLICY_REFERENCE)
encodeParamaters(output, indenter, "Policy",
ref.getReference().toString());