01: /*
02: * Copyright (c) 2002-2006 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.xwork.config;
06:
07: import com.opensymphony.xwork.config.entities.PackageConfig;
08: import org.apache.commons.logging.Log;
09: import org.apache.commons.logging.LogFactory;
10:
11: import java.util.ArrayList;
12: import java.util.Collections;
13: import java.util.List;
14: import java.util.StringTokenizer;
15:
16: /**
17: * ConfigurationUtil
18: *
19: * @author Jason Carreira
20: * Created May 23, 2003 11:22:49 PM
21: */
22: public class ConfigurationUtil {
23:
24: private static final Log LOG = LogFactory
25: .getLog(ConfigurationUtil.class);
26:
27: private ConfigurationUtil() {
28: }
29:
30: public static List buildParentsFromString(
31: Configuration configuration, String parent) {
32: if ((parent == null) || (parent.equals(""))) {
33: return Collections.EMPTY_LIST;
34: }
35:
36: StringTokenizer tokenizer = new StringTokenizer(parent, ", ");
37: List parents = new ArrayList();
38:
39: while (tokenizer.hasMoreTokens()) {
40: String parentName = tokenizer.nextToken().trim();
41:
42: if (!parentName.equals("")) {
43: PackageConfig parentPackageContext = configuration
44: .getPackageConfig(parentName);
45:
46: if (parentPackageContext == null) {
47: LOG.error("Unable to find parent package "
48: + parentName);
49: } else {
50: parents.add(parentPackageContext);
51: }
52: }
53: }
54:
55: return parents;
56: }
57: }
|