use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.
the class CreditsLoader method load.
public CreditsLoader load() {
String configProperty = AppContext.getProperty("cuba.creditsConfig");
if (StringUtils.isBlank(configProperty)) {
log.info("Property cuba.creditsConfig is empty");
return this;
}
StringTokenizer tokenizer = new StringTokenizer(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 = AppBeans.get(Dom4jTools.class).readDocument(xml).getRootElement();
loadLicenses(rootElement);
loadConfig(rootElement);
}
Collections.sort(items);
return this;
}
use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.
the class WebExternalUIComponentsSource method _registerAppComponents.
protected void _registerAppComponents() {
String configNames = AppContext.getProperty(WEB_COMPONENTS_CONFIG_XML_PROP);
if (Strings.isNullOrEmpty(configNames)) {
return;
}
log.debug("Loading UI components from {}", configNames);
StringTokenizer tokenizer = new StringTokenizer(configNames);
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("Unable to load components config " + location, e);
} finally {
IOUtils.closeQuietly(stream);
}
} else {
log.warn("Resource {} not found, ignore it", location);
}
}
}
use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.
the class CubaDispatcherServlet method getContextConfigLocation.
@Override
public String getContextConfigLocation() {
String configProperty = AppContext.getProperty(SPRING_CONTEXT_CONFIG);
if (StringUtils.isBlank(configProperty)) {
throw new IllegalStateException("Missing " + SPRING_CONTEXT_CONFIG + " application property");
}
File baseDir = new File(AppContext.getProperty("cuba.confDir"));
StringTokenizer tokenizer = new StringTokenizer(configProperty);
String[] tokenArray = tokenizer.getTokenArray();
StringBuilder locations = new StringBuilder();
for (String token : tokenArray) {
String location;
if (ResourceUtils.isUrl(token)) {
location = token;
} else {
if (token.startsWith("/"))
token = token.substring(1);
File file = new File(baseDir, token);
if (file.exists()) {
location = file.toURI().toString();
} else {
location = "classpath:" + token;
}
}
locations.append(location).append(" ");
}
return locations.toString();
}
use of org.apache.commons.text.StringTokenizer in project synopsys-detect by blackducksoftware.
the class CommandParser method parseCommandString.
public List<String> parseCommandString(String commandString) {
logger.trace(String.format("origCommand : %s", commandString));
String quotesRemovedCommand = encodeQuotedWhitespace(commandString);
logger.trace(String.format("quotesRemovedCommand: %s", quotesRemovedCommand));
StringTokenizer tokenizer = new StringTokenizer(quotesRemovedCommand);
tokenizer.setQuoteMatcher(StringMatcherFactory.INSTANCE.quoteMatcher());
List<String> commandList = new ArrayList<>();
while (tokenizer.hasNext()) {
String token = tokenizer.nextToken();
String part = restoreWhitespace(token);
commandList.add(part);
}
return commandList;
}
use of org.apache.commons.text.StringTokenizer in project hl7v2-fhir-converter by LinuxForHealth.
the class HL7Segment method createHL7Segment.
private static HL7Segment createHL7Segment(String rawSegment) {
StringTokenizer stk = new StringTokenizer(rawSegment, ".");
String segment = null;
List<String> group = new ArrayList<>();
List<String> tokens = stk.getTokenList();
if (tokens.size() > 1) {
group.addAll(tokens.subList(0, tokens.size() - 1));
segment = tokens.get(tokens.size() - 1);
} else if (tokens.size() == 1) {
segment = tokens.get(0);
} else {
throw new IllegalArgumentException("rawSegment cannot be parsed:" + rawSegment);
}
return new HL7Segment(group, segment, false);
}
Aggregations