String inferName(String name) { if(name.length()==0) name = Dom.convertName(seedName()); return name; }
elementName = Dom.convertName(clz.getSimpleName().toString());
public static String toXMLName(final String name) { return name == null ? name : Dom.convertName(name); }
public void addAttribute(String name, Attribute annotation) { attributes.put(Dom.convertName(name), annotation); }
public void addAttribute(String name, Attribute annotation) { attributes.put(Dom.convertName(name), annotation); }
public void removeAttribute(String name) { attributes.remove(Dom.convertName(name)); }
public void removeAttribute(String name) { attributes.remove(Dom.convertName(name)); }
public String getXmlName() { return Dom.convertName(def.substring(def.lastIndexOf(".")+1)); } }
public String getXmlName() { return Dom.convertName(def.substring(def.lastIndexOf(".")+1)); } }
public static String convertAttributeName(final String s ) { // do not alter any name that is already all lower-case or that contains a "-" */ if ( s.equals( s.toLowerCase(Locale.getDefault()) ) || s.indexOf("-") >= 0 ) { return(s); } // Dom.convertName() has a bug: IsFooBar => is-foo-bar, but is-foo-bar => -foo-bar. return Dom.convertName(s); }
String inferName(String name) { if(name.length()==0) name = Dom.convertName(seedName()); return name; }
public Object run(ConfigBeanProxy param) { PropertyBag bag = (PropertyBag) param; final List<Property> propertyList = new ArrayList<Property>(bag.getProperty()); setProperty(target, attribute, getValue(propertyList, property)); final String message = MessageFormat.format("Moved {0}.property.{1} to {0}.{2}", Dom.convertName(Dom.unwrap(target).getProxyType().getSimpleName()), property, Dom.convertName(attribute)); report(context, message); bag.getProperty().clear(); bag.getProperty().addAll(propertyList); return param; } }, target);
public Object run(ConfigBeanProxy param) { PropertyBag bag = (PropertyBag) param; final List<Property> propertyList = new ArrayList<Property>(bag.getProperty()); setProperty(target, attribute, getValue(propertyList, property)); final String message = MessageFormat.format("Moved {0}.property.{1} to {0}.{2}", Dom.convertName(Dom.unwrap(target).getProxyType().getSimpleName()), property, Dom.convertName(attribute)); report(context, message); bag.getProperty().clear(); bag.getProperty().addAll(propertyList); return param; } }, target);
private boolean createMissingElementFor(Class configBeanType, ActionReport report) throws Exception { boolean defaultConfigCreated = false; if (ConfigExtension.class.isAssignableFrom(configBeanType)) { if (config.checkIfExtensionExists(configBeanType)) { report.appendMessage(localStrings.getLocalString("create.module.config.already.exists", "Configuration for {0} already exists. The command didn't change the existing configuration.", Dom.convertName(configBeanType.getSimpleName()))); report.appendMessage(LINE_SEPARATOR); return false; } config.getExtensionByType(configBeanType); report.appendMessage(localStrings.getLocalString("create.module.config.done", "Configuration for {0} added to domain.xml", Dom.convertName(configBeanType.getSimpleName()))); report.appendMessage(LINE_SEPARATOR); defaultConfigCreated = true; } else if (configBeanType.isAssignableFrom(DomainExtension.class)) { if (domain.checkIfExtensionExists(configBeanType)) { report.appendMessage(localStrings.getLocalString("create.module.config.already.exists", "Configuration for {0} already exists. The command didn't change the existing configuration.", Dom.convertName(configBeanType.getSimpleName()))); report.appendMessage(LINE_SEPARATOR); return false; } domain.getExtensionByType(configBeanType); report.appendMessage(localStrings.getLocalString("create.module.config.done", "Configuration for {0} added to domain.xml", Dom.convertName(configBeanType.getSimpleName()))); report.appendMessage(LINE_SEPARATOR); defaultConfigCreated = true; } return defaultConfigCreated; }
@Override public void parse(ParsingContext context, Holder<ClassLoader> loader) { this.context = context; AnnotationType configured = (AnnotationType) context.getTypes().getBy(Configured.class.getName()); if (configured==null) return; for (AnnotatedElement ae : configured.allAnnotatedTypes()) { if (!(ae instanceof ExtensibleType)) { continue; } MultiMap<String,String> metadata = new MultiMap<String,String>(); parse((ExtensibleType<?>) ae, metadata); AnnotationModel c = ae.getAnnotation(Configured.class.getName()); String elementName = (String) c.getValues().get("value"); if(elementName==null || elementName.length()==0) { // infer default elementName = Dom.convertName(ae.getName().substring(ae.getName().lastIndexOf('.')+1)); } metadata.add(ConfigMetadata.TARGET, ae.getName()); // register the injector. LazyInhabitant inhabitant = new LazyInhabitant(habitat, loader, NoopConfigInjector.class.getName(), metadata); habitat.addIndex(inhabitant, InjectionTarget.class.getName(), ae.getName()); habitat.addIndex(inhabitant, ConfigInjector.class.getName(), elementName); } }
@Override public void parse(ParsingContext context, Holder<ClassLoader> loader) { this.context = context; AnnotationType configured = (AnnotationType) context.getTypes().getBy(Configured.class.getName()); if (configured==null) return; for (AnnotatedElement ae : configured.allAnnotatedTypes()) { if (!(ae instanceof ExtensibleType)) { continue; } MultiMap<String,String> metadata = new MultiMap<String,String>(); parse((ExtensibleType<?>) ae, metadata); AnnotationModel c = ae.getAnnotation(Configured.class.getName()); String elementName = (String) c.getValues().get("value"); if(elementName==null || elementName.length()==0) { // infer default elementName = Dom.convertName(ae.getName().substring(ae.getName().lastIndexOf('.')+1)); } metadata.add(ConfigMetadata.TARGET, ae.getName()); // register the injector. LazyInhabitant inhabitant = new LazyInhabitant(habitat, loader, NoopConfigInjector.class.getName(), metadata); habitat.addIndex(inhabitant, InjectionTarget.class.getName(), ae.getName()); habitat.addIndex(inhabitant, ConfigInjector.class.getName(), elementName); } }
private void generateElement(AnnotationModel element, MethodModel m, MultiMap<String, String> metadata) { String name = Dom.convertName(m.getName()); String xmlTokenName = "<" + name + ">"; String[] arguments = m.getArgumentTypes(); String refTypeAsString; if (arguments.length==0) { refTypeAsString = m.getReturnType(); } else { if (arguments.length!=1) { throw new RuntimeException("@Element method cannot have more than 1 argument " + m.getSignature()); } refTypeAsString = arguments[0]; } boolean isCollection = refTypeAsString.startsWith("java.util.List<L"); if (isCollection) { refTypeAsString = refTypeAsString.substring("java.util.List<L".length()); } Boolean isReference = (Boolean) element.getValues().get("reference"); Type refType = context.getTypes().getBy(refTypeAsString); if (refType==null || (isReference!=null && isReference)) { // leaf metadata.add(xmlTokenName, makeCollectionIfNecessary(isCollection, "leaf")); if (isReference!=null && isReference) { metadata.add(xmlTokenName, "reference"); } } else { // node metadata.add(xmlTokenName, makeCollectionIfNecessary(isCollection, refTypeAsString)); } }
private void generateElement(AnnotationModel element, MethodModel m, MultiMap<String, String> metadata) { String name = Dom.convertName(m.getName()); String xmlTokenName = "<" + name + ">"; String[] arguments = m.getArgumentTypes(); String refTypeAsString; if (arguments.length==0) { refTypeAsString = m.getReturnType(); } else { if (arguments.length!=1) { throw new RuntimeException("@Element method cannot have more than 1 argument " + m.getSignature()); } refTypeAsString = arguments[0]; } boolean isCollection = refTypeAsString.startsWith("java.util.List<L"); if (isCollection) { refTypeAsString = refTypeAsString.substring("java.util.List<L".length()); } Boolean isReference = (Boolean) element.getValues().get("reference"); Type refType = context.getTypes().getBy(refTypeAsString); if (refType==null || (isReference!=null && isReference)) { // leaf metadata.add(xmlTokenName, makeCollectionIfNecessary(isCollection, "leaf")); if (isReference!=null && isReference) { metadata.add(xmlTokenName, "reference"); } } else { // node metadata.add(xmlTokenName, makeCollectionIfNecessary(isCollection, refTypeAsString)); } }
private void generateAttribute(AnnotationModel attribute, MethodModel m, MultiMap<String, String> metadata) { String name = Dom.convertName(m.getName()); String xmlTokenName = '@' + name; boolean isRequired = Boolean.parseBoolean((String) attribute.getValues().get("isRequired"));
private void generateAttribute(AnnotationModel attribute, MethodModel m, MultiMap<String, String> metadata) { String name = Dom.convertName(m.getName()); String xmlTokenName = '@' + name; boolean isRequired = Boolean.parseBoolean((String) attribute.getValues().get("isRequired"));