}; taskCmdSubTypes.removeAll(Arrays.asList(exclTaskCmds)); for( XmlElement xmlElemAnno : xmlElemsAnno.value() ) { Class xmlElemAnnoType = xmlElemAnno.type(); assertTrue( xmlElemAnnoType.getName() + " does not extend the " + TaskCommand.class.getSimpleName() + " class!", taskCmdSubTypes.contains(xmlElemAnnoType)); for( XmlElement xmlElemAnno : xmlElemsAnno.value() ) { Class xmlElemAnnoType = xmlElemAnno.type(); taskCmdSubTypes.remove(xmlElemAnnoType);
else if(xes!=null) ann = xes.value();
if (elems != null) { result = new ArrayList<NamedType>(); for (XmlElement elem : elems.value()) { String name = elem.name(); if (MARKER_FOR_DEFAULT.equals(name)) name = null;
else if(xes!=null) ann = xes.value();
static boolean supportsCriteriaValue(Class<? extends SingleValuedPredicate> simplePredicateClass, CriteriaValue<?> value) { if (simplePredicateClass == null) { throw new IllegalArgumentException("simplePredicateClass was null"); } if (value == null) { throw new IllegalArgumentException("valueClass was null"); } XmlElements elementsAnnotation = CriteriaSupportUtils.findXmlElementsAnnotation(simplePredicateClass); if (elementsAnnotation != null) { XmlElement[] elements = elementsAnnotation.value(); for (XmlElement element : elements) { if (value.getClass().equals(element.type())) { return true; } } } return false; }
private boolean checkIfParentChildRelationIsPossible(Class srcClass, Class targetClass) { XmlElements targetClassAnnotation = (XmlElements) getFieldAnnotation(targetClass, XmlElements.class); if (targetClassAnnotation == null) { return false; } for (XmlElement xe : targetClassAnnotation.value()) { if (srcClass.isAssignableFrom(xe.type())) { return true; } } return false; } }
private String findKeyForField(String key, Mappings.Getter getter, Class<?> componentType) { String k = null; final XmlElement xmlElt = getter.reader.getAnnotation(XmlElement.class); if (xmlElt != null && !Jaxbs.isDefault(xmlElt.name())) { k = xmlElt.name(); } final XmlElements xmlElts = getter.reader.getAnnotation(XmlElements.class); if (xmlElts != null) { for (final XmlElement xml : xmlElts.value()) { if (xml.type() == componentType && !Jaxbs.isDefault(xml.name())) { k = xml.name(); } } } if (k == null) { if (MethodAccessMode.MethodReader.class.isInstance(getter)) { k = Introspector.decapitalize(Method.class.cast(Reflections.get(MethodAccessMode.MethodReader.class.cast(getter), "method")).getName().replaceFirst("get", " ")); } else if (FieldAccessMode.FieldReader.class.isInstance(getter)) { k = Introspector.decapitalize(Field.class.cast(Reflections.get(FieldAccessMode.FieldReader.class.cast(getter), "field")).getName()); } else { k = key; } } return k; }
XmlElements xmlElements = field.getAnnotation(XmlElements.class); assert xmlElements != null; for (XmlElement xe : xmlElements.value()) { if (xe.type().equals(child.getClass())) { return new QName(child.getOriginatingNamespaceURI(), xe.name());
if (field.isAnnotationPresent(XmlElements.class)) { XmlElement[] xmlElements = field.getAnnotation(XmlElements.class) .value(); for (XmlElement xmlElement : xmlElements) { if (isJaxbComplexTypeClass(xmlElement.type()))
XmlElements xmlElements = getAnnotation(XmlElements.class); if (xmlElements != null) { XmlElement[] elementChoices = xmlElements.value(); if (elementChoices.length == 0) { xmlElements = null; this.choices = new ArrayList<Element>(); if (xmlElements != null) { for (XmlElement element : xmlElements.value()) { try { Class clazz = element.type();
XmlElements xmlElements = getAnnotation(XmlElements.class); if (xmlElements != null) { XmlElement[] elementChoices = xmlElements.value(); if (elementChoices.length == 0) { xmlElements = null; this.choices = new ArrayList<Element>(); if (xmlElements != null) { for (final XmlElement element : xmlElements.value()) { DecoratedTypeMirror typeMirror = Annotations.mirrorOf(new Callable<Class<?>>() { @Override
XmlElements xmlElements = getAnnotation(XmlElements.class); if (xmlElements != null) { XmlElement[] elementChoices = xmlElements.value(); if (elementChoices.length == 0) { xmlElements = null; this.choices = new ArrayList<Element>(); if (xmlElements != null) { for (final XmlElement element : xmlElements.value()) { DecoratedTypeMirror typeMirror = Annotations.mirrorOf(new Callable<Class<?>>() { @Override
XmlElements xmlElements = getAnnotation(XmlElements.class); if (xmlElements != null) { XmlElement[] elementChoices = xmlElements.value(); if (elementChoices.length == 0) { xmlElements = null; this.choices = new ArrayList<Element>(); if (xmlElements != null) { for (XmlElement element : xmlElements.value()) { try { Class clazz = element.type();
public ValidationResult validateElement(Element element) { ValidationResult result = validateAccessor(element); XmlElements xmlElements = element.getAnnotation(XmlElements.class); if ((element.isCollectionType()) && (element.getBaseType() != KnownXmlType.ANY_TYPE) && (xmlElements != null) && (xmlElements.value() != null) && (xmlElements.value().length > 1)) { result.addError(element.getPosition(), "A parameterized collection accessor cannot be annotated with XmlElements that has a value with a length greater than one."); } QName ref = element.getRef(); if ((ref != null) && (element.getBaseType().isAnonymous())) { result.addError(element.getPosition(), "Element whose namespace differs from that of its type definition must not have an anonymous base type."); } return result; }
Field commandsField = JaxbCommandsResponse.class.getDeclaredField("responses"); XmlElements xmlElemsAnno = (XmlElements) commandsField.getAnnotations()[0]; XmlElement[] xmlElems = xmlElemsAnno.value();
Field commandsField = JaxbCommandsResponse.class.getDeclaredField("responses"); XmlElements xmlElemsAnno = (XmlElements) commandsField.getAnnotations()[0]; XmlElement[] xmlElems = xmlElemsAnno.value();
/** * If you think this test is a mistake: beware, this test is smarter than * you. */ @Test public void acceptedCommandsCanBeSerializedTest() throws Exception { Field commandsField = JaxbCommandsRequest.class.getDeclaredField("commands"); XmlElements xmlElemsAnno = (XmlElements) commandsField.getAnnotations()[0]; XmlElement[] xmlElems = xmlElemsAnno.value(); Set<Class> cmdSet = getAcceptedCommandClassSet(); assertEquals(AcceptedServerCommands.class.getSimpleName() + " contains a different set of Commands than " + JaxbCommandsRequest.class.getSimpleName(), cmdSet.size(), xmlElems.length); Set<String> xmlElemNameSet = new HashSet<String>(); for( XmlElement xmlElemAnno : xmlElems ) { Class cmdClass = xmlElemAnno.type(); String name = xmlElemAnno.name(); assertTrue(name + " is used twice as a name.", xmlElemNameSet.add(name)); assertTrue(cmdClass.getSimpleName() + " is present in " + AcceptedServerCommands.class.getSimpleName() + " but not in " + JaxbCommandsRequest.class.getSimpleName(), cmdSet.remove(cmdClass)); } for( Class cmdClass : cmdSet ) { logger.error("Missing: " + cmdClass.getSimpleName()); } assertEquals("See output for classes in " + AcceptedServerCommands.class.getSimpleName() + " that are not in " + JaxbCommandsRequest.class.getSimpleName(), 0, cmdSet.size()); }
/** * If you think this test is a mistake: beware, this test is smarter than you. Seriously. * Heck, this test is smarter than *me*, and I wrote it! * * @throws Exception */ @Test public void acceptedCommandsCanBeSerializedTest() throws Exception { // Only neccessary to run once Assume.assumeTrue(getType().equals(TestType.JAXB)); Field commandsField = JaxbCommandsRequest.class.getDeclaredField("commands"); XmlElements xmlElemsAnno = (XmlElements) commandsField.getAnnotations()[0]; XmlElement[] xmlElems = xmlElemsAnno.value(); Set<Class> cmdSet = new HashSet<Class>(AcceptedCommands.getSet()); assertEquals(AcceptedCommands.class.getSimpleName() + " contains a different set of Commands than " + JaxbCommandsRequest.class.getSimpleName(), cmdSet.size(), xmlElems.length); Set<String> xmlElemNameSet = new HashSet<String>(); for (XmlElement xmlElemAnno : xmlElems) { Class cmdClass = xmlElemAnno.type(); String name = xmlElemAnno.name(); assertTrue(name + " is used twice as a name.", xmlElemNameSet.add(name)); assertTrue(cmdClass.getSimpleName() + " is present in " + AcceptedCommands.class.getSimpleName() + " but not in " + JaxbCommandsRequest.class.getSimpleName(), cmdSet.remove(cmdClass)); } for (Class cmdClass : cmdSet) { logger.error("Missing: " + cmdClass.getSimpleName()); } assertEquals("See output for classes in " + AcceptedCommands.class.getSimpleName() + " that are not in " + JaxbCommandsRequest.class.getSimpleName(), 0, cmdSet.size()); }