Java Code Examples for org.w3c.dom.Element.getChildNodes()

The following are Jave code examples for showing how to use getChildNodes() of the org.w3c.dom.Element class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: kaltura-ce-sakai-extension   File: KalturaPartnerUsageListResponse.java   View Source Code Vote up 6 votes
public KalturaPartnerUsageListResponse(Element node) throws KalturaApiException {
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("total")) {
            this.total = ParseUtils.parseObject(KalturaVarPartnerUsageItem.class, aNode);
            continue;
        } else if (nodeName.equals("objects")) {
            this.objects = ParseUtils.parseArray(KalturaVarPartnerUsageItem.class, aNode);
            continue;
        } else if (nodeName.equals("totalCount")) {
            this.totalCount = ParseUtils.parseInt(txt);
            continue;
        } 
    }
}
 
Example 2
Project: convertigo-engine   File: XSDExtractor.java   View Source Code Vote up 6 votes
protected void parse(Element element) {
	if (XMLUtils.findChildNode(element, Node.ELEMENT_NODE) != null) {
		this.type = ELEMENT_COMPLEX_TYPE;
	}
	else if (element.hasAttributes()) {
		this.type = ELEMENT_COMPLEX_TYPE;
	}
	else {
		this.type = ELEMENT_SIMPLE_TYPE;
		this.value = element.getTextContent().trim();
	}
	
	NamedNodeMap map = element.getAttributes();
	for (int i=0; i<map.getLength(); i++) {
		add(map.item(i));
	}
	
	NodeList list = element.getChildNodes();
	for (int i=0; i<list.getLength(); i++) {
		add(list.item(i));
	}
}
 
Example 3
Project: kaltura-ce-sakai-extension   File: KalturaYahooSyndicationFeed.java   View Source Code Vote up 6 votes
public KalturaYahooSyndicationFeed(Element node) throws KalturaApiException {
    super(node);
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("category")) {
            this.category = KalturaYahooSyndicationFeedCategories.get(ParseUtils.parseString(txt));
            continue;
        } else if (nodeName.equals("adultContent")) {
            this.adultContent = KalturaYahooSyndicationFeedAdultValues.get(ParseUtils.parseString(txt));
            continue;
        } else if (nodeName.equals("feedDescription")) {
            this.feedDescription = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("feedLandingPage")) {
            this.feedLandingPage = ParseUtils.parseString(txt);
            continue;
        } 
    }
}
 
Example 4
Project: TuLiPA-frames   File: XMLTTMCTAGReader.java   View Source Code Vote up 5 votes
public static SemLit getDom(Element e, NameFactory nf) {
    SemLit sem = new SemDom();

    int argnum = 1;
    NodeList l = e.getChildNodes();
    for (int i = 0; i < l.getLength(); i++) {
        Node n = l.item(i);

        if (n.getNodeType() == Node.ELEMENT_NODE) {
            Element el = (Element) n;
            if (el.getTagName().equals("sym")) {
                Value semval = getSingleValue(el, nf);
                switch (argnum) {
                case 1:
                    ((SemDom) sem).setArg1(semval);
                    argnum++;
                    break;
                case 2:
                    ((SemDom) sem).setArg2(semval);
                    argnum++;
                    break;
                default:// skip
                }
            }
        }
    }

    return sem;
}
 
Example 5
Project: kaltura-ce-sakai-extension   File: KalturaIndexAdvancedFilter.java   View Source Code Vote up 5 votes
public KalturaIndexAdvancedFilter(Element node) throws KalturaApiException {
    super(node);
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("indexIdGreaterThan")) {
            this.indexIdGreaterThan = ParseUtils.parseInt(txt);
            continue;
        } 
    }
}
 
Example 6
Project: kaltura-ce-sakai-extension   File: KalturaAccessControl.java   View Source Code Vote up 5 votes
public KalturaAccessControl(Element node) throws KalturaApiException {
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("id")) {
            this.id = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("partnerId")) {
            this.partnerId = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("name")) {
            this.name = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("systemName")) {
            this.systemName = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("description")) {
            this.description = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("createdAt")) {
            this.createdAt = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("isDefault")) {
            this.isDefault = KalturaNullableBoolean.get(ParseUtils.parseInt(txt));
            continue;
        } else if (nodeName.equals("restrictions")) {
            this.restrictions = ParseUtils.parseArray(KalturaBaseRestriction.class, aNode);
            continue;
        } else if (nodeName.equals("containsUnsuportedRestrictions")) {
            this.containsUnsuportedRestrictions = ParseUtils.parseBool(txt);
            continue;
        } 
    }
}
 
Example 7
Project: openjdk-jdk10   File: DOMUtils.java   View Source Code Vote up 5 votes
/** Gets the fist child of the given name, or null. */
public static Element getFirstChildElement( Element parent, String nsUri, String localPart ) {
    NodeList children = parent.getChildNodes();
    for( int i=0; i<children.getLength(); i++ ) {
        Node item = children.item(i);
        if(!(item instanceof Element ))     continue;

        if(nsUri.equals(item.getNamespaceURI())
        && localPart.equals(item.getLocalName()) )
            return (Element)item;
    }
    return null;
}
 
Example 8
Project: xtf   File: PomModifier.java   View Source Code Vote up 5 votes
private List<Element> childElements(final Element parentNode, final String elementName) {
	final List<Element> ret = new ArrayList<>();
	final NodeList nodes = parentNode.getChildNodes(); 
	for (int i = 0; i < nodes.getLength(); i++) {
		if (nodes.item(i).getNodeType() != Node.ELEMENT_NODE) {
			continue;
		}
		final Element element = (Element)nodes.item(i);
		if (elementName.equals(element.getTagName())) {
			ret.add(element);
		}
	}
	return ret;
}
 
Example 9
Project: kaltura-ce-sakai-extension   File: KalturaThumbParamsBaseFilter.java   View Source Code Vote up 5 votes
public KalturaThumbParamsBaseFilter(Element node) throws KalturaApiException {
    super(node);
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("formatEqual")) {
            this.formatEqual = KalturaContainerFormat.get(ParseUtils.parseString(txt));
            continue;
        } 
    }
}
 
Example 10
Project: kaltura-ce-sakai-extension   File: KalturaConvartableJobData.java   View Source Code Vote up 5 votes
public KalturaConvartableJobData(Element node) throws KalturaApiException {
    super(node);
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("srcFileSyncLocalPath")) {
            this.srcFileSyncLocalPath = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("actualSrcFileSyncLocalPath")) {
            this.actualSrcFileSyncLocalPath = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("srcFileSyncRemoteUrl")) {
            this.srcFileSyncRemoteUrl = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("engineVersion")) {
            this.engineVersion = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("flavorParamsOutputId")) {
            this.flavorParamsOutputId = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("flavorParamsOutput")) {
            this.flavorParamsOutput = ParseUtils.parseObject(KalturaFlavorParamsOutput.class, aNode);
            continue;
        } else if (nodeName.equals("mediaInfoId")) {
            this.mediaInfoId = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("currentOperationSet")) {
            this.currentOperationSet = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("currentOperationIndex")) {
            this.currentOperationIndex = ParseUtils.parseInt(txt);
            continue;
        } 
    }
}
 
Example 11
Project: Java-APIs   File: DisplayName.java   View Source Code Vote up 5 votes
protected DisplayName(Element element) {
	logger.debug("Constructor - entry");

	NodeList nodeList = element.getChildNodes();
	for (int n = 0; n < nodeList.getLength(); n++) {
		Node node = nodeList.item(n);
		if (node.getNodeType() == Node.ELEMENT_NODE) {
			Element childElement = (Element) node;
			logger.trace("Unrecognized child node: '"
					+ childElement.getNodeName() + "' ("
					+ this.getClass().getName() + ")");
		} else if (node.getNodeType() == Node.TEXT_NODE) {
			this.setValue(node.getNodeValue());
		}
	}

	NamedNodeMap namedNodeMap = element.getAttributes();
	if (namedNodeMap != null) {
		for (int a = 0; a < namedNodeMap.getLength(); a++) {
			Attr attributeNode = (Attr) namedNodeMap.item(a);
			if ("NPT".equals(attributeNode.getName())) {
				setMatchOnNPT("1".equals(attributeNode.getValue()));
			} else {
				logger.trace("Unrecognized attribute: '" + attributeNode.getName() + "' (" + this.getClass().getName() + ")");
			}
		}
	}

	logger.debug("Constructor - exit");
}
 
Example 12
Project: kaltura-ce-sakai-extension   File: KalturaUserRole.java   View Source Code Vote up 5 votes
public KalturaUserRole(Element node) throws KalturaApiException {
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("id")) {
            this.id = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("name")) {
            this.name = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("description")) {
            this.description = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("status")) {
            this.status = KalturaUserRoleStatus.get(ParseUtils.parseInt(txt));
            continue;
        } else if (nodeName.equals("partnerId")) {
            this.partnerId = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("permissionNames")) {
            this.permissionNames = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("tags")) {
            this.tags = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("createdAt")) {
            this.createdAt = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("updatedAt")) {
            this.updatedAt = ParseUtils.parseInt(txt);
            continue;
        } 
    }
}
 
Example 13
Project: ats-framework   File: ConfigurationResource.java   View Source Code Vote up 5 votes
/**
 * This method will read a tree of elements and their attributes
 * 
 * @param element the root element of the tree
 */
private void readXmlElement(
                             LinkedList<String> currentElementPath,
                             Element element ) {

    //append this node element to the current path
    currentElementPath.add(element.getNodeName());

    NodeList childNodes = element.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node childNode = childNodes.item(i);
        if (childNode.getNodeType() == Node.ELEMENT_NODE) {
            readXmlElement(currentElementPath, (Element) childNode);
        }
    }

    //read all attributes
    NamedNodeMap attributes = element.getAttributes();
    for (int i = 0; i < attributes.getLength(); i++) {
        Attr attribute = (Attr) attributes.item(i);

        String propertyName = getCurrentXmlElementPath(currentElementPath) + attribute.getName();
        String propertyValue = attribute.getValue();

        //put in the properties table
        properties.put(propertyName, propertyValue);

        log.debug("Added property with name '" + propertyName + "' and value '" + propertyValue + "'");
    }

    //after we are done with the node, remove it from the path
    currentElementPath.removeLast();
}
 
Example 14
Project: convertigo-engine   File: LogStep.java   View Source Code Vote up 5 votes
@Override
public void configure(Element element) throws Exception {
	super.configure(element);
	
	String version = element.getAttribute("version");
       
	if (version == null) {
		String s = XMLUtils.prettyPrintDOM(element);
		EngineException ee = new EngineException("Unable to find version number for the database object \"" + getName() + "\".\nXML data: " + s);
		throw ee;
	}

	if (VersionUtils.compare(version, "4.6.0") < 0) {
		NodeList properties = element.getElementsByTagName("property");
		Element propValue = (Element) XMLUtils.findNodeByAttributeValue(properties, "name", "level");

		Node xmlNode = null;
		NodeList nl = propValue.getChildNodes();
		int len_nl = nl.getLength();
		for (int j = 0 ; j < len_nl ; j++) {
			xmlNode = nl.item(j);
			if (xmlNode.getNodeType() == Node.ELEMENT_NODE) {
				String sLevel = (String) XMLUtils.readObjectFromXml((Element) xmlNode);
				if (sLevel.equals("warning")) setLevel(Level.WARN.toString());
				else if (sLevel.equals("message")) setLevel(Level.INFO.toString());
				else if (sLevel.equals("debug")) setLevel(Level.DEBUG.toString());
				else if (sLevel.equals("debug2")) setLevel(Level.TRACE.toString());
				else if (sLevel.equals("debug3")) setLevel(Level.TRACE.toString());
				continue;
			}
		}
		
		hasChanged = true;
		Engine.logBeans.warn("(Transaction) The object \"" + getName() + "\" has been updated to version 4.6.0");
	}		
}
 
Example 15
Project: kaltura-ce-sakai-extension   File: KalturaAmazonS3StorageProfile.java   View Source Code Vote up 5 votes
public KalturaAmazonS3StorageProfile(Element node) throws KalturaApiException {
    super(node);
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("filesPermissionInS3")) {
            this.filesPermissionInS3 = KalturaAmazonS3StorageProfileFilesPermissionLevel.get(ParseUtils.parseString(txt));
            continue;
        } 
    }
}
 
Example 16
Project: kaltura-ce-sakai-extension   File: KalturaAssetResource.java   View Source Code Vote up 5 votes
public KalturaAssetResource(Element node) throws KalturaApiException {
    super(node);
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("assetId")) {
            this.assetId = ParseUtils.parseString(txt);
            continue;
        } 
    }
}
 
Example 17
Project: kaltura-ce-sakai-extension   File: KalturaFilter.java   View Source Code Vote up 5 votes
public KalturaFilter(Element node) throws KalturaApiException {
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("orderBy")) {
            this.orderBy = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("advancedSearch")) {
            this.advancedSearch = ParseUtils.parseObject(KalturaSearchItem.class, aNode);
            continue;
        } 
    }
}
 
Example 18
Project: kaltura-ce-sakai-extension   File: KalturaMetadata.java   View Source Code Vote up 4 votes
public KalturaMetadata(Element node) throws KalturaApiException {
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("id")) {
            this.id = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("partnerId")) {
            this.partnerId = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("metadataProfileId")) {
            this.metadataProfileId = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("metadataProfileVersion")) {
            this.metadataProfileVersion = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("metadataObjectType")) {
            this.metadataObjectType = KalturaMetadataObjectType.get(ParseUtils.parseString(txt));
            continue;
        } else if (nodeName.equals("objectId")) {
            this.objectId = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("version")) {
            this.version = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("createdAt")) {
            this.createdAt = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("updatedAt")) {
            this.updatedAt = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("status")) {
            this.status = KalturaMetadataStatus.get(ParseUtils.parseInt(txt));
            continue;
        } else if (nodeName.equals("xml")) {
            this.xml = ParseUtils.parseString(txt);
            continue;
        } 
    }
}
 
Example 19
Project: hadoop   File: QueueConfigurationParser.java   View Source Code Vote up 4 votes
private Queue parseResource(Element queuesNode) {
  Queue rootNode = null;
  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);
  }
}
 
Example 20
Project: kaltura-ce-sakai-extension   File: KalturaWidget.java   View Source Code Vote up 4 votes
public KalturaWidget(Element node) throws KalturaApiException {
    NodeList childNodes = node.getChildNodes();
    for (int i = 0; i < childNodes.getLength(); i++) {
        Node aNode = childNodes.item(i);
        String nodeName = aNode.getNodeName();
        String txt = aNode.getTextContent();
        if (nodeName.equals("id")) {
            this.id = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("sourceWidgetId")) {
            this.sourceWidgetId = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("rootWidgetId")) {
            this.rootWidgetId = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("partnerId")) {
            this.partnerId = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("entryId")) {
            this.entryId = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("uiConfId")) {
            this.uiConfId = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("securityType")) {
            this.securityType = KalturaWidgetSecurityType.get(ParseUtils.parseInt(txt));
            continue;
        } else if (nodeName.equals("securityPolicy")) {
            this.securityPolicy = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("createdAt")) {
            this.createdAt = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("updatedAt")) {
            this.updatedAt = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("partnerData")) {
            this.partnerData = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("widgetHTML")) {
            this.widgetHTML = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("enforceEntitlement")) {
            this.enforceEntitlement = ParseUtils.parseBool(txt);
            continue;
        } else if (nodeName.equals("privacyContext")) {
            this.privacyContext = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("addEmbedHtml5Support")) {
            this.addEmbedHtml5Support = ParseUtils.parseBool(txt);
            continue;
        } 
    }
}