Java Code Examples for org.w3c.dom.Element

The following are top voted examples for showing how to use org.w3c.dom.Element. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: kaltura-ce-sakai-extension   File: KalturaRule.java   View source code 10 votes vote down vote up
public KalturaRule(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("message")) {
            this.message = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("actions")) {
            this.actions = ParseUtils.parseArray(KalturaAccessControlAction.class, aNode);
            continue;
        } else if (nodeName.equals("conditions")) {
            this.conditions = ParseUtils.parseArray(KalturaCondition.class, aNode);
            continue;
        } else if (nodeName.equals("contexts")) {
            this.contexts = ParseUtils.parseArray(KalturaAccessControlContextTypeHolder.class, aNode);
            continue;
        } else if (nodeName.equals("stopProcessing")) {
            this.stopProcessing = ParseUtils.parseBool(txt);
            continue;
        } 
    }
}
 
Example 2
Project: dble   File: XMLRuleLoader.java   View source code 7 votes vote down vote up
/**
 * tableRule tag:
 * <tableRule name="sharding-by-month">
 * <rule>
 * <columns>create_date</columns>
 * <algorithm>partbymonth</algorithm>
 * </rule>
 * </tableRule>
 *
 * @param root
 * @throws SQLSyntaxErrorException
 */
private void loadTableRules(Element root) throws SQLSyntaxErrorException {
    NodeList list = root.getElementsByTagName("tableRule");
    for (int i = 0, n = list.getLength(); i < n; ++i) {
        Node node = list.item(i);
        if (node instanceof Element) {
            Element e = (Element) node;
            String name = e.getAttribute("name");
            if (StringUtil.isEmpty(name)) {
                throw new ConfigException("name is null or empty");
            }
            if (tableRules.containsKey(name)) {
                throw new ConfigException("table rule " + name + " duplicated!");
            }
            NodeList ruleNodes = e.getElementsByTagName("rule");
            int length = ruleNodes.getLength();
            if (length > 1) {
                throw new ConfigException("only one rule can defined :" + name);
            }
            //rule has only one element now. Maybe it will not contains one rule in feature
            //RuleConfig:rule->function
            RuleConfig rule = loadRule((Element) ruleNodes.item(0));
            tableRules.put(name, new TableRuleConfig(name, rule));
        }
    }
}
 
Example 3
Project: OpenJSharp   File: Util.java   View source code 7 votes vote down vote up
public static Element nextElement(Iterator iter) {
    while (iter.hasNext()) {
        Node n = (Node) iter.next();
        if (n instanceof Text) {
            Text t = (Text) n;
            if (t.getData().trim().length() == 0)
                continue;
            fail("parsing.nonWhitespaceTextFound", t.getData().trim());
        }
        if (n instanceof Comment)
            continue;
        if (!(n instanceof Element))
            fail("parsing.elementExpected");
        return (Element) n;
    }

    return null;
}
 
Example 4
Project: kaltura-ce-sakai-extension   File: KalturaSessionService.java   View source code 6 votes vote down vote up
/**  Start a session with Kaltura's server.   The result KS is the session key that
you should pass to all services that requires a ticket.     */
 public String start(String secret, String userId, KalturaSessionType type, int partnerId, int expiry, String privileges) throws KalturaApiException {
     KalturaParams kparams = new KalturaParams();
     kparams.add("secret", secret);
     kparams.add("userId", userId);
     kparams.add("type", type);
     kparams.add("partnerId", partnerId);
     kparams.add("expiry", expiry);
     kparams.add("privileges", privileges);
     this.kalturaClient.queueServiceCall("session", "start", kparams);
     if (this.kalturaClient.isMultiRequest())
         return null;
     Element resultXmlElement = this.kalturaClient.doQueue();
     String resultText = resultXmlElement.getTextContent();
     return ParseUtils.parseString(resultText);
 }
 
Example 5
Project: rapidminer   File: ParameterTypeTupel.java   View source code 6 votes vote down vote up
@Override
protected void writeDefinitionToXML(Element typeElement) {

	Element childTypesElement = XMLTools.addTag(typeElement, ELEMENT_CHILD_TYPES);
	for (ParameterType type : types) {
		Element childTypeElement = XMLTools.addTag(childTypesElement, ELEMENT_CHILD_TYPE);
		type.writeDefinitionToXML(childTypeElement);
	}

	// now default list
	Element defaultEntriesElement = XMLTools.addTag(typeElement, ELEMENT_DEFAULT_ENTRIES);
	for (Object defaultValue : defaultValues) {
		Element defaultEntryElement = XMLTools.addTag(defaultEntriesElement, ELEMENT_DEFAULT_ENTRY);
		if (defaultValue != null && defaultValue instanceof String) {
			defaultEntryElement.setTextContent(defaultValue.toString());
		} else {
			defaultEntriesElement.setAttribute(ATTRIBUTE_IS_NULL, "true");
		}
	}
}
 
Example 6
Project: pay   File: XMLParser.java   View source code 6 votes vote down vote up
public static Map<String,Object> getMapFromXML(String xmlString) throws ParserConfigurationException, IOException, SAXException {

        //这里用Dom的方式解析回包的最主要目的是防止API新增回包字段
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        InputStream is =  IOUtils.toInputStream(xmlString);
        Document document = builder.parse(is);
        //获取到document里面的全部结点
        NodeList allNodes = document.getFirstChild().getChildNodes();
        Node node;
        Map<String, Object> map = new HashMap<String, Object>();
        int i=0;
        while (i < allNodes.getLength()) {
            node = allNodes.item(i);
            if(node instanceof Element){
                map.put(node.getNodeName(),node.getTextContent());
            }
            i++;
        }
        return map;

    }
 
Example 7
Project: ChronoBike   File: CEntityResourceForm.java   View source code 6 votes vote down vote up
/**
 * @param root
 */
public void ExportCustomProperties(Document doc)
{
	Element eForm = doc.getDocumentElement() ;
	if (!m_csCustomOnloadMethod.equals(""))
	{
		eForm.setAttribute("customOnload", m_csCustomOnloadMethod) ;
	}
	if (!m_csCustomSubmitMethod.equals(""))
	{
		eForm.setAttribute("customSubmit", m_csCustomSubmitMethod) ;
	}
	if (!m_csDefaultCursor.equals(""))
	{
		eForm.setAttribute("defaultCursor", m_csDefaultCursor) ;
	}
}
 
Example 8
Project: kaltura-ce-sakai-extension   File: KalturaCountryRestriction.java   View source code 6 votes vote down vote up
public KalturaCountryRestriction(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("countryRestrictionType")) {
            this.countryRestrictionType = KalturaCountryRestrictionType.get(ParseUtils.parseInt(txt));
            continue;
        } else if (nodeName.equals("countryList")) {
            this.countryList = ParseUtils.parseString(txt);
            continue;
        } 
    }
}
 
Example 9
Project: kaltura-ce-sakai-extension   File: KalturaConversionAttribute.java   View source code 6 votes vote down vote up
public KalturaConversionAttribute(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("flavorParamsId")) {
            this.flavorParamsId = ParseUtils.parseInt(txt);
            continue;
        } else if (nodeName.equals("name")) {
            this.name = ParseUtils.parseString(txt);
            continue;
        } else if (nodeName.equals("value")) {
            this.value = ParseUtils.parseString(txt);
            continue;
        } 
    }
}
 
Example 10
Project: ibench   File: XSDReader.java   View source code 6 votes vote down vote up
private Schema visitRoot(Node root, String nameSchema){
	Schema s = new Schema(nameSchema);
	types = new SetAssociativeArray();
	dummyNr = 0;
	//process the complexType nodes under the schema node
	NodeList children = root.getChildNodes();
	int nr=children.getLength();
	for(int j=0; j<nr; j++){
		if (children.item(j).getNodeName().equalsIgnoreCase("xs:complexType")){
			Node nodeCT = children.item(j);
			String name = getAttr("name",nodeCT);
			vtools.dataModel.schema.Element eCT = processComplexTypeNode(nodeCT,name,false);
			types.add(eCT.getLabel(), eCT.getType().clone());
		}	
	}
	//process the element nodes under the schema node
	for(int j=0; j<nr; j++){
		if (children.item(j).getNodeName().equalsIgnoreCase("xs:element")){
			vtools.dataModel.schema.Element elem = processElementNode(children.item(j));
			s.addRootElement(elem);
		}
	}
	
	return s;
}
 
Example 11
Project: springboot-shiro-cas-mybatis   File: AbstractMetadataResolverAdapter.java   View source code 6 votes vote down vote up
/**
 * Build single metadata resolver.
 *
 * @param metadataFilterChain the metadata filters chained together
 * @param resource the resource
 * @param document the xml document to parse
 * @return list of resolved metadata from resources.
 * @throws IOException the iO exception
 */
private List<MetadataResolver> buildSingleMetadataResolver(final MetadataFilter metadataFilterChain,
                                         final Resource resource, final Document document) throws IOException {
    final List<MetadataResolver> resolvers = new ArrayList<>();
    final Element metadataRoot = document.getDocumentElement();
    final DOMMetadataResolver metadataProvider = new DOMMetadataResolver(metadataRoot);

    metadataProvider.setParserPool(this.configBean.getParserPool());
    metadataProvider.setFailFastInitialization(true);
    metadataProvider.setRequireValidMetadata(this.requireValidMetadata);
    metadataProvider.setId(metadataProvider.getClass().getCanonicalName());
    if (metadataFilterChain != null) {
        metadataProvider.setMetadataFilter(metadataFilterChain);
    }
    logger.debug("Initializing metadata resolver for [{}]", resource.getURL());

    try {
        metadataProvider.initialize();
    } catch (final ComponentInitializationException ex) {
        logger.warn("Could not initialize metadata resolver. Resource will be ignored", ex);
    }
    resolvers.add(metadataProvider);
    return resolvers;
}
 
Example 12
Project: jdk8u-jdk   File: DOMExcC14NMethod.java   View source code 6 votes vote down vote up
private void unmarshalParams(Element paramsElem) {
    String prefixListAttr = paramsElem.getAttributeNS(null, "PrefixList");
    this.inclusiveNamespaces = prefixListAttr;
    int begin = 0;
    int end = prefixListAttr.indexOf(' ');
    List<String> prefixList = new ArrayList<String>();
    while (end != -1) {
        prefixList.add(prefixListAttr.substring(begin, end));
        begin = end + 1;
        end = prefixListAttr.indexOf(' ', begin);
    }
    if (begin <= prefixListAttr.length()) {
        prefixList.add(prefixListAttr.substring(begin));
    }
    this.params = new ExcC14NParameterSpec(prefixList);
}
 
Example 13
Project: bdf2   File: ProcessDefinition.java   View source code 6 votes vote down vote up
@Override
public Element parseModel(Document doc){
	Element process=doc.createElement("process");
	if(StringHelper.isNotEmpty(name)){
		process.setAttribute("name", name);
	}
	process.setAttribute("xmlns", "http://jbpm.org/4.4/jpdl");
	if(StringHelper.isNotEmpty(key)){
		process.setAttribute("key", key);
	}
	if(StringHelper.isNotEmpty(version)){
		process.setAttribute("version", version);
	}
	if(StringHelper.isNotEmpty(description)){
		Element desc=doc.createElement("description");
		desc.setTextContent(description);
		process.appendChild(desc);
	}
	return process;
}
 
Example 14
Project: incubator-netbeans   File: XMLUtil.java   View source code 6 votes vote down vote up
/**
 * Find all direct child elements of an element.
 * More useful than {@link Element#getElementsByTagNameNS} because it does
 * not recurse into recursive child elements.
 * Children which are all-whitespace text nodes or comments are ignored; others cause
 * an exception to be thrown.
 * @param parent a parent element in a DOM tree
 * @return a list of direct child elements (may be empty)
 * @throws IllegalArgumentException if there are non-element children besides whitespace
 */
static List<Element> findSubElements(Element parent) throws IllegalArgumentException {
    NodeList l = parent.getChildNodes();
    List<Element> elements = new ArrayList<>(l.getLength());
    for (int i = 0; i < l.getLength(); i++) {
        Node n = l.item(i);
        if (n.getNodeType() == Node.ELEMENT_NODE) {
            elements.add((Element)n);
        } else if (n.getNodeType() == Node.TEXT_NODE) {
            String text = ((Text)n).getNodeValue();
            if (text.trim().length() > 0) {
                throw new IllegalArgumentException("non-ws text encountered in " + parent + ": " + text); // NOI18N
            }
        } else if (n.getNodeType() == Node.COMMENT_NODE) {
            // OK, ignore
        } else {
            throw new IllegalArgumentException("unexpected non-element child of " + parent + ": " + n); // NOI18N
        }
    }
    return elements;
}
 
Example 15
Project: cuttlefish   File: GraphMLExporter.java   View source code 6 votes vote down vote up
private Element createGraphElement(Element root) {
	Element graphEl = doc.createElement("graph");
	root.appendChild(graphEl);

	if (network.getEdgeCount(true) > network.getEdgeCount(false)) {
		graphEl.setAttribute("edgedefault", "directed");
	} else {
		graphEl.setAttribute("edgedefault", "undirected");
	}

	// Create nodes
	createNodes(graphEl);

	// Create edges
	createEdges(graphEl);

	return graphEl;
}
 
Example 16
Project: incubator-netbeans   File: ShortcutWizard.java   View source code 6 votes vote down vote up
ShortcutWizard(AntProjectCookie project, Element target, ShortcutIterator it) {
    this.project = project;
    this.target = target;
    this.it = it;
    it.initialize(this);
    setPanelsAndSettings(it, this);
    setTitle(NbBundle.getMessage(ShortcutWizard.class, "TITLE_wizard"));
    putProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, Boolean.TRUE); // NOI18N
    putProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, Boolean.TRUE); // NOI18N
    putProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, Boolean.TRUE); // NOI18N
    String desc = target.getAttribute("description"); // NOI18n
    putProperty(PROP_DISPLAY_NAME, desc);
    // XXX deal with toolbar short desc somehow: #39985
    // Need to have another field in toolbar panel, and also patch AntActionInstance
    // to respond to Action.SHORT_DESCRIPTION, presumably as the <description>.
}
 
Example 17
Project: EspressoViews   File: QueryDefinitionParser.java   View source code 6 votes vote down vote up
public static void addConnectionDetailsToDefFile(String filePath, Map<String,String> connDet ){
	Document doc = getXmlDocument(filePath);
	Element newConnection= doc.createElement("DBConnectionDefinition");
	newConnection.appendChild(doc.createElement("connectionName"));
		newConnection.getLastChild().appendChild(doc.createTextNode(connDet.get("CONNECTIONNAME")));
	newConnection.appendChild(doc.createElement("connectionType"));
		newConnection.getLastChild().appendChild(doc.createTextNode(connDet.get("CONNECTIONTYPE")));		
	newConnection.appendChild(doc.createElement("dbType"));
		newConnection.getLastChild().appendChild(doc.createTextNode(connDet.get("DBTYPE")));
	newConnection.appendChild(doc.createElement("serviceName"));
		newConnection.getLastChild().appendChild(doc.createTextNode(connDet.get("SERVICENAME")));
	newConnection.appendChild(doc.createElement("host"));
		newConnection.getLastChild().appendChild(doc.createTextNode(connDet.get("HOST")));
	newConnection.appendChild(doc.createElement("userName"));
		newConnection.getLastChild().appendChild(doc.createTextNode(connDet.get("USERNAME")));
	
	getElementByTagName(doc,"DBConnectionDefinition").getParentNode().appendChild(newConnection); 	
	//getElementByTagName(doc,"ROOT").appendChild(newConnection);	
	storeXmlDocToFile(filePath, doc);		
	showMeTheDoc(newConnection, 1);
}
 
Example 18
Project: incubator-netbeans   File: TestUtilTest.java   View source code 6 votes vote down vote up
public void testCreateCompletion() throws Exception {
    HintContext c = TestUtil.createCompletion("<fooHERE/>");
    assertHintContext(c, Node.ELEMENT_NODE, "foo", null, "foo");
    assertTrue("right type acc. to instanceof", c instanceof Element);
    c = TestUtil.createCompletion("<foo/>");
    assertNull("no hint here", c);
    c = TestUtil.createCompletion("<foo><barHERE/></foo>");
    assertHintContext(c, Node.ELEMENT_NODE, "bar", null, "bar");
    Node n = c.getParentNode();
    assertEquals("parent is an element", Node.ELEMENT_NODE, n.getNodeType());
    assertEquals("parent is <foo>", "foo", n.getNodeName());
    c = TestUtil.createCompletion("<foo><bar attrHERE='whatever'/></foo>");
    assertHintContext(c, Node.ATTRIBUTE_NODE, "attr", null, "attr");
    Element owner = ((Attr)c).getOwnerElement();
    assertEquals("parent is <bar>", "bar", owner.getNodeName());
    c = TestUtil.createCompletion("<foo><bar attr='somethingHERE'/></foo>");
    assertHintContext(c, Node.ATTRIBUTE_NODE, null, "something", "something");
    owner = ((Attr)c).getOwnerElement();
    assertEquals("parent is <bar>", "bar", owner.getNodeName());
    c = TestUtil.createCompletion("<foo>somethingHERE</foo>");
    assertHintContext(c, Node.TEXT_NODE, null, "something", "something");
    n = c.getParentNode();
    assertEquals("parent is an element", Node.ELEMENT_NODE, n.getNodeType());
    assertEquals("parent is <foo>", "foo", n.getNodeName());
}
 
Example 19
Project: incubator-netbeans   File: CslJar.java   View source code 6 votes vote down vote up
private List<Element> getAttributeElements(Document doc, String path) {
    Element parent = findPath(doc, path);

    List<Element> attributes = new ArrayList<Element>();

    if (parent != null) {
        for (Element f : getElementChildren(parent)) {
            String tag = f.getTagName();
            if (ATTR.equals(tag)) { // NOI18N
                attributes.add(f);
            }
        }
    }

    return attributes;
}
 
Example 20
Project: openjdk-jdk10   File: ElementImpl.java   View source code 6 votes vote down vote up
/**
 * @see <a
 * href="http://www.w3.org/TR/2008/REC-ElementTraversal-20081222/#attribute-lastElementChild">
 * Element Traversal Specification</a>
 */
@Override
public final Element getLastElementChild() {
    Node n = getLastChild();
    while (n != null) {
        switch (n.getNodeType()) {
            case Node.ELEMENT_NODE:
                return (Element) n;
            case Node.ENTITY_REFERENCE_NODE:
                final Element e = getLastElementChild(n);
                if (e != null) {
                    return e;
                }
                break;
        }
        n = n.getPreviousSibling();
    }
    return null;
}
 
Example 21
Project: Proyecto-DASI   File: ReadXMLTestRobots.java   View source code 5 votes vote down vote up
private String getRobotCoordinateZ(Element info, String tagcoordinate, String tagdimension){
      String valuez = "";        
NodeList coordinateNmElmntLst = info.getElementsByTagName(tagcoordinate);
Node coordinateNode = coordinateNmElmntLst.item(0);
if (coordinateNode.getNodeType() == Node.ELEMENT_NODE){
 Element coorInfo = (Element) coordinateNode;			  			  
 //Obtain information about z coordinate for the current robot 
 NodeList zNmElmntLst = coorInfo.getElementsByTagName(tagdimension);
 Element zNmElmnt = (Element) zNmElmntLst.item(0);
 NodeList zNm = zNmElmnt.getChildNodes();					  
 valuez = ((Node)zNm.item(0)).getNodeValue();				  
}
return valuez;
}
 
Example 22
Project: oscm   File: MigrationBillingSharesResultOperatorRevShare.java   View source code 5 votes vote down vote up
private void migrateOperatorRevenueAttribute(Element element) {
    if (!element
            .hasAttribute(BillingShareResultXmlTags.ATTRIBUTE_NAME_OPERATOR_REVENUE)) {
        element.setAttribute(
                BillingShareResultXmlTags.ATTRIBUTE_NAME_OPERATOR_REVENUE,
                "0.00");
    }
}
 
Example 23
Project: kaltura-ce-sakai-extension   File: KalturaEntryDistributionService.java   View source code 5 votes vote down vote up
/**  Add new Entry Distribution     */
public KalturaEntryDistribution add(KalturaEntryDistribution entryDistribution) throws KalturaApiException {
    KalturaParams kparams = new KalturaParams();
    kparams.add("entryDistribution", entryDistribution);
    this.kalturaClient.queueServiceCall("contentdistribution_entrydistribution", "add", kparams);
    if (this.kalturaClient.isMultiRequest())
        return null;
    Element resultXmlElement = this.kalturaClient.doQueue();
    return ParseUtils.parseObject(KalturaEntryDistribution.class, resultXmlElement);
}
 
Example 24
Project: ciguan   File: ConfigurationTest.java   View source code 5 votes vote down vote up
private static Class<?> ensureType(String pType, Element pSource) {
	Class<?> tType = cObjectTypes.get(pType);
	if (tType != null) {
		return tType;
	}
	if (pType.endsWith("_list")) {
		pType = pType.replace("_list", "");
		if (cAsList.containsKey(pType)) {
			tType = Object.class;
		}
	}
	if (pType.endsWith("[]")) {
		pType = pType.replace("[]", "");
	}
	if (tType == null && pType.startsWith("com.")) {
		cObjectTypes.put(pType, tType = find(pType));
	}
	else if (tType == null) {
		int tPos = pType.indexOf(":");
		String tSimpleName = pType.substring(tPos + 1);
		String tNamespace = tPos == -1 ? "" : pType.substring(0, tPos);
		for (Map.Entry<String, String> tPackage : cSearchPackages.entrySet()) {
			if (tNamespace.equals(tPackage.getValue())) {
				tType = find(tPackage.getKey() + "." + tSimpleName);
				if (tType != null) {
					cObjectTypes.put(pType, tType);
					break;
				}
			}
		}
	}
	if (tType == null) {
		error("Type not found: " + pType, pSource);
	}
	return tType;
}
 
Example 25
Project: incubator-netbeans   File: AnnotationProcessingQueryImpl.java   View source code 5 votes vote down vote up
public @Override Set<? extends Trigger> annotationProcessingEnabled() {
    Set<Trigger> result = triggerCache;
    if (result != null) {
        return result;
    }
    result = EnumSet.noneOf(Trigger.class);
    if (ap != null) {
        for (Element e : XMLUtil.findSubElements(ap)) {
            if (e.getLocalName().equals(EL_SCAN_TRIGGER)) {
                result.add(Trigger.ON_SCAN);
            } else if (e.getLocalName().equals(EL_EDITOR_TRIGGER)) {
                result.add(Trigger.IN_EDITOR);
            }
        }
    }
    if (result.size() == 1 && result.contains(Trigger.IN_EDITOR)) {
        //Contains only editor-trigger
        //Add required scan-trigger and log
        result.add(Trigger.ON_SCAN);
        LOG.log(
            Level.WARNING, 
            "Project {0} project.xml contains annotation processing editor-trigger only. The scan-trigger is required as well, adding it into the APQ.Result.", //NOI18N
            FileUtil.getFileDisplayName(helper.getProjectDirectory()));
    }
    synchronized (LCK) {
        if (triggerCache == null) {
            triggerCache = result;
        }
    }
    return result;
}
 
Example 26
Project: QN-ACTR-Release   File: JabaModel.java   View source code 5 votes vote down vote up
private Element makeSolutionElement(Document root) {
	//TODO: non sono compresi i risultati aggregati (quelli che prendo sono giusti?? gli aggregati sono gli ultimi??)
	Element result_element = root.createElement("solutions");
	result_element.setAttribute("ok", "true");
	result_element.setAttribute("solutionMethod", "analytical");
	for (int i = 0; i < stations; i++) {
		Element stationresults_element = (Element) result_element.appendChild(root.createElement("stationresults"));
		stationresults_element.setAttribute("station", this.stationNames[i]);
		for (int j = 0; j < classes; j++) {
			Element classesresults_element = (Element) stationresults_element.appendChild(root.createElement("classresults"));
			classesresults_element.setAttribute("customerclass", classNames[j]);

			Element Q_element = (Element) classesresults_element.appendChild(root.createElement("measure"));
			Q_element.setAttribute("measureType", "Queue length");
			Q_element.setAttribute("successful", "true");
			Q_element.setAttribute("meanValue", Double.toString(this.queueLen[i][j]));

			Element X_element = (Element) classesresults_element.appendChild(root.createElement("measure"));
			X_element.setAttribute("measureType", "Throughput");
			X_element.setAttribute("successful", "true");
			X_element.setAttribute("meanValue", Double.toString(this.throughput[i][j]));

			Element R_element = (Element) classesresults_element.appendChild(root.createElement("measure"));
			R_element.setAttribute("measureType", "Response time");
			R_element.setAttribute("successful", "true");
			R_element.setAttribute("meanValue", Double.toString(this.resTimes[i][j]));

			Element U_element = (Element) classesresults_element.appendChild(root.createElement("measure"));
			U_element.setAttribute("measureType", "Utilization");
			U_element.setAttribute("successful", "true");
			U_element.setAttribute("meanValue", Double.toString(this.util[i][j]));
		}
	}
	return result_element;
}
 
Example 27
Project: Equella   File: OAIProtocol.java   View source code 5 votes vote down vote up
protected void processMetadataToLO(Object o, PropBagEx xml)
{
	PropBagEx element = new PropBagEx((Element) o);
	try
	{
		String xsltName = getProfile().getAttribute("schemaInputTransform"); //$NON-NLS-1$
		if( xsltName != null && !xsltName.isEmpty() )
		{
			xml.append("item/oai", element); //$NON-NLS-1$

			LOGGER.info(CurrentLocale.get(KEY_PFX + "log.transform.before")); //$NON-NLS-1$
			LOGGER.info(xml.toString());

			xml.setXML(transformSchema(xml, xsltName));

			LOGGER.info(CurrentLocale.get(KEY_PFX + "log.transform.after")); //$NON-NLS-1$
			LOGGER.info(xml.toString());
		}
		else
		{
			new OAIDublinCore().processMetadataToLO(element, xml);
		}
	}
	catch( Exception e )
	{
		e.printStackTrace();
		throw new RuntimeException(e);
	}
}
 
Example 28
Project: lams   File: AttributeValueTypeMarshaller.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallElementContent(XMLObject xmlObject, Element domElement) throws MarshallingException {
    AttributeValueType attributeValue = (AttributeValueType) xmlObject;
    
    if(attributeValue.getValue() != null){
        XMLHelper.appendTextContent(domElement, attributeValue.getValue());
    }
}
 
Example 29
Project: Lagerta   File: KeyValuePersistenceSettingsRegistry.java   View source code 5 votes vote down vote up
/**
 * Parses xml from String.
 *
 * @param xml String containing xml.
 * @return XML DOM element.
 */
private static Element parse(String xml) {
    try {
        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        return builder.parse(new InputSource(new StringReader(xml))).getDocumentElement();
    }
    catch (Throwable e) {
        throw new IllegalArgumentException("Failed to parse persistence settings:" +
            SystemHelper.LINE_SEPARATOR + xml, e);
    }
}
 
Example 30
Project: jdk8u-jdk   File: XMLSignature.java   View source code 5 votes vote down vote up
/**
 * Returns the KeyInfo child. If we are in signing mode and the KeyInfo
 * does not exist yet, it is created on demand and added to the Signature.
 * <br>
 * This allows to add arbitrary content to the KeyInfo during signing.
 *
 * @return the KeyInfo object
 */
public KeyInfo getKeyInfo() {
    // check to see if we are signing and if we have to create a keyinfo
    if (this.state == MODE_SIGN && this.keyInfo == null) {

        // create the KeyInfo
        this.keyInfo = new KeyInfo(this.doc);

        // get the Element from KeyInfo
        Element keyInfoElement = this.keyInfo.getElement();
        Element firstObject =
            XMLUtils.selectDsNode(
                this.constructionElement.getFirstChild(), Constants._TAG_OBJECT, 0
            );

        if (firstObject != null) {
            // add it before the object
            this.constructionElement.insertBefore(keyInfoElement, firstObject);
            XMLUtils.addReturnBeforeChild(this.constructionElement, firstObject);
        } else {
            // add it as the last element to the signature
            this.constructionElement.appendChild(keyInfoElement);
            XMLUtils.addReturnToElement(this.constructionElement);
        }
    }

    return this.keyInfo;
}
 
Example 31
Project: OpenJSharp   File: DOMKeyValue.java   View source code 5 votes vote down vote up
public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
    throws MarshalException
{
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    // create KeyValue element
    Element kvElem = DOMUtils.createElement(ownerDoc, "KeyValue",
                                            XMLSignature.XMLNS, dsPrefix);
    marshalPublicKey(kvElem, ownerDoc, dsPrefix, context);

    parent.appendChild(kvElem);
}
 
Example 32
Project: verify-hub   File: ExecuteAttributeQueryRequestTest.java   View source code 5 votes vote down vote up
@Test
public void run_shouldCallInboundMessageValidatorWithAttributeQuery() throws Exception {
    when(attributeQueryRequestClient.sendQuery(any(Element.class), anyString(), any(SessionId.class), any(URI.class))).thenReturn(matchingServiceResponse);
    Response response = aResponse().build();
    when(elementToResponseTransformer.apply(matchingServiceResponse)).thenReturn(response);

    executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto);

    verify(matchingRequestSignatureValidator).validate(attributeQuery, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
}
 
Example 33
Project: kaltura-ce-sakai-extension   File: KalturaPartnerService.java   View source code 5 votes vote down vote up
/**  Create a new Partner object     */
public KalturaPartner register(KalturaPartner partner, String cmsPassword, int templatePartnerId) throws KalturaApiException {
    KalturaParams kparams = new KalturaParams();
    kparams.add("partner", partner);
    kparams.add("cmsPassword", cmsPassword);
    kparams.add("templatePartnerId", templatePartnerId);
    this.kalturaClient.queueServiceCall("partner", "register", kparams);
    if (this.kalturaClient.isMultiRequest())
        return null;
    Element resultXmlElement = this.kalturaClient.doQueue();
    return ParseUtils.parseObject(KalturaPartner.class, resultXmlElement);
}
 
Example 34
Project: jdk8u-jdk   File: XMLCipher.java   View source code 5 votes vote down vote up
Element toElement() {
    Element result =
        XMLUtils.createElementInEncryptionSpace(
            contextDocument, EncryptionConstants._TAG_CIPHERDATA
        );
    if (cipherType == VALUE_TYPE) {
        result.appendChild(((CipherValueImpl) cipherValue).toElement());
    } else if (cipherType == REFERENCE_TYPE) {
        result.appendChild(((CipherReferenceImpl) cipherReference).toElement());
    }

    return result;
}
 
Example 35
Project: OpenJSharp   File: XSDHandler.java   View source code 5 votes vote down vote up
/**
 * Extract location information from an Element node, and create a
 * new SimpleLocator object from such information. Returning null means
 * no information can be retrieved from the element.
 */
public SimpleLocator element2Locator(Element e) {
    if (!( e instanceof ElementImpl))
        return null;

    SimpleLocator l = new SimpleLocator();
    return element2Locator(e, l) ? l : null;
}
 
Example 36
Project: openjdk-jdk10   File: SCDBasedBindingSet.java   View source code 5 votes vote down vote up
private Target(Target parent, Element src, SCD scd) {
    if(parent==null) {
        this.nextSibling = topLevel;
        topLevel = this;
    } else {
        this.nextSibling = parent.firstChild;
        parent.firstChild = this;
    }
    this.src = src;
    this.scd = scd;
}
 
Example 37
Project: lams   File: PasswordMarshaller.java   View source code 5 votes vote down vote up
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
    Password password = (Password) xmlObject;
    if (!DatatypeHelper.isEmpty(password.getType())) {
        domElement.setAttributeNS(null, Password.TYPE_ATTRIB_NAME, password.getType());
    }
    super.marshallAttributes(xmlObject, domElement);
}
 
Example 38
Project: bohemia   File: XmlUtils.java   View source code 5 votes vote down vote up
/** 
 * Sets the namespace to specific element. 
 * 
 * @param element the element to set 
 * @param namespace the namespace to set 
 * @param schemaLocation the XML schema file location URI 
 */  
public static void setNamespace(Element element, String namespace,  
        String schemaLocation) {  
    element.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,  
            XMLConstants.XMLNS_ATTRIBUTE, namespace);  
    element.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLNS_XSI,  
            XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);  
    element.setAttributeNS(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI,  
            XSI_SCHEMA_LOCATION, schemaLocation);  
}
 
Example 39
Project: convertigo-engine   File: ComparableFieldElement.java   View source code 5 votes vote down vote up
public static int getLine(Element fieldElement) throws ClassCastException {
	int line = -1;
	String fieldName = fieldElement.getAttribute("name");
	if (fieldName.indexOf(Parameter.JavelinField.getName()) != 0)
		throw new ClassCastException("[ComparableFieldElement] The object trying to be compared with is not a ComparableFieldElement.");
	String ln = fieldName.substring(fieldName.indexOf("l", 8)+1);
	line = Integer.parseInt(ln);
	return line;
}
 
Example 40
Project: incubator-netbeans   File: RatReportTask.java   View source code 5 votes vote down vote up
private void doPopulateUnapproved(Map<String, ModuleInfo> moduleRATInfo, Element rootElement, XPath path) throws XPathExpressionException {
    NodeList evaluate = (NodeList) path.evaluate("descendant::resource[license-approval/@name=\"false\"]", rootElement, XPathConstants.NODESET);
    for (int i = 0; i < evaluate.getLength(); i++) {
        String resources = relativize(evaluate.item(i).getAttributes().getNamedItem("name").getTextContent());
        String moduleName = getModuleName(resources);
        if (!moduleRATInfo.containsKey(moduleName)) {
            moduleRATInfo.get(NOT_CLUSTER).addUnapproved(resources);
        } else {
            moduleRATInfo.get(moduleName).addUnapproved(resources);
        }
    }
}