org.jvnet.hk2.config.Dom.convertName()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中org.jvnet.hk2.config.Dom.convertName()方法的一些代码示例,展示了Dom.convertName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dom.convertName()方法的具体详情如下:
包路径:org.jvnet.hk2.config.Dom
类名称:Dom
方法名:convertName

Dom.convertName介绍

暂无

代码示例

代码示例来源:origin: javaee/glassfish

String inferName(String name) {
  if(name.length()==0)
    name = Dom.convertName(seedName());
  return name;
}

代码示例来源:origin: javaee/glassfish

elementName = Dom.convertName(clz.getSimpleName().toString());

代码示例来源:origin: org.glassfish.main.common/amx-core

public static String toXMLName(final String name)
{
  return name == null ? name : Dom.convertName(name);
}

代码示例来源:origin: org.glassfish.main.admin/admin-cli

public void addAttribute(String name, Attribute annotation) {
  attributes.put(Dom.convertName(name), annotation);
}

代码示例来源:origin: org.glassfish.admin/admin-cli

public void addAttribute(String name, Attribute annotation) {
  attributes.put(Dom.convertName(name), annotation);
}

代码示例来源:origin: org.glassfish.main.admin/admin-cli

public void removeAttribute(String name) {
  attributes.remove(Dom.convertName(name));
}

代码示例来源:origin: org.glassfish.admin/admin-cli

public void removeAttribute(String name) {
  attributes.remove(Dom.convertName(name));
}

代码示例来源:origin: org.glassfish.main.admin/admin-cli

public String getXmlName() {
    return Dom.convertName(def.substring(def.lastIndexOf(".")+1));
  }
}

代码示例来源:origin: org.glassfish.admin/admin-cli

public String getXmlName() {
    return Dom.convertName(def.substring(def.lastIndexOf(".")+1));
  }
}

代码示例来源:origin: org.glassfish.main.common/amx-core

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);
}

代码示例来源:origin: eclipse-ee4j/glassfish

String inferName(String name) {
  if(name.length()==0)
    name = Dom.convertName(seedName());
  return name;
}

代码示例来源:origin: org.glassfish.admin/config-api

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);

代码示例来源:origin: org.glassfish.main.admin/config-api

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);

代码示例来源:origin: org.glassfish.main.admin/config-api

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;
}

代码示例来源:origin: org.glassfish.hk2/config

@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);
  }
}

代码示例来源:origin: com.sun.enterprise/config

@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);
  }
}

代码示例来源:origin: com.sun.enterprise/config

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));
  }
}

代码示例来源:origin: org.glassfish.hk2/config

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));
  }
}

代码示例来源:origin: com.sun.enterprise/config

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"));

代码示例来源:origin: org.glassfish.hk2/config

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"));

相关文章

微信公众号

最新文章

更多