private void findFieldProperties(C c, XmlAccessType at) {
// always find properties from the super class first
C sc = nav().getSuperClass(c);
if (shouldRecurseSuperClass(sc)) {
findFieldProperties(sc,at);
}
for( F f : nav().getDeclaredFields(c) ) {
Annotation[] annotations = reader().getAllFieldAnnotations(f,this);
boolean isDummy = reader().hasFieldAnnotation(OverrideAnnotationOf.class, f);
if( nav().isTransient(f) ) {
// it's an error for transient field to have any binding annotation
if(hasJAXBAnnotation(annotations))
builder.reportError(new IllegalAnnotationException(
Messages.TRANSIENT_FIELD_NOT_BINDABLE.format(nav().getFieldName(f)),
getSomeJAXBAnnotation(annotations)));
} else
if( nav().isStaticField(f) ) {
// static fields are bound only when there's explicit annotation.
if(hasJAXBAnnotation(annotations))
addProperty(createFieldSeed(f),annotations, false);
} else {
if(at==XmlAccessType.FIELD
||(at==XmlAccessType.PUBLIC_MEMBER && nav().isPublicField(f))
|| hasJAXBAnnotation(annotations)) {
if (isDummy) {
ClassInfo<T, C> top = getBaseClass();
while ((top != null) && (top.getProperty("content") == null)) {
top = top.getBaseClass();
}
DummyPropertyInfo prop = (DummyPropertyInfo) top.getProperty("content");
PropertySeed seed = createFieldSeed(f);
((DummyPropertyInfo)prop).addType(createReferenceProperty(seed));
} else {
addProperty(createFieldSeed(f), annotations, false);
}
}
checkFieldXmlLocation(f);
}
}
}
java类javax.xml.bind.annotation.XmlAccessType的实例源码
ClassInfoImpl.java 文件源码
项目:openjdk-icedtea7
阅读 26
收藏 0
点赞 0
评论 0
DateModuleResultXmlTest.java 文件源码
项目:kalibro
阅读 36
收藏 0
点赞 0
评论 0
@Test
public void shouldHaveClassAnnotations() {
Class<DateModuleResultXml> xmlClass = DateModuleResultXml.class;
assertEquals("dateModuleResult", xmlClass.getAnnotation(XmlRootElement.class).name());
assertEquals(XmlAccessType.FIELD, xmlClass.getAnnotation(XmlAccessorType.class).value());
}
DateMetricResultXmlTest.java 文件源码
项目:kalibro
阅读 35
收藏 0
点赞 0
评论 0
@Test
public void shouldHaveClassAnnotations() {
Class<DateMetricResultXml> xmlClass = DateMetricResultXml.class;
assertEquals("dateMetricResult", xmlClass.getAnnotation(XmlRootElement.class).name());
assertEquals(XmlAccessType.FIELD, xmlClass.getAnnotation(XmlAccessorType.class).value());
}
ProcessTimeXmlTest.java 文件源码
项目:kalibro
阅读 34
收藏 0
点赞 0
评论 0
@Test
public void shouldHaveClassAnnotations() {
Class<ProcessTimeXml> xmlClass = ProcessTimeXml.class;
assertEquals("stateTime", xmlClass.getAnnotation(XmlRootElement.class).name());
assertEquals(XmlAccessType.FIELD, xmlClass.getAnnotation(XmlAccessorType.class).value());
}
XmlTest.java 文件源码
项目:kalibro
阅读 35
收藏 0
点赞 0
评论 0
@Test
public void shouldHaveFieldXmlAccess() throws ClassNotFoundException {
XmlAccessorType accessorType = dtoClass().getAnnotation(XmlAccessorType.class);
assertNotNull(accessorType);
assertEquals(XmlAccessType.FIELD, accessorType.value());
}
JAXBContextInitializer.java 文件源码
项目:cxf-plus
阅读 33
收藏 0
点赞 0
评论 0
/**
* Checks if the method is accepted as a JAXB property getter.
*/
static boolean isMethodAccepted(Method method, XmlAccessType accessType) {
// We only accept non static property getters which are not marked @XmlTransient
if (Modifier.isStatic(method.getModifiers())
|| method.isAnnotationPresent(XmlTransient.class)
|| !Modifier.isPublic(method.getModifiers())) {
return false;
}
// must not have parameters and return type must not be void
if (method.getReturnType() == Void.class
|| method.getParameterTypes().length != 0
|| method.getDeclaringClass().equals(Throwable.class)) {
return false;
}
boolean isPropGetter = method.getName().startsWith("get") || method.getName().startsWith("is");
if (!isPropGetter
|| method.getAnnotation(XmlJavaTypeAdapter.class) != null) {
return false;
}
int beginIndex = 3;
if (method.getName().startsWith("is")) {
beginIndex = 2;
}
try {
method.getDeclaringClass().getMethod("set" + method.getName().substring(beginIndex),
new Class[] {method.getReturnType()});
} catch (Exception e) {
//getter, but no setter
return false;
}
if (accessType == XmlAccessType.NONE
|| accessType == XmlAccessType.FIELD) {
return checkJaxbAnnotation(method.getAnnotations());
} else {
return true;
}
}