| <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>OptimizePartsBuilder.java</title><link rel="stylesheet" href="../.resources/prettify.css" type="text/css"/><script type="text/javascript" src="../.resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="right"><a href="../.sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Coverage Report</a> > <a href="index.html" class="el_package">org.apache.rampart.policy.builders</a> > <span class="el_source">OptimizePartsBuilder.java</span></div><h1>OptimizePartsBuilder.java</h1><pre class="source lang-java linenums">/* |
| * Copyright 2001-2004 The Apache Software Foundation. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| package org.apache.rampart.policy.builders; |
| |
| import java.util.Iterator; |
| |
| import javax.xml.namespace.QName; |
| |
| import org.apache.axiom.om.OMElement; |
| import org.apache.neethi.Assertion; |
| import org.apache.neethi.AssertionBuilderFactory; |
| import org.apache.neethi.builders.AssertionBuilder; |
| import org.apache.rampart.policy.model.OptimizePartsConfig; |
| import org.apache.rampart.policy.model.RampartConfig; |
| |
| /** |
| * OptimizePartsBuilder creates the OptimizePartsConfig |
| * |
| * This clase deserialize the following XML fragment inside the RampartConfig. |
| * Example |
| <pre> |
| &lt;ramp:optimizeParts&gt;<br /> |
| &lt;ramp:expressions&gt;<br /> |
| &lt;ramp:expression&gt;//ns1:data1&lt;/ramp:expression&gt;<br /> |
| &lt;ramp:expression&gt;//ns2:data2&lt;/ramp:expression&gt;<br /> |
| &lt;/ramp:expressions&gt;<br /> |
| &nbsp;&lt;ramp:namespaces&gt;<br /> |
| &lt;nampespace uri="http://test1.com" prefix="ns1"/&gt;<br /> |
| &lt;nampespace uri="http://test2.com" prefix="ns2"/&gt;<br /> |
| &lt;/ramp:namespaces&gt;<br /> |
| &lt;/ramp:optimizeParts&gt; |
| </pre> |
| * @see OptimizePartsConfig |
| */ |
| <span class="nc" id="L48">public class OptimizePartsBuilder implements AssertionBuilder<OMElement> {</span> |
| |
| public Assertion build(OMElement element, AssertionBuilderFactory factory) throws IllegalArgumentException { |
| <span class="nc" id="L51"> OptimizePartsConfig assertion = new OptimizePartsConfig();</span> |
| <span class="nc" id="L52"> OMElement expressionsElem = element.getFirstChildWithName(new QName(RampartConfig.NS, OptimizePartsConfig.EXPRESSIONS_LN));</span> |
| |
| <span class="nc bnc" id="L54" title="All 2 branches missed."> if(expressionsElem != null){</span> |
| <span class="nc" id="L55"> Iterator iterator = expressionsElem.getChildElements();</span> |
| <span class="nc bnc" id="L56" title="All 2 branches missed."> while(iterator.hasNext()){</span> |
| <span class="nc" id="L57"> OMElement elem = (OMElement)iterator.next();</span> |
| <span class="nc" id="L58"> String expression = elem.getText();</span> |
| <span class="nc" id="L59"> assertion.addExpression(expression);</span> |
| <span class="nc" id="L60"> }</span> |
| |
| } |
| |
| <span class="nc" id="L64"> OMElement nsElem = element.getFirstChildWithName(new QName(RampartConfig.NS, OptimizePartsConfig.NAMESPACES_LN));</span> |
| <span class="nc bnc" id="L65" title="All 2 branches missed."> if(nsElem != null){</span> |
| <span class="nc" id="L66"> Iterator iterator = nsElem.getChildElements();</span> |
| <span class="nc bnc" id="L67" title="All 2 branches missed."> while(iterator.hasNext()){</span> |
| <span class="nc" id="L68"> OMElement elem = (OMElement)iterator.next();</span> |
| <span class="nc" id="L69"> String namespace = elem.getText();</span> |
| <span class="nc" id="L70"> String prefix = elem.getAttributeValue(new QName("", OptimizePartsConfig.PREFIX_ATTR));</span> |
| <span class="nc" id="L71"> String uri = elem.getAttributeValue(new QName("", OptimizePartsConfig.URI_ATTR));</span> |
| <span class="nc" id="L72"> assertion.addNamespaces(prefix, uri);</span> |
| <span class="nc" id="L73"> }</span> |
| |
| } |
| <span class="nc" id="L76"> return assertion;</span> |
| } |
| |
| public QName[] getKnownElements() { |
| <span class="nc" id="L80"> return new QName[] {new QName(RampartConfig.NS, OptimizePartsConfig.OPTIMIZE_PARTS_LN)};</span> |
| } |
| |
| } |
| </pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.6.1.201212231917</span></div></body></html> |