[Sunxacml-commit] sunxacml/com/sun/xacml/attr AttributeSelector.java,1.7,1.8
Brought to you by:
farrukh_najmi,
sethp
From: Seth P. <se...@us...> - 2004-05-12 21:27:31
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17329/com/sun/xacml/attr Modified Files: AttributeSelector.java Log Message: updated to provide namespace mapping node Index: AttributeSelector.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/AttributeSelector.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AttributeSelector.java 6 May 2004 21:10:35 -0000 1.7 --- AttributeSelector.java 12 May 2004 21:27:20 -0000 1.8 *************** *** 81,86 **** private String xpathVersion; /** ! * Creates a new <code>AttributeSelector</code>. * * @param type the data type of the attribute values this selector --- 81,89 ---- private String xpathVersion; + // the policy root, where we get namespace mapping details + private Node policyRoot; + /** ! * Creates a new <code>AttributeSelector</code> with no policy root. * * @param type the data type of the attribute values this selector *************** *** 91,102 **** * XPath version string (the identifier for XPath 1.0 * is provided in <code>AbstractPolicy</code>) - * */ public AttributeSelector(URI type, String contextPath, boolean mustBePresent, String xpathVersion) { this.type = type; this.contextPath = contextPath; this.mustBePresent = mustBePresent; this.xpathVersion = xpathVersion; } --- 94,123 ---- * XPath version string (the identifier for XPath 1.0 * is provided in <code>AbstractPolicy</code>) */ public AttributeSelector(URI type, String contextPath, boolean mustBePresent, String xpathVersion) { + this(type, contextPath, null, mustBePresent, xpathVersion); + } + + /** + * Creates a new <code>AttributeSelector</code>. + * + * @param type the data type of the attribute values this selector + * looks for + * @param contextPath the XPath to query + * @param policyRoot the root DOM Element for the policy containing this + * selector, which defines namespace mappings + * @param mustBePresent must resolution find a match + * @param xpathVersion the XPath version to use, which must be a valid + * XPath version string (the identifier for XPath 1.0 + * is provided in <code>AbstractPolicy</code>) + */ + public AttributeSelector(URI type, String contextPath, Node policyRoot, + boolean mustBePresent, String xpathVersion) { this.type = type; this.contextPath = contextPath; this.mustBePresent = mustBePresent; this.xpathVersion = xpathVersion; + this.policyRoot = policyRoot; } *************** *** 162,167 **** } ! return new AttributeSelector(type, contextPath, mustBePresent, ! xpathVersion); } --- 183,201 ---- } ! // as of 1.2 we need the root element of the policy so we can get ! // the namespace mapping, but in order to leave the APIs unchanged, ! // we'll walk up the tree to find the root rather than pass this ! // element around through all the code ! Node policyRoot = null; ! Node node = root.getParentNode(); ! ! while ((node != null) && (node.getNodeType() == Node.ELEMENT_NODE)) { ! policyRoot = node; ! node = node.getParentNode(); ! } ! ! // create the new selector ! return new AttributeSelector(type, contextPath, policyRoot, ! mustBePresent, xpathVersion); } *************** *** 234,239 **** public EvaluationResult evaluate(EvaluationCtx context) { // query the context ! EvaluationResult result = context.getAttribute(contextPath, type, ! xpathVersion); // see if we got anything --- 268,273 ---- public EvaluationResult evaluate(EvaluationCtx context) { // query the context ! EvaluationResult result = context.getAttribute(contextPath, policyRoot, ! type, xpathVersion); // see if we got anything |