java中elements_Java Element.elements方法代碼示例

本文整理匯總了Java中org.dom4j.Element.elements方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.elements方法的具體用法?Java Element.elements怎麽用?Java Element.elements使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.dom4j.Element的用法示例。

在下文中一共展示了Element.elements方法的20個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: parseActions

​點讚 4

import org.dom4j.Element; //導入方法依賴的package包/類

public List parseActions(Element element){

List actions=new ArrayList();

for(Object obj:element.elements()){

if(obj==null || !(obj instanceof Element)){

continue;

}

Element ele=(Element)obj;

String name=ele.getName();

for(ActionParser actionParser:actionParsers){

if(actionParser.support(name)){

actions.add(actionParser.parse(ele));

break;

}

}

}

return actions;

}

開發者ID:youseries,項目名稱:urule,代碼行數:18,

示例2: parseDatasetNode

​點讚 3

import org.dom4j.Element; //導入方法依賴的package包/類

/** parse a dataset node from xml */

private static OozieDatasetNode parseDatasetNode(Element xml_node) {

List childNodes = xml_node.elements();

OozieDatasetNode node = new OozieDatasetNode();

for( Element child : childNodes){

String value = child.getText();

String name = child.getName();

if ("id".equals(name))

node.setId(value);

else if ("moduleId".equals(name))

node.setModuleId(value);

else if ("x".equals(name))

node.setX((int) Float.parseFloat(value));

else if ("y".equals(name))

node.setY((int) Float.parseFloat(value));

else if ("file".equals(name))

node.setFile(value);

}

return node;

}

開發者ID:ICT-BDA,項目名稱:EasyML,代碼行數:24,

示例3: parse

​點讚 3

import org.dom4j.Element; //導入方法依賴的package包/類

@Override

public CheckboxInputComponent parse(Element element) {

CheckboxInputComponent checkbox=new CheckboxInputComponent();

checkbox.setBindParameter(element.attributeValue("bind-parameter"));

checkbox.setOptionsInline(Boolean.valueOf(element.attributeValue("options-inline")));

checkbox.setLabel(element.attributeValue("label"));

checkbox.setType(element.attributeValue("type"));

checkbox.setLabelPosition(LabelPosition.valueOf(element.attributeValue("label-position")));

List options=new ArrayList();

for(Object obj:element.elements()){

if(obj==null || !(obj instanceof Element)){

continue;

}

Element ele=(Element)obj;

if(!ele.getName().equals("option")){

continue;

}

Option option=new Option();

options.add(option);

option.setLabel(ele.attributeValue("label"));

option.setValue(ele.attributeValue("value"));

}

checkbox.setOptions(options);

return checkbox;

}

開發者ID:youseries,項目名稱:ureport,代碼行數:26,

示例4: element2Map

​點讚 3

import org.dom4j.Element; //導入方法依賴的package包/類

/**

* Element to map

* @param e

* @param map

*/

public static void element2Map(Element e, Map map) {

List list = e.elements();

if (e.attributeCount() > 0) {

for (Object attri : e.attributes()) {

Attribute at = (Attribute)attri;

map.put(at.getName(), at.getValue());

}

}

if (list.size() < 1 && DataUtil.isEmpty(e.getText())) {

return;

} else if (list.size() < 1 && !DataUtil.isEmpty(e.getText())) {

map.put("text", e.getText());

}

for (Object aList : list) {

Element iter = (Element)aList;

Map cMap = new HashMap();

element2Map(iter, cMap);

map.put(iter.getName(), cMap);

}

}

開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:26,

示例5: parseParameters

​點讚 3

import org.dom4j.Element; //導入方法依賴的package包/類

private List parseParameters(Element element){

List parameters=new ArrayList();

for(Object obj:element.elements()){

if(obj==null || !(obj instanceof Element)){

continue;

}

Element ele=(Element)obj;

if(!ele.getName().equals("parameter")){

continue;

}

Parameter param=new Parameter();

param.setName(ele.attributeValue("name"));

param.setDefaultValue(ele.attributeValue("default-value"));

param.setType(DataType.valueOf(ele.attributeValue("type")));

parameters.add(param);

}

return parameters;

}

開發者ID:youseries,項目名稱:ureport,代碼行數:19,

示例6: getKeysInXML

​點讚 3

import org.dom4j.Element; //導入方法依賴的package包/類

/**

* 從指定的xml文件返回在zookeeper中的key集合

*

* @param fromDoc

* 源xml文件

* @param znodePath

* znode路徑前綴

* @return

*/

public static Set getKeysInXML(Document fromDoc, String znodePath) {

Set xmlKeys = new HashSet<>();

Element rootEle = fromDoc.getRootElement();

List paramsList = rootEle.elements("params");

for (Element paramEle : paramsList) {

String paramName = paramEle.attributeValue("name");

List paramList = paramEle.elements("param");

for (Element param : paramList) {

String paramKey = param.attributeValue("name");

xmlKeys.add(znodePath + "/" + paramName + "/" + paramKey);

}

}

return xmlKeys;

}

開發者ID:jtjsir,項目名稱:zookeeper-test-demo,代碼行數:25,

示例7: addEntityListenerClasses

​點讚 3

import org.dom4j.Element; //導入方法依賴的package包/類

private List addEntityListenerClasses(Element element, String packageName, List addedClasses) {

List localAddedClasses = new ArrayList();

Element listeners = element.element( "entity-listeners" );

if ( listeners != null ) {

@SuppressWarnings( "unchecked" )

List elements = listeners.elements( "entity-listener" );

for (Element listener : elements) {

String listenerClassName = buildSafeClassName( listener.attributeValue( "class" ), packageName );

if ( classOverriding.containsKey( listenerClassName ) ) {

//maybe switch it to warn?

if ( "entity-listener".equals( classOverriding.get( listenerClassName ).getName() ) ) {

LOG.duplicateListener( listenerClassName );

continue;

}

throw new IllegalStateException("Duplicate XML entry for " + listenerClassName);

}

localAddedClasses.add( listenerClassName );

classOverriding.put( listenerClassName, listener );

}

}

LOG.debugf( "Adding XML overriding information for listeners: %s", localAddedClasses );

addedClasses.addAll( localAddedClasses );

return localAddedClasses;

}

開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,

示例8: parserVarList

​點讚 3

import org.dom4j.Element; //導入方法依賴的package包/類

/**

* 解析list類型全局變量

* @param node vars節點

* @return 返回所有list類型變量

*/

public static Map parserVarList(Element node){

Map vars = new HashMap();

if(node!=null){

List childs = node.elements("list");

if(childs!=null&&childs.size()>0){

for(Element list : childs){

List itemsE = list.elements();

List itemsContainer = new ArrayList();

for(Element item : itemsE){

itemsContainer.add(item.getText());

}

vars.put(list.attributeValue("name"),itemsContainer);

}

}

}

return vars;

}

開發者ID:javahaohao,項目名稱:gen_code,代碼行數:23,

示例9: parseConnections

​點讚 2

import org.dom4j.Element; //導入方法依賴的package包/類

protected List parseConnections(Element element){

List connections=new ArrayList();

for(Object obj:element.elements()){

if(obj==null || !(obj instanceof Element)){

continue;

}

Element ele=(Element)obj;

if(!ele.getName().equals("connection")){

continue;

}

connections.add(buildConnection(ele));

}

return connections;

}

開發者ID:youseries,項目名稱:urule,代碼行數:15,

示例10: bindNamedAttributeNodes

​點讚 2

import org.dom4j.Element; //導入方法依賴的package包/類

private static void bindNamedAttributeNodes(Element subElement, AnnotationDescriptor ann) {

List namedAttributeNodes = subElement.elements("named-attribute-node");

List annNamedAttributeNodes = new ArrayList( );

for(Element namedAttributeNode : namedAttributeNodes){

AnnotationDescriptor annNamedAttributeNode = new AnnotationDescriptor( NamedAttributeNode.class );

copyStringAttribute( annNamedAttributeNode, namedAttributeNode, "value", true );

copyStringAttribute( annNamedAttributeNode, namedAttributeNode, "subgraph", false );

copyStringAttribute( annNamedAttributeNode, namedAttributeNode, "key-subgraph", false );

annNamedAttributeNodes.add( (NamedAttributeNode) AnnotationFactory.create( annNamedAttributeNode ) );

}

ann.setValue( "attributeNodes", annNamedAttributeNodes.toArray( new NamedAttributeNode[annNamedAttributeNodes.size()] ) );

}

開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,

示例11: parse

​點讚 2

import org.dom4j.Element; //導入方法依賴的package包/類

public SpringBean parse(Element element) {

SpringBean bean=new SpringBean();

bean.setId(element.attributeValue("id"));

for(Object obj:element.elements()){

if(obj==null || !(obj instanceof Element)){

continue;

}

Element ele=(Element)obj;

if(ele.getName().equals("method")){

Method method=parseMethod(ele);

bean.addMethod(method);

}

}

return bean;

}

開發者ID:youseries,項目名稱:urule,代碼行數:16,

示例12: initializeTimePatternData

​點讚 2

import org.dom4j.Element; //導入方法依賴的package包/類

@SuppressWarnings("unchecked")

private void initializeTimePatternData(Element rootElement) throws Exception {

loadExistingTimePatterns(session.getUniqueId());

Element timePatternsElement = rootElement.element(PointInTimeDataExport.sTimePatternsElementName);

for(Element timePatternElement : (List) timePatternsElement.elements()){

elementTimePattern(timePatternElement);

}

}

開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:11,

示例13: parse

​點讚 2

import org.dom4j.Element; //導入方法依賴的package包/類

@Override

public Value parse(Element element) {

SlashValue value=new SlashValue();

List slashes=new ArrayList();

value.setSlashes(slashes);

for(Object obj:element.elements()){

if(obj==null || !(obj instanceof Element)){

continue;

}

Element ele=(Element)obj;

if(ele.getName().equals("slash")){

Slash slash=new Slash();

slashes.add(slash);

slash.setDegree(Integer.valueOf(ele.attributeValue("degree")));

slash.setX(Integer.valueOf(ele.attributeValue("x")));

slash.setY(Integer.valueOf(ele.attributeValue("y")));

slash.setText(ele.attributeValue("text"));

}else if(ele.getName().equals("base64-data")){

String prefix="data:image/png;base64,";

String base64Data=ele.getText();

if(base64Data.startsWith(prefix)){

base64Data=base64Data.substring(prefix.length(),base64Data.length());

}

value.setBase64Data(base64Data);

}

}

return value;

}

開發者ID:youseries,項目名稱:ureport,代碼行數:29,

示例14: setUp

​點讚 2

import org.dom4j.Element; //導入方法依賴的package包/類

@Before

public void setUp() throws Exception {

InputStream is = new FileInputStream(new File(xmlFile));

if (is == null) {

throw new FileNotFoundException("Excel的描述文件 : " + xmlFile + " 未找到.");

}

SAXReader saxReader = new SAXReader();

Document document = saxReader.read(is);

// 根節點

Element root = document.getRootElement();

// 一次導入

onceList = root.elements("onceImport");

// 重複導入

List repeatList = root.elements("repeatImport");

// 校驗器的定義

List validators = root.elements("validators");

// 單元格校驗

List cellValidators = root.elements("cell-validators");

excelStruct = new ExcelStruct();

// 讀取校驗器配置

// parseValidatorConfig(excelStruct, validators, cellValidators);

// simpleParseOnceImport(excelStruct, onceList);

is.close();

}

開發者ID:ssqfzc,項目名稱:ExcelUtils,代碼行數:31,

示例15: orderSequenceElements

​點讚 2

import org.dom4j.Element; //導入方法依賴的package包/類

/**

* Put sequence elements in the order specified by the sequence compositor.

*

* @param parent NOT YET DOCUMENTED

*/

public void orderSequenceElements(Element parent) {

String xpath = parent.getPath();

List order = schemaHelper.getChildrenOrder(xpath);

// just as a safeguard, don't reorder if there is only one child

// for the schemaNode, since parent is probably a repeating element

// and reordering would wipe out all but one child

if (order.size() < 2)

return;

// map element name to a list of elements to accomodate repeating elements

Map elementMap = new HashMap();

List elements = parent.elements();

for (int i = elements.size() - 1; i > -1; i--) {

Element e = (Element) elements.get(i);

String tagName = e.getName();

List items = (List) elementMap.get(tagName);

if (items == null)

items = new ArrayList();

items.add(0, e.detach()); // add to beginning to maintain doc ordering

elementMap.put(tagName, items);

}

for (Iterator i = order.iterator(); i.hasNext(); ) {

String name = (String) i.next();

elements = (List) elementMap.get(name);

if (elements != null) {

for (Iterator ii = elements.iterator(); ii.hasNext(); ) {

parent.add((Element) ii.next());

}

}

}

}

開發者ID:NCAR,項目名稱:joai-project,代碼行數:39,

示例16: importXml

​點讚 2

import org.dom4j.Element; //導入方法依賴的package包/類

public void importXml(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

DiskFileItemFactory factory = new DiskFileItemFactory();

ServletContext servletContext = req.getSession().getServletContext();

File repository = (File) servletContext.getAttribute("javax.servlet.context.tempdir");

factory.setRepository(repository);

ServletFileUpload upload = new ServletFileUpload(factory);

InputStream inputStream=null;

try {

List items = upload.parseRequest(req);

if(items.size()!=1){

throw new ServletException("Upload xml file is invalid.");

}

FileItem item=items.get(0);

inputStream=item.getInputStream();

String xmlContent=IOUtils.toString(inputStream, "utf-8");

List variables=new ArrayList();

Document doc=DocumentHelper.parseText(xmlContent);

Element root=doc.getRootElement();

String clazz=root.attributeValue("clazz");

for(Object obj:root.elements()){

if(obj==null || !(obj instanceof Element)){

continue;

}

Element ele=(Element)obj;

Variable var=new Variable();

var.setAct(Act.InOut);

var.setDefaultValue(ele.attributeValue("defaultValue"));

var.setLabel(ele.attributeValue("label"));

var.setName(ele.attributeValue("name"));

var.setType(Datatype.valueOf(ele.attributeValue("type")));

variables.add(var);

}

Map result=new HashMap();

result.put("clazz", clazz);

result.put("variables", variables);

writeObjectToJson(resp, result);

} catch (Exception e) {

throw new ServletException(e);

} finally {

IOUtils.closeQuietly(inputStream);

}

}

開發者ID:youseries,項目名稱:urule,代碼行數:43,

示例17: getBean

​點讚 2

import org.dom4j.Element; //導入方法依賴的package包/類

/**

* 獲取property內嵌的bean.

* @param name id或者bean的name

* @param root 根節點.

* @return 返回封裝完整的bean.

* @throws Exception Exception.

*/

public Object getBean(String name, Element root) throws Exception {

Object object = null;

List beans = root.elements();

if (beans.size() > 0) {

for (Element bean : beans) {

if (bean.attributeValue("name").equals(name)) {

// 如果bean name相同則開始創建對象

String clazz = bean.attributeValue("class");

// 通過反射來創建對象

Class beanClass = Class.forName(clazz);

object = beanClass.newInstance();

List propertys = bean.elements();

if (propertys.size() > 0) {

for (Element property : propertys) {

String key = property.attributeValue("name");

Field field = beanClass.getDeclaredField(key);

field.setAccessible(true);

List childBean = property.elements();

// 如果property下內嵌bean

if (childBean.size() > 0) {

field.set(object, getBean(key, property));

}

if (property.attribute("ref") != null) {

/**

* 此屬性的值是一個對象.這裏由於直接調用getBean方法賦值給對象,返回的對象一定是Bean參數的對象, 因此強製轉換不會出問題

*/

String refid = property.attributeValue("ref");

field.set(object, getBean(refid));

} else {

/**

* 此屬性值是一個字符串.這裏單獨處理int,float類型變量.如果不處理,會將String類型直接賦值給int類型,

* 發生ClassCastException

*/

String value = property.attributeValue("value");

/**

* 需要對類型進行判斷,處理String類型.

*/

field.set(object, value);

}

}

}

}

}

}

return object;

}

開發者ID:haifeiWu,項目名稱:push-server,代碼行數:62,

示例18: parse

​點讚 2

import org.dom4j.Element; //導入方法依賴的package包/類

@Override

public CellDefinition parse(Element element) {

CellDefinition cell=new CellDefinition();

cell.setName(element.attributeValue("name"));

cell.setColumnNumber(Integer.valueOf(element.attributeValue("col")));

cell.setRowNumber(Integer.valueOf(element.attributeValue("row")));

cell.setLeftParentCellName(element.attributeValue("left-cell"));

cell.setTopParentCellName(element.attributeValue("top-cell"));

String rowSpan=element.attributeValue("row-span");

if(StringUtils.isNotBlank(rowSpan)){

cell.setRowSpan(Integer.valueOf(rowSpan));

}

String colSpan=element.attributeValue("col-span");

if(StringUtils.isNotBlank(colSpan)){

cell.setColSpan(Integer.valueOf(colSpan));

}

String expand=element.attributeValue("expand");

if(StringUtils.isNotBlank(expand)){

cell.setExpand(Expand.valueOf(expand));

}

String fillBlankRows=element.attributeValue("fill-blank-rows");

if(StringUtils.isNotBlank(fillBlankRows)){

cell.setFillBlankRows(Boolean.valueOf(fillBlankRows));

String multiple=element.attributeValue("multiple");

if(StringUtils.isNotBlank(multiple)){

cell.setMultiple(Integer.valueOf(multiple));

}

}

cell.setLinkTargetWindow(element.attributeValue("link-target-window"));

String linkUrl=element.attributeValue("link-url");

cell.setLinkUrl(linkUrl);

if(StringUtils.isNotBlank(linkUrl)){

if(linkUrl.startsWith(ExpressionUtils.EXPR_PREFIX) && linkUrl.endsWith(ExpressionUtils.EXPR_SUFFIX)){

String expr=linkUrl.substring(2,linkUrl.length()-1);

Expression urlExpression=ExpressionUtils.parseExpression(expr);

cell.setLinkUrlExpression(urlExpression);

}

}

List linkParameters=null;

List conditionPropertyItems=null;

for(Object obj:element.elements()){

if(!(obj instanceof Element)){

continue;

}

Element ele=(Element)obj;

Object parseData=parseValue(ele);

if(parseData instanceof Value){

Value value=(Value)parseData;

cell.setValue(value);

}else if(parseData instanceof CellStyle){

CellStyle cellStyle=(CellStyle)parseData;

cell.setCellStyle(cellStyle);

}else if(parseData instanceof LinkParameter){

if(linkParameters==null){

linkParameters=new ArrayList();

}

linkParameters.add((LinkParameter)parseData);

}else if(parseData instanceof ConditionPropertyItem){

if(conditionPropertyItems==null){

conditionPropertyItems=new ArrayList();

}

conditionPropertyItems.add((ConditionPropertyItem)parseData);

}

}

if(linkParameters!=null){

cell.setLinkParameters(linkParameters);

}

cell.setConditionPropertyItems(conditionPropertyItems);

if(cell.getValue()==null){

throw new ReportException("Cell ["+cell.getName()+"] value not define.");

}

return cell;

}

開發者ID:youseries,項目名稱:ureport,代碼行數:74,

示例19: parseApp

​點讚 1

import org.dom4j.Element; //導入方法依賴的package包/類

@SuppressWarnings("unchecked")

private void parseApp(Element root){

this.app_tags = root.elements(APP_TAG);

}

開發者ID:troopson,項目名稱:etagate,代碼行數:7,

示例20: ChoiceGuard

​點讚 1

import org.dom4j.Element; //導入方法依賴的package包/類

/**

* Constructor for the ChoiceGuard object

*

* @param compositor NOT YET DOCUMENTED

* @param instanceElement NOT YET DOCUMENTED

*/

public ChoiceGuard(Compositor compositor, Element instanceElement) {

this (compositor, instanceElement.elements());

}

開發者ID:NCAR,項目名稱:joai-project,代碼行數:10,

注:本文中的org.dom4j.Element.elements方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值