Example usage for org.w3c.dom NamedNodeMap getNamedItem

List of usage examples for org.w3c.dom NamedNodeMap getNamedItem

Introduction

In this page you can find the example usage for org.w3c.dom NamedNodeMap getNamedItem.

Prototype

public Node getNamedItem(String name);

Source Link

Document

Retrieves a node specified by name.

Usage

From source file:org.apache.axis2.description.WSDL11ToAxisServiceBuilder.java

/**
 * Get the Extensible elements form wsdl4jExtensibleElements
 * <code>Vector</code> if any and copy them to <code>Component</code>
 * <p/> Note - SOAP body extensible element will be processed differently
 *
 * @param wsdl4jExtensibleElements//from  w  w w  . ja v a2s. c  om
 * @param description                   where is the ext element (port , portype , biding)
 * @param wsdl4jDefinition
 * @param originOfExtensibilityElements -
 *                                      this will indicate the place this extensibility element came
 *                                      from.
 */
private void copyExtensibleElements(List wsdl4jExtensibleElements, Definition wsdl4jDefinition,
        AxisDescription description, String originOfExtensibilityElements) throws AxisFault {

    ExtensibilityElement wsdl4jExtensibilityElement;

    for (Iterator iterator = wsdl4jExtensibleElements.iterator(); iterator.hasNext();) {

        wsdl4jExtensibilityElement = (ExtensibilityElement) iterator.next();

        if (wsdl4jExtensibilityElement instanceof UnknownExtensibilityElement) {

            UnknownExtensibilityElement unknown = (UnknownExtensibilityElement) (wsdl4jExtensibilityElement);
            QName type = unknown.getElementType();

            // <wsp:Policy>
            if (WSDLConstants.WSDL11Constants.POLICY.equals(type)) {
                if (isTraceEnabled) {
                    log.trace("copyExtensibleElements:: PolicyElement found " + unknown);
                }
                Policy policy = (Policy) PolicyUtil.getPolicyComponent(unknown.getElement());
                description.getPolicySubject().attachPolicy(policy);

                //                    int attachmentScope =
                //                            getPolicyAttachmentPoint(description, originOfExtensibilityElements);
                //                    if (attachmentScope > -1) {
                //                        description.getPolicyInclude().addPolicyElement(
                //                                attachmentScope, policy);
                //                    }
                // <wsp:PolicyReference>
            } else if (WSDLConstants.WSDL11Constants.POLICY_REFERENCE.equals(type)) {
                if (isTraceEnabled) {
                    log.trace("copyExtensibleElements:: PolicyReference found " + unknown);
                }
                PolicyReference policyReference = (PolicyReference) PolicyUtil
                        .getPolicyComponent(unknown.getElement());
                description.getPolicySubject().attachPolicyReference(policyReference);

                //                    int attachmentScope =
                //                            getPolicyAttachmentPoint(description, originOfExtensibilityElements);
                //                    if (attachmentScope > -1) {
                //                        description.getPolicyInclude().addPolicyRefElement(
                //                                attachmentScope, policyReference);
                //                    }
            } else if (AddressingConstants.Final.WSAW_USING_ADDRESSING.equals(type)
                    || AddressingConstants.Submission.WSAW_USING_ADDRESSING.equals(unknown.getElementType())) {
                if (isTraceEnabled) {
                    log.trace("copyExtensibleElements:: wsaw:UsingAddressing found " + unknown);
                }
                // FIXME We need to set this the appropriate Axis Description AxisEndpoint or
                // AxisBinding .
                if (originOfExtensibilityElements.equals(PORT)
                        || originOfExtensibilityElements.equals(BINDING)) {
                    if (Boolean.TRUE.equals(unknown.getRequired())) {
                        AddressingHelper.setAddressingRequirementParemeterValue(axisService,
                                AddressingConstants.ADDRESSING_REQUIRED);
                    } else {
                        AddressingHelper.setAddressingRequirementParemeterValue(axisService,
                                AddressingConstants.ADDRESSING_OPTIONAL);
                    }
                }

            } else if (wsdl4jExtensibilityElement.getElementType() != null
                    && wsdl4jExtensibilityElement.getElementType().getNamespaceURI()
                            .equals(org.apache.axis2.namespace.Constants.FORMAT_BINDING)) {
                Element typeMapping = unknown.getElement();

                NodeList typeMaps = typeMapping
                        .getElementsByTagNameNS(org.apache.axis2.namespace.Constants.FORMAT_BINDING, "typeMap");
                int count = typeMaps.getLength();
                HashMap typeMapper = new HashMap();
                for (int index = 0; index < count; index++) {
                    Node node = typeMaps.item(index);
                    NamedNodeMap attributes = node.getAttributes();
                    Node typeName = attributes.getNamedItem("typeName");

                    if (typeName != null) {
                        String prefix = getPrefix(typeName.getNodeValue());

                        if (prefix != null) {
                            String ns = (String) wsdl4jDefinition.getNamespaces().get(prefix);
                            if (ns != null) {
                                Node formatType = attributes.getNamedItem("formatType");
                                typeMapper.put(new QName(ns, getTypeName(typeName.getNodeValue())),
                                        formatType.getNodeValue());
                            }

                        }
                    }
                }
            } else if (wsdl4jExtensibilityElement.getElementType() != null && wsdl4jExtensibilityElement
                    .getElementType().getNamespaceURI().equals(org.apache.axis2.namespace.Constants.JAVA_NS)) {
                Element unknowJavaElement = unknown.getElement();
                if (unknowJavaElement.getLocalName().equals("address")) {
                    NamedNodeMap nameAttributes = unknowJavaElement.getAttributes();
                    Node node = nameAttributes.getNamedItem("className");
                    Parameter serviceClass = new Parameter();
                    serviceClass.setName("className");
                    serviceClass.setValue(node.getNodeValue());
                    axisService.addParameter(serviceClass);
                    Parameter transportName = new Parameter();
                    transportName.setName("TRANSPORT_NAME");
                    transportName.setValue("java");
                    axisService.addParameter(transportName);
                }
            } else {
                // Ignore this element - it is a totally unknown element
                if (isTraceEnabled) {
                    log.trace("copyExtensibleElements:: Unknown Extensibility Element found " + unknown);
                }
            }

        } else if (wsdl4jExtensibilityElement instanceof SOAP12Address) {
            SOAP12Address soapAddress = (SOAP12Address) wsdl4jExtensibilityElement;
            if (description instanceof AxisEndpoint) {
                setEndpointURL((AxisEndpoint) description, soapAddress.getLocationURI());
            }

        } else if (wsdl4jExtensibilityElement instanceof SOAPAddress) {
            SOAPAddress soapAddress = (SOAPAddress) wsdl4jExtensibilityElement;
            if (description instanceof AxisEndpoint) {
                setEndpointURL((AxisEndpoint) description, soapAddress.getLocationURI());
            }
        } else if (wsdl4jExtensibilityElement instanceof HTTPAddress) {
            HTTPAddress httpAddress = (HTTPAddress) wsdl4jExtensibilityElement;
            if (description instanceof AxisEndpoint) {
                setEndpointURL((AxisEndpoint) description, httpAddress.getLocationURI());
            }

        } else if (wsdl4jExtensibilityElement instanceof Schema) {
            Schema schema = (Schema) wsdl4jExtensibilityElement;
            // just add this schema - no need to worry about the imported
            // ones
            axisService.addSchema(getXMLSchema(schema.getElement(), schema.getDocumentBaseURI()));

        } else if (wsdl4jExtensibilityElement instanceof SOAP12Operation) {
            SOAP12Operation soapOperation = (SOAP12Operation) wsdl4jExtensibilityElement;
            AxisBindingOperation axisBindingOperation = (AxisBindingOperation) description;

            String style = soapOperation.getStyle();
            if (style != null) {
                axisBindingOperation.setProperty(WSDLConstants.WSDL_1_1_STYLE, style);
            }

            String soapActionURI = soapOperation.getSoapActionURI();

            if (this.isCodegen && ((soapActionURI == null) || (soapActionURI.equals("")))) {
                soapActionURI = axisBindingOperation.getAxisOperation().getInputAction();
            }

            if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled())
                log.debug("WSDL Binding Operation: " + axisBindingOperation.getName() + ", SOAPAction: "
                        + soapActionURI);

            if (soapActionURI != null && !soapActionURI.equals("")) {
                axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION, soapActionURI);
                axisBindingOperation.getAxisOperation().setSoapAction(soapActionURI);
                if (!isServerSide) {
                    axisBindingOperation.getAxisOperation().setOutputAction(soapActionURI);
                }

                axisService.mapActionToOperation(soapActionURI, axisBindingOperation.getAxisOperation());
            }

        } else if (wsdl4jExtensibilityElement instanceof SOAPOperation) {
            SOAPOperation soapOperation = (SOAPOperation) wsdl4jExtensibilityElement;
            AxisBindingOperation axisBindingOperation = (AxisBindingOperation) description;

            String style = soapOperation.getStyle();
            if (style != null) {
                axisBindingOperation.setProperty(WSDLConstants.WSDL_1_1_STYLE, style);
            }

            String soapAction = soapOperation.getSoapActionURI();
            if (this.isCodegen && ((soapAction == null) || (soapAction.equals("")))) {
                soapAction = axisBindingOperation.getAxisOperation().getInputAction();
            }

            if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled())
                log.debug("WSDL Binding Operation: " + axisBindingOperation.getName() + ", SOAPAction: "
                        + soapAction);

            if (soapAction != null) {
                axisBindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION, soapAction);
                axisBindingOperation.getAxisOperation().setSoapAction(soapAction);
                if (!isServerSide) {
                    axisBindingOperation.getAxisOperation().setOutputAction(soapAction);
                }

                axisService.mapActionToOperation(soapAction, axisBindingOperation.getAxisOperation());
            }
        } else if (wsdl4jExtensibilityElement instanceof HTTPOperation) {
            HTTPOperation httpOperation = (HTTPOperation) wsdl4jExtensibilityElement;
            AxisBindingOperation axisBindingOperation = (AxisBindingOperation) description;

            String httpLocation = httpOperation.getLocationURI();
            if (httpLocation != null) {
                // change the template to make it same as WSDL 2 template
                httpLocation = httpLocation.replaceAll("\\(", "{");
                httpLocation = httpLocation.replaceAll("\\)", "}");
                axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocation);

            }
            axisBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_INPUT_SERIALIZATION,
                    HTTPConstants.MEDIA_TYPE_TEXT_XML);

        } else if (wsdl4jExtensibilityElement instanceof SOAP12Header) {

            SOAP12Header soapHeader = (SOAP12Header) wsdl4jExtensibilityElement;
            SOAPHeaderMessage headerMessage = new SOAPHeaderMessage();

            headerMessage.setNamespaceURI(soapHeader.getNamespaceURI());
            headerMessage.setUse(soapHeader.getUse());

            Boolean required = soapHeader.getRequired();

            if (required != null) {
                headerMessage.setRequired(required.booleanValue());
            }

            if (wsdl4jDefinition != null) {
                // find the relevant schema part from the messages
                Message msg = wsdl4jDefinition.getMessage(soapHeader.getMessage());

                if (msg == null) {
                    msg = getMessage(wsdl4jDefinition, soapHeader.getMessage(), new HashSet());
                }

                if (msg == null) {
                    // TODO i18n this
                    throw new AxisFault("message " + soapHeader.getMessage() + " not found in the WSDL ");
                }
                Part msgPart = msg.getPart(soapHeader.getPart());

                if (msgPart == null) {
                    // TODO i18n this
                    throw new AxisFault("message part " + soapHeader.getPart() + " not found in the WSDL ");
                }
                // see basic profile 4.4.2 Bindings and Faults header, fault and headerfaults
                // can only have elements
                headerMessage.setElement(msgPart.getElementName());
            }

            headerMessage.setMessage(soapHeader.getMessage());
            headerMessage.setPart(soapHeader.getPart());

            if (description instanceof AxisBindingMessage) {
                AxisBindingMessage bindingMessage = (AxisBindingMessage) description;
                List soapHeaders = (List) bindingMessage.getProperty(WSDL2Constants.ATTR_WSOAP_HEADER);
                if (soapHeaders == null) {
                    soapHeaders = new ArrayList();
                    bindingMessage.setProperty(WSDL2Constants.ATTR_WSOAP_HEADER, soapHeaders);
                }
                soapHeaders.add(headerMessage);
            }

        } else if (wsdl4jExtensibilityElement instanceof SOAPHeader) {

            SOAPHeader soapHeader = (SOAPHeader) wsdl4jExtensibilityElement;
            SOAPHeaderMessage headerMessage = new SOAPHeaderMessage();
            headerMessage.setNamespaceURI(soapHeader.getNamespaceURI());
            headerMessage.setUse(soapHeader.getUse());
            Boolean required = soapHeader.getRequired();
            if (null != required) {
                headerMessage.setRequired(required.booleanValue());
            }
            if (null != wsdl4jDefinition) {
                // find the relevant schema part from the messages
                Message msg = wsdl4jDefinition.getMessage(soapHeader.getMessage());

                if (msg == null) {
                    msg = getMessage(wsdl4jDefinition, soapHeader.getMessage(), new HashSet());
                }

                if (msg == null) {
                    // todo i18n this
                    throw new AxisFault("message " + soapHeader.getMessage() + " not found in the WSDL ");
                }
                Part msgPart = msg.getPart(soapHeader.getPart());
                if (msgPart == null) {
                    // todo i18n this
                    throw new AxisFault("message part " + soapHeader.getPart() + " not found in the WSDL ");
                }
                headerMessage.setElement(msgPart.getElementName());
            }
            headerMessage.setMessage(soapHeader.getMessage());

            headerMessage.setPart(soapHeader.getPart());

            if (description instanceof AxisBindingMessage) {
                AxisBindingMessage bindingMessage = (AxisBindingMessage) description;
                List soapHeaders = (List) bindingMessage.getProperty(WSDL2Constants.ATTR_WSOAP_HEADER);
                if (soapHeaders == null) {
                    soapHeaders = new ArrayList();
                    bindingMessage.setProperty(WSDL2Constants.ATTR_WSOAP_HEADER, soapHeaders);
                }
                soapHeaders.add(headerMessage);
            }
        } else if (wsdl4jExtensibilityElement instanceof SOAPBinding) {

            SOAPBinding soapBinding = (SOAPBinding) wsdl4jExtensibilityElement;
            AxisBinding axisBinding = (AxisBinding) description;

            axisBinding.setType(soapBinding.getTransportURI());

            axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION,
                    SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);

            String style = soapBinding.getStyle();
            if (style != null) {
                axisBinding.setProperty(WSDLConstants.WSDL_1_1_STYLE, style);
            }

        } else if (wsdl4jExtensibilityElement instanceof SOAP12Binding) {

            SOAP12Binding soapBinding = (SOAP12Binding) wsdl4jExtensibilityElement;
            AxisBinding axisBinding = (AxisBinding) description;

            axisBinding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION,
                    SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);

            String style = soapBinding.getStyle();
            if (style != null) {
                axisBinding.setProperty(WSDLConstants.WSDL_1_1_STYLE, style);
            }

            String transportURI = soapBinding.getTransportURI();
            axisBinding.setType(transportURI);

        } else if (wsdl4jExtensibilityElement instanceof HTTPBinding) {
            HTTPBinding httpBinding = (HTTPBinding) wsdl4jExtensibilityElement;
            AxisBinding axisBinding = (AxisBinding) description;
            // set the binding style same as the wsd2 to process smoothly
            axisBinding.setType(WSDL2Constants.URI_WSDL2_HTTP);
            axisBinding.setProperty(WSDL2Constants.ATTR_WHTTP_METHOD, httpBinding.getVerb());
        } else if (wsdl4jExtensibilityElement instanceof MIMEContent) {
            if (description instanceof AxisBindingMessage) {
                MIMEContent mimeContent = (MIMEContent) wsdl4jExtensibilityElement;
                String messageSerialization = mimeContent.getType();
                AxisBindingMessage bindingMessage = (AxisBindingMessage) description;
                setMessageSerialization((AxisBindingOperation) bindingMessage.getParent(),
                        originOfExtensibilityElements, messageSerialization);
            }
        } else if (wsdl4jExtensibilityElement instanceof MIMEMimeXml) {
            if (description instanceof AxisBindingMessage) {
                AxisBindingMessage bindingMessage = (AxisBindingMessage) description;
                setMessageSerialization((AxisBindingOperation) bindingMessage.getParent(),
                        originOfExtensibilityElements, HTTPConstants.MEDIA_TYPE_TEXT_XML);
            }
        } else if (wsdl4jExtensibilityElement instanceof HTTPUrlEncoded) {
            if (description instanceof AxisBindingMessage) {
                AxisBindingMessage bindingMessage = (AxisBindingMessage) description;
                setMessageSerialization((AxisBindingOperation) bindingMessage.getParent(),
                        originOfExtensibilityElements, HTTPConstants.MEDIA_TYPE_X_WWW_FORM);
            }
        }
    }
}

From source file:org.apache.axis2.jaxws.wsdl.impl.SchemaReaderImpl.java

private String readSchemaTargetnamespace(Schema schema) {
    Node root = schema.getElement();
    if (root != null) {
        NamedNodeMap nodeMap = root.getAttributes();
        Node attributeNode = nodeMap.getNamedItem(SCHEMA_TARGETNAMESPACE);
        if (attributeNode != null) {
            return attributeNode.getNodeValue();
        }//from   ww w .ja v a  2 s. c  o  m
    }
    return null;
}

From source file:org.apache.axis2.jaxws.wsdl.impl.SchemaReaderImpl.java

private String readSchemaBindingPackageName(Schema schema) {

    /* JAXB Specification section 7.6 have following important points
       * 1) <schemaBindings> binding declaration have schema scope
       * 2) For inline annotation  a <schemaBindings> is valid only in the annotation element of the <schema> element.
       * 3) There must only be a single instance of <schemaBindings> declaration in the annotation element of the <schema> element.
       *///  ww  w  .ja v a2s. c om

    //Get root node for schema.
    Node root = schema.getElement();
    if (root.hasChildNodes()) {

        //get all child nodes for schema
        NodeList list = root.getChildNodes();

        //search for JAXB schemaBinding customization in schema element definitions.
        for (int i = 0; i < list.getLength(); i++) {
            Node childNode = list.item(i);
            if (isElementName(JAXB_SCHEMA_BINDING, childNode)) {

                //SchemaBinding has been defined, so lets look for package element.
                NodeList schemaBindingNodeList = childNode.getChildNodes();
                for (int j = 0; j < schemaBindingNodeList.getLength(); j++) {
                    Node schemaBindingNode = schemaBindingNodeList.item(j);
                    if (isElementName(JAXB_SCHEMA_BINDING_PACKAGE, schemaBindingNode)) {

                        //Package Element found, so lets read the package name attribute and return that.
                        NamedNodeMap nodeMap = schemaBindingNode.getAttributes();
                        Node attributeNode = nodeMap.getNamedItem(JAXB_SCHEMA_Binding_PACKAGENAME);
                        return attributeNode.getNodeValue();
                    }
                }
            }
        }
    }
    return null;
}

From source file:org.apache.cocoon.bean.helpers.BeanConfigurator.java

private static String getAttributeValue(Node node, String attr) throws IllegalArgumentException {
    NamedNodeMap nodes = node.getAttributes();
    if (nodes != null) {
        Node attribute = nodes.getNamedItem(attr);
        if (attribute != null && attribute.getNodeValue() != null) {
            return attribute.getNodeValue();
        }//w w w. j a va  2  s . co  m
    }
    throw new IllegalArgumentException("Missing " + attr + " attribute on <" + node.getNodeName() + "> node");
}

From source file:org.apache.cocoon.bean.helpers.BeanConfigurator.java

private static boolean hasAttribute(Node node, String attr) {
    NamedNodeMap nodes = node.getAttributes();
    if (nodes != null) {
        Node attribute = nodes.getNamedItem(attr);
        return (attribute != null);
    }/*from www . j  a  v  a  2  s. c  om*/
    return false;
}

From source file:org.apache.cocoon.bean.helpers.BeanConfigurator.java

private static boolean getBooleanAttributeValue(Node node, String attr) {
    NamedNodeMap nodes = node.getAttributes();
    if (nodes != null) {
        Node attribute = nodes.getNamedItem(attr);

        if (attribute != null) {
            String value = attribute.getNodeValue();
            return BooleanUtils.toBoolean(value);
        }//from  w w w  .java2  s .com
    }
    return false;
}

From source file:org.apache.geode.session.tests.ContainerInstall.java

/**
 * Checks to see whether the given XML node has the exact attributes given in the attributes
 * hashmap//w w w .  j a v a 2s .  c  om
 * 
 * @param checkSimilarValues If true, will also check to make sure that the given node's
 *        attributes also have the exact same values as the ones given in the attributes HashMap.
 * @return True if the node has only the attributes the are given by the HashMap (no more and no
 *         less attributes). If {@param checkSimilarValues} is true then only returns true if the
 *         node shares attributes with the given attribute list exactly.
 */
private static boolean nodeHasExactAttributes(Node node, HashMap<String, String> attributes,
        boolean checkSimilarValues) {
    NamedNodeMap nodeAttrs = node.getAttributes();

    // Check to make sure the node has all attribute fields
    for (String key : attributes.keySet()) {
        Node attr = nodeAttrs.getNamedItem(key);
        if (attr == null || (checkSimilarValues && !attr.getTextContent().equals(attributes.get(key)))) {
            return false;
        }
    }

    // Check to make sure the node does not have more than the attribute fields
    for (int i = 0; i < nodeAttrs.getLength(); i++) {
        String attr = nodeAttrs.item(i).getNodeName();
        if (attributes.get(attr) == null
                || (checkSimilarValues && !attributes.get(attr).equals(nodeAttrs.item(i).getTextContent()))) {
            return false;
        }
    }

    return true;
}

From source file:org.apache.hadoop.mapred.QueueConfigurationParser.java

private Queue parseResource(Element queuesNode) {
    Queue rootNode = null;//from w  w w.  j av  a 2  s  .com
    try {
        if (!QUEUES_TAG.equals(queuesNode.getTagName())) {
            LOG.info("Bad conf file: top-level element not <queues>");
            throw new RuntimeException("No queues defined ");
        }
        NamedNodeMap nmp = queuesNode.getAttributes();
        Node acls = nmp.getNamedItem(ACLS_ENABLED_TAG);

        if (acls != null) {
            LOG.warn("Configuring " + ACLS_ENABLED_TAG + " flag in " + QueueManager.QUEUE_CONF_FILE_NAME
                    + " is not valid. " + "This tag is ignored. Configure " + MRConfig.MR_ACLS_ENABLED
                    + " in mapred-site.xml. See the " + " documentation of " + MRConfig.MR_ACLS_ENABLED
                    + ", which is used for enabling job level authorization and "
                    + " queue level authorization.");
        }

        NodeList props = queuesNode.getChildNodes();
        if (props == null || props.getLength() <= 0) {
            LOG.info(" Bad configuration no queues defined ");
            throw new RuntimeException(" No queues defined ");
        }

        //We have root level nodes.
        for (int i = 0; i < props.getLength(); i++) {
            Node propNode = props.item(i);
            if (!(propNode instanceof Element)) {
                continue;
            }

            if (!propNode.getNodeName().equals(QUEUE_TAG)) {
                LOG.info("At root level only \" queue \" tags are allowed ");
                throw new RuntimeException("Malformed xml document no queue defined ");
            }

            Element prop = (Element) propNode;
            //Add children to root.
            Queue q = createHierarchy("", prop);
            if (rootNode == null) {
                rootNode = new Queue();
                rootNode.setName("");
            }
            rootNode.addChild(q);
        }
        return rootNode;
    } catch (DOMException e) {
        LOG.info("Error parsing conf file: " + e);
        throw new RuntimeException(e);
    }
}

From source file:org.apache.hadoop.mapred.QueueConfigurationParser.java

/**
 * Populate the properties for Queue/* w  w  w  . j  av  a2  s.co  m*/
 *
 * @param field
 * @return
 */
private Properties populateProperties(Element field) {
    Properties props = new Properties();

    NodeList propfields = field.getChildNodes();

    for (int i = 0; i < propfields.getLength(); i++) {
        Node prop = propfields.item(i);

        //If this node is not of type element
        //skip this.
        if (!(prop instanceof Element)) {
            continue;
        }

        if (PROPERTY_TAG.equals(prop.getNodeName())) {
            if (prop.hasAttributes()) {
                NamedNodeMap nmp = prop.getAttributes();
                if (nmp.getNamedItem(KEY_TAG) != null && nmp.getNamedItem(VALUE_TAG) != null) {
                    props.setProperty(nmp.getNamedItem(KEY_TAG).getTextContent(),
                            nmp.getNamedItem(VALUE_TAG).getTextContent());
                }
            }
        }
    }
    return props;
}

From source file:org.apache.jackrabbit.core.query.lucene.IndexingConfigurationImpl.java

/**
 * Creates property configurations defined in the <code>config</code>.
 *
 * @param config the fulltext indexing configuration.
 * @param propConfigs will be filled with exact <code>Name</code> to
 *                    <code>PropertyConfig</code> mappings.
 * @param namePatterns will be filled with <code>NamePattern</code>s.
 * @throws IllegalNameException   if the node type name contains illegal
 *                                characters.
 * @throws NamespaceException if the node type contains an unknown
 *                                prefix.
 *///from   w  w  w.j a  v a  2  s  .  c  o  m
private void createPropertyConfigs(Node config, Map<Name, PropertyConfig> propConfigs,
        List<NamePattern> namePatterns) throws IllegalNameException, NamespaceException {
    NodeList childNodes = config.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node n = childNodes.item(i);
        if (n.getNodeName().equals("property")) {
            NamedNodeMap attributes = n.getAttributes();
            // get boost value
            float boost = 1.0f;
            Node boostAttr = attributes.getNamedItem("boost");
            if (boostAttr != null) {
                try {
                    boost = Float.parseFloat(boostAttr.getNodeValue());
                } catch (NumberFormatException e) {
                    // use default
                }
            }

            // get nodeScopeIndex flag
            boolean nodeScopeIndex = true;
            Node nsIndex = attributes.getNamedItem("nodeScopeIndex");
            if (nsIndex != null) {
                nodeScopeIndex = Boolean.valueOf(nsIndex.getNodeValue());
            }

            // get isRegexp flag
            boolean isRegexp = false;
            Node regexp = attributes.getNamedItem("isRegexp");
            if (regexp != null) {
                isRegexp = Boolean.valueOf(regexp.getNodeValue());
            }

            // get useInExcerpt flag
            boolean useInExcerpt = true;
            Node excerpt = attributes.getNamedItem("useInExcerpt");
            if (excerpt != null) {
                useInExcerpt = Boolean.valueOf(excerpt.getNodeValue());
            }

            PropertyConfig pc = new PropertyConfig(boost, nodeScopeIndex, useInExcerpt);

            if (isRegexp) {
                namePatterns.add(new NamePattern(getTextContent(n), pc, resolver));
            } else {
                Name propName = resolver.getQName(getTextContent(n));
                propConfigs.put(propName, pc);
            }
        }
    }
}