当前位置: 首页>>代码示例>>Java>>正文


Java StrTokenizer类代码示例

本文整理汇总了Java中org.apache.commons.lang.text.StrTokenizer的典型用法代码示例。如果您正苦于以下问题:Java StrTokenizer类的具体用法?Java StrTokenizer怎么用?Java StrTokenizer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StrTokenizer类属于org.apache.commons.lang.text包,在下文中一共展示了StrTokenizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: propertiesFromString

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
/**
 * Converts a String back to connection parameters.
 * @param input String from configuration
 * @return JDBC connection parameters
 */
public static Properties propertiesFromString(String input) {
  if (input != null && !input.isEmpty()) {
    Properties result = new Properties();
    StrTokenizer propertyTokenizer = StrTokenizer.getCSVInstance(input);
    StrTokenizer valueTokenizer = StrTokenizer.getCSVInstance();
    valueTokenizer.setDelimiterChar('=');
    while (propertyTokenizer.hasNext()) {
      valueTokenizer.reset(propertyTokenizer.nextToken());
      String[] values = valueTokenizer.getTokenArray();
      if (values.length == 2) {
        result.put(values[0], values[1]);
      }
    }
    return result;
  } else {
    return null;
  }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:24,代码来源:DBConfiguration.java

示例2: propertiesFromString

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
/**
 * Converts a String back to connection parameters.
 * @param input String from configuration
 * @return JDBC connection parameters
 */
protected static Properties propertiesFromString(String input) {
  if (input != null && !input.isEmpty()) {
    Properties result = new Properties();
    StrTokenizer propertyTokenizer = StrTokenizer.getCSVInstance(input);
    StrTokenizer valueTokenizer = StrTokenizer.getCSVInstance();
    valueTokenizer.setDelimiterChar('=');
    while (propertyTokenizer.hasNext()){
      valueTokenizer.reset(propertyTokenizer.nextToken());
      String[] values = valueTokenizer.getTokenArray();
      if (values.length==2) {
        result.put(values[0], values[1]);
      }
    }
    return result;
  } else {
    return null;
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:24,代码来源:DBConfiguration.java

示例3: createFromString

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
/**
 * @param proxysettings
 *           String to convert
 * @return
 * @throws Exception
 */
public static ProxyItem createFromString( String proxysettings) throws Exception{
   ProxyItem returnvalue = null;
   try {
      StrTokenizer tokenizer = new StrTokenizer(proxysettings, DELIMITER);
      String[] tokenArray = tokenizer.getTokenArray();
      String name = tokenArray[0];
      String host = tokenArray[1];
      int port = Integer.parseInt(tokenArray[2]);
      returnvalue = new ProxyItem(host, port, name, true);
   } catch (Exception e) {
      throw new Exception("Error while parsing proxysettings", e);
   }

   return returnvalue;
}
 
开发者ID:nextinterfaces,项目名称:http4e,代码行数:22,代码来源:ProxyItem.java

示例4: init

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
private void init() {
    rootItems.clear();

    String configName = AppContext.getProperty(MENU_CONFIG_XML_PROP);

    StrTokenizer tokenizer = new StrTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                Element rootElement = Dom4j.readDocument(stream).getRootElement();
                loadMenuItems(rootElement, null);
            } catch (IOException e) {
                throw new RuntimeException(e.getMessage(), e);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        } else {
            log.warn("Resource " + location + " not found, ignore it");
        }
    }
}
 
开发者ID:cuba-platform,项目名称:sampler,代码行数:25,代码来源:SamplesMenuConfig.java

示例5: _registerAppComponents

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
protected void _registerAppComponents() {
    String configName = AppContext.getProperty(WEB_COMPONENTS_CONFIG_XML_PROP);
    StrTokenizer tokenizer = new StrTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                _registerComponent(stream);
            } catch (ClassNotFoundException | IOException e) {
                throw new RuntimeException(e);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        } else {
            log.warn("Resource {} not found, ignore it", location);
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:WebExternalUIComponentsSource.java

示例6: init

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
protected void init() {
    StopWatch initTiming = new Slf4JStopWatch("ViewRepository.init." + getClass().getSimpleName());

    storage.clear();
    readFileNames.clear();

    String configName = AppContext.getProperty("cuba.viewsConfig");
    if (!StringUtils.isBlank(configName)) {
        Element rootElem = DocumentHelper.createDocument().addElement("views");

        StrTokenizer tokenizer = new StrTokenizer(configName);
        for (String fileName : tokenizer.getTokenArray()) {
            addFile(rootElem, fileName);
        }

        checkDuplicates(rootElem);

        for (Element viewElem : Dom4j.elements(rootElem, "view")) {
            deployView(rootElem, viewElem, new HashSet<>());
        }
    }

    initTiming.stop();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:AbstractViewRepository.java

示例7: initAppContext

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
protected void initAppContext() {
    String configProperty = AppContext.getProperty(SPRING_CONTEXT_CONFIG);
    if (StringUtils.isBlank(configProperty)) {
        throw new IllegalStateException("Missing " + SPRING_CONTEXT_CONFIG + " application property");
    }

    StrTokenizer tokenizer = new StrTokenizer(configProperty);
    String[] locations = tokenizer.getTokenArray();
    replaceLocationsFromConf(locations);

    ApplicationContext appContext = createApplicationContext(locations);
    AppContext.Internals.setApplicationContext(appContext);

    Events events = AppBeans.get(Events.NAME);
    events.publish(new AppContextInitializedEvent(appContext));

    log.debug("AppContext initialized");
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:19,代码来源:AbstractAppContextLoader.java

示例8: _registerWindowLoaders

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
protected void _registerWindowLoaders() {
    String configName = AppContext.getProperty(DESKTOP_COMPONENTS_CONFIG_XML_PROP);
    StrTokenizer tokenizer = new StrTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                Element rootElement = Dom4j.readDocument(stream)
                        .getRootElement();
                _loadWindowLoaders(rootElement);
            } catch (IOException e) {
                throw new RuntimeException(e);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        } else {
            log.warn("Resource {} not found, ignore it", location);
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:DesktopExternalUIComponentsSource.java

示例9: init

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
protected void init() {
    String configName = AppContext.getProperty(CUBA_REST_JSON_TRANSFORMATION_CONFIG_PROP_NAME);
    StrTokenizer tokenizer = new StrTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                loadConfig(Dom4j.readDocument(stream).getRootElement());
            } catch (IOException e) {
                throw new RuntimeException(e);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        } else {
            log.warn("Resource " + location + " not found, ignore it");
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:RestJsonTransformations.java

示例10: init

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
protected void init() {
    String configName = AppContext.getProperty(CUBA_REST_QUERIES_CONFIG_PROP_NAME);
    StrTokenizer tokenizer = new StrTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                loadConfig(Dom4j.readDocument(stream).getRootElement());
            } catch (IOException e) {
                throw new RuntimeException(e);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        } else {
            log.warn("Resource " + location + " not found, ignore it");
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:RestQueriesConfiguration.java

示例11: init

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
protected void init() {
    String configName = AppContext.getProperty(CUBA_REST_SERVICES_CONFIG_PROP_NAME);
    StrTokenizer tokenizer = new StrTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                loadConfig(Dom4j.readDocument(stream).getRootElement());
            } catch (IOException e) {
                throw new RuntimeException("Error on parsing rest services config", e);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        } else {
            log.warn("Resource " + location + " not found, ignore it");
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:RestServicesConfiguration.java

示例12: init

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
protected void init() {
    String configName = AppContext.getProperty(CUBA_REST_SERVICES_CONFIG_PROP_NAME);
    StrTokenizer tokenizer = new StrTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                loadConfig(Dom4j.readDocument(stream).getRootElement());
            } catch (IOException e) {
                throw new RuntimeException(e);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        } else {
            log.warn("Resource " + location + " not found, ignore it");
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:RestServicePermissions.java

示例13: load

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
public CreditsLoader load() {
    String configProperty = AppContext.getProperty("cuba.creditsConfig");
    if (StringUtils.isBlank(configProperty)) {
        log.info("Property cuba.creditsConfig is empty");
        return this;
    }

    StrTokenizer tokenizer = new StrTokenizer(configProperty);
    String[] locations = tokenizer.getTokenArray();

    for (String location : locations) {
        Resources resources = AppBeans.get(Resources.NAME);
        String xml = resources.getResourceAsString(location);
        if (xml == null) {
            log.debug("Resource {} not found, ignore it", location);
            continue;
        }
        Element rootElement = Dom4j.readDocument(xml).getRootElement();
        loadLicenses(rootElement);
        loadConfig(rootElement);
    }

    Collections.sort(items);

    return this;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:27,代码来源:CreditsLoader.java

示例14: init

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
protected void init() {
    rootItems.clear();

    String configName = AppContext.getProperty(MENU_CONFIG_XML_PROP);

    StrTokenizer tokenizer = new StrTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                Element rootElement = Dom4j.readDocument(stream).getRootElement();
                loadMenuItems(rootElement, null);
            } catch (IOException e) {
                throw new RuntimeException(e);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        } else {
            log.warn("Resource " + location + " not found, ignore it");
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:MenuConfig.java

示例15: compileSpecific

import org.apache.commons.lang.text.StrTokenizer; //导入依赖的package包/类
private void compileSpecific() {
    Node<BasicPermissionTarget> root = new Node<>(
            new BasicPermissionTarget("category:specific", getMessage("permissionConfig.specificRoot"), null));
    specific = new Tree<>(root);

    final String configName = AppContext.getProperty(PERMISSION_CONFIG_XML_PROP);
    StrTokenizer tokenizer = new StrTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                String xml = IOUtils.toString(stream, StandardCharsets.UTF_8);
                compileSpecific(xml, root);
            } catch (IOException e) {
                throw new RuntimeException("Unable to read permission config", e);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        } else {
            log.warn("Resource {} not found, ignore it", location);
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:26,代码来源:PermissionConfig.java


注:本文中的org.apache.commons.lang.text.StrTokenizer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。