本文整理了Java中org.dom4j.Element.getPath()
方法的一些代码示例,展示了Element.getPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getPath()
方法的具体详情如下:
包路径:org.dom4j.Element
类名称:Element
方法名:getPath
暂无
代码示例来源:origin: com.thoughtworks.xstream/xstream
public void appendErrors(ErrorWriter errorWriter) {
errorWriter.add("xpath", currentElement.getPath());
}
代码示例来源:origin: hibernate/hibernate-orm
private static void copyIntegerAttribute(AnnotationDescriptor annotation, Element element, String attributeName) {
String attribute = element.attributeValue( attributeName );
if ( attribute != null ) {
String annotationAttributeName = getJavaAttributeNameFromXMLOne( attributeName );
annotation.setValue( annotationAttributeName, attribute );
try {
int length = Integer.parseInt( attribute );
annotation.setValue( annotationAttributeName, length );
}
catch ( NumberFormatException e ) {
throw new AnnotationException(
element.getPath() + attributeName + " not parseable: " + attribute + " (" + SCHEMA_VALIDATION + ")"
);
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
private EntityListeners getEntityListeners(Element tree, XMLContext.Default defaults) {
Element element = tree != null ? tree.element( "entity-listeners" ) : null;
if ( element != null ) {
List<Class> entityListenerClasses = new ArrayList<>();
for ( Element subelement : (List<Element>) element.elements( "entity-listener" ) ) {
String className = subelement.attributeValue( "class" );
try {
entityListenerClasses.add(
classLoaderAccess.classForName(
XMLContext.buildSafeClassName( className, defaults )
)
);
}
catch ( ClassLoadingException e ) {
throw new AnnotationException(
"Unable to find " + element.getPath() + ".class: " + className, e
);
}
}
AnnotationDescriptor ad = new AnnotationDescriptor( EntityListeners.class );
ad.setValue( "value", entityListenerClasses.toArray( new Class[entityListenerClasses.size()] ) );
return AnnotationFactory.create( ad );
}
else if ( defaults.canUseJavaAnnotations() ) {
return getPhysicalAnnotation( EntityListeners.class );
}
else {
return null;
}
}
代码示例来源:origin: hibernate/hibernate-orm
private void addTargetClass(Element element, AnnotationDescriptor ad, String nodeName, XMLContext.Default defaults) {
String className = element.attributeValue( nodeName );
if ( className != null ) {
Class clazz;
try {
clazz = classLoaderAccess.classForName( XMLContext.buildSafeClassName( className, defaults ) );
}
catch ( ClassLoadingException e ) {
throw new AnnotationException(
"Unable to find " + element.getPath() + " " + nodeName + ": " + className, e
);
}
ad.setValue( getJavaAttributeNameFromXMLOne( nodeName ), clazz );
}
}
代码示例来源:origin: hibernate/hibernate-orm
private void getMapKeyClass(List<Annotation> annotationList, Element element, XMLContext.Default defaults) {
String nodeName = "map-key-class";
Element subelement = element != null ? element.element( nodeName ) : null;
if ( subelement != null ) {
String mapKeyClassName = subelement.attributeValue( "class" );
AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyClass.class );
if ( StringHelper.isNotEmpty( mapKeyClassName ) ) {
Class clazz;
try {
clazz = classLoaderAccess.classForName(
XMLContext.buildSafeClassName( mapKeyClassName, defaults )
);
}
catch ( ClassLoadingException e ) {
throw new AnnotationException(
"Unable to find " + element.getPath() + " " + nodeName + ": " + mapKeyClassName, e
);
}
ad.setValue( "value", clazz );
}
annotationList.add( AnnotationFactory.create( ad ) );
}
}
代码示例来源:origin: hibernate/hibernate-orm
private Column getColumn(Element element, boolean isMandatory, Element current) {
//Element subelement = element != null ? element.element( "column" ) : null;
if ( element != null ) {
AnnotationDescriptor column = new AnnotationDescriptor( Column.class );
copyStringAttribute( column, element, "name", false );
copyBooleanAttribute( column, element, "unique" );
copyBooleanAttribute( column, element, "nullable" );
copyBooleanAttribute( column, element, "insertable" );
copyBooleanAttribute( column, element, "updatable" );
copyStringAttribute( column, element, "column-definition", false );
copyStringAttribute( column, element, "table", false );
copyIntegerAttribute( column, element, "length" );
copyIntegerAttribute( column, element, "precision" );
copyIntegerAttribute( column, element, "scale" );
return (Column) AnnotationFactory.create( column );
}
else {
if ( isMandatory ) {
throw new AnnotationException( current.getPath() + ".column is mandatory. " + SCHEMA_VALIDATION );
}
return null;
}
}
代码示例来源:origin: org.dom4j/dom4j
public String getPath(Element context) {
// From XPaths perspective, entities are included in text
Element parent = getParent();
return ((parent != null) && (parent != context)) ? (parent
.getPath(context) + "/text()") : "text()";
}
代码示例来源:origin: org.dom4j/dom4j
public String getPath(Element context) {
Element parent = getParent();
return ((parent != null) && (parent != context)) ? (parent
.getPath(context) + "/processing-instruction()")
: "processing-instruction()";
}
代码示例来源:origin: org.dom4j/dom4j
public String getPath(Element context) {
Element parent = getParent();
return ((parent != null) && (parent != context)) ? (parent
.getPath(context) + "/text()") : "text()";
}
代码示例来源:origin: org.dom4j/dom4j
public String getPath(Element context) {
Element parent = getParent();
return ((parent != null) && (parent != context)) ? (parent
.getPath(context) + "/comment()") : "comment()";
}
代码示例来源:origin: org.dom4j/dom4j
public String getPath(Element context) {
StringBuffer path = new StringBuffer(10);
Element parent = getParent();
if ((parent != null) && (parent != context)) {
path.append(parent.getPath(context));
path.append('/');
}
path.append(getXPathNameStep());
return path.toString();
}
代码示例来源:origin: org.dom4j/dom4j
public String getPath(Element context) {
StringBuilder result = new StringBuilder();
Element parent = getParent();
if ((parent != null) && (parent != context)) {
result.append(parent.getPath(context));
result.append("/");
}
result.append("@");
String uri = getNamespaceURI();
String prefix = getNamespacePrefix();
if ((uri == null) || (uri.length() == 0) || (prefix == null)
|| (prefix.length() == 0)) {
result.append(getName());
} else {
result.append(getQualifiedName());
}
return result.toString();
}
代码示例来源:origin: org.hibernate/hibernate-annotations
private static void copyIntegerAttribute(AnnotationDescriptor annotation, Element element, String attributeName) {
String attribute = element.attributeValue( attributeName );
if ( attribute != null ) {
String annotationAttributeName = getJavaAttributeNameFromXMLOne( attributeName );
annotation.setValue( annotationAttributeName, attribute );
try {
int length = Integer.parseInt( attribute );
annotation.setValue( annotationAttributeName, length );
}
catch (NumberFormatException e) {
throw new AnnotationException(
element.getPath() + attributeName + " not parseable: " + attribute + " (" + SCHEMA_VALIDATION + ")"
);
}
}
}
代码示例来源:origin: org.hibernate/hibernate-annotations
private void addTargetClass(Element element, AnnotationDescriptor ad, String nodeName, XMLContext.Default defaults) {
String className = element.attributeValue( nodeName );
if ( className != null ) {
Class clazz;
try {
clazz = ReflectHelper.classForName(
XMLContext.buildSafeClassName( className, defaults ),
this.getClass()
);
}
catch (ClassNotFoundException e) {
throw new AnnotationException(
"Unable to find " + element.getPath() + " " + nodeName + ": " + className, e
);
}
ad.setValue( getJavaAttributeNameFromXMLOne(nodeName), clazz );
}
}
代码示例来源:origin: org.hibernate/hibernate-annotations
"Unable to find " + element.getPath() + ".class: " + className, e
);
代码示例来源:origin: org.dom4j/dom4j
public String getPath(Element context) {
if (this == context) {
return ".";
}
Element parent = getParent();
if (parent == null) {
return "/" + getXPathNameStep();
} else if (parent == context) {
return getXPathNameStep();
}
return parent.getPath(context) + "/" + getXPathNameStep();
}
代码示例来源:origin: org.hibernate/hibernate-annotations
private Column getColumn(Element element, boolean isMandatory, Element current) {
//Element subelement = element != null ? element.element( "column" ) : null;
if ( element != null ) {
AnnotationDescriptor column = new AnnotationDescriptor( Column.class );
copyStringAttribute( column, element, "name", false );
copyBooleanAttribute( column, element, "unique" );
copyBooleanAttribute( column, element, "nullable" );
copyBooleanAttribute( column, element, "insertable" );
copyBooleanAttribute( column, element, "updatable" );
copyStringAttribute( column, element, "column-definition", false );
copyStringAttribute( column, element, "table", false );
copyIntegerAttribute( column, element, "length" );
copyIntegerAttribute( column, element, "precision" );
copyIntegerAttribute( column, element, "scale" );
return (Column) AnnotationFactory.create( column );
}
else {
if ( isMandatory ) {
throw new AnnotationException( current.getPath() + ".column is mandatory. " + SCHEMA_VALIDATION );
}
return null;
}
}
代码示例来源:origin: dom4j/dom4j
public String getPath(Element context) {
Element parent = getParent();
return ((parent != null) && (parent != context)) ? (parent
.getPath(context) + "/comment()") : "comment()";
}
代码示例来源:origin: org.dom4j/com.springsource.org.dom4j
public String getPath(Element context) {
// From XPaths perspective, entities are included in text
Element parent = getParent();
return ((parent != null) && (parent != context)) ? (parent
.getPath(context) + "/text()") : "text()";
}
代码示例来源:origin: dom4j/dom4j
public String getPath(Element context) {
StringBuffer path = new StringBuffer(10);
Element parent = getParent();
if ((parent != null) && (parent != context)) {
path.append(parent.getPath(context));
path.append('/');
}
path.append(getXPathNameStep());
return path.toString();
}
内容来源于网络,如有侵权,请联系作者删除!