本文整理汇总了Java中org.dom4j.Element.attribute方法的典型用法代码示例。如果您正苦于以下问题:Java Element.attribute方法的具体用法?Java Element.attribute怎么用?Java Element.attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dom4j.Element
的用法示例。
在下文中一共展示了Element.attribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindSimpleValue
import org.dom4j.Element; //导入方法依赖的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() );
}
示例2: addJunctionConnection
import org.dom4j.Element; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public boolean addJunctionConnection(final String id, final String fromNode,
final String from_x, final String from_y,
final String toNode,
final String to_x, final String to_y,
final String dir)
{
String s = "intconnction[@fromNode='"+fromNode+"' and @toNode='"+toNode+"']";
List<Element> list = junction.selectNodes(s);
if(list.isEmpty())
{
intconnction = junction.addElement("intconnction");
intconnction.addAttribute("id", id);
intconnction.addAttribute("numLanes", "1");
intconnction.addAttribute("fromNode", fromNode);
intconnction.addAttribute("from_x", from_x);
intconnction.addAttribute("from_y", from_y);
intconnction.addAttribute("toNode", toNode);
intconnction.addAttribute("to_x", to_x);
intconnction.addAttribute("to_y", to_y);
intconnction.addAttribute("dir", dir);
return true;
}
else
{
Iterator<Element> iter = list.iterator();
//System.out.println(list.size());
while (iter.hasNext())
{
Element ele = iter.next();
Attribute attr = ele.attribute("numLanes");
Integer numLanes = Integer.parseInt(attr.getValue())+1;
attr.setValue(numLanes.toString());
}
//System.out.println("有重复的lane");
return false;
}
}
示例3: bindColumnsOrFormula
import org.dom4j.Element; //导入方法依赖的package包/类
private static void bindColumnsOrFormula(Element node, SimpleValue simpleValue, String path,
boolean isNullable, Mappings mappings) {
Attribute formulaNode = node.attribute( "formula" );
if ( formulaNode != null ) {
Formula f = new Formula();
f.setFormula( formulaNode.getText() );
simpleValue.addFormula( f );
}
else {
bindColumns( node, simpleValue, isNullable, true, path, mappings );
}
}
示例4: checkAttribute
import org.dom4j.Element; //导入方法依赖的package包/类
public Attribute checkAttribute(Node node, String attrName) throws DocumentException {
if (!(node instanceof Element))
throw new CheckMessagesException("Node is not an element", this, node);
Element element = (Element) node;
Attribute attr = element.attribute(attrName);
if (attr == null)
throw new CheckMessagesException("Missing " + attrName + " attribute", this, node);
return attr;
}
示例5: initialise
import org.dom4j.Element; //导入方法依赖的package包/类
public void initialise(Element element, NamespacePrefixResolver nspr, PermissionModel permissionModel)
{
Attribute authorityAttribute = element.attribute(AUTHORITY);
if(authorityAttribute != null)
{
authority = authorityAttribute.getStringValue();
}
Attribute permissionAttribute = element.attribute(PERMISSION);
if(permissionAttribute != null)
{
permissionReference = permissionModel.getPermissionReference(null, permissionAttribute.getStringValue());
}
}
示例6: getTypeFromXML
import org.dom4j.Element; //导入方法依赖的package包/类
private static Type getTypeFromXML(Element node) throws MappingException {
Type type;
Attribute typeNode = node.attribute("type");
if (typeNode==null) typeNode = node.attribute("id-type"); //for an any
if (typeNode==null) {
return null; //we will have to use reflection
}
else {
type = TypeFactory.heuristicType( typeNode.getValue() );
if (type==null) throw new MappingException( "Could not interpret type: " + typeNode.getValue() );
}
return type;
}
示例7: getInheritance
import org.dom4j.Element; //导入方法依赖的package包/类
private Inheritance getInheritance(Element tree, XMLContext.Default defaults) {
Element element = tree != null ? tree.element( "inheritance" ) : null;
if ( element != null ) {
AnnotationDescriptor ad = new AnnotationDescriptor( Inheritance.class );
Attribute attr = element.attribute( "strategy" );
InheritanceType strategy = InheritanceType.SINGLE_TABLE;
if ( attr != null ) {
String value = attr.getValue();
if ( "SINGLE_TABLE".equals( value ) ) {
strategy = InheritanceType.SINGLE_TABLE;
}
else if ( "JOINED".equals( value ) ) {
strategy = InheritanceType.JOINED;
}
else if ( "TABLE_PER_CLASS".equals( value ) ) {
strategy = InheritanceType.TABLE_PER_CLASS;
}
else {
throw new AnnotationException(
"Unknown InheritanceType in XML: " + value + " (" + SCHEMA_VALIDATION + ")"
);
}
}
ad.setValue( "strategy", strategy );
return AnnotationFactory.create( ad );
}
else if ( defaults.canUseJavaAnnotations() ) {
return getPhysicalAnnotation( Inheritance.class );
}
else {
return null;
}
}
示例8: makeVersion
import org.dom4j.Element; //导入方法依赖的package包/类
private static final void makeVersion(Element node, SimpleValue model) {
// VERSION UNSAVED-VALUE
Attribute nullValueNode = node.attribute( "unsaved-value" );
if ( nullValueNode != null ) {
model.setNullValue( nullValueNode.getValue() );
}
else {
model.setNullValue( "undefined" );
}
}
示例9: isCallable
import org.dom4j.Element; //导入方法依赖的package包/类
private static boolean isCallable(Element element, boolean supportsCallable)
throws MappingException {
Attribute attrib = element.attribute( "callable" );
if ( attrib != null && "true".equals( attrib.getValue() ) ) {
if ( !supportsCallable ) {
throw new MappingException( "callable attribute not supported yet!" );
}
return true;
}
return false;
}
示例10: replaceAll
import org.dom4j.Element; //导入方法依赖的package包/类
@Override
public Document replaceAll(Document document, Map<String, String> pro) {
/**
* <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");
// System.out.println("属性"+attribute.getName() +":" + attribute.getValue());
String contentuid = attribute.getValue();
// String text = e.getText();
String newText = (String) pro.get(contentuid);
if (newText != null && !"".equals(newText)) {
e.setText(newText);
// System.out.println(contentuid + "=" + text + "|" + newText);
// System.out.println(contentuid + "=" + newText);
}
}
return document;
}
示例11: getMatcher
import org.dom4j.Element; //导入方法依赖的package包/类
private Matcher getMatcher(Element element) throws FilterException {
// These will be either BugCode, Method, or Or elements.
String name = element.getName();
if (name.equals("BugCode")) {
return new BugCodeMatcher(element.valueOf("@name"));
} else if (name.equals("Method")) {
Attribute nameAttr = element.attribute("name");
Attribute paramsAttr = element.attribute("params");
Attribute returnsAttr = element.attribute("returns");
if (nameAttr == null)
throw new FilterException("Missing name attribute in Method element");
if ((paramsAttr != null || returnsAttr != null) && (paramsAttr == null || returnsAttr == null))
throw new FilterException("Method element must have both params and returns attributes if either is used");
if (paramsAttr == null)
return new MethodMatcher(nameAttr.getValue());
else
return new MethodMatcher(nameAttr.getValue(), paramsAttr.getValue(), returnsAttr.getValue());
} else if (name.equals("Or")) {
OrMatcher orMatcher = new OrMatcher();
Iterator i = element.elementIterator();
while (i.hasNext()) {
orMatcher.addChild(getMatcher((Element) i.next()));
}
return orMatcher;
} else
throw new FilterException("Unknown element: " + name);
}
示例12: bindSimpleValue
import org.dom4j.Element; //导入方法依赖的package包/类
public static void bindSimpleValue(Element node, SimpleValue simpleValue, boolean isNullable,
String path, Mappings mappings) throws MappingException {
bindSimpleValueType( node, simpleValue, mappings );
bindColumnsOrFormula( node, simpleValue, path, isNullable, mappings );
Attribute fkNode = node.attribute( "foreign-key" );
if ( fkNode != null ) simpleValue.setForeignKeyName( fkNode.getValue() );
}
示例13: makeIdentifier
import org.dom4j.Element; //导入方法依赖的package包/类
private static void makeIdentifier(Element node, SimpleValue model, Mappings mappings)
throws MappingException {
//GENERATOR
Element subnode = node.element("generator");
if ( subnode!=null ) {
model.setIdentifierGeneratorStrategy( subnode.attributeValue("class") );
Properties params = new Properties();
if ( mappings.getSchemaName()!=null ) {
params.setProperty( PersistentIdentifierGenerator.SCHEMA, mappings.getSchemaName() );
}
params.setProperty( PersistentIdentifierGenerator.TABLE, model.getTable().getName() );
params.setProperty(
PersistentIdentifierGenerator.PK,
( (Column) model.getColumnIterator().next() ).getName()
);
Iterator iter = subnode.elementIterator("param");
while( iter.hasNext() ) {
Element childNode = (Element) iter.next();
params.setProperty(
childNode.attributeValue("name"),
childNode.getText()
);
}
model.setIdentifierGeneratorProperties(params);
}
model.getTable().setIdentifierValue(model);
// ID UNSAVED-VALUE
Attribute nullValueNode = node.attribute("unsaved-value");
if (nullValueNode!=null) {
model.setNullValue( nullValueNode.getValue() );
}
else {
model.setNullValue("null");
}
}
示例14: makeIdentifier
import org.dom4j.Element; //导入方法依赖的package包/类
private static void makeIdentifier(Element node, SimpleValue model, Mappings mappings) {
// GENERATOR
Element subnode = node.element( "generator" );
if ( subnode != null ) {
final String generatorClass = subnode.attributeValue( "class" );
model.setIdentifierGeneratorStrategy( generatorClass );
Properties params = new Properties();
// YUCK! but cannot think of a clean way to do this given the string-config based scheme
params.put( PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, mappings.getObjectNameNormalizer() );
if ( mappings.getSchemaName() != null ) {
params.setProperty(
PersistentIdentifierGenerator.SCHEMA,
mappings.getObjectNameNormalizer().normalizeIdentifierQuoting( mappings.getSchemaName() )
);
}
if ( mappings.getCatalogName() != null ) {
params.setProperty(
PersistentIdentifierGenerator.CATALOG,
mappings.getObjectNameNormalizer().normalizeIdentifierQuoting( mappings.getCatalogName() )
);
}
Iterator iter = subnode.elementIterator( "param" );
while ( iter.hasNext() ) {
Element childNode = (Element) iter.next();
params.setProperty( childNode.attributeValue( "name" ), childNode.getTextTrim() );
}
model.setIdentifierGeneratorProperties( params );
}
model.getTable().setIdentifierValue( model );
// ID UNSAVED-VALUE
Attribute nullValueNode = node.attribute( "unsaved-value" );
if ( nullValueNode != null ) {
model.setNullValue( nullValueNode.getValue() );
}
else {
if ( "assigned".equals( model.getIdentifierGeneratorStrategy() ) ) {
model.setNullValue( "undefined" );
}
else {
model.setNullValue( null );
}
}
}
示例15: initialise
import org.dom4j.Element; //导入方法依赖的package包/类
public void initialise(Element element, NamespacePrefixResolver nspr, PermissionModel permissionModel)
{
super.initialise(element, nspr, permissionModel);
Attribute att = element.attribute(EXPOSE);
if (att != null)
{
isExposed = Boolean.parseBoolean(att.getStringValue());
}
else
{
isExposed = true;
}
att = element.attribute(REQUIRES_TYPE);
if (att != null)
{
requiresType = Boolean.parseBoolean(att.getStringValue());
}
else
{
requiresType = true;
}
Attribute defaultPermissionAttribute = element.attribute(DEFAULT_PERMISSION);
if(defaultPermissionAttribute != null)
{
if(defaultPermissionAttribute.getStringValue().equalsIgnoreCase(ALLOW))
{
defaultPermission = AccessStatus.ALLOWED;
}
else if(defaultPermissionAttribute.getStringValue().equalsIgnoreCase(DENY))
{
defaultPermission = AccessStatus.DENIED;
}
else
{
throw new PermissionModelException("The default permission must be deny or allow");
}
}
else
{
defaultPermission = AccessStatus.DENIED;
}
for (Iterator gtgit = element.elementIterator(GRANTED_TO_GROUP); gtgit.hasNext(); /**/)
{
QName qName;
Element grantedToGroupsElement = (Element) gtgit.next();
Attribute typeAttribute = grantedToGroupsElement.attribute(GTG_TYPE);
if (typeAttribute != null)
{
qName = QName.createQName(typeAttribute.getStringValue(), nspr);
}
else
{
qName = getTypeQName();
}
String grantedName = grantedToGroupsElement.attributeValue(GTG_NAME);
grantedToGroups.add(PermissionReferenceImpl.getPermissionReference(qName, grantedName));
}
}