Package org.jdom.xpath

Examples of org.jdom.xpath.XPath$XPathString


      if(dom == null) {
        continue;
      }
      ToolInfo toolInfo = result.getTool().getToolInfo();
      try {
        XPath xpath = XPath.newInstance("//fits:"+element.getName());
        xpath.addNamespace("fits",Fits.XML_NAMESPACE);
        Element e = (Element)xpath.selectSingleNode(dom);
        if(e != null) {
          e.setAttribute("toolname",toolInfo.getName());
          e.setAttribute("toolversion",toolInfo.getVersion());
          fitsElements.add(e);
          e.getParent().removeContent(e);
View Full Code Here


     * @throws JDOMException if elements cannot be parsed correctly
     */
    public boolean isConstrained( String url, Role role ) throws JDOMException
    {
        Element root = m_webxml.getRootElement();
        XPath xpath;
        String selector;

        // Get all constraints that have our URL pattern
        // (Note the crazy j: prefix to denote the 2.4 j2ee schema)
        selector = "//j:web-app/j:security-constraint[j:web-resource-collection/j:url-pattern=\"" + url + "\"]";
        xpath = XPath.newInstance( selector );
        xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
        List<?> constraints = xpath.selectNodes( root );

        // Get all constraints that match our Role pattern
        selector = "//j:web-app/j:security-constraint[j:auth-constraint/j:role-name=\"" + role.getName() + "\"]";
        xpath = XPath.newInstance( selector );
        xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
        List<?> roles = xpath.selectNodes( root );

        // If we can't find either one, we must not be constrained
        if ( constraints.size() == 0 )
        {
            return false;
View Full Code Here

        Set<Role> roles = new HashSet<Role>();
        Element root = webxml.getRootElement();

        // Get roles referred to by constraints
        String selector = "//j:web-app/j:security-constraint/j:auth-constraint/j:role-name";
        XPath xpath = XPath.newInstance( selector );
        xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
        List<?> nodes = xpath.selectNodes( root );
        for( Iterator<?> it = nodes.iterator(); it.hasNext(); )
        {
            String role = ( (Element) it.next() ).getTextTrim();
            roles.add( new Role( role ) );
        }

        // Get all defined roles
        selector = "//j:web-app/j:security-role/j:role-name";
        xpath = XPath.newInstance( selector );
        xpath.addNamespace( "j", J2EE_SCHEMA_24_NAMESPACE );
        nodes = xpath.selectNodes( root );
        for( Iterator<?> it = nodes.iterator(); it.hasNext(); )
        {
            String role = ( (Element) it.next() ).getTextTrim();
            roles.add( new Role( role ) );
        }
View Full Code Here

        try {
            SAXBuilder builder = new SAXBuilder();
            Document doc = builder.build(rep.getStream());
            Map map = new HashMap();

            XPath passwordPath = XPath.newInstance("/html/body/ul/li/span");
            XPath rolePath = XPath.newInstance("/html/body/ul/li/ul/li");
            Element passwordObj = (Element) passwordPath.selectSingleNode(doc);
            List roleObjs = rolePath.selectNodes(doc);
            List roles = new ArrayList();

            map.put("password", passwordObj.getText());

            Iterator it = roleObjs.iterator();
View Full Code Here

    public Map readRepresentation(Representation rep) {
        try {
            SAXBuilder builder = new SAXBuilder();
            Document doc = builder.build(rep.getStream());
            Map map = new HashMap();
            XPath passwordPath = XPath.newInstance("/user/password");
            XPath rolePath = XPath.newInstance("/user/roles/role/@name");
            Element passwordObj = (Element) passwordPath.selectSingleNode(doc);
            List roleObjs = rolePath.selectNodes(doc);
            List roles = new ArrayList();

            Iterator it = roleObjs.iterator();

            while (it.hasNext()) {
View Full Code Here

        if (_minInstances != null) {
            return _minInstances.intValue();
        }
        Number result = null;
        try {
            XPath xpath = XPath.newInstance(_minInstancesQuery);
            result = (Number) xpath.selectSingleNode(_myTask._net.getInternalDataDocument());
        } catch (JDOMException e) {
            e.printStackTrace();
        } catch (ClassCastException e) {
            throw new RuntimeException("The minInstances query at " + _myTask
                    + " didn't produce numerical output as excepted.");
View Full Code Here

        if (_maxInstances != null) {
            return _maxInstances.intValue();
        }
        Number result = null;
        try {
            XPath xpath = XPath.newInstance(_maxInstancesQuery);
            result = (Number) xpath.selectSingleNode(_myTask._net.getInternalDataDocument());
        } catch (JDOMException e) {
            e.printStackTrace();
        } catch (ClassCastException e) {
            throw new RuntimeException("The maxInstances query at " + _myTask
                    + " didn't produce numerical output as excepted.");
View Full Code Here

        if (_threshold != null) {
            return _threshold.intValue();
        }
        Number result = null;
        try {
            XPath xpath = XPath.newInstance(_thresholdQuery);
            result = (Number) xpath.selectSingleNode(_myTask._net.getInternalDataDocument());
        } catch (JDOMException e) {
            e.printStackTrace();
        } catch (ClassCastException e) {
            throw new RuntimeException("The threshold query at " + _myTask
                    + " didn't produce numerical output as excepted.");
View Full Code Here

            if (flow.isDefaultFlow()) {
                ((YCondition) flow.getNextElement()).add(pmgr, tokenToSend);
                return;
            }
            try {
                XPath xpath = XPath.newInstance("boolean(" + flow.getXpathPredicate() + ")");
                Boolean result = (Boolean) xpath.selectSingleNode(_net.getInternalDataDocument());
                if (result.booleanValue()) {
                    ((YCondition) flow.getNextElement()).add(pmgr, tokenToSend);
                    return;
                }
            } catch (JDOMException e) {
View Full Code Here

        Collections.sort(flows);
        YFlow flow;
        for (int i = 0; i < flows.size(); i++) {
            flow = (YFlow) flows.get(i);
            try {
                XPath xpath = XPath.newInstance("boolean(" + flow.getXpathPredicate() + ")");
                Boolean result = (Boolean) xpath.selectSingleNode(_net.getInternalDataDocument());
                if (result.booleanValue()) {
                    ((YCondition) flow.getNextElement()).add(pmgr, tokenToSend);
                    noTokensOutputted = false;
                }
            } catch (JDOMException e) {
View Full Code Here

TOP

Related Classes of org.jdom.xpath.XPath$XPathString

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.