com.alibaba.citrus.util.FileUtil.normalizeExtension()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(145)

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

FileUtil.normalizeExtension介绍

[英]规格化文件名后缀。

  • 除去两边空白。
  • 转成小写。
  • 除去开头的“.”。
  • 对空白的后缀,返回null
    [中]规格化文件名后缀。
  • 除去两边空白。
  • 转成小写。
  • 除去开头的“.”。
  • 对空白的后缀,返回null

代码示例

代码示例来源:origin: webx/citrus

@Override
protected void init() throws Exception {
  if (extensions == null) {
    extensions = EMPTY_STRING_ARRAY;
  }
  for (int i = 0; i < extensions.length; i++) {
    extensions[i] = FileUtil.normalizeExtension(extensions[i]);
  }
}

代码示例来源:origin: webx/citrus

@Override
protected void init() throws Exception {
  if (extensions == null) {
    extensions = EMPTY_STRING_ARRAY;
  }
  for (int i = 0; i < extensions.length; i++) {
    extensions[i] = FileUtil.normalizeExtension(extensions[i]);
  }
}

代码示例来源:origin: webx/citrus

public void setExtension(String exts) {
  extensions.clear();
  // 支持无后缀
  if (exts == null) {
    extensions.add(null);
  } else {
    String[] extArray = StringUtil.split(exts, ", ");
    for (String ext : extArray) {
      extensions.add(normalizeExtension(ext));
    }
  }
}

代码示例来源:origin: webx/citrus

public void setExtension(String exts) {
  extensions.clear();
  // 支持无后缀
  if (exts == null) {
    extensions.add(null);
  } else {
    String[] extArray = StringUtil.split(exts, ", ");
    for (String ext : extArray) {
      extensions.add(normalizeExtension(ext));
    }
  }
}

代码示例来源:origin: webx/citrus

private String[] normalizeStrings(String[] strs, int type) {
  if (isEmptyArray(strs)) {
    return null;
  }
  List<String> strList = createLinkedList();
  for (String str : strs) {
    switch (type) {
      case 0:
        str = normalizeContentType(str);
        break;
      case 1:
        str = FileUtil.normalizeExtension(str);
        break;
      default:
        unreachableCode();
    }
    if (str != null) {
      strList.add(str);
    }
  }
  if (strList.isEmpty()) {
    return null;
  } else {
    return strList.toArray(new String[strList.size()]);
  }
}

代码示例来源:origin: webx/citrus

private String[] normalizeStrings(String[] strs, int type) {
  if (isEmptyArray(strs)) {
    return null;
  }
  List<String> strList = createLinkedList();
  for (String str : strs) {
    switch (type) {
      case 0:
        str = normalizeContentType(str);
        break;
      case 1:
        str = FileUtil.normalizeExtension(str);
        break;
      default:
        unreachableCode();
    }
    if (str != null) {
      strList.add(str);
    }
  }
  if (strList.isEmpty()) {
    return null;
  } else {
    return strList.toArray(new String[strList.size()]);
  }
}

代码示例来源:origin: webx/citrus

ext = normalizeExtension(ext);
defaultExtension = normalizeExtension(defaultExtension);

代码示例来源:origin: webx/citrus

ext = normalizeExtension(ext);
defaultExtension = normalizeExtension(defaultExtension);

代码示例来源:origin: webx/citrus

@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
  parseBeanDefinitionAttributes(element, parserContext, builder);
  Map<Object, Object> engines = createManagedMap(element, parserContext);
  Map<Object, Object> mappings = createManagedMap(element, parserContext);
  ElementSelector engineSelector = ns(templateEnginesConfigurationPoint.getNamespaceUri());
  ElementSelector mappingSelector = and(sameNs(element), name("template-mapping"));
  for (Element subElement : subElements(element)) {
    // engine
    if (engineSelector.accept(subElement)) {
      BeanDefinitionHolder engine = parseConfigurationPointBean(subElement,
                                   templateEnginesConfigurationPoint, parserContext, builder);
      engines.put(engine.getBeanName(), engine);
    }
    // mapping
    else if (mappingSelector.accept(subElement)) {
      String ext = normalizeExtension(subElement.getAttribute("extension"));
      String engineName = assertNotNull(trimToNull(subElement.getAttribute("engine")), "engine");
      assertNotNull(ext, "extension");
      assertTrue(!mappings.containsKey(ext), "duplicated extension: %s", ext);
      mappings.put(ext, engineName);
    }
  }
  builder.addPropertyValue("engines", engines);
  builder.addPropertyValue("engineNameMappings", mappings);
  attributesToProperties(element, builder, "defaultExtension", "searchExtensions", "searchLocalizedTemplates",
              "cacheEnabled");
}

代码示例来源:origin: webx/citrus

@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
  parseBeanDefinitionAttributes(element, parserContext, builder);
  Map<Object, Object> engines = createManagedMap(element, parserContext);
  Map<Object, Object> mappings = createManagedMap(element, parserContext);
  ElementSelector engineSelector = ns(templateEnginesConfigurationPoint.getNamespaceUri());
  ElementSelector mappingSelector = and(sameNs(element), name("template-mapping"));
  for (Element subElement : subElements(element)) {
    // engine
    if (engineSelector.accept(subElement)) {
      BeanDefinitionHolder engine = parseConfigurationPointBean(subElement,
                                   templateEnginesConfigurationPoint, parserContext, builder);
      engines.put(engine.getBeanName(), engine);
    }
    // mapping
    else if (mappingSelector.accept(subElement)) {
      String ext = normalizeExtension(subElement.getAttribute("extension"));
      String engineName = assertNotNull(trimToNull(subElement.getAttribute("engine")), "engine");
      assertNotNull(ext, "extension");
      assertTrue(!mappings.containsKey(ext), "duplicated extension: %s", ext);
      mappings.put(ext, engineName);
    }
  }
  builder.addPropertyValue("engines", engines);
  builder.addPropertyValue("engineNameMappings", mappings);
  attributesToProperties(element, builder, "defaultExtension", "searchExtensions", "searchLocalizedTemplates",
              "cacheEnabled");
}

代码示例来源:origin: com.alibaba.citrus/citrus-webx-all

@Override
protected void init() throws Exception {
  if (extensions == null) {
    extensions = EMPTY_STRING_ARRAY;
  }
  for (int i = 0; i < extensions.length; i++) {
    extensions[i] = FileUtil.normalizeExtension(extensions[i]);
  }
}

代码示例来源:origin: com.alibaba.citrus/citrus-webx-all

public void setExtension(String exts) {
  extensions.clear();
  // 支持无后缀
  if (exts == null) {
    extensions.add(null);
  } else {
    String[] extArray = StringUtil.split(exts, ", ");
    for (String ext : extArray) {
      extensions.add(normalizeExtension(ext));
    }
  }
}

代码示例来源:origin: com.alibaba.citrus/citrus-webx-all

private String[] normalizeStrings(String[] strs, int type) {
  if (isEmptyArray(strs)) {
    return null;
  }
  List<String> strList = createLinkedList();
  for (String str : strs) {
    switch (type) {
      case 0:
        str = normalizeContentType(str);
        break;
      case 1:
        str = FileUtil.normalizeExtension(str);
        break;
      default:
        unreachableCode();
    }
    if (str != null) {
      strList.add(str);
    }
  }
  if (strList.isEmpty()) {
    return null;
  } else {
    return strList.toArray(new String[strList.size()]);
  }
}

代码示例来源:origin: com.alibaba.citrus/citrus-webx-all

ext = normalizeExtension(ext);
defaultExtension = normalizeExtension(defaultExtension);

代码示例来源:origin: com.alibaba.citrus/citrus-webx-all

@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
  parseBeanDefinitionAttributes(element, parserContext, builder);
  Map<Object, Object> engines = createManagedMap(element, parserContext);
  Map<Object, Object> mappings = createManagedMap(element, parserContext);
  ElementSelector engineSelector = ns(templateEnginesConfigurationPoint.getNamespaceUri());
  ElementSelector mappingSelector = and(sameNs(element), name("template-mapping"));
  for (Element subElement : subElements(element)) {
    // engine
    if (engineSelector.accept(subElement)) {
      BeanDefinitionHolder engine = parseConfigurationPointBean(subElement,
                                   templateEnginesConfigurationPoint, parserContext, builder);
      engines.put(engine.getBeanName(), engine);
    }
    // mapping
    else if (mappingSelector.accept(subElement)) {
      String ext = normalizeExtension(subElement.getAttribute("extension"));
      String engineName = assertNotNull(trimToNull(subElement.getAttribute("engine")), "engine");
      assertNotNull(ext, "extension");
      assertTrue(!mappings.containsKey(ext), "duplicated extension: %s", ext);
      mappings.put(ext, engineName);
    }
  }
  builder.addPropertyValue("engines", engines);
  builder.addPropertyValue("engineNameMappings", mappings);
  attributesToProperties(element, builder, "defaultExtension", "searchExtensions", "searchLocalizedTemplates",
              "cacheEnabled");
}

相关文章