You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by hl...@apache.org on 2003/09/05 01:58:14 UTC
cvs commit: jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl RegistryImpl.java
hlship 2003/09/04 16:58:14
Modified: hivemind/src/java/org/apache/commons/hivemind Registry.java
hivemind/src/java/org/apache/commons/hivemind/impl
RegistryImpl.java
Log:
Add method getSymbolValue() to Registry.
Revision Changes Path
1.8 +12 -1 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/Registry.java
Index: Registry.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/Registry.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Registry.java 30 Aug 2003 14:29:52 -0000 1.7
+++ Registry.java 4 Sep 2003 23:58:14 -0000 1.8
@@ -127,6 +127,17 @@
public String expandSymbols(String input, Location location);
/**
+ * Searches through the available {@link SymbolSource}s to find the
+ * first one that returns a non-null value for the provided symbol name.
+ * May return null if no symbol source can provide a value.
+ *
+ * @param name The name of the symbol.
+ * @return The value for the symbol, or null.
+ */
+ public String getSymbolValue(String name);
+
+
+ /**
* Returns the locale for which the registry was created.
*/
1.10 +19 -11 jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/RegistryImpl.java
Index: RegistryImpl.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/RegistryImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- RegistryImpl.java 30 Aug 2003 14:29:51 -0000 1.9
+++ RegistryImpl.java 4 Sep 2003 23:58:14 -0000 1.10
@@ -109,7 +109,7 @@
public Module getModule(String moduleId)
{
- Module result = (Module)_modules.get(moduleId);
+ Module result = (Module) _modules.get(moduleId);
if (result == null)
throw new ApplicationRuntimeException(
@@ -136,7 +136,7 @@
* Splits a qualified id, returning just the module id
* portion.
*/
- static String split(String fullId)
+ static String split(String fullId)
{
int dotx = fullId.lastIndexOf('.');
@@ -256,9 +256,7 @@
if (symbolLength > 0)
{
String variableName =
- text.substring(
- symbolStart,
- symbolStart + symbolLength);
+ text.substring(symbolStart, symbolStart + symbolLength);
result.append(expandSymbol(variableName, location));
@@ -301,6 +299,18 @@
private String expandSymbol(String name, Location location)
{
+ String value = getSymbolValue(name);
+
+ if (value != null)
+ return value;
+
+ LOG.error(HiveMind.format("BaseRegistry.no-such-symbol", name, location));
+
+ return "${" + name + "}";
+ }
+
+ public String getSymbolValue(String name)
+ {
SymbolSource[] sources = getSymbolSources();
for (int i = 0; i < sources.length; i++)
@@ -311,12 +321,10 @@
return value;
}
- LOG.error(HiveMind.format("BaseRegistry.no-such-symbol", name, location));
-
- return "${" + name + "}";
+ return null;
}
- private synchronized SymbolSource[] getSymbolSources()
+ private synchronized SymbolSource[] getSymbolSources()
{
if (_variableSources != null)
return _variableSources;
@@ -330,7 +338,7 @@
for (int i = 0; i < count; i++)
{
- SymbolSourceContribution c = (SymbolSourceContribution)contributions.get(i);
+ SymbolSourceContribution c = (SymbolSourceContribution) contributions.get(i);
_variableSources[i] = c.getSource();
}