ConstraintFieldNodepublic class ConstraintFieldNode extends WebRuntimeNode node for cache-mapping tag |
Methods Summary |
---|
protected java.util.Map | getDispatchTable()all sub-implementation of this class can use a dispatch table to map xml element to
method name on the descriptor class for setting the element value.
Map dispatchTable = super.getDispatchTable();
// for backward compatibility with S1AS 7 dtd
dispatchTable.put(RuntimeTagNames.VALUE, "addValue");
dispatchTable.put(RuntimeTagNames.CONSTRAINT_FIELD_VALUE, "addValue");
return dispatchTable;
| public void | startElement(com.sun.enterprise.deployment.node.XMLElement element, org.xml.sax.Attributes attributes)
if (element.getQName().equals(RuntimeTagNames.CONSTRAINT_FIELD)) {
ConstraintField descriptor =
(ConstraintField) getRuntimeDescriptor();
for (int i=0; i<attributes.getLength();i++) {
if (RuntimeTagNames.NAME.equals(attributes.getQName(i))) {
descriptor.setAttributeValue(ConstraintField.NAME,
attributes.getValue(i));
} else
if (RuntimeTagNames.SCOPE.equals(attributes.getQName(i))) {
descriptor.setAttributeValue(ConstraintField.SCOPE,
attributes.getValue(i));
} else
if (RuntimeTagNames.CACHE_ON_MATCH.equals(
attributes.getQName(i))) {
descriptor.setAttributeValue(
ConstraintField.CACHE_ON_MATCH,
attributes.getValue(i));
} else
if (RuntimeTagNames.CACHE_ON_MATCH_FAILURE.equals(
attributes.getQName(i))) {
descriptor.setAttributeValue(
ConstraintField.CACHE_ON_MATCH_FAILURE,
attributes.getValue(i));
}
}
// From sun-web-app_2_3-0.dtd to sun-web-app_2_4-0.dtd,
// the element name "value" is changed to "constraint-field-value",
// need to make sure both will work
} else if (element.getQName().equals(RuntimeTagNames.VALUE) ||
element.getQName().equals(RuntimeTagNames.CONSTRAINT_FIELD_VALUE)) {
ConstraintField descriptor =
(ConstraintField) getRuntimeDescriptor();
int index = descriptor.sizeValue();
for (int i=0; i<attributes.getLength();i++) {
if (RuntimeTagNames.MATCH_EXPR.equals(
attributes.getQName(i))) {
descriptor.setAttributeValue(ConstraintField.VALUE,
index, ConstraintField.MATCH_EXPR,
attributes.getValue(i));
} else
if (RuntimeTagNames.CACHE_ON_MATCH.equals(
attributes.getQName(i))) {
descriptor.setAttributeValue(ConstraintField.VALUE,
index, ConstraintField.CACHE_ON_MATCH,
attributes.getValue(i));
} else
if (RuntimeTagNames.CACHE_ON_MATCH_FAILURE.equals(
attributes.getQName(i))) {
descriptor.setAttributeValue(ConstraintField.VALUE,
index, ConstraintField.CACHE_ON_MATCH_FAILURE,
attributes.getValue(i));
}
}
} else super.startElement(element, attributes);
| public void | writeDescriptor(org.w3c.dom.Node parent, java.lang.String nodeName, com.sun.enterprise.deployment.runtime.web.ConstraintField[] descriptors)write the descriptor class to a DOM tree and return it
for (int i=0;i<descriptors.length;i++) {
writeDescriptor(parent, nodeName, descriptors[i]);
}
| public org.w3c.dom.Node | writeDescriptor(org.w3c.dom.Node parent, java.lang.String nodeName, com.sun.enterprise.deployment.runtime.web.ConstraintField descriptor)write the descriptor class to a DOM tree and return it
Element constraintField = (Element) super.writeDescriptor(parent, nodeName, descriptor);
// value*
String[] values = descriptor.getValue();
for (int i=0;i<values.length;i++) {
Element value = (Element) appendTextChild(constraintField, RuntimeTagNames.CONSTRAINT_FIELD_VALUE, values[i]);
setAttribute(value, RuntimeTagNames.MATCH_EXPR, (String) descriptor.getAttributeValue(ConstraintField.VALUE, i, ConstraintField.MATCH_EXPR));
setAttribute(value, RuntimeTagNames.CACHE_ON_MATCH, (String) descriptor.getAttributeValue(ConstraintField.VALUE, i, ConstraintField.CACHE_ON_MATCH));
setAttribute(value, RuntimeTagNames.CACHE_ON_MATCH_FAILURE, (String) descriptor.getAttributeValue(ConstraintField.VALUE, i, ConstraintField.CACHE_ON_MATCH_FAILURE));
}
// name, scope, cache-on-match, cache-on-match-failure attributes
setAttribute(constraintField, RuntimeTagNames.NAME, (String) descriptor.getAttributeValue(ConstraintField.NAME));
setAttribute(constraintField, RuntimeTagNames.SCOPE, (String) descriptor.getAttributeValue(ConstraintField.SCOPE));
setAttribute(constraintField, RuntimeTagNames.CACHE_ON_MATCH, (String) descriptor.getAttributeValue(ConstraintField.CACHE_ON_MATCH));
setAttribute(constraintField, RuntimeTagNames.CACHE_ON_MATCH_FAILURE, (String) descriptor.getAttributeValue(ConstraintField.CACHE_ON_MATCH_FAILURE));
return constraintField;
|
|