當前位置: 首頁>>代碼示例>>Java>>正文


Java Attribute類代碼示例

本文整理匯總了Java中org.dom4j.Attribute的典型用法代碼示例。如果您正苦於以下問題:Java Attribute類的具體用法?Java Attribute怎麽用?Java Attribute使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: element2Map

import org.dom4j.Attribute; //導入依賴的package包/類
/**
 * Element to map
 * @param e
 * @param map
 */
public static void element2Map(Element e, Map<String, Object> map) {
    List<Object> 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<String, Object> cMap = new HashMap<String, Object>();
        element2Map(iter, cMap);
        map.put(iter.getName(), cMap);
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:26,代碼來源:XmlUtil.java

示例2: element2Map

import org.dom4j.Attribute; //導入依賴的package包/類
/**
 * Element to map
 * 
 * @param e
 * @return
 */
public static void element2Map(Element e, Map<String, Object> map) {
	List<Object> 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<String, Object> cMap = new HashMap<String, Object>();
		element2Map(iter, cMap);
		map.put(iter.getName(), cMap);
	}
}
 
開發者ID:guokezheng,項目名稱:automat,代碼行數:27,代碼來源:XmlUtil.java

示例3: getOptimisticLockMode

import org.dom4j.Attribute; //導入依賴的package包/類
private static int getOptimisticLockMode(Attribute olAtt) throws MappingException {
	
	if (olAtt==null) return Versioning.OPTIMISTIC_LOCK_VERSION;
	String olMode = olAtt.getValue();
	if ( olMode==null || "version".equals(olMode) ) {
		return Versioning.OPTIMISTIC_LOCK_VERSION;
	}
	else if ( "dirty".equals(olMode) ) {
		return Versioning.OPTIMISTIC_LOCK_DIRTY;
	}
	else if ( "all".equals(olMode) ) {
		return Versioning.OPTIMISTIC_LOCK_ALL;
	}
	else if ( "none".equals(olMode) ) {
		return Versioning.OPTIMISTIC_LOCK_NONE;
	}
	else {
		throw new MappingException("Unsupported optimistic-lock style: " + olMode);
	}
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:21,代碼來源:Binder.java

示例4: init

import org.dom4j.Attribute; //導入依賴的package包/類
public void init (Document  schemaDoc) {
	rootElement = schemaDoc.getRootElement();
	
	if (rootElement == null) {
		prtln ("SchemaProps ERROR: rootElement not found");
		return;
	}
	
	setProp ("namespace", rootElement.getNamespace());
	
	setDefaultProps ();
	
	for (Iterator i=rootElement.attributeIterator();i.hasNext();) {
		Attribute att = (Attribute)i.next();
		setProp (att.getName(), att.getValue());
	}
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:18,代碼來源:SchemaProps.java

示例5: bindColumn

import org.dom4j.Attribute; //導入依賴的package包/類
public static void bindColumn(Element node, Column model, boolean isNullable) {
	Attribute lengthNode = node.attribute("length");
	if (lengthNode!=null) model.setLength( Integer.parseInt( lengthNode.getValue() ) );
	Attribute nullNode = node.attribute("not-null");
	model.setNullable( (nullNode!=null) ?
		!StringHelper.booleanValue( nullNode.getValue() ) :
		isNullable
	);
	Attribute unqNode = node.attribute("unique");
	model.setUnique( unqNode!=null && StringHelper.booleanValue( unqNode.getValue() ) );
	model.setCheckConstraint( node.attributeValue("check") );
	//Attribute qtNode = node.attribute("quote");
	//model.setQuoted( qtNode!=null && StringHelper.booleanValue( qtNode.getValue() ) );
	Attribute typeNode = node.attribute("sql-type");
	model.setSqlType( (typeNode==null) ? null : typeNode.getValue() );
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:17,代碼來源:Binder.java

示例6: updateElement

import org.dom4j.Attribute; //導入依賴的package包/類
/**
 * Update the attributes of element
 *
 * @param element
 * @param properties
 */
private static void updateElement(Element element, Map<String, String> properties) {
    for (Map.Entry<String, String> entry : properties.entrySet()) {
        String key = entry.getKey();
        if (key.startsWith("tools:")) {
            continue;
        }
        String keyNoPrefix = key;
        String[] values = StringUtils.split(key, ":");
        if (values.length > 1) {
            keyNoPrefix = values[1];
        }
        if (null == entry.getValue()) {
            continue;
        } else {
            Attribute attribute = element.attribute(keyNoPrefix);
            if (null != attribute) {
                attribute.setValue(entry.getValue());
            } else {
                element.addAttribute(key, entry.getValue());
            }
        }
    }
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:30,代碼來源:ManifestFileUtils.java

示例7: getVersionName

import org.dom4j.Attribute; //導入依賴的package包/類
/**
 * Update the plug-in's minSdkVersion and targetSdkVersion
 *
 * @param androidManifestFile
 * @throws IOException
 * @throws DocumentException
 */
public static String getVersionName(File androidManifestFile) throws IOException, DocumentException {
    SAXReader reader = new SAXReader();
    String versionName = "";
    if (androidManifestFile.exists()) {
        Document document = reader.read(androidManifestFile);// Read the XML file
        Element root = document.getRootElement();// Get the root node
        if ("manifest".equalsIgnoreCase(root.getName())) {
            List<Attribute> attributes = root.attributes();
            for (Attribute attr : attributes) {
                if (StringUtils.equalsIgnoreCase(attr.getName(), "versionName")) {
                    versionName = attr.getValue();
                }
            }
        }
    }
    return versionName;
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:25,代碼來源:ManifestFileUtils.java

示例8: getVersionCode

import org.dom4j.Attribute; //導入依賴的package包/類
public static String getVersionCode(File androidManifestFile) throws IOException, DocumentException {
    SAXReader reader = new SAXReader();
    String versionCode = "";
    if (androidManifestFile.exists()) {
        Document document = reader.read(androidManifestFile);// Read the XML file
        Element root = document.getRootElement();// Get the root node
        if ("manifest".equalsIgnoreCase(root.getName())) {
            List<Attribute> attributes = root.attributes();
            for (Attribute attr : attributes) {
                if (StringUtils.equalsIgnoreCase(attr.getName(), "versionCode")) {
                    versionCode = attr.getValue();
                }
            }
        }
    }
    return versionCode;
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:18,代碼來源:ManifestFileUtils.java

示例9: initOuterJoinFetchSetting

import org.dom4j.Attribute; //導入依賴的package包/類
private static void initOuterJoinFetchSetting(Element node, Fetchable model) {
	Attribute jfNode = node.attribute("outer-join");
	if ( jfNode==null ) {
		model.setOuterJoinFetchSetting(OuterJoinLoader.AUTO);
	}
	else {
		String eoj = jfNode.getValue();
		if ( "auto".equals(eoj) ) {
			model.setOuterJoinFetchSetting(OuterJoinLoader.AUTO);
		}
		else {
			model.setOuterJoinFetchSetting(
				"true".equals(eoj) ? OuterJoinLoader.EAGER : OuterJoinLoader.LAZY
			);
		}
	}
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:18,代碼來源:Binder.java

示例10: getClassTableName

import org.dom4j.Attribute; //導入依賴的package包/類
private static String getClassTableName(
		PersistentClass model,
		Element node,
		String schema,
		String catalog,
		Table denormalizedSuperTable,
		Mappings mappings) {
	Attribute tableNameNode = node.attribute( "table" );
	String logicalTableName;
	String physicalTableName;
	if ( tableNameNode == null ) {
		logicalTableName = StringHelper.unqualify( model.getEntityName() );
		physicalTableName = getNamingStrategyDelegate( mappings ).determineImplicitPrimaryTableName(
				model.getEntityName(),
				model.getJpaEntityName()
		);
	}
	else {
		logicalTableName = tableNameNode.getValue();
		physicalTableName = getNamingStrategyDelegate( mappings ).toPhysicalTableName( logicalTableName );
	}
	mappings.addTableBinding( schema, catalog, logicalTableName, physicalTableName, denormalizedSuperTable );
	return physicalTableName;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:HbmBinder.java

示例11: getOptimisticLockStyle

import org.dom4j.Attribute; //導入依賴的package包/類
private static OptimisticLockStyle getOptimisticLockStyle(Attribute olAtt) throws MappingException {
	if ( olAtt == null ) {
		return OptimisticLockStyle.VERSION;
	}

	final String olMode = olAtt.getValue();
	if ( olMode == null || "version".equals( olMode ) ) {
		return OptimisticLockStyle.VERSION;
	}
	else if ( "dirty".equals( olMode ) ) {
		return OptimisticLockStyle.DIRTY;
	}
	else if ( "all".equals( olMode ) ) {
		return OptimisticLockStyle.ALL;
	}
	else if ( "none".equals( olMode ) ) {
		return OptimisticLockStyle.NONE;
	}
	else {
		throw new MappingException( "Unsupported optimistic-lock style: " + olMode );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:HbmBinder.java

示例12: process

import org.dom4j.Attribute; //導入依賴的package包/類
@Override
public <T> T process(T xml, Iterable<Effect> effects) throws XmlBuilderException {
    if (!canHandle(xml)) {
        throw new IllegalArgumentException("XML model is not supported");
    }
    final Node xmlNode = (Node) xml;
    final Dom4jNode<?> node;
    switch (xmlNode.getNodeType()) {
        case Node.DOCUMENT_NODE:
            node = new Dom4jDocument((Document) xmlNode);
            break;
        case Node.ELEMENT_NODE:
            node = new Dom4jElement((Element) xmlNode);
            break;
        case Node.ATTRIBUTE_NODE:
            node = new Dom4jAttribute((Attribute) xmlNode);
            break;
        default:
            throw new IllegalArgumentException("XML node type is not supported");
    }
    final Navigator<Dom4jNode> navigator = new Dom4jNavigator(xmlNode);
    for (Effect effect : effects) {
        effect.perform(navigator, node);
    }
    return xml;
}
 
開發者ID:SimY4,項目名稱:xpath-to-xml,代碼行數:27,代碼來源:Dom4jNavigatorSpi.java

示例13: toMap

import org.dom4j.Attribute; //導入依賴的package包/類
@Override
public Map toMap(Document document) {
  Map<String, String> m = new HashMap<String, String>();
  /**
   * <contentList> <content contentuid=
   * "h00007224gb454g4b8bgb762g7865d9ee3dbb">如果不是這樣的話!哈,開玩笑啦,我們在一起很合適,就像麵包上的果醬。你想和我組隊嗎?我敢說你們需要一點野獸風味!</content>
   * <content contentuid="h0001d8b9g13d6g4605g85e9g708fe1e537c8">定製</content> </contentList>
   */
  // 獲取根節點元素對象
  Element root = document.getRootElement();
  // 子節點
  List<Element> list = root.elements();
  // 使用遞歸
  Iterator<Element> iterator = list.iterator();
  while (iterator.hasNext()) {
    Element e = iterator.next();
    Attribute attribute = e.attribute("contentuid");
    m.put(attribute.getValue(), e.getText());
  }
  return m;
}
 
開發者ID:SvenAugustus,項目名稱:Divinity_Original_Sin_2_zhCN,代碼行數:22,代碼來源:DOS2ToMap.java

示例14: writeAttributes

import org.dom4j.Attribute; //導入依賴的package包/類
protected void writeAttributes(Element element) throws IOException {
    for (int i = 0, size = element.attributeCount(); i < size; i++) {
        Attribute attribute = element.attribute(i);
           char quote = format.getAttributeQuoteCharacter();
           if (element.attributeCount() > 2) {
               writePrintln();
               indent();
               writer.write(format.getIndent());
           } else {
           	writer.write(" ");
           }
           writer.write(attribute.getQualifiedName());
           writer.write("=");
           writer.write(quote);
           writeEscapeAttributeEntities(attribute.getValue());
           writer.write(quote);
    }
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:19,代碼來源:LowercaseTableNames.java

示例15: bindSimpleValue

import org.dom4j.Attribute; //導入依賴的package包/類
public static void bindSimpleValue(Element node, SimpleValue model, boolean isNullable, String path, Mappings mappings) 
throws MappingException {
	model.setType( getTypeFromXML(node) );

	Attribute formulaNode = node.attribute("formula");
	if (formulaNode!=null) {
		Formula f = new Formula();
		f.setFormula( formulaNode.getText() );
		model.setFormula(f);
	}
	else {
		bindColumns(node, model, isNullable, true, path, mappings);
	}

	Attribute fkNode = node.attribute("foreign-key");
	if (fkNode!=null) model.setForeignKeyName( fkNode.getValue() );
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:18,代碼來源:Binder.java


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