本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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());
}
}
示例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() );
}
示例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());
}
}
}
}
示例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;
}
示例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;
}
示例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
);
}
}
}
示例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;
}
示例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 );
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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() );
}