• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DefaultAttribute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.dom4j.tree.DefaultAttribute的典型用法代码示例。如果您正苦于以下问题:Java DefaultAttribute类的具体用法?Java DefaultAttribute怎么用?Java DefaultAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DefaultAttribute类属于org.dom4j.tree包,在下文中一共展示了DefaultAttribute类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getXmlValueText

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
private Object getXmlValueText(List nodes) {
    if (nodes == null || nodes.isEmpty()) {
        return null;
    }
    Object node = nodes.get(0);
    if (node instanceof DefaultText) {
        return StringUtils.trim(((DefaultText) node).getText());
    }
    if (node instanceof DefaultAttribute) {
        return StringUtils.trim(((DefaultAttribute) node).getText());
    }
    if (node instanceof DefaultElement) {
        return StringUtils.trim(((DefaultElement) node).getText());
    }

    throw new IllegalArgumentException("unsupported node type ["+node+"].");
}
 
开发者ID:brucezee,项目名称:jspider,代码行数:18,代码来源:XmlParser.java


示例2: addRelations

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
public void addRelations(List<RelationsContainer> relationsContainerList){
	try {
		for (int i = 0; i < relationsContainerList.size(); i++) {
			RelationsContainer relationsContainer = relationsContainerList.get(i);
			List<?> nodeList = relationsContainer.getNodeList();
			Records records = (Records)bygleService.getObject(Records.class,relationsContainer.getIdRecord());
			for (Iterator<?> iterator = nodeList.iterator(); iterator.hasNext();) {
				DefaultAttribute defaultAttribute = (DefaultAttribute)iterator.next();
				Records relatedRecord = getRecords(defaultAttribute.getStringValue());
				if(relatedRecord!=null){
					addRelation(records, relatedRecord, defaultAttribute);
				}
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:regestaexe,项目名称:bygle-ldp,代码行数:19,代码来源:RelationsService.java


示例3: addRelation

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
private void addRelation(Records records,Records relatedRecord,DefaultAttribute defaultAttribute){
	try {
		RelationTypes relationTypes = getRelationTypes(defaultAttribute.getParent().getNamespace().getPrefix()+":"+defaultAttribute.getParent().getName());
		DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Relations.class);
		detachedCriteria.add(Restrictions.eq("relationTypes",relationTypes));
		detachedCriteria.add(Restrictions.disjunction().add(Restrictions.eq("recordsByRefIdRecord1", records)).add(Restrictions.eq("recordsByRefIdRecord2", relatedRecord)));
		detachedCriteria.add(Restrictions.disjunction().add(Restrictions.eq("recordsByRefIdRecord1",relatedRecord)).add(Restrictions.eq("recordsByRefIdRecord2", records)));
		List<?> relationList = bygleService.getList(detachedCriteria);
		if(relationList.size()==0){
			RelationsId relationsId = new RelationsId(records.getIdRecord(), relatedRecord.getIdRecord(), relationTypes.getIdRelationType());
			Relations relations = new Relations(relationsId, records, relatedRecord, relationTypes);
			bygleService.add(relations);
		}
	}catch (HibernateException e) {
		e.printStackTrace();
	}
}
 
开发者ID:regestaexe,项目名称:bygle-ldp,代码行数:18,代码来源:RelationsService.java


示例4: removeRelation

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
private void removeRelation(Records records,Records relatedRecord,DefaultAttribute defaultAttribute){
	try {
		RelationTypes relationTypes = getRelationTypes(defaultAttribute.getParent().getNamespace().getPrefix()+":"+defaultAttribute.getParent().getName());
		DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Relations.class);
		detachedCriteria.add(Restrictions.eq("relationTypes",relationTypes));
		detachedCriteria.add(Restrictions.disjunction().add(Restrictions.eq("recordsByRefIdRecord1",records)).add(Restrictions.eq("recordsByRefIdRecord2", relatedRecord)));
		detachedCriteria.add(Restrictions.disjunction().add(Restrictions.eq("recordsByRefIdRecord1",relatedRecord)).add(Restrictions.eq("recordsByRefIdRecord2", records)));
		List<?> relationList = bygleService.getList(detachedCriteria);
		if(relationList.size()!=0){
			Relations relations = (Relations)relationList.get(0);
			bygleService.remove(relations);
		}
	}catch (HibernateException e) {
		e.printStackTrace();
	}
}
 
开发者ID:regestaexe,项目名称:bygle-ldp,代码行数:17,代码来源:RelationsService.java


示例5: testNamespaceNodesAreInherited

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
public void testNamespaceNodesAreInherited() throws JaxenException
{
        Namespace ns0 = Namespace.get("p0", "www.acme0.org");
        Namespace ns1 = Namespace.get("p1", "www.acme1.org");
        Namespace ns2 = Namespace.get("p2", "www.acme2.org");
        Element element = new DefaultElement("test", ns1);
        Attribute attribute = new DefaultAttribute("pre:foo", "bar", ns2);
        element.add(attribute);
        Element root = new DefaultElement("root", ns0);
        root.add(element);
        Document doc = new DefaultDocument(root);
        
        XPath xpath = new Dom4jXPath( "/*/*/namespace::node()" );

        List results = xpath.selectNodes( doc );

        assertEquals( 4,
                      results.size() );
}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:20,代码来源:DOM4JXPathTest.java


示例6: buildDocument

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
/**
 * @param doc
 */
public void buildDocument(final DefaultDocument doc) {
    // Manifest is the root-node of the document, therefore we need to pass the
    // "doc"
    final DefaultElement manifestElement = new DefaultElement(CPCore.MANIFEST);

    manifestElement.add(new DefaultAttribute(CPCore.IDENTIFIER, this.identifier));
    manifestElement.add(new DefaultAttribute(CPCore.SCHEMALOCATION, this.schemaLocation));
    // manifestElement.setNamespace(this.getNamespace()); //FIXME: namespace

    doc.add(manifestElement);

    if (metadata != null) {
        metadata.buildDocument(manifestElement);
    }
    organizations.buildDocument(manifestElement);
    resources.buildDocument(manifestElement);

}
 
开发者ID:huihoo,项目名称:olat,代码行数:22,代码来源:CPManifest.java


示例7: sendRosterToComponent

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
private void sendRosterToComponent(IQ requestPacket, Collection<RosterItem> items, String subdomain) {

        IQ response = IQ.createResultIQ(requestPacket);
        response.setTo(subdomain);
        Element query = new DefaultElement( QName.get("query","jabber:iq:roster"));
        for (RosterItem i : items) {
            String jid = i.getJid().toString();
            if (!jid.equals(subdomain) && jid.contains(subdomain)) {
                Log.debug("Roster exchange for external component " + subdomain + ". Sending user " + i.getJid().toString());
                Element item = new DefaultElement("item", null);
                item.add(new DefaultAttribute("jid", i.getJid().toString()));
                item.add(new DefaultAttribute("name", i.getNickname()));
                item.add(new DefaultAttribute("subscription", "both"));
                for (String s : i.getGroups()) {
                    Element group = new DefaultElement("group");
                    group.setText(s);
                    item.add(group);
                }
                query.add(item);
            }
        }
        response.setChildElement(query);
        dispatchPacket(response);
    }
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:25,代码来源:IQRosterPayloadProcessor.java


示例8: sendRosterToComponent

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
private void sendRosterToComponent(IQ requestPacket, Collection<RosterItem> items, String subdomain) {

		IQ response = IQ.createResultIQ(requestPacket);
		response.setTo(subdomain);
		Element query = new DefaultElement("query");
		for (RosterItem i : items) {
			String jid = i.getJid().toString();
			if (!jid.equals(subdomain) && jid.contains(subdomain)) {
				Log.debug("Roster exchange for external component " + subdomain + ". Sending user " + i.getJid().toString());
				Element item = new DefaultElement("item", null);
				item.add(new DefaultAttribute("jid", i.getJid().toString()));
				item.add(new DefaultAttribute("name", i.getNickname()));
				item.add(new DefaultAttribute("subscription", "both"));
				for (String s : i.getGroups()) {
					Element group = new DefaultElement("group");
					group.setText(s);
					item.add(group);
				}
				query.add(item);
			}
		}
		query.addNamespace("", "jabber:iq:roster");

		response.setChildElement(query);
		dispatchPacket(response);
	}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:27,代码来源:IQRosterPayloadProcessor.java


示例9: sendRosterToComponent

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
private void sendRosterToComponent(IQ requestPacket, Collection<RosterItem> items) {
	Log.debug("Sending contacts from user " + requestPacket.getFrom().toString() + " to external Component");
	IQ response = IQ.createResultIQ(requestPacket);
	response.setTo(_componentName);
	Element query = new DefaultElement("query");
	for (RosterItem i : items) {
		if (i.getJid().toString().contains(_componentName)) {
			Log.debug("Roster exchange for external component " + _componentName + ". Sending user "
					+ i.getJid().toString());
			Element item = new DefaultElement("item", null);
			item.add(new DefaultAttribute("jid", i.getJid().toString()));
			item.add(new DefaultAttribute("name", i.getNickname()));
			item.add(new DefaultAttribute("subscription", "both"));
			for (String s : i.getGroups()) {
				Element group = new DefaultElement("group");
				group.setText(s);
				item.add(group);
			}
			query.add(item);
		}
	}
	query.addNamespace("", "jabber:iq:roster");
	
	response.setChildElement(query);
	dispatchPacket(response);
}
 
开发者ID:surevine,项目名称:openfire-bespoke,代码行数:27,代码来源:SendRosterProcessor.java


示例10: setVersion

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
void setVersion(final File xml, final int newVersion) throws DocumentException {
	SAXReader xmlReader = new SAXReader();
	Document doc = xmlReader.read(xml);

	XPath xpathSelector = DocumentHelper.createXPath("/settings");
	List<?> results = xpathSelector.selectNodes(doc);
	for (Iterator<?> iter = results.iterator(); iter.hasNext();) {
		Element element = (Element) iter.next();
		Attribute attr = element.attribute("version");
		if (attr == null) {
			element.add(new DefaultAttribute("version", String.valueOf(newVersion)));
		} else {
			attr.setText(String.valueOf(newVersion));
		}
	}

	try {
		FileOutputStream fos = new FileOutputStream(xml);
		OutputFormat outformat = OutputFormat.createPrettyPrint();
		outformat.setEncoding("UTF-16");
		XMLWriter writer = new XMLWriter(fos, outformat);
		writer.write(doc);
		writer.flush();
	} catch (IOException ioe) {
		LOG.error("Failed to update the serttings.xml version number", ioe);
		throw new RuntimeException(ioe);
	}
}
 
开发者ID:GoldenGnu,项目名称:jeveassets,代码行数:29,代码来源:Update.java


示例11: createElementInstance

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
public static <I> I createElementInstance(Class<? extends I> clazz, Element el)
    throws InstantiationException, IllegalAccessException {
  I instance = clazz.newInstance();

  for (Object attrObj : el.attributes()) {
    DefaultAttribute attrib = (DefaultAttribute) attrObj;
    setObjectFieldValue(instance, attrib.getName(), attrib.getValue());
  }

  return instance;
}
 
开发者ID:brunocvcunha,项目名称:taskerbox,代码行数:12,代码来源:TaskerboxFactory.java


示例12: testJaxen20AttributeNamespaceNodes

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
public void testJaxen20AttributeNamespaceNodes() throws JaxenException
{

    Namespace ns1 = Namespace.get("p1", "www.acme1.org");
    Namespace ns2 = Namespace.get("p2", "www.acme2.org");
    Element element = new DefaultElement("test", ns1);
    Attribute attribute = new DefaultAttribute("pre:foo", "bar", ns2);
    element.add(attribute); 
    Document doc = new DefaultDocument(element);
    
    XPath xpath = new Dom4jXPath( "//namespace::node()" );
    List results = xpath.selectNodes( doc );
    assertEquals( 3, results.size() );

}
 
开发者ID:jaxen-xpath,项目名称:jaxen,代码行数:16,代码来源:DOM4JXPathTest.java


示例13: createAttribute

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
public static Attribute createAttribute(final String attributeName, final String value) {
  return new DefaultAttribute(attributeName, value);
}
 
开发者ID:AndreasWBartels,项目名称:libraries,代码行数:4,代码来源:ObjectToDomConverterUtilities.java


示例14: buildChannel

import org.dom4j.tree.DefaultAttribute; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"})
public static TaskerboxChannel<?> buildChannel(Element xmlChannel) throws Exception {

  log.info("Building channel with Class " + xmlChannel.getName());

  Class<TaskerboxChannel> channelClass =
      (Class<TaskerboxChannel>) Class.forName(xmlChannel.getName());
  final TaskerboxChannel channel = channelClass.newInstance();

  for (Object attrObj : xmlChannel.attributes()) {
    DefaultAttribute attrib = (DefaultAttribute) attrObj;

    setObjectFieldValue(channel, attrib.getName(), attrib.getValue());
    log.debug("Adding Property in bag: " + attrib.getName() + " = " + attrib.getValue());
    channel.addProperty(attrib.getName(), attrib.getValue());

  }

  List<ITaskerboxAction> actions = new ArrayList<>();
  for (Element channelChildren : (List<Element>) xmlChannel.elements()) {
    Class<? extends ITaskerboxAction> actionClass =
        (Class<? extends ITaskerboxAction>) Class.forName(channelChildren.getName());
    ITaskerboxAction action =
        TaskerboxFactory.createElementInstance(actionClass, channelChildren);

    try {
      log.info("Validando Action " + action.getClass());
      TaskerboxValidationUtils.validate(action);
    } catch (IllegalArgumentException e) {
      e.printStackTrace();
      log.error("Erro ao validar action", e);
      continue;
    }

    action.setChannel(channel);
    if (action.getId() == null) {
      action.setId(channel.getId() + "Action");
    }
    action.setup();
    actions.add(action);
  }

  if (actions == null || actions.isEmpty()) {
    throw new IllegalArgumentException("Not defined actions for channel " + channel.getId());
  }

  channel.setActions(actions);

  TaskerboxValidationUtils.validate(channel);

  return channel;
}
 
开发者ID:brunocvcunha,项目名称:taskerbox,代码行数:53,代码来源:TaskerboxFactory.java



注:本文中的org.dom4j.tree.DefaultAttribute类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Spans类代码示例发布时间:2022-05-21
下一篇:
Java ConnectionFactoryBuilder类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap