public static CPluginCustomization findCustomization(CClassInfo classInfo, QName name) { final CCustomizations customizations = CustomizationUtils.getCustomizations(classInfo); final CPluginCustomization customization = customizations.find(name.getNamespaceURI(), name.getLocalPart()); if (customization != null) { customization.markAsAcknowledged(); } return customization; }
public static CPluginCustomization createCustomization( final Element element) { final CPluginCustomization customization = new CPluginCustomization( element, null); return customization; }
private void checkCustomizations(CClassInfo customizable) { for (final CPluginCustomization pluginCustomization : CustomizationUtils .getCustomizations(customizable)) { final Element element = pluginCustomization.element; if (!pluginCustomization.isAcknowledged() // && Customizations.NAMESPACE_URI.equals(element // .getNamespaceURI()) ) { logger.warn("Unacknowledged customization [" + getName(element) + "] in the class [" + customizable.getName() + "]."); pluginCustomization.markAsAcknowledged(); } } }
public static List<CPluginCustomization> getPropertyCustomizationsInClass(CClassInfo classInfo, CPropertyInfo propertyInfo, QName propertyCustomizationName) { final List<CPluginCustomization> foundPropertyCustomizations = new LinkedList<CPluginCustomization>(); final List<CPluginCustomization> classCustomizations = CustomizationUtils.getCustomizations(classInfo); for (CPluginCustomization classCustomization : classCustomizations) { if (fixNull(classCustomization.element.getNamespaceURI()) .equals(propertyCustomizationName.getNamespaceURI()) && fixNull(classCustomization.element.getLocalName()) .equals(propertyCustomizationName.getLocalPart()) && propertyInfo.getName(false).equals(classCustomization.element.getAttribute("name"))) { final Element classCustomizationElement = classCustomization.element; final NodeList nodes = classCustomizationElement.getChildNodes(); final int length = nodes.getLength(); for (int index = 0; index < length; index++) { final Node node = nodes.item(index); if (node.getNodeType() == Node.ELEMENT_NODE) { final Element element = (Element) node; classCustomization.markAsAcknowledged(); final CPluginCustomization propertyCustomization = new CPluginCustomization(element, classCustomization.locator); propertyCustomization.markAsAcknowledged(); foundPropertyCustomizations.add(propertyCustomization); } } } } return foundPropertyCustomizations; }
protected void removeAnnotationFromEnumConstantOutline(final JCodeModel codeModel, final Outline outline, final EnumConstantOutline enumConstantOutline, final CCustomizations customizations, final ErrorHandler errorHandler) { for (final CPluginCustomization customization : customizations) { final Element element = customization.element; final QName name = new QName(element.getNamespaceURI(), element.getLocalName()); if (isCustomizationElementName(name)) { customization.markAsAcknowledged(); final AnnotationTarget annotationTarget = AnnotationTarget .getAnnotationTarget(element, AnnotationTarget.ENUM_CONSTANT); try { final JAnnotatable annotatable = annotationTarget .getAnnotatable(outline, enumConstantOutline); removeAnnotation(codeModel, errorHandler, customization, element, annotatable); } catch (IllegalArgumentException iaex) { logger.error("Error applying the annotation.", iaex); } } } }
public static List<CPluginCustomization> findCustomizations(CClassInfo classInfo, QName name) { final CCustomizations customizations = CustomizationUtils.getCustomizations(classInfo); final List<CPluginCustomization> pluginCustomizations = new LinkedList<CPluginCustomization>(); for (CPluginCustomization pluginCustomization : customizations) { if (fixNull(pluginCustomization.element.getNamespaceURI()).equals(name.getNamespaceURI()) && fixNull(pluginCustomization.element.getLocalName()).equals(name.getLocalPart())) { pluginCustomization.markAsAcknowledged(); pluginCustomizations.add(pluginCustomization); } } return pluginCustomizations; }
private List<FacetCustomization> detectCustomizations(CCustomizable ca) { List<FacetCustomization> facetCustomizations = new ArrayList<FacetCustomization>(); List<CPluginCustomization> pluginCustomizations = ca.getCustomizations(); if (pluginCustomizations != null) for (CPluginCustomization c : pluginCustomizations) { c.markAsAcknowledged(); String groups = c.element.getAttribute("groups"); String message = c.element.getAttribute("message"); String type = c.element.getAttribute("type"); if (type.equals("")) throw new RuntimeException("DOM attribute \"type\" is required in custom facet declarations."); String value = c.element.getAttribute("value"); facetCustomizations.add(new FacetCustomization(groups, message, type, value)); } return facetCustomizations; } }
/** * Clone given configuration and apply settings from global/class/field JAXB customization. */ protected static <T extends CommonConfiguration> T applyConfigurationFromCustomizations( CommonConfiguration configuration, CCustomizations customizations, boolean cloneClassConfiguration) throws IOException, ClassNotFoundException { CPluginCustomization customization = customizations.find(XEW_QNAME.getNamespaceURI(), XEW_QNAME.getLocalPart()); if (customization == null) { if (cloneClassConfiguration) { return (T) new ClassConfiguration(configuration); } return (T) configuration; } customization.markAsAcknowledged(); NamedNodeMap attributes = customization.element.getAttributes(); if (cloneClassConfiguration) { configuration = new ClassConfiguration(configuration); } for (int i = 0; i < attributes.getLength(); i++) { Node attribute = attributes.item(i); if (attribute.getNamespaceURI() == null) { applyConfigurationOption(configuration, ConfigurationOption.byOption(attribute.getNodeName()), attribute.getNodeValue()); } } return (T) configuration; }
String typePropertyName = null; parentTypeCustomization.markAsAcknowledged(); if (parentTypeCustomization.element.hasAttribute(X_ANNOTATION_JSON_TYPE_PROPERTY_NAME)) { typePropertyName = parentTypeCustomization.element.getAttribute(X_ANNOTATION_JSON_TYPE_PROPERTY_NAME); if (subTypeCustomization != null) { String typeName = null; subTypeCustomization.markAsAcknowledged(); if (subTypeCustomization.element.hasAttribute(X_ANNOTATION_JSON_SUBTYPE_NAME)) { typeName = subTypeCustomization.element.getAttribute(X_ANNOTATION_JSON_SUBTYPE_NAME);
/** * Gets the list of {@link CPluginCustomization}s from this. * * <p> * Note that calling this method marks all those plug-in customizations * as 'used'. So call it only when it's really necessary. */ public CCustomizations toCustomizationList() { CCustomizations r=null; for( BIDeclaration d : this ) { if(d instanceof BIXPluginCustomization) { BIXPluginCustomization pc = (BIXPluginCustomization) d; pc.markAsAcknowledged(); if(!Ring.get(Model.class).options.pluginURIs.contains(pc.getName().getNamespaceURI())) continue; // this isn't a plugin customization if(r==null) r = new CCustomizations(); r.add(new CPluginCustomization(pc.element,pc.getLocation())); } } if(r==null) r = CCustomizations.EMPTY; return new CCustomizations(r); } /** An instance with the empty contents. */
if(!p.isAcknowledged()) { ehf.error( p.locator, Messages.format( Messages.ERR_UNACKNOWLEDGED_CUSTOMIZATION, p.element.getNodeName() )); ehf.error(
/** * Gets the list of top-level {@link CPluginCustomization}s. */ private CCustomizations getGlobalCustomizations() { CCustomizations r=null; for( Element e : DOMUtil.getChildElements(dom) ) { if(!model.options.pluginURIs.contains(e.getNamespaceURI())) continue; // this isn't a plugin customization if(r==null) r = new CCustomizations(); r.add(new CPluginCustomization(e, DOMLocator.getLocationInfo(e))); } if(r==null) r = CCustomizations.EMPTY; return new CCustomizations(r); }
/** * This method adds {@link ContentType} annotation and a CONTENT TYPE * constant of type "public static final String" to the JAXB generated Java * class. It reads the "meta:content-type" annotation element in the schema * and adds a corresponding Java annotation if not empty. * * @param implClass the element which will be annotated * @param customizations schema customizations for this element */ private void addContentTypeAnnotation(JDefinedClass implClass, CCustomizations customizations) { if (implClass == null) { return; } CPluginCustomization customization = customizations.find(NAMESPACE_URI, ELEMENT_CONTENT_TYPE); if (customization == null) { return; } customization.markAsAcknowledged(); String contentType = customization.element.getTextContent(); if (contentType != null) { JAnnotationUse annotation = implClass.annotate(ContentType.class); annotation.param("value", contentType.trim()); final JCodeModel codeModel = implClass.owner(); JExpression contentTypeConst = JExpr.lit(contentType); @SuppressWarnings("unused") JFieldVar contentTypeField = implClass.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, codeModel.ref(String.class), CONTENT_TYPE_CONST, contentTypeConst); } }
c.markAsAcknowledged(); String javaType = fo.getRawType().name(); _log.debug("CobolJAXBAnnotator::run::ClassOutline::" + c.element.getLocalName() + " type=" + javaType); c.markAsAcknowledged();
private void checkCustomizations(CClassInfo classInfo, CPropertyInfo customizable) { for (CPluginCustomization pluginCustomization : CustomizationUtils .getCustomizations(customizable)) { if (!pluginCustomization.isAcknowledged() && Customizations.NAMESPACE_URI .equals(pluginCustomization.element .getNamespaceURI())) { logger.warn("Unacknowledged customization [" + getName(pluginCustomization.element) + "] in the property [" + classInfo.getName() + "." + customizable.getName(true) + "]."); pluginCustomization.markAsAcknowledged(); } } }
public static void markAsAcknowledged( final CPluginCustomization customization) { if (customization != null && NAMESPACE_URI .equals(customization.element.getNamespaceURI())) { customization.markAsAcknowledged(); } }
public static boolean containsCustomization(FieldOutline fieldOutline, QName name) { final CPluginCustomization customization = findCustomization(fieldOutline, name); if (customization != null) { customization.markAsAcknowledged(); } return customization != null; }
if (fixNull(classCustomization.element.getNamespaceURI()) .equals(propertyCustomizationName.getNamespaceURI()) && fixNull(classCustomization.element.getLocalName()) .equals(propertyCustomizationName.getLocalPart()) && propertyInfo.getName(false).equals(classCustomization.element.getAttribute("name"))) { if (node.getNodeType() == Node.ELEMENT_NODE) { final Element element = (Element) node; if (fixNull(element.getNamespaceURI()).equals(customizationName.getNamespaceURI()) && fixNull(element.getLocalName()).equals(customizationName.getLocalPart())) { classCustomization.markAsAcknowledged(); final CPluginCustomization propertyCustomization = new CPluginCustomization(element, classCustomization.locator); propertyCustomization.markAsAcknowledged(); foundPropertyCustomizations.add(propertyCustomization);
protected void annotateEnumConstantOutline(final JCodeModel codeModel, final Outline outline, final EnumConstantOutline enumConstantOutline, final CCustomizations customizations, final ErrorHandler errorHandler) { for (final CPluginCustomization customization : customizations) { final Element element = customization.element; final QName name = new QName(element.getNamespaceURI(), element.getLocalName()); if (isCustomizationElementName(name)) { customization.markAsAcknowledged(); final AnnotationTarget annotationTarget = AnnotationTarget .getAnnotationTarget(element, AnnotationTarget.ENUM_CONSTANT); try { final JAnnotatable annotatable = annotationTarget .getAnnotatable(outline, enumConstantOutline); annotate(codeModel, errorHandler, customization, element, annotatable); } catch (IllegalArgumentException iaex) { logger.error("Error applying the annotation.", iaex); } } } }
public static List<CPluginCustomization> findCustomizations(CEnumLeafInfo enumInfo, QName name) { final CCustomizations customizations = CustomizationUtils.getCustomizations(enumInfo); final List<CPluginCustomization> pluginCustomizations = new LinkedList<CPluginCustomization>(); for (CPluginCustomization pluginCustomization : customizations) { if (fixNull(pluginCustomization.element.getNamespaceURI()).equals(name.getNamespaceURI()) && fixNull(pluginCustomization.element.getLocalName()).equals(name.getLocalPart())) { pluginCustomization.markAsAcknowledged(); pluginCustomizations.add(pluginCustomization); } } return pluginCustomizations; }