commonjava-developer Mailing List for CommonJava Open Component Project (Page 7)
Brought to you by:
johnqueso
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(10) |
Feb
(114) |
Mar
(169) |
Apr
(25) |
May
|
Jun
(5) |
Jul
(17) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: John C. <joh...@co...> - 2004-03-23 15:08:53
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects/core/src/main In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9593/projects/core/src/main Log Message: Directory /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects/core/src/main added to the repository |
From: John C. <joh...@co...> - 2004-03-23 15:08:52
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9593/projects/core Log Message: Directory /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects/core added to the repository |
From: John C. <joh...@co...> - 2004-03-23 15:08:52
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9593/projects Log Message: Directory /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects added to the repository |
From: John C. <joh...@co...> - 2004-03-23 15:08:52
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects/core/src/main/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9593/projects/core/src/main/java Log Message: Directory /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects/core/src/main/java added to the repository |
From: John C. <joh...@co...> - 2004-03-23 15:08:52
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects/core/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9593/projects/core/src Log Message: Directory /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects/core/src added to the repository |
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/qtags In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23133/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/qtags Modified Files: OplAttributeTag.java OplChildOfTag.java OplPropertiesContainerTag.java OplParserTag.java Log Message: fixed some issues with velocity NodeParser template and the global nature of #set() directives... Index: OplChildOfTag.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/qtags/OplChildOfTag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- OplChildOfTag.java 8 Mar 2004 14:36:34 -0000 1.1 +++ OplChildOfTag.java 23 Mar 2004 01:49:00 -0000 1.2 @@ -23,7 +23,7 @@ * @qtags.parameter allowed-value="true" * @qtags.parameter allowed-value="false" */ - String getRequired(); + boolean getRequired(); /** Specifies the method to use in the ancestor parser for configuring it with this * parser's resulting instance. Index: OplParserTag.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/qtags/OplParserTag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- OplParserTag.java 8 Mar 2004 14:36:34 -0000 1.1 +++ OplParserTag.java 23 Mar 2004 01:49:00 -0000 1.2 @@ -18,6 +18,6 @@ * @qtags.parameter allowed-value="true" * @qtags.parameter allowed-value="false" */ - String getRoot(); + boolean getRoot(); } Index: OplAttributeTag.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/qtags/OplAttributeTag.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- OplAttributeTag.java 16 Mar 2004 22:47:33 -0000 1.3 +++ OplAttributeTag.java 23 Mar 2004 01:49:00 -0000 1.4 @@ -18,21 +18,21 @@ * @qtags.parameter allowed-value="true" * @qtags.parameter allowed-value="false" */ - String getUseBody(); + boolean getUseBody(); /** Whether the attribute is required. * @qtags.parameter default="false" * @qtags.parameter allowed-value="true" * @qtags.parameter allowed-value="false" */ - String getRequired(); + boolean getRequired(); /** Whether the attribute value will be resolved using the context properties before returning. * @qtags.parameter default="false" * @qtags.parameter allowed-value="true" * @qtags.parameter allowed-value="false" */ - String getResolveValue(); + boolean getResolveValue(); /** One line of code to extract/format the value before setting it on the config instance. */ @@ -48,7 +48,7 @@ * @qtags.parameter allowed-value="true" * @qtags.parameter allowed-value="false" */ - String getBeforeChildren(); + boolean getBeforeChildren(); /** The XML-Schema type of the attribute. Currently supports: * @qtags.parameter default="string" Index: OplPropertiesContainerTag.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/qtags/OplPropertiesContainerTag.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- OplPropertiesContainerTag.java 8 Mar 2004 23:06:41 -0000 1.1 +++ OplPropertiesContainerTag.java 23 Mar 2004 01:49:00 -0000 1.2 @@ -17,6 +17,6 @@ * @qtags.parameter allowed-value="true" * @qtags.parameter allowed-value="false" */ - String getDelegate(); + boolean getDelegate(); } |
From: John C. <joh...@co...> - 2004-03-23 01:59:24
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23133/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet Modified Files: OplNodeParserPlugin.vm Log Message: fixed some issues with velocity NodeParser template and the global nature of #set() directives... Index: OplNodeParserPlugin.vm =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/OplNodeParserPlugin.vm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- OplNodeParserPlugin.vm 16 Mar 2004 22:47:34 -0000 1.5 +++ OplNodeParserPlugin.vm 23 Mar 2004 01:49:00 -0000 1.6 @@ -56,21 +56,30 @@ protected final void doBeforeChildren(ElementInfo info) throws ParseException{ #foreach($method in $class.methods) #if(!$method.getNamedParameter("opl.attribute", "use-body")) - #if($method.getNamedParameter("opl.attribute", "before-children") == "true") + #if($method.getNamedParameter("opl.attribute", "before-children")) try{ #set($attrName = $method.getNamedParameter("opl.attribute", "name")) - String $attrName = getAttribute(${plugin.getAttributeConstant($method)}, info, ${method.getNamedParameter("opl.attribute", "resolve-value")}); + + #set($resolve = true) + #set($resolve = ${method.getNamedParameter("opl.attribute", "resolve-value")}) + String ${attrName} = getAttribute(${plugin.getAttributeConstant($method)}, info, $resolve); + + #set($extractor = false) #set($extractor = $method.getNamedParameter("opl.attribute", "extractor")) + + #set($validator = false) #set($validator = $method.getNamedParameter("opl.attribute", "validator")) - #set($notRequired = $method.getNamedParameter("opl.attribute", "required") == "false") + + #set($required = false) + #set($required = $method.getNamedParameter("opl.attribute", "required")) + #if($extractor) - #set($ex = ${extractor.replaceAll("@@value", $attrName)}) - #set($call = $plugin.formatInvocation($method, $ex)) - #if($notRequired) + #set($call = $plugin.formatInvocation($method, $extractor.replaceAll("@@value", $attrName))) + #if(!$required) if($attrName != null){ #end #if($validator) - if(${validator.replaceAll("@@value", ${ex})}){ + if(${validator.replaceAll("@@value", $extractor.replaceAll("@@value", $attrName))}){ instance.${call}; } else{ @@ -79,12 +88,12 @@ #else instance.${call}; #end - #if($notRequired) + #if(!$required) } #end #else #set($call = $plugin.formatInvocation($method, $attrName)) - #if($notRequired) + #if(!$required) if($attrName != null){ #end #if($validator) @@ -97,7 +106,7 @@ #else instance.${call}; #end - #if($notRequired) + #if(!$required) } #end #end @@ -115,32 +124,40 @@ } #end #end + #end } protected final void doAfterChildren(ElementInfo info, String bodyText) throws ParseException{ #foreach($method in $class.methods) - #if($method.getNamedParameter("opl.attribute", "before-children") == "false" || $method.getNamedParameter("opl.attribute", "use-body") == "true") + #if($method.getNamedParameter("opl.attribute", "before-children") == "false" || $method.getNamedParameter("opl.attribute", "use-body")) try{ #set($attrName = $method.getNamedParameter("opl.attribute", "name")) - #if($method.getNamedParameter("opl.attribute", "use-body") == "true") + #if($method.getNamedParameter("opl.attribute", "use-body")) String ${attrName} = bodyText; #else - String ${attrName} = getAttribute(${plugin.getAttributeConstant($method)}, info, ${method.getNamedParameter("opl.attribute", "resolve-value")}); + #set($resolve = true) + #set($resolve = ${method.getNamedParameter("opl.attribute", "resolve-value")}) + String ${attrName} = getAttribute(${plugin.getAttributeConstant($method)}, info, $resolve); #end + #set($extractor = false) #set($extractor = $method.getNamedParameter("opl.attribute", "extractor")) + + #set($validator = false) #set($validator = $method.getNamedParameter("opl.attribute", "validator")) - #set($notRequired = $method.getNamedParameter("opl.attribute", "required") == "false") + + #set($required = false) + #set($required = $method.getNamedParameter("opl.attribute", "required")) + #if($extractor) - #set($ex = ${extractor.replaceAll("@@value", $attrName)}) - #set($call = $plugin.formatInvocation($method, $ex)) - #if($notRequired) + #set($call = $plugin.formatInvocation($method, $extractor.replaceAll("@@value", $attrName))) + #if(!$required) if($attrName != null){ #end #if($validator) - if(${validator.replaceAll("@@value", ${ex})}){ + if(${validator.replaceAll("@@value", $extractor.replaceAll("@@value", $attrName))}){ instance.${call}; } else{ @@ -149,12 +166,12 @@ #else instance.${call}; #end - #if($notRequired) + #if(!$required) } #end #else #set($call = $plugin.formatInvocation($method, $attrName)) - #if($notRequired) + #if(!$required) if($attrName != null){ #end #if($validator) @@ -167,7 +184,7 @@ #else instance.${call}; #end - #if($notRequired) + #if(!$required) } #end #end |
From: John C. <joh...@co...> - 2004-03-23 01:59:24
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/test-project/src/java/org/commonjava/opl/xdoclet/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23133/projects/opl-xdoclet/test-project/src/java/org/commonjava/opl/xdoclet/test Modified Files: TestSubConfig.java TestConfig.java Log Message: fixed some issues with velocity NodeParser template and the global nature of #set() directives... Index: TestConfig.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/test-project/src/java/org/commonjava/opl/xdoclet/test/TestConfig.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- TestConfig.java 12 Mar 2004 19:46:56 -0000 1.3 +++ TestConfig.java 23 Mar 2004 01:49:00 -0000 1.4 @@ -15,31 +15,31 @@ /** * @opl.attribute - * name="testParam" + * name="testReqResStringBeforeChildren" * required="true" * resolve-value="true" * type="string" * before-children="true" */ - public void setTestParam(String param1){ + public void testReqResStringBeforeChildren(String param1){ } /** * @opl.attribute - * name="anotherTestParam" + * name="testNonReqNonResIntExtractAfterChildren" * required="false" * resolve-value="false" * type="int" * extractor="Strings.toInteger(@@value).intValue()" * before-children="false" */ - public void setAnotherTestParam(int param2){ + public void testNonReqNonResIntExtractAfterChildren(int param2){ } /** * @opl.delegate */ - public void setBoolParam(Boolean bParam){ + public void delegatedMethod(Boolean bParam){ } /** Index: TestSubConfig.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/test-project/src/java/org/commonjava/opl/xdoclet/test/TestSubConfig.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- TestSubConfig.java 16 Mar 2004 22:47:32 -0000 1.4 +++ TestSubConfig.java 23 Mar 2004 01:49:00 -0000 1.5 @@ -8,7 +8,7 @@ /** * @opl.parser node="subConfig" * @opl.aux-import import="org.commonjava.util.Strings" - * @opl.properties-container + * @opl.properties-container delegate="true" * @opl.child-of * class="org.commonjava.opl.xdoclet.test.TestSubConfigConsumer" * required="true" @@ -23,31 +23,43 @@ /** * @opl.attribute - * name="testParam" - * required="true" - * resolve-value="true" - * type="string" - * before-children="true" + * name="testNonReqNonResIntExtractValidateAfterChildren" + * required="false" + * resolve-value="false" + * type="int" + * extractor="Strings.toInteger(@@value).intValue()" + * validator="@@value > 0" + * before-children="false" */ - public void setTestParam(String param3){ + public void testNonReqNonResIntExtractValidateAfterChildren(int param4){ } - + /** * @opl.attribute - * name="anotherTestParam" + * name="testNonReqResIntExtractValidateBeforeChildren" * required="false" - * resolve-value="false" * type="int" * extractor="Strings.toInteger(@@value).intValue()" * validator="@@value > 0" - * before-children="false" + * before-children="true" */ - public void setAnotherTestParam(int param4){ + public void testNonReqResIntExtractValidateBeforeChildren(int param4){ } /** * @opl.attribute - * name="yetAnotherTestParam" + * name="testReqResStringBeforeChildren" + * required="true" + * resolve-value="true" + * type="string" + * before-children="true" + */ + public void testReqResStringBeforeChildren(String param3){ + } + + /** + * @opl.attribute + * name="testBodyNonReqIntExtractValidateBeforeChildren" * use-body="true" * required="false" * type="int" @@ -55,24 +67,24 @@ * validator="@@value > 0" * before-children="true" */ - public void setYetAnotherTestParam(int param4){ + public void testBodyNonReqIntExtractValidateBeforeChildren(int param4){ } /** - * @opl.delegate value="true" + * @opl.delegate */ - public void setBoolParam(Boolean bParam){ + public void delegatedMethod(Boolean bParam){ } - /* - * @opl.delegate value="true" + /** + * @opl.delegate */ public void setProperties(Properties props){ this.properties = props; } - /* - * @opl.delegate value="true" + /** + * @opl.delegate */ public Properties getProperties(){ return this.properties; |
From: John C. <joh...@co...> - 2004-03-22 16:01:36
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-config-jndi/src/java/org/commonjava/config/jndi/xmlparse In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17559/src/java/org/commonjava/config/jndi/xmlparse Modified Files: JndiConfigAttributes.java JndiConfigParser.java Log Message: added baseContext attribute to the JndiConfig. Index: JndiConfigParser.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-config-jndi/src/java/org/commonjava/config/jndi/xmlparse/JndiConfigParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- JndiConfigParser.java 16 Jan 2004 02:20:24 -0000 1.6 +++ JndiConfigParser.java 22 Mar 2004 15:51:14 -0000 1.7 @@ -16,10 +16,9 @@ import org.commonjava.opl.generics.properties.PropertiesContainer; import org.commonjava.util.Strings; -//TODO: Add JavaDoc to JndiConfigParser in commonjava-config-jndi! -/** +/** Parses a JNDI configuration object. * - * @ + * @author John Casey * */ public class JndiConfigParser extends NodeParser @@ -93,6 +92,8 @@ */ protected void doAfterChildren(ElementInfo info, String body) throws ParseException { String refId = getAttribute(JndiConfigAttributes.REF_ID, info); + String baseContext = getAttribute(JndiConfigAttributes.BASE_CONTEXT, info); + Boolean useCtxEnv = Strings.toBoolean(getAttribute(JndiConfigAttributes.USE_CONTEXT_ENV, info)); JndiConfigConsumer consumer = (JndiConfigConsumer)findAncestorOfType( @@ -103,6 +104,10 @@ config.setUseContextEnvironment(useCtxEnv.booleanValue()); } + if(baseContext != null){ + config.setBaseContext(baseContext); + } + if(consumer != null){ if(config.getId() != null){ if(refId != null){ Index: JndiConfigAttributes.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-config-jndi/src/java/org/commonjava/config/jndi/xmlparse/JndiConfigAttributes.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- JndiConfigAttributes.java 15 Dec 2003 01:49:55 -0000 1.4 +++ JndiConfigAttributes.java 22 Mar 2004 15:51:14 -0000 1.5 @@ -15,6 +15,7 @@ public static final String ID = "id"; public static final String REF_ID = "refId"; public static final String USE_CONTEXT_ENV = "useContextEnvironment"; + public static final String BASE_CONTEXT = "baseContext"; /** Constants library; deny construction */ |
From: John C. <joh...@co...> - 2004-03-22 16:01:36
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-config-jndi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17559 Modified Files: project.xml Log Message: added baseContext attribute to the JndiConfig. Index: project.xml =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-config-jndi/project.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- project.xml 20 Feb 2004 21:16:53 -0000 1.8 +++ project.xml 22 Mar 2004 15:51:14 -0000 1.9 @@ -5,7 +5,7 @@ <id>commonjava-config-jndi</id> <name>JNDI Configurations</name> <groupId>commonjava</groupId> - <currentVersion>2.1-4</currentVersion> + <currentVersion>2.1-5</currentVersion> <organization> <name>CommonJava Open Component Project</name> <url>http://www.commonjava.org</url> |
From: John C. <joh...@co...> - 2004-03-22 16:01:36
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-config-jndi/src/java/org/commonjava/config/jndi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17559/src/java/org/commonjava/config/jndi Modified Files: JndiConfig.java Log Message: added baseContext attribute to the JndiConfig. Index: JndiConfig.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-config-jndi/src/java/org/commonjava/config/jndi/JndiConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- JndiConfig.java 15 Dec 2003 01:49:54 -0000 1.2 +++ JndiConfig.java 22 Mar 2004 15:51:14 -0000 1.3 @@ -19,6 +19,7 @@ private Properties properties; private String id; private boolean useContextEnvironment = true; + private String baseContext; /** Create new JndiConfig. */ @@ -82,4 +83,20 @@ this.useContextEnvironment = useContextEnvironment; } + /** Get the base context from which all access to JNDI via this configuration should be based. + * For example, the EJB spec dictates that EJB's should be bound under the context: + * "java:comp/env". Therfore, the baseContext attribute should be set to "java:comp/env". + */ + public String getBaseContext() { + return baseContext; + } + + /** Set the base context from which all access to JNDI via this configuration should be based. + * For example, the EJB spec dictates that EJB's should be bound under the context: + * "java:comp/env". Therfore, the baseContext attribute should be set to "java:comp/env". + */ + public void setBaseContext(String string) { + baseContext = string; + } + } |
From: John C. <joh...@co...> - 2004-03-17 05:16:18
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-console In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11045 Modified Files: project.xml Log Message: fixed dependencies. Index: project.xml =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-console/project.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- project.xml 17 Mar 2004 03:52:48 -0000 1.3 +++ project.xml 17 Mar 2004 05:06:54 -0000 1.4 @@ -36,15 +36,8 @@ <dependencies> <dependency> <groupId>commonjava</groupId> - <artifactId>commonjava-lang</artifactId> - <version>2.0</version> - <url>http://www.commonjava.org</url> - </dependency> - - <dependency> - <groupId>commonjava</groupId> <artifactId>commonjava-util</artifactId> - <version>2.0</version> + <version>2.0-5</version> <url>http://www.commonjava.org</url> </dependency> |
From: John C. <joh...@co...> - 2004-03-17 04:02:11
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-console In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30808 Modified Files: project.xml .classpath Log Message: removed dependency on commonjava-lang...it was only for the exception. Index: .classpath =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-console/.classpath,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- .classpath 20 Feb 2004 21:17:38 -0000 1.4 +++ .classpath 17 Mar 2004 03:52:48 -0000 1.5 @@ -1,16 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> - <classpath> - <classpathentry kind="src" path="src\java"> - </classpathentry> - <classpathentry kind="var" rootpath="JRE_SRCROOT" path="JRE_LIB" sourcepath="JRE_SRC"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-lang-2.0.jar"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-util-2.0.jar"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.2.jar"> - </classpathentry> - <classpathentry kind="output" path="target\classes"> - </classpathentry> -</classpath> \ No newline at end of file + <classpathentry kind="src" path="src/java"/> + <classpathentry kind="var" path="JRE_LIB" sourcepath="JRE_SRC"/> + <classpathentry kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-util-2.0.jar"/> + <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.2.jar"/> + <classpathentry kind="output" path="target/classes"/> +</classpath> Index: project.xml =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-console/project.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- project.xml 18 Feb 2004 06:12:31 -0000 1.2 +++ project.xml 17 Mar 2004 03:52:48 -0000 1.3 @@ -5,7 +5,7 @@ <id>commonjava-console</id> <name>Console Framework</name> <groupId>commonjava</groupId> - <currentVersion>2.0-1</currentVersion> + <currentVersion>2.0-2</currentVersion> <organization> <name>CommonJava Open Component Project</name> <url>http://www.commonjava.org</url> |
From: John C. <joh...@co...> - 2004-03-17 04:02:10
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-console/src/java/org/commonjava/console In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30808/src/java/org/commonjava/console Modified Files: PromptConfig.java CommandLineException.java Log Message: removed dependency on commonjava-lang...it was only for the exception. Index: CommandLineException.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-console/src/java/org/commonjava/console/CommandLineException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CommandLineException.java 18 Sep 2003 00:46:59 -0000 1.1 +++ CommandLineException.java 17 Mar 2004 03:52:48 -0000 1.2 @@ -17,14 +17,12 @@ package org.commonjava.console; -import org.commonjava.lang.CommonJavaException; - /** * * @author John Casey * @version */ -public class CommandLineException extends CommonJavaException { +public class CommandLineException extends Exception { /** * Creates new <code>CommandLineException</code> without detail message. @@ -32,13 +30,12 @@ public CommandLineException() { } - /** * Constructs an <code>CommandLineException</code> with the specified detail message. * @param msg the detail message. */ public CommandLineException(String msg) { - super(msg); + super(msg); } public CommandLineException(Throwable t){ Index: PromptConfig.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-console/src/java/org/commonjava/console/PromptConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PromptConfig.java 18 Feb 2004 06:12:31 -0000 1.1 +++ PromptConfig.java 17 Mar 2004 03:52:48 -0000 1.2 @@ -6,12 +6,11 @@ import java.io.PrintStream; import org.commonjava.console.option.OptionFormat; -import org.commonjava.lang.Verifiable; /** * @author jdcasey */ -public class PromptConfig implements Verifiable { +public class PromptConfig { private InputStream in; private OutputStream out; |
From: John C. <joh...@co...> - 2004-03-17 04:01:15
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-util/src/java/org/commonjava/util/pool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30595/src/java/org/commonjava/util/pool Modified Files: PoolException.java Log Message: removed dependency on commonjava-lang...it was only for exceptions. Index: PoolException.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-util/src/java/org/commonjava/util/pool/PoolException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PoolException.java 18 Sep 2003 06:28:59 -0000 1.1 +++ PoolException.java 17 Mar 2004 03:51:53 -0000 1.2 @@ -11,15 +11,13 @@ package org.commonjava.util.pool; -import org.commonjava.lang.CommonJavaException; - /** * The base class for all Exceptions in this package. * * @author James Lewis * @version 1.0 */ -public class PoolException extends CommonJavaException +public class PoolException extends Exception { public PoolException(String message) |
From: John C. <joh...@co...> - 2004-03-17 04:01:15
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-util/src/java/org/commonjava/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30595/src/java/org/commonjava/util Modified Files: XmlFormatException.java SearchAndReplaceException.java TreeParseException.java Log Message: removed dependency on commonjava-lang...it was only for exceptions. Index: TreeParseException.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-util/src/java/org/commonjava/util/TreeParseException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- TreeParseException.java 18 Sep 2003 06:28:59 -0000 1.1 +++ TreeParseException.java 17 Mar 2004 03:51:53 -0000 1.2 @@ -17,13 +17,11 @@ package org.commonjava.util; -import org.commonjava.lang.CommonJavaException; - /** Signals an error during parsing of a Tree or subclass of Tree. * * @author John Casey */ -public class TreeParseException extends CommonJavaException{ +public class TreeParseException extends Exception{ /** Creates a new instance of TreeParseException * Index: SearchAndReplaceException.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-util/src/java/org/commonjava/util/SearchAndReplaceException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- SearchAndReplaceException.java 18 Sep 2003 06:28:59 -0000 1.1 +++ SearchAndReplaceException.java 17 Mar 2004 03:51:53 -0000 1.2 @@ -6,14 +6,12 @@ package org.commonjava.util; -import org.commonjava.lang.CommonJavaException; - /** Signals an error (usually related to the state of a SearchAndReplace object) * during some type of processing within the SearchAndReplaceController. * * @author John Casey */ -public class SearchAndReplaceException extends CommonJavaException { +public class SearchAndReplaceException extends Exception { /** * Creates a new instance of <code>SearchAndReplaceException</code> without detail message. Index: XmlFormatException.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-util/src/java/org/commonjava/util/XmlFormatException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- XmlFormatException.java 16 Feb 2004 06:52:39 -0000 1.1 +++ XmlFormatException.java 17 Mar 2004 03:51:53 -0000 1.2 @@ -15,13 +15,11 @@ package org.commonjava.util; -import org.commonjava.lang.CommonJavaException; - /** signals an exception during the object formatting process. * * @author John Casey */ -public class XmlFormatException extends CommonJavaException{ +public class XmlFormatException extends Exception{ /** Creates a new instance of XmlFormatException */ public XmlFormatException() { |
From: John C. <joh...@co...> - 2004-03-17 04:01:15
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30595 Modified Files: project.xml .classpath Log Message: removed dependency on commonjava-lang...it was only for exceptions. Index: .classpath =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-util/.classpath,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- .classpath 19 Feb 2004 14:20:06 -0000 1.6 +++ .classpath 17 Mar 2004 03:51:53 -0000 1.7 @@ -1,18 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> - <classpath> - <classpathentry kind="src" path="src\java"> - </classpathentry> - <classpathentry output="target\test-classes" kind="src" path="src\test"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"> - </classpathentry> - <classpathentry kind="var" rootpath="JRE_SRCROOT" path="JRE_LIB" sourcepath="JRE_SRC"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commonjava/jars/commonjava-lang-2.0.jar"> - </classpathentry> - <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.2.jar"> - </classpathentry> - <classpathentry kind="output" path="target\classes"> - </classpathentry> -</classpath> \ No newline at end of file + <classpathentry kind="var" path="MAVEN_REPO/commons-logging/jars/commons-logging-1.0.3.jar"/> + <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-3.8.1.jar"/> + <classpathentry kind="output" path="target/classes"/> +</classpath> Index: project.xml =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-util/project.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- project.xml 10 Mar 2004 21:47:41 -0000 1.7 +++ project.xml 17 Mar 2004 03:51:53 -0000 1.8 @@ -5,7 +5,7 @@ <id>commonjava-util</id> <name>Utilities</name> <groupId>commonjava</groupId> - <currentVersion>2.0-4</currentVersion> + <currentVersion>2.0-5</currentVersion> <organization> <name>CommonJava Open Component Project</name> <url>http://www.commonjava.org</url> @@ -32,13 +32,6 @@ <dependencies> <dependency> - <groupId>commonjava</groupId> - <artifactId>commonjava-lang</artifactId> - <version>2.0</version> - <url>http://www.commonjava.org</url> - </dependency> - - <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.0.2</version> |
From: John C. <joh...@co...> - 2004-03-16 22:56:57
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv555/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet Modified Files: OplXsdPlugin.jelly OplNodeParserPlugin.vm Log Message: added use-body attribute to the OplAttributeTag class, to support pulling attribute values directly from the element's body content. Index: OplXsdPlugin.jelly =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/OplXsdPlugin.jelly,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- OplXsdPlugin.jelly 8 Mar 2004 14:36:34 -0000 1.1 +++ OplXsdPlugin.jelly 16 Mar 2004 22:47:33 -0000 1.2 @@ -42,35 +42,37 @@ </if> <forEach var="method" items="${class.methods}"> <set var="attrTag" value="${method.getTagByName('opl.attribute')}"/> - <if test="${attrTag != null}"> - <x:element name="xs:attribute"> - <x:attribute name="name">${attrTag.getNamedParameter('name')}</x:attribute> - <set var="requiredVal" value="${attrTag.getNamedParameter('required')}"/> - <choose> - <when test="${requiredVal != null}"> - <choose> - <when test="${requiredVal == 'false'}"> - <x:attribute name="use">optional</x:attribute> - </when> - <otherwise> - <x:attribute name="use">required</x:attribute> - </otherwise> - </choose> - </when> - <otherwise> - <x:attribute name="use">optional</x:attribute> - </otherwise> - </choose> - <set var="typeVal" value="${attrTag.getNamedParameter('type')}"/> - <choose> - <when test="${typeVal != null}"> - <x:attribute name="type">xs:${typeVal}</x:attribute> - </when> - <otherwise> - <x:attribute name="type">xs:string</x:attribute> - </otherwise> - </choose> - </x:element> + <if test="${attrTag.getNamedParameter('use-body') == 'false'}"> + <if test="${attrTag != null}"> + <x:element name="xs:attribute"> + <x:attribute name="name">${attrTag.getNamedParameter('name')}</x:attribute> + <set var="requiredVal" value="${attrTag.getNamedParameter('required')}"/> + <choose> + <when test="${requiredVal != null}"> + <choose> + <when test="${requiredVal == 'false'}"> + <x:attribute name="use">optional</x:attribute> + </when> + <otherwise> + <x:attribute name="use">required</x:attribute> + </otherwise> + </choose> + </when> + <otherwise> + <x:attribute name="use">optional</x:attribute> + </otherwise> + </choose> + <set var="typeVal" value="${attrTag.getNamedParameter('type')}"/> + <choose> + <when test="${typeVal != null}"> + <x:attribute name="type">xs:${typeVal}</x:attribute> + </when> + <otherwise> + <x:attribute name="type">xs:string</x:attribute> + </otherwise> + </choose> + </x:element> + </if> </if> </forEach> </x:element> Index: OplNodeParserPlugin.vm =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/OplNodeParserPlugin.vm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- OplNodeParserPlugin.vm 12 Mar 2004 19:46:56 -0000 1.4 +++ OplNodeParserPlugin.vm 16 Mar 2004 22:47:34 -0000 1.5 @@ -22,11 +22,14 @@ ${plugin.buildImplementsClause($class)} { #foreach($method in $class.methods) - #if($method.getNamedParameter("opl.attribute", "name")) + #if(!$method.getNamedParameter("opl.attribute", "use-body")) + #if($method.getNamedParameter("opl.attribute", "name")) private static final String ${plugin.getAttributeConstant($method)} = "${method.getNamedParameter("opl.attribute", "name")}"; + #end #end #end + private ${class.fullyQualifiedName} instance = new ${class.fullyQualifiedName}(); #if($plugin.shouldGenerateLocalPropertyContainer($class)) private Properties properties = new Properties(); @@ -52,6 +55,7 @@ protected final void doBeforeChildren(ElementInfo info) throws ParseException{ #foreach($method in $class.methods) + #if(!$method.getNamedParameter("opl.attribute", "use-body")) #if($method.getNamedParameter("opl.attribute", "before-children") == "true") try{ #set($attrName = $method.getNamedParameter("opl.attribute", "name")) @@ -110,15 +114,22 @@ } } #end + #end #end } protected final void doAfterChildren(ElementInfo info, String bodyText) throws ParseException{ #foreach($method in $class.methods) - #if($method.getNamedParameter("opl.attribute", "before-children") == "false") + #if($method.getNamedParameter("opl.attribute", "before-children") == "false" || $method.getNamedParameter("opl.attribute", "use-body") == "true") try{ #set($attrName = $method.getNamedParameter("opl.attribute", "name")) - String $attrName = getAttribute(${plugin.getAttributeConstant($method)}, info, ${method.getNamedParameter("opl.attribute", "resolve-value")}); + + #if($method.getNamedParameter("opl.attribute", "use-body") == "true") + String ${attrName} = bodyText; + #else + String ${attrName} = getAttribute(${plugin.getAttributeConstant($method)}, info, ${method.getNamedParameter("opl.attribute", "resolve-value")}); + #end + #set($extractor = $method.getNamedParameter("opl.attribute", "extractor")) #set($validator = $method.getNamedParameter("opl.attribute", "validator")) #set($notRequired = $method.getNamedParameter("opl.attribute", "required") == "false") |
From: John C. <joh...@co...> - 2004-03-16 22:56:56
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv555/projects/opl-xdoclet Modified Files: maven.xml Log Message: added use-body attribute to the OplAttributeTag class, to support pulling attribute values directly from the element's body content. Index: maven.xml =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/maven.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- maven.xml 8 Mar 2004 14:36:34 -0000 1.1 +++ maven.xml 16 Mar 2004 22:47:32 -0000 1.2 @@ -8,6 +8,12 @@ <attainGoal name="qtags"/> </c:if> </preGoal> + + <goal name="test-project"> + <maven:maven descriptor="${basedir}/test-project/project.xml" + goals="clean,java:compile" + ignoreFailures="false" /> + </goal> <goal name="qtags"> <c:set var="gensrc" value="${maven.build.dir}/generated-src"/> |
From: John C. <joh...@co...> - 2004-03-16 22:56:56
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/test-project/src/java/org/commonjava/opl/xdoclet/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv555/projects/opl-xdoclet/test-project/src/java/org/commonjava/opl/xdoclet/test Modified Files: TestSubConfig.java Log Message: added use-body attribute to the OplAttributeTag class, to support pulling attribute values directly from the element's body content. Index: TestSubConfig.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/test-project/src/java/org/commonjava/opl/xdoclet/test/TestSubConfig.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- TestSubConfig.java 12 Mar 2004 19:46:56 -0000 1.3 +++ TestSubConfig.java 16 Mar 2004 22:47:32 -0000 1.4 @@ -46,6 +46,19 @@ } /** + * @opl.attribute + * name="yetAnotherTestParam" + * use-body="true" + * required="false" + * type="int" + * extractor="Strings.toInteger(@@value).intValue()" + * validator="@@value > 0" + * before-children="true" + */ + public void setYetAnotherTestParam(int param4){ + } + + /** * @opl.delegate value="true" */ public void setBoolParam(Boolean bParam){ |
From: John C. <joh...@co...> - 2004-03-16 22:56:56
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/qtags In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv555/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/qtags Modified Files: OplAttributeTag.java Log Message: added use-body attribute to the OplAttributeTag class, to support pulling attribute values directly from the element's body content. Index: OplAttributeTag.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/projects/opl-xdoclet/src/java/org/commonjava/opl/xdoclet/qtags/OplAttributeTag.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- OplAttributeTag.java 8 Mar 2004 23:06:41 -0000 1.2 +++ OplAttributeTag.java 16 Mar 2004 22:47:33 -0000 1.3 @@ -13,6 +13,13 @@ */ String getName_(); + /** Whether this attribute's content is the body of the element. + * @qtags.parameter default="false" + * @qtags.parameter allowed-value="true" + * @qtags.parameter allowed-value="false" + */ + String getUseBody(); + /** Whether the attribute is required. * @qtags.parameter default="false" * @qtags.parameter allowed-value="true" |
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2746/src/java/org/commonjava/opl Modified Files: NodeParser.java OPLModelRoot.java ParserLibrary.java OPLEngine.java IgnoredElementParser.java DocumentDriver.java NamespaceResolver.java IgnoreEverythingParserLibrary.java NoSuchParserException.java ParserConfigurationException.java GenericNamespaceResolver.java LibraryConfigurationException.java SAXDriver.java ParseException.java OPLDriver.java MissingAttributeException.java NoSuchLibraryException.java OPLContext.java ElementInfo.java Log Message: updated to 0.2, made method call parameter generation more robust. Index: NodeParser.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/NodeParser.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- NodeParser.java 20 Feb 2004 21:16:03 -0000 1.15 +++ NodeParser.java 12 Mar 2004 19:46:52 -0000 1.16 @@ -3,8 +3,6 @@ */ package org.commonjava.opl; -import java.io.PrintWriter; -import java.io.StringWriter; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; Index: OPLModelRoot.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/OPLModelRoot.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- OPLModelRoot.java 18 Sep 2003 04:56:57 -0000 1.1 +++ OPLModelRoot.java 12 Mar 2004 19:46:53 -0000 1.2 @@ -3,15 +3,15 @@ */ package org.commonjava.opl; + /** Represents a parser which forms the base of a parse model. - * + * * @author John Casey */ -public interface OPLModelRoot { - +public interface OPLModelRoot +{ /** Retrieve the parsed object from the model. * @return the parsed object. */ public Object getParsedObject() throws ParseException; - } Index: ParserLibrary.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/ParserLibrary.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ParserLibrary.java 10 Oct 2003 00:15:46 -0000 1.2 +++ ParserLibrary.java 12 Mar 2004 19:46:53 -0000 1.3 @@ -3,12 +3,11 @@ */ package org.commonjava.opl; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; -import org.commonjava.reflection.Reflector; -import org.commonjava.reflection.ReflectorException; - /** Collection of parsers, tied together under a common namespace. * In short, this class represents all the possible parsers for a * given namespace. @@ -155,16 +154,74 @@ try { Object[] params = null; + Class[] sig = null; if(parent == null){ params = new Object[]{ctx}; + sig = new Class[]{OPLContext.class}; } else{ params = new Object[]{ctx, parent}; + sig = new Class[]{OPLContext.class, NodeParser.class}; } - result = (NodeParser)Reflector.newInstance(parserCls, params); + + Constructor cons = parserCls.getConstructor(sig); + result = (NodeParser)cons.newInstance(params); } - catch (ReflectorException e) { - throw new ParserConfigurationException(e); + catch(InstantiationException e){ + throw new ParserConfigurationException( + "Error instantitating parser library for node: " + nodeName, + e + ); + } + catch(IllegalAccessException e){ + throw new ParserConfigurationException( + "Illegal access while instantitating parser for node: " + nodeName, + e + ); + } + catch(IllegalArgumentException e){ + StringBuffer buffer = new StringBuffer(); + buffer.append("Illegal argument"); + if(parent != null){buffer.append('s');} + buffer.append(" { ").append(ctx); + if(parent != null){buffer.append("[, ").append(parent).append(']');} + buffer.append(" } while instantiating parser for node: ").append(nodeName); + + throw new ParserConfigurationException( + buffer.toString(), + e + ); + } + catch(InvocationTargetException e){ + throw new ParserConfigurationException( + "Problem invoking constructor (with/without namespace param) instantitating parser " + + "for node: " + + nodeName, + e + ); + } + catch (SecurityException e) { + throw new ParserConfigurationException( + "Security violation while instantitating parser for node: " + nodeName, + e + ); + } + catch (NoSuchMethodException e) { + StringBuffer buffer = new StringBuffer(); + buffer.append("No appropriate constructor could be found for parser of node: ").append(nodeName); + buffer.append("Please specify a constructor with the following signature:\n\n"); + + int lastDot = parserCls.getName().lastIndexOf('.'); + String simpleCls = parserCls.getName().substring(lastDot +1); + + buffer.append("\tpublic ").append(simpleCls).append("(OPLContext ctx"); + if(parent != null){buffer.append(", NodeParser parent");} + buffer.append(")\n\nin class ").append(parserCls.getName()); + + throw new ParserConfigurationException( + buffer.toString(), + e + ); } if(result != null){ Index: OPLEngine.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/OPLEngine.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- OPLEngine.java 18 Feb 2004 06:12:10 -0000 1.5 +++ OPLEngine.java 12 Mar 2004 19:46:53 -0000 1.6 @@ -3,76 +3,90 @@ */ package org.commonjava.opl; -import java.io.InputStream; - import org.w3c.dom.Document; import org.w3c.dom.Node; + import org.xml.sax.InputSource; +import java.io.InputStream; + + /** Engine which drives the parsing of some XML data into * an object model. - * + * * @author John Casey */ -public class OPLEngine { - +public class OPLEngine +{ private OPLDriver driver; /** Deny creation, use getInstance() instead. */ - private OPLEngine(OPLDriver driver) { + private OPLEngine(OPLDriver driver) + { this.driver = driver; } - + /** Retrieve the singleton * @return the singleton instance */ - public static OPLEngine getInstance(OPLDriver driver){ + public static OPLEngine getInstance(OPLDriver driver) + { return new OPLEngine(driver); } - + public Object parse(InputStream in) throws ParseException { return driver.parse(new OPLContext(), in); } - - public Object parse(InputStream in, boolean ignoreUnrecognized) throws ParseException + + public Object parse(InputStream in, boolean ignoreUnrecognized) + throws ParseException { return driver.parse(new OPLContext(ignoreUnrecognized), in); } - + public Object parse(InputSource in) throws ParseException { return driver.parse(new OPLContext(), in); } - - public Object parse(InputSource in, boolean ignoreUnrecognized) throws ParseException + + public Object parse(InputSource in, boolean ignoreUnrecognized) + throws ParseException { return driver.parse(new OPLContext(ignoreUnrecognized), in); } - - public Object parse(Document document) throws ParseException{ + + public Object parse(Document document) throws ParseException + { return driver.parse(new OPLContext(), document); } - - public Object parse(Document document, boolean ignoreUnrecognized) throws ParseException{ + + public Object parse(Document document, boolean ignoreUnrecognized) + throws ParseException + { return driver.parse(new OPLContext(ignoreUnrecognized), document); } - - public Object parse(Node node) throws ParseException{ + + public Object parse(Node node) throws ParseException + { return driver.parse(new OPLContext(), node); } - - public Object parse(Node node, boolean ignoreUnrecognized) throws ParseException{ + + public Object parse(Node node, boolean ignoreUnrecognized) + throws ParseException + { return driver.parse(new OPLContext(ignoreUnrecognized), node); } - - public Object parse(String uri) throws ParseException{ + + public Object parse(String uri) throws ParseException + { return driver.parse(new OPLContext(), uri); } - - public Object parse(String uri, boolean ignoreUnrecognized) throws ParseException{ + + public Object parse(String uri, boolean ignoreUnrecognized) + throws ParseException + { return driver.parse(new OPLContext(ignoreUnrecognized), uri); } - } Index: IgnoredElementParser.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/IgnoredElementParser.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- IgnoredElementParser.java 10 Oct 2003 00:15:46 -0000 1.3 +++ IgnoredElementParser.java 12 Mar 2004 19:46:53 -0000 1.4 @@ -3,56 +3,57 @@ */ package org.commonjava.opl; -import java.util.Properties; - import org.commonjava.opl.generics.properties.PropertiesContainer; +import java.util.Properties; + /** Generic parser which ignores the current element. This can be used - * from any dynalib or explicit ParserLibrary implementation to simply + * from any dynalib or explicit ParserLibrary implementation to simply * say "I'm skipping this element" or "I don't care about this element". - * + * * @author John Casey */ -public final class IgnoredElementParser extends NodeParser - implements PropertiesContainer +public final class IgnoredElementParser extends NodeParser implements PropertiesContainer { - private Properties parsingProperties; /** Create a new IgnoredElementParser * @param context The parse context * @param parent The parent of this parser */ - public IgnoredElementParser(OPLContext context, NodeParser parent) { + public IgnoredElementParser(OPLContext context, NodeParser parent) + { super(context, parent); } /** Create a new IgnoredElementParser * @param context The parse context */ - public IgnoredElementParser(OPLContext context) { + public IgnoredElementParser(OPLContext context) + { super(context); } /** Set the properties for use in parsing children of this parser. - * + * * @param properties the properties to use in parsing child nodes. - * + * * @see org.commonjava.opl.PropertiesContainer#setProperties(java.util.Properties) */ - public void setProperties(Properties properties) { + public void setProperties(Properties properties) + { this.parsingProperties = properties; } /** Get the properties for use in parsing children of this parser. - * + * * @return the properties to use in parsing child nodes. - * + * * @see org.commonjava.opl.PropertiesContainer#getProperties() */ - public Properties getProperties() { + public Properties getProperties() + { return parsingProperties; } - } Index: DocumentDriver.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/DocumentDriver.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- DocumentDriver.java 18 Feb 2004 06:12:10 -0000 1.11 +++ DocumentDriver.java 12 Mar 2004 19:46:53 -0000 1.12 @@ -4,56 +4,59 @@ */ package org.commonjava.opl; -import java.io.IOException; -import java.io.InputStream; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.TransformerException; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.apache.xpath.XPathAPI; + import org.commonjava.io.IOFactory; import org.commonjava.io.IOResource; + import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.traversal.NodeIterator; + import org.xml.sax.InputSource; import org.xml.sax.SAXException; +import java.io.IOException; +import java.io.InputStream; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; + + /** Driver used in OPL parsing, which uses a DOM Document to drive the parsing * process via a set of NodeParsers. - * + * * @author John Casey * */ -public class DocumentDriver implements OPLDriver { - +public class DocumentDriver implements OPLDriver +{ private static final Log LOG = LogFactory.getLog(DocumentDriver.class); - private static DocumentBuilderFactory FACTORY; - private NodeParser parent; private NamespaceResolver resolver; private boolean validating = false; /** Create a new DocumentDriver. */ - public DocumentDriver() { - } + public DocumentDriver() {} /** Create a new DocumentDriver. * @param parent The parent NodeParser to use, which will treat * this parsed document as a subsection of another parsing effort, * as in the case of an import operation. */ - public DocumentDriver(NodeParser parent) { + public DocumentDriver(NodeParser parent) + { this.parent = parent; } - /** Parse the XML content on the specified input stream, and return the + /** Parse the XML content on the specified input stream, and return the * resulting object. * @param context the parsing context * @param in the input stream @@ -62,30 +65,31 @@ * @throws ParseException * @see org.commonjava.opl.OPLDriver#parse(org.commonjava.opl.OPLContext, java.io.InputStream, boolean) */ - public Object parse(OPLContext context, InputStream in) - throws MissingAttributeException, ParseException + public Object parse(OPLContext context, InputStream in) + throws MissingAttributeException, ParseException { initDocumentBuilderFactory(); - + assert (FACTORY != null); - + try { DocumentBuilder builder = FACTORY.newDocumentBuilder(); Document document = builder.parse(in); + return parseInternal(context, document.getDocumentElement()); } - catch (ParserConfigurationException e) { + catch(ParserConfigurationException e) { throw new ParseException("Mis-configured JAXP.", e); } - catch (SAXException e) { + catch(SAXException e) { throw new ParseException("Error parsing DOM.", e); } - catch (IOException e) { + catch(IOException e) { throw new ParseException("Error reading XML from InputStream.", e); } } - /** Parse the XML content stored at the specified URI, and return the + /** Parse the XML content stored at the specified URI, and return the * resulting object. * @param context the parsing context * @param uri the URI to open and parse @@ -94,34 +98,34 @@ * @throws ParseException * @see org.commonjava.opl.OPLDriver#parse(org.commonjava.opl.OPLContext, java.lang.String, boolean) */ - public Object parse(OPLContext context, String uri) - throws MissingAttributeException, ParseException + public Object parse(OPLContext context, String uri) + throws MissingAttributeException, ParseException { initDocumentBuilderFactory(); - + assert (FACTORY != null); - + try { DocumentBuilder builder = FACTORY.newDocumentBuilder(); IOResource resource = IOFactory.getInstance().getResource(uri); - + Document document = builder.parse(resource.getInputStream()); resource.close(); - + return parseInternal(context, document.getDocumentElement()); } - catch (ParserConfigurationException e) { + catch(ParserConfigurationException e) { throw new ParseException("Mis-configured JAXP.", e); } - catch (SAXException e) { + catch(SAXException e) { throw new ParseException("Error parsing DOM.", e); } - catch (IOException e) { + catch(IOException e) { throw new ParseException("Error reading Document source.", e); } } - /** Parse the XML content on the specified SAX input source, and return the + /** Parse the XML content on the specified SAX input source, and return the * resulting object. * @param context the parsing context * @param in the input source @@ -130,32 +134,33 @@ * @throws ParseException * @see org.commonjava.opl.OPLDriver#parse(org.commonjava.opl.OPLContext, org.xml.sax.InputSource, boolean) */ - public Object parse(OPLContext context, InputSource in) - throws MissingAttributeException, ParseException + public Object parse(OPLContext context, InputSource in) + throws MissingAttributeException, ParseException { initDocumentBuilderFactory(); - + assert (FACTORY != null); - + try { DocumentBuilder builder = FACTORY.newDocumentBuilder(); Document document = builder.parse(in); + return parseInternal(context, document.getDocumentElement()); } - catch (ParserConfigurationException e) { + catch(ParserConfigurationException e) { throw new ParseException("Mis-configured JAXP.", e); } - catch (SAXException e) { + catch(SAXException e) { throw new ParseException("Error parsing DOM.", e); } - catch (IOException e) { + catch(IOException e) { throw new ParseException("Error reading XML from InputStream.", e); } } - /** Parse the XML content in the specified document object, and return the - * resulting object. - * + /** Parse the XML content in the specified document object, and return the + * resulting object. + * * @param context the parsing context * @param document the DOM document to parse * @param ignoreUnrecognized whether to ignore unrecognized element types. @@ -163,15 +168,15 @@ * @throws ParseException * @see org.commonjava.opl.OPLDriver#parse(org.commonjava.opl.OPLContext, org.w3c.dom.Document, boolean) */ - public Object parse(OPLContext context, Document document) - throws MissingAttributeException, ParseException + public Object parse(OPLContext context, Document document) + throws MissingAttributeException, ParseException { return parseInternal(context, document.getDocumentElement()); } - - /** Parse the XML content in the specified document object, and return the - * resulting object. - * + + /** Parse the XML content in the specified document object, and return the + * resulting object. + * * @param context the parsing context * @param document the DOM document to parse * @param ignoreUnrecognized whether to ignore unrecognized element types. @@ -179,18 +184,18 @@ * @throws ParseException * @see org.commonjava.opl.OPLDriver#parse(org.commonjava.opl.OPLContext, org.w3c.dom.Document, boolean) */ - public Object parse(OPLContext context, Node node) - throws MissingAttributeException, ParseException + public Object parse(OPLContext context, Node node) + throws MissingAttributeException, ParseException { return parseInternal(context, node); } - + /** Traverse all elements in the specified document, building an object tree * as a result. The specified context is used to manage parser and library * creation and mapping, and the ignoreUnrecognized is a flag which tells us * whether to ignore elements the context cannot find a mapping for. * @param context The parsing context - * @param document The document to parse. + * @param document The document to parse. * @param ignoreUnrecognized whether to ignore unrecognized element types. * @return the parsed object. * @throws IOException @@ -198,48 +203,46 @@ * @see org.commonjava.opl.OPLDriver#parse(java.io.InputStream, boolean) */ private Object parseInternal(OPLContext context, Node root) - throws MissingAttributeException, ParseException + throws MissingAttributeException, ParseException { - if (LOG.isTraceEnabled()) { + if(LOG.isTraceEnabled()) { LOG.trace("Root node is: " + root); } - - if(root == null){ + + if(root == null) { throw new ParseException("Root configuration node is null. Parsing aborted."); } - - if (LOG.isTraceEnabled()) { + + if(LOG.isTraceEnabled()) { LOG.trace( - "Root namespace is: \'" + root.getNamespaceURI() + "\'\n" + - "Root local name is: \'" + root.getLocalName() + "\'\n" + - "Root parent is: " + parent + "\n" + + "Root namespace is: \'" + root.getNamespaceURI() + "\'\n" + "Root local name is: \'" + + root.getLocalName() + "\'\n" + "Root parent is: " + parent + "\n" + "Root node name is: \'" + root.getNodeName() + "\'" ); } NodeParser rootParser = null; + if(parent != null) { - rootParser = context.newParser( - root.getNamespaceURI(), root.getLocalName(), parent, root.getNodeName() - ); + rootParser = + context.newParser(root.getNamespaceURI(), root.getLocalName(), parent, root.getNodeName()); } else { String uri = root.getNamespaceURI(); - if(resolver != null){ + + if(resolver != null) { uri = resolver.lookupNamespace(uri); } - rootParser = context.newParser( - uri, root.getLocalName(), root.getNodeName() - ); + + rootParser = context.newParser(uri, root.getLocalName(), root.getNodeName()); } - - if(parent == null && !(rootParser instanceof OPLModelRoot)){ + + if((parent == null) && !(rootParser instanceof OPLModelRoot)) { throw new ParseException("Invalid document element: " + root.getNodeName()); } - - + parseNode(rootParser, context, root); - + if(parent == null) { return ((OPLModelRoot)rootParser).getParsedObject(); } @@ -247,44 +250,41 @@ return null; } } - + /** Parse a single node. Call recursively to traverse the DOM. * @param node The node to parse * @throws ParseException in case of an error parsing the node. */ - private void parseNode(NodeParser currentParser, OPLContext context, - Node currentNode) - throws MissingAttributeException, ParseException + private void parseNode(NodeParser currentParser, OPLContext context, Node currentNode) + throws MissingAttributeException, ParseException { - DOMElementInfo info = new DOMElementInfo(currentNode, context); currentParser.checkRequiredAttributes(info); currentParser.doBeforeChildren(info); - + try { NodeIterator children = XPathAPI.selectNodeIterator(currentNode, "*"); Node child = null; - while((child = children.nextNode()) != null){ - + + while((child = children.nextNode()) != null) { String uri = child.getNamespaceURI(); - if(resolver != null){ + + if(resolver != null) { uri = resolver.lookupNamespace(uri); } - - NodeParser childParser = context.newParser( - uri, child.getLocalName(), currentParser, child.getNodeName() - ); + + NodeParser childParser = + context.newParser(uri, child.getLocalName(), currentParser, child.getNodeName()); parseNode(childParser, context, child); } } - catch (TransformerException e) { + catch(TransformerException e) { throw new ParseException( - "Error selecting children of current node for processing: " + - currentNode.getNodeName(), + "Error selecting children of current node for processing: " + currentNode.getNodeName(), e ); } - + String body = info.getBody(); currentParser.doAfterChildren(info, body); } @@ -292,11 +292,12 @@ /** Make sure the DocumentBuilderFactory which is shared for all instances of * DocumentDriver is initialized. */ - private void initDocumentBuilderFactory(){ - synchronized(DocumentDriver.class){ - if(FACTORY == null){ + private void initDocumentBuilderFactory() + { + synchronized(DocumentDriver.class) { + if(FACTORY == null) { FACTORY = DocumentBuilderFactory.newInstance(); - + // configure the FACTORY. FACTORY.setNamespaceAware(true); FACTORY.setValidating(validating); @@ -307,21 +308,38 @@ } } + /** Set the resolver used to resolve potential namspace mappings from external + * (i.e. SAX, or real XML namespaces) to internal (OPL). + * @param resolver The resolver to use + */ + public void setNamespaceResolver(NamespaceResolver resolver) + { + this.resolver = resolver; + } + + /* (non-Javadoc) + * @see org.commonjava.opl.OPLDriver#setValidating(boolean) + */ + public void setValidating(boolean validating) + { + this.validating = validating; + } + /** ElementInfo implementation which uses a DOM Node object as backing * for both the namespace and attribute lookup functions. */ - public static class DOMElementInfo implements ElementInfo{ - + public static class DOMElementInfo implements ElementInfo + { private static final Log LOG = LogFactory.getLog(DOMElementInfo.class); - private Node node; private OPLContext context; - + /** Construct a new DOMElementInfo instance, with the specified Node as * namespace and attribute source. * @param node The node to use for namespace and attribute lookups. */ - DOMElementInfo(Node node, OPLContext context){ + DOMElementInfo(Node node, OPLContext context) + { this.node = node; this.context = context; } @@ -332,39 +350,40 @@ * @return the value of the attribute, or null * @see org.commonjava.opl.ElementInfo#getRawAttributeValue(java.lang.String) */ - public String getRawAttributeValue(String attributeName) - throws ParseException + public String getRawAttributeValue(String attributeName) + throws ParseException { - if("text()".equals(attributeName)){ + if("text()".equals(attributeName)) { throw new ParseException("Element body text is not available here."); } - else{ + else { return _getRawAttributeValue(attributeName); } } - + /** Return the attribute mapped to the specified name, or null if none exists. * @param attributeName the name of the attribute * @return the value of the attribute, or null * @see org.commonjava.opl.ElementInfo#getRawAttributeValue(java.lang.String) */ - private String _getRawAttributeValue(String attributeName) - throws MissingAttributeException + private String _getRawAttributeValue(String attributeName) + throws MissingAttributeException { String value = null; + try { Node attr = XPathAPI.selectSingleNode(node, "@" + attributeName); - if (attr != null) { + if(attr != null) { value = attr.getNodeValue(); } } - catch (TransformerException e) { - if(LOG.isDebugEnabled()){ + catch(TransformerException e) { + if(LOG.isDebugEnabled()) { LOG.debug(attributeName + ": attribute not found in " + node.getLocalName()); } } - + return value; } @@ -372,34 +391,18 @@ * @return the namespace URI * @see org.commonjava.opl.ElementInfo#getNamespaceUri() */ - public String getNamespaceUri() { + public String getNamespaceUri() + { return node.getNamespaceURI(); } - + /** Convenience method to provide easy access to the body text of the * node represented here. * @return the value of the text() XPath expression. */ - String getBody() throws ParseException{ + String getBody() throws ParseException + { return _getRawAttributeValue("text()"); } } - - /** Set the resolver used to resolve potential namspace mappings from external - * (i.e. SAX, or real XML namespaces) to internal (OPL). - * @param resolver The resolver to use - */ - public void setNamespaceResolver(NamespaceResolver resolver) - { - this.resolver = resolver; - } - - /* (non-Javadoc) - * @see org.commonjava.opl.OPLDriver#setValidating(boolean) - */ - public void setValidating(boolean validating) - { - this.validating = validating; - } - } Index: NamespaceResolver.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/NamespaceResolver.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- NamespaceResolver.java 8 Jan 2004 20:35:11 -0000 1.1 +++ NamespaceResolver.java 12 Mar 2004 19:46:53 -0000 1.2 @@ -1,21 +1,20 @@ /* Created on Jan 8, 2004 */ package org.commonjava.opl; + /** Represents a way of resolving namespaces to other namespaces. * One possible use of this resolution would be to convert "real" * XML namespaces (namespaces which would allow XML validation via a SAX * parser, for instance) to OPL namespaces. - * + * * @author jdcasey */ public interface NamespaceResolver { - /** Return the OPL namespace for the specified XML namespace. - * + * * @param namespace the namespace to resolve. * @return the OPL-specific namespace mapping. */ public String lookupNamespace(String namespace); - } Index: IgnoreEverythingParserLibrary.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/IgnoreEverythingParserLibrary.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- IgnoreEverythingParserLibrary.java 18 Sep 2003 04:56:57 -0000 1.1 +++ IgnoreEverythingParserLibrary.java 12 Mar 2004 19:46:53 -0000 1.2 @@ -4,23 +4,24 @@ package org.commonjava.opl; -/** Parser library which ignores all the content +/** Parser library which ignores all the content * of the elements it is used to parse. - * + * * @author John Casey */ -public class IgnoreEverythingParserLibrary extends ParserLibrary { - - /** Create a new parser library which ignores all the content +public class IgnoreEverythingParserLibrary extends ParserLibrary +{ + /** Create a new parser library which ignores all the content * of the elements it is used to parse. * @param namespace our namespace. */ - public IgnoreEverythingParserLibrary(String namespace) { + public IgnoreEverythingParserLibrary(String namespace) + { super(namespace); } /** Regardless of the node type, return IgnoreElementParser. - * + * * NOTE: This method overrides newParser * @param nodeName the name of the node for which to create a parser. * @param params The constructor arguments for the parser. @@ -29,20 +30,20 @@ * @throws ParserConfigurationException * @see org.commonjava.opl.ParserLibrary#newParser(java.lang.String, java.lang.Object[]) */ - protected NodeParser createParser(String nodeName, OPLContext ctx, - NodeParser parent) - throws NoSuchParserException, ParserConfigurationException + protected NodeParser createParser(String nodeName, OPLContext ctx, NodeParser parent) + throws NoSuchParserException, ParserConfigurationException { NodeParser result = null; - if(parent != null){ + + if(parent != null) { result = new IgnoredElementParser(ctx, parent); } - else{ + else { result = new IgnoredElementParser(ctx); } - + result.setParserLibrary(this); + return result; } - } Index: NoSuchParserException.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/NoSuchParserException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- NoSuchParserException.java 18 Sep 2003 04:56:57 -0000 1.1 +++ NoSuchParserException.java 12 Mar 2004 19:46:53 -0000 1.2 @@ -3,47 +3,56 @@ */ package org.commonjava.opl; + //TODO: Document NoSuchParserException + /** * @author jdcasey */ -public class NoSuchParserException extends ParseException { - +public class NoSuchParserException extends ParseException +{ //TODO: Document NoSuchParserException constructor! + /** - * + * */ - public NoSuchParserException() { + public NoSuchParserException() + { //TODO Implement NoSuchParserException constructor super(); } //TODO: Document NoSuchParserException constructor! + /** * @param message */ - public NoSuchParserException(String message) { + public NoSuchParserException(String message) + { //TODO Implement NoSuchParserException constructor super(message); } //TODO: Document NoSuchParserException constructor! + /** * @param message * @param cause */ - public NoSuchParserException(String message, Throwable cause) { + public NoSuchParserException(String message, Throwable cause) + { //TODO Implement NoSuchParserException constructor super(message, cause); } //TODO: Document NoSuchParserException constructor! + /** * @param cause */ - public NoSuchParserException(Throwable cause) { + public NoSuchParserException(Throwable cause) + { //TODO Implement NoSuchParserException constructor super(cause); } - } Index: ParserConfigurationException.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/ParserConfigurationException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ParserConfigurationException.java 18 Sep 2003 04:56:57 -0000 1.1 +++ ParserConfigurationException.java 12 Mar 2004 19:46:53 -0000 1.2 @@ -3,47 +3,56 @@ */ package org.commonjava.opl; + //TODO: Document ParserConfigurationException + /** * @author jdcasey */ -public class ParserConfigurationException extends ParseException { - +public class ParserConfigurationException extends ParseException +{ //TODO: Document ParserConfigurationException constructor! + /** - * + * */ - public ParserConfigurationException() { + public ParserConfigurationException() + { //TODO Implement ParserConfigurationException constructor super(); } //TODO: Document ParserConfigurationException constructor! + /** * @param message */ - public ParserConfigurationException(String message) { + public ParserConfigurationException(String message) + { //TODO Implement ParserConfigurationException constructor super(message); } //TODO: Document ParserConfigurationException constructor! + /** * @param message * @param cause */ - public ParserConfigurationException(String message, Throwable cause) { + public ParserConfigurationException(String message, Throwable cause) + { //TODO Implement ParserConfigurationException constructor super(message, cause); } //TODO: Document ParserConfigurationException constructor! + /** * @param cause */ - public ParserConfigurationException(Throwable cause) { + public ParserConfigurationException(Throwable cause) + { //TODO Implement ParserConfigurationException constructor super(cause); } - } Index: GenericNamespaceResolver.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/GenericNamespaceResolver.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- GenericNamespaceResolver.java 18 Feb 2004 06:12:10 -0000 1.3 +++ GenericNamespaceResolver.java 12 Mar 2004 19:46:53 -0000 1.4 @@ -3,12 +3,13 @@ import java.util.Properties; -/** Generic alias-resolving namespace mapper, which allows the + +/** Generic alias-resolving namespace mapper, which allows the * specification of alias namespaces which will simply resolve * to other namespaces (no higher-level logic here) for the purposes - * of substituting OPL namespaces for XML namespaces (SAX-resolvable), + * of substituting OPL namespaces for XML namespaces (SAX-resolvable), * for instance. - * + * * @author jdcasey */ public class GenericNamespaceResolver implements NamespaceResolver @@ -19,51 +20,54 @@ * substitutes one namespace for another, effectively creating * a map of aliases. */ - public GenericNamespaceResolver() - { - } - + public GenericNamespaceResolver() {} + /** Add a new namespace alias to this resolver. - * + * * @param nativeNS the native (OPL) namespace * @param aliasNS the alias (XML, SAX, etc.) namespace */ - public void addAlias(String aliasNS, String nativeNS){ + public void addAlias(String aliasNS, String nativeNS) + { namespaceMappings.setProperty(aliasNS, nativeNS); } /** Return the OPL namespace for the specified XML namespace. - * + * * @param namespace the namespace to resolve. * @return the OPL-specific namespace mapping. */ public String lookupNamespace(String namespace) { String result = _lookup(namespace); - if(result == null){ + + if(result == null) { return namespace; } - else{ + else { return result; } } - + /** Perform the actual lookup, which may turn out to be a recursive search. - * Repeat this recursively until the result of the lookup is null. Then, + * Repeat this recursively until the result of the lookup is null. Then, * return the last non-null result. * @param namespace the namespace to resolve * @return the result of the [recursive] lookup */ - private String _lookup(String namespace){ - if(namespace == null){return null;} - + private String _lookup(String namespace) + { + if(namespace == null) { + return null; + } + String result = namespaceMappings.getProperty(namespace); String ns = result; - while((ns = _lookup(ns)) != null){ + + while((ns = _lookup(ns)) != null) { result = ns; } - + return result; } - } Index: LibraryConfigurationException.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/LibraryConfigurationException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- LibraryConfigurationException.java 18 Sep 2003 04:56:57 -0000 1.1 +++ LibraryConfigurationException.java 12 Mar 2004 19:46:53 -0000 1.2 @@ -3,47 +3,56 @@ */ package org.commonjava.opl; + //TODO: Document LibraryConfigurationException + /** * @author jdcasey */ -public class LibraryConfigurationException extends ParseException { - +public class LibraryConfigurationException extends ParseException +{ //TODO: Document LibraryConfigurationException constructor! + /** - * + * */ - public LibraryConfigurationException() { + public LibraryConfigurationException() + { //TODO Implement LibraryConfigurationException constructor super(); } //TODO: Document LibraryConfigurationException constructor! + /** * @param message */ - public LibraryConfigurationException(String message) { + public LibraryConfigurationException(String message) + { //TODO Implement LibraryConfigurationException constructor super(message); } //TODO: Document LibraryConfigurationException constructor! + /** * @param message * @param cause */ - public LibraryConfigurationException(String message, Throwable cause) { + public LibraryConfigurationException(String message, Throwable cause) + { //TODO Implement LibraryConfigurationException constructor super(message, cause); } //TODO: Document LibraryConfigurationException constructor! + /** * @param cause */ - public LibraryConfigurationException(Throwable cause) { + public LibraryConfigurationException(Throwable cause) + { //TODO Implement LibraryConfigurationException constructor super(cause); } - } Index: SAXDriver.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/SAXDriver.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- SAXDriver.java 18 Feb 2004 06:12:10 -0000 1.9 +++ SAXDriver.java 12 Mar 2004 19:46:53 -0000 1.10 @@ -4,9 +4,21 @@ */ package org.commonjava.opl; +import org.commonjava.io.IOFactory; +import org.commonjava.io.IOResource; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; + import java.util.Properties; import java.util.Stack; @@ -16,55 +28,46 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; -import org.commonjava.io.IOFactory; -import org.commonjava.io.IOResource; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; /** OPL driver implementation which uses SAX events to drive the construction * of an object tree via NodeParsers. - * + * * @author John Casey * */ -public class SAXDriver extends DefaultHandler implements OPLDriver{ - +public class SAXDriver extends DefaultHandler implements OPLDriver +{ private static SAXParserFactory FACTORY; - private NodeParser parent; private Stack currentPath = new Stack(); private OPLContext context; private NamespaceResolver resolver; private boolean validating = false; - private SAXElementHolder currentElement; - + /** Construct a new SAXDriver for parsing an XML document with OPL. */ - public SAXDriver() { - } + public SAXDriver() {} /** Construct a new SAXDriver for parsing an XML document with OPL. * @param parent The parent NodeParser to use, which will treat * this parsed document as a subsection of another parsing effort, * as in the case of an import operation. */ - public SAXDriver(NodeParser parent) { + public SAXDriver(NodeParser parent) + { this.parent = parent; } - + /** Set the namespace resolver instance to be used in retrieving the * OPL namespace for a given input namespace. */ - public void setNamespaceResolver(NamespaceResolver resolver){ + public void setNamespaceResolver(NamespaceResolver resolver) + { this.resolver = resolver; } - /** Parse the XML content on the specified input stream, and return the + /** Parse the XML content on the specified input stream, and return the * resulting object. * @param context the parsing context * @param in the input stream @@ -74,13 +77,14 @@ * @see org.commonjava.opl.OPLDriver#parse(org.commonjava.opl.OPLContext, java.io.InputStream, boolean) */ public Object parse(OPLContext context, InputStream in) - throws MissingAttributeException, ParseException + throws MissingAttributeException, ParseException { this.context = context; + return parseInternal(new InputSource(in)); } - /** Parse the XML content stored at the specified URI, and return the + /** Parse the XML content stored at the specified URI, and return the * resulting object. * @param context the parsing context * @param uri the URI to open and parse @@ -90,28 +94,31 @@ * @see org.commonjava.opl.OPLDriver#parse(org.commonjava.opl.OPLContext, java.lang.String, boolean) */ public Object parse(OPLContext context, String uri) - throws MissingAttributeException, ParseException + throws MissingAttributeException, ParseException { this.context = context; + IOResource resource = null; + try { resource = IOFactory.getInstance().getResource(uri); + return parseInternal(new InputSource(resource.getInputStream())); } - catch (IOException e) { + catch(IOException e) { throw new ParseException("Error retrieving resource for: " + uri, e); } - finally{ - if(resource != null){ + finally { + if(resource != null) { try { resource.close(); } - catch (IOException e1) {} + catch(IOException e1) {} } } } - /** Parse the XML content on the specified SAX input source, and return the + /** Parse the XML content on the specified SAX input source, and return the * resulting object. * @param context the parsing context * @param in the input source @@ -121,17 +128,18 @@ * @see org.commonjava.opl.OPLDriver#parse(org.commonjava.opl.OPLContext, org.xml.sax.InputSource, boolean) */ public Object parse(OPLContext context, InputSource in) - throws MissingAttributeException, ParseException + throws MissingAttributeException, ParseException { this.context = context; + return parseInternal(in); } - /** Parse the XML content in the specified document object, and return the + /** Parse the XML content in the specified document object, and return the * resulting object. This is NOT efficient for this type of driver, it is - * merely provided for (a)consistency, and (b)those developers who find + * merely provided for (a)consistency, and (b)those developers who find * themselves painted into a corner as far as driver choice. - * + * * @param context the parsing context * @param document the DOM document to serialize and then re-parse (ick!) * @param ignoreUnrecognized whether to ignore unrecognized element types. @@ -140,21 +148,20 @@ * @see org.commonjava.opl.OPLDriver#parse(org.commonjava.opl.OPLContext, org.w3c.dom.Document, boolean) */ public Object parse(OPLContext context, Document document) - throws MissingAttributeException, ParseException + throws MissingAttributeException, ParseException { this.context = context; - ByteArrayInputStream bain = new ByteArrayInputStream( - document.toString().getBytes() - ); - + + ByteArrayInputStream bain = new ByteArrayInputStream(document.toString().getBytes()); + return parseInternal(new InputSource(bain)); } - - /** Parse the XML content in the specified DOM node object, and return the + + /** Parse the XML content in the specified DOM node object, and return the * resulting object. This is NOT efficient for this type of driver, it is - * merely provided for (a)consistency, and (b)those developers who find + * merely provided for (a)consistency, and (b)those developers who find * themselves painted into a corner as far as driver choice. - * + * * @param context the parsing context * @param node the DOM node to wrap in a document, serialize and then re-parse (ick!) * @param ignoreUnrecognized whether to ignore unrecognized element types. @@ -163,27 +170,30 @@ * @see org.commonjava.opl.OPLDriver#parse(org.commonjava.opl.OPLContext, org.w3c.dom.Document, boolean) */ public Object parse(OPLContext context, Node node) - throws MissingAttributeException, ParseException + throws MissingAttributeException, ParseException { this.context = context; + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - + DocumentBuilder builder = null; - try {builder = factory.newDocumentBuilder();} - catch (ParserConfigurationException e) { + + try { + builder = factory.newDocumentBuilder(); + } + catch(ParserConfigurationException e) { throw new ParseException("Error creating document builder to wrap node.", e); } - + Document document = builder.newDocument(); document.appendChild(node); - ByteArrayInputStream bain = new ByteArrayInputStream( - document.toString().getBytes() - ); - + + ByteArrayInputStream bain = new ByteArrayInputStream(document.toString().getBytes()); + return parseInternal(new InputSource(bain)); } - - /** Parse the XML content on the specified SAX input source, and return the + + /** Parse the XML content on the specified SAX input source, and return the * resulting object. * @param in the input source * @return the parsed object @@ -193,18 +203,19 @@ private Object parseInternal(InputSource in) throws MissingAttributeException, ParseException { ensureFactoryInitialized(); - + try { SAXParser saxParser = FACTORY.newSAXParser(); saxParser.parse(in, this); + NodeParser parser = currentElement.getParser(); - if(parent == null && !(parser instanceof OPLModelRoot)){ + + if((parent == null) && !(parser instanceof OPLModelRoot)) { throw new ParseException( - "Document element must map to a NodeParser that " + - "implements OPLModelRoot." + "Document element must map to a NodeParser that " + "implements OPLModelRoot." ); } - + if(parent == null) { return ((OPLModelRoot)parser).getParsedObject(); } @@ -212,26 +223,26 @@ return null; } } - catch (ParserConfigurationException e) { + catch(ParserConfigurationException e) { throw new ParseException("JAXP configuration error.", e); } - catch (SAXException e) { + catch(SAXException e) { //HACK This SHOULD BE getCause(), but it seems like SAXException is broken... Exception cause = e.getException(); - - if(cause != null && (cause instanceof ParseException)){ + + if((cause != null) && (cause instanceof ParseException)) { throw (ParseException)cause; } - else{ + else { throw new ParseException("SAX Exception parsing document.", e); } } - catch (IOException e) { + catch(IOException e) { throw new ParseException("Error parsing document", e); } } - /** Append the specified subsection of the specified character array to the + /** Append the specified subsection of the specified character array to the * existing body content of the current element. * @param ch the character array * @param start the starting index @@ -240,12 +251,12 @@ * @see org.xml.sax.ContentHandler#characters(char[], int, int) */ public void characters(char[] ch, int start, int length) - throws SAXException + throws SAXException { currentElement.appendBody(ch, start, length); } - /** Handle the end-of-element SAX event by calling doAfterChildren() on the + /** Handle the end-of-element SAX event by calling doAfterChildren() on the * current node parser, and then (if possible) resetting the current element * to the parent element. * @param uri The namespace uri of the element being closed @@ -255,25 +266,24 @@ * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String) */ public void endElement(String uri, String localName, String qName) - throws SAXException + throws SAXException { - if(currentElement == null){ + if(currentElement == null) { throw new SAXException("End of document already reached."); } - - try{ + + try { SAXElementInfo info = currentElement.getInfo(); NodeParser parser = currentElement.getParser(); String body = currentElement.getBody(); - + parser.doAfterChildren(info, body); - - if(currentPath.size() > 0){ + + if(currentPath.size() > 0) { currentElement = (SAXElementHolder)currentPath.pop(); - } } - catch(ParseException e){ + catch(ParseException e) { throw new SAXException(e); } } @@ -284,24 +294,24 @@ * @param uri the namespace of the new element * @param localName the local (unqualified) name of the new element * @param qName the qualified name of the new element - * @param attributes the set of attributes specified in this element's + * @param attributes the set of attributes specified in this element's * declaration * @throws org.xml.sax.SAXException * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes) */ - public void startElement(String ns, String localName, String qName, - Attributes attributes) - throws SAXException + public void startElement(String ns, String localName, String qName, Attributes attributes) + throws SAXException { try { NodeParser parser = null; String uri = ns; - if(resolver != null){ + + if(resolver != null) { uri = resolver.lookupNamespace(ns); } - - if (currentElement == null) { + + if(currentElement == null) { if(parent == null) { parser = context.newParser(uri, localName, qName); } @@ -312,54 +322,64 @@ else { parser = context.newParser(uri, localName, currentElement.getParser(), qName); currentPath.push(currentElement); - } - + Properties props = new Properties(); - for(int i=0; i<attributes.getLength(); i++){ + + for(int i = 0; i < attributes.getLength(); i++) { props.setProperty(attributes.getLocalName(i), attributes.getValue(i)); } - + SAXElementInfo info = new SAXElementInfo(uri, props, context); currentElement = new SAXElementHolder(localName, parser, info); - + parser.checkRequiredAttributes(info); parser.doBeforeChildren(info); } - catch (ParseException e) { + catch(ParseException e) { throw new SAXException(e); } } - + /** Ensure that the SAXParserFactory instance shared by all instances of * SAXDriver is initialized. */ - private void ensureFactoryInitialized(){ - synchronized(SAXDriver.class){ - if(FACTORY == null){ + private void ensureFactoryInitialized() + { + synchronized(SAXDriver.class) { + if(FACTORY == null) { FACTORY = SAXParserFactory.newInstance(); FACTORY.setNamespaceAware(true); FACTORY.setValidating(validating); } } } - + + /* (non-Javadoc) + * @see org.commonjava.opl.OPLDriver#setValidating(boolean) + */ + public void setValidating(boolean validating) + { + this.validating = validating; + } + /** ElementInfo implementation which uses a SAX Attributes object * as a backing for the attribute lookup mechanism. */ - public static class SAXElementInfo implements ElementInfo{ - + public static class SAXElementInfo implements ElementInfo + { private String namespace; private Properties attributes; private OPLContext context; - - /** Create a new SAXElementInfo, backed with the specified + + /** Create a new SAXElementInfo, backed with the specified * namespace specification and Attributes instance. * @param namespace The namespace for this element. - * @param attributes The Attributes object containing this element's + * @param attributes The Attributes object containing this element's * attribute declarations. */ - private SAXElementInfo(String namespace, Properties attributes, OPLContext context){ + private SAXElementInfo(String namespace, Properties attributes, OPLContext context) + { this.namespace = namespace; this.attributes = attributes; this.context = context; @@ -372,8 +392,8 @@ * @throws ParseException * @see org.commonjava.opl.ElementInfo#getRawAttributeValue(java.lang.String) */ - public String getRawAttributeValue(String attributeName) - throws ParseException + public String getRawAttributeValue(String attributeName) + throws ParseException { return attributes.getProperty(attributeName); } @@ -382,75 +402,73 @@ * @return the namespace URI. * @see org.commonjava.opl.ElementInfo#getNamespaceUri() */ - public String getNamespaceUri() { + public String getNamespaceUri() + { return namespace; } - } - + /** Specialized container used to co-locate a NodeParser instance with an * ElementInfo instance, to make them manageable as a single unit, as in Stack * push() and pop() operations. This class is used purely for management * convenience. */ - private static class SAXElementHolder{ + private static class SAXElementHolder + { private String nodeName; private SAXElementInfo info; private NodeParser parser; private StringBuffer body = new StringBuffer(); - + /** Create a new SAXElementHolder instance * @param info The SAXElementInfo instance to embed. * @param parser The NodeParser instance to embed. */ - SAXElementHolder(String nodeName, NodeParser parser, SAXElementInfo info){ + SAXElementHolder(String nodeName, NodeParser parser, SAXElementInfo info) + { this.nodeName = nodeName; this.parser = parser; this.info = info; } - - String getNodeName(){ + + String getNodeName() + { return nodeName; } - + /** Return the SAXElementInfo instance embedded herein. * @return the element info object. */ - SAXElementInfo getInfo(){ + SAXElementInfo getInfo() + { return info; } - + /** Return the NodeParser instance embedded herein. * @return the node parser. */ - NodeParser getParser(){ + NodeParser getParser() + { return parser; } - + /** Append a sub-array of the specified character array to the accumulated * body buffer for the parsing effort represented here. * @param chars The character array * @param start The starting index of the sub-array * @param length The size of the sub-array. */ - void appendBody(char[] chars, int start, int length){ + void appendBody(char[] chars, int start, int length) + { body.append(String.valueOf(chars, start, length)); } - + /** Return the accumulated body text for the element represented here. * @return the body text. */ - String getBody(){ + String getBody() + { return body.toString().trim(); } } - - /* (non-Javadoc) - * @see org.commonjava.opl.OPLDriver#setValidating(boolean) - */ - public void setValidating(boolean validating) - { - this.validating = validating; - } - } Index: ParseException.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/ParseException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ParseException.java 18 Sep 2003 04:56:57 -0000 1.1 +++ ParseException.java 12 Mar 2004 19:46:53 -0000 1.2 @@ -3,47 +3,56 @@ */ package org.commonjava.opl; + //TODO: Document ParseException + /** * @author jdcasey */ -public class ParseException extends Exception { - +public class ParseException extends Exception +{ //TODO: Document ParseException constructor! + /** - * + * */ - public ParseException() { + public ParseException() + { //TODO Implement ParseException constructor super(); } //TODO: Document ParseException constructor! + /** * @param message */ - public ParseException(String message) { + public ParseException(String message) + { //TODO Implement ParseException constructor super(message); } //TODO: Document ParseException constructor! + /** * @param message * @param cause */ - public ... [truncated message content] |
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/test/org/commonjava/opl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2746/src/test/org/commonjava/opl Modified Files: DocumentDriverTest.java SAXDriverTest.java OPLTestParser.java OPLTestParserResult.java Log Message: updated to 0.2, made method call parameter generation more robust. Index: DocumentDriverTest.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/test/org/commonjava/opl/DocumentDriverTest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- DocumentDriverTest.java 20 Feb 2004 21:16:04 -0000 1.8 +++ DocumentDriverTest.java 12 Mar 2004 19:46:53 -0000 1.9 @@ -4,39 +4,45 @@ */ package org.commonjava.opl; +import junit.framework.TestCase; + import java.util.Properties; -import junit.framework.TestCase; //TODO Document SAXDriverTest.java in commonjava-opl + /** * @author jdcasey * */ -public class DocumentDriverTest extends TestCase { - +public class DocumentDriverTest extends TestCase +{ /** * Constructor for SAXDriverTest. * @param arg0 */ - public DocumentDriverTest(String arg0) { + public DocumentDriverTest(String arg0) + { super(arg0); } - public static void main(String[] args) { + public static void main(String[] args) + { junit.textui.TestRunner.run(DocumentDriverTest.class); } - - public void testParseUri() throws ParseException{ + + public void testParseUri() throws ParseException + { System.out.println("Test 1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + try { DocumentDriver driver = new DocumentDriver(); OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test.xml"); - + Properties props = result.getProperties(); props.list(System.out); - + assertEquals("value", props.getProperty("param")); assertTrue(result.getBooleanValue().booleanValue()); assertFalse(result.getBooleanValue2().booleanValue()); @@ -45,24 +51,27 @@ assertEquals(result.getLongValue().longValue(), 2); assertEquals(result.getLongValue2().longValue(), 20); } - catch (Throwable e) { + catch(Throwable e) { e.printStackTrace(System.out); System.out.flush(); fail(e.getMessage()); } + System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<< Test 1"); } - public void testParseUri2(){ + public void testParseUri2() + { System.out.println("Test 2 >>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + try { DocumentDriver driver = new DocumentDriver(); OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test2.xml"); - + Properties props = result.getProperties(); props.list(System.out); - + assertEquals("value", props.getProperty("param")); assertTrue(result.getBooleanValue().booleanValue()); assertTrue(result.getBooleanValue2().booleanValue()); @@ -71,28 +80,31 @@ assertEquals(result.getLongValue().longValue(), 2); assertEquals(result.getLongValue2().longValue(), 2); } - catch (Throwable e) { + catch(Throwable e) { e.printStackTrace(System.out); System.out.flush(); fail(e.getMessage()); } + System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<< Test 2"); } - public void testParseUri3(){ + public void testParseUri3() + { System.out.println("Test 3 >>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + try { DocumentDriver driver = new DocumentDriver(); OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test3-main.xml"); - + Properties props = result.getProperties(); props.list(System.out); - + System.out.println(result.getBooleanValue2()); System.out.println(result.getIntegerValue2()); System.out.println(result.getLongValue2()); - + assertEquals("value", props.getProperty("param")); assertTrue(result.getBooleanValue().booleanValue()); assertTrue(result.getBooleanValue2().booleanValue()); @@ -101,28 +113,31 @@ assertEquals(result.getLongValue().longValue(), 2); assertEquals(result.getLongValue2().longValue(), 2); } - catch (Throwable e) { + catch(Throwable e) { e.printStackTrace(System.out); System.out.flush(); fail(e.getMessage()); } + System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<< Test 3"); } - public void testParseUri4(){ + public void testParseUri4() + { System.out.println("Test 4 >>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + try { DocumentDriver driver = new DocumentDriver(); OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test4.xml"); - + Properties props = result.getProperties(); props.list(System.out); - + System.out.println(result.getBooleanValue2()); System.out.println(result.getIntegerValue2()); System.out.println(result.getLongValue2()); - + assertEquals("value1", props.getProperty("param1")); assertEquals("value2", props.getProperty("param2")); assertTrue(result.getBooleanValue().booleanValue()); @@ -132,28 +147,31 @@ assertEquals(result.getLongValue().longValue(), 2); assertEquals(result.getLongValue2().longValue(), 2); } - catch (Throwable e) { + catch(Throwable e) { e.printStackTrace(System.out); System.out.flush(); fail(e.getMessage()); } + System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<< Test 4"); } - public void testParseUri5(){ + public void testParseUri5() + { System.out.println("Test 5 >>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + try { DocumentDriver driver = new DocumentDriver(); OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test5.xml"); - + Properties props = result.getProperties(); props.list(System.out); - + System.out.println(result.getBooleanValue2()); System.out.println(result.getIntegerValue2()); System.out.println(result.getLongValue2()); - + assertEquals("value1", props.getProperty("param1")); assertEquals("value2", props.getProperty("param2")); assertNull(props.getProperty("param3")); @@ -164,29 +182,32 @@ assertEquals(result.getLongValue().longValue(), 2); assertEquals(result.getLongValue2().longValue(), 2); } - catch (Throwable e) { + catch(Throwable e) { e.printStackTrace(System.out); System.out.flush(); fail(e.getMessage()); } + System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<< Test 5"); } - public void testParseUri6(){ + public void testParseUri6() + { System.out.println("Test 6 >>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + try { GenericNamespaceResolver resolver = new GenericNamespaceResolver(); resolver.addAlias("http://www.commonjava.org/schema/test", "opl:testlib"); - + DocumentDriver driver = new DocumentDriver(); driver.setNamespaceResolver(resolver); - + OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test6.xml"); - + Properties props = result.getProperties(); props.list(System.out); - + assertEquals("value", props.getProperty("param")); assertTrue(result.getBooleanValue().booleanValue()); assertFalse(result.getBooleanValue2().booleanValue()); @@ -195,31 +216,32 @@ assertEquals(result.getLongValue().longValue(), 2); assertEquals(result.getLongValue2().longValue(), 20); } - catch (Throwable e) { + catch(Throwable e) { e.printStackTrace(System.out); System.out.flush(); fail(e.getMessage()); } + System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<< Test 6"); } - public void testParseUri7(){ + public void testParseUri7() + { System.out.println("Test 7 >>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + try { DocumentDriver driver = new DocumentDriver(); OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test7.xml"); - + fail("Required attribute was missing and should have triggered a MissingAttributeException."); } - catch (MissingAttributeException e) { - } - catch (ParseException e) - { + catch(MissingAttributeException e) {} + catch(ParseException e) { e.printStackTrace(); fail("Parse of test7.xml failed."); } + System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<< Test 7"); } - } Index: SAXDriverTest.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/test/org/commonjava/opl/SAXDriverTest.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- SAXDriverTest.java 16 Jan 2004 01:37:13 -0000 1.7 +++ SAXDriverTest.java 12 Mar 2004 19:46:54 -0000 1.8 @@ -4,48 +4,52 @@ */ package org.commonjava.opl; +import junit.framework.TestCase; + import java.util.Properties; -import junit.framework.TestCase; //TODO Document SAXDriverTest.java in commonjava-opl + /** * @author jdcasey * */ -public class SAXDriverTest extends TestCase { - +public class SAXDriverTest extends TestCase +{ /** * Constructor for SAXDriverTest. * @param arg0 */ - public SAXDriverTest(String arg0) { + public SAXDriverTest(String arg0) + { super(arg0); } - public static void main(String[] args) { + public static void main(String[] args) + { junit.textui.TestRunner.run(SAXDriverTest.class); } - + // public void testParseInputStream(){ // } // // public void testParseInputSource(){ // } - - public void testParseUri(){ + public void testParseUri() + { try { SAXDriver driver = new SAXDriver(); OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test.xml"); - + Properties props = result.getProperties(); props.list(System.out); - + System.out.println(result.getBooleanValue2()); System.out.println(result.getIntegerValue2()); System.out.println(result.getLongValue2()); - + assertEquals("value", props.getProperty("param")); assertTrue(result.getBooleanValue().booleanValue()); assertFalse(result.getBooleanValue2().booleanValue()); @@ -54,26 +58,27 @@ assertEquals(result.getLongValue().longValue(), 2); assertEquals(result.getLongValue2().longValue(), 20); } - catch (Throwable e) { + catch(Throwable e) { e.printStackTrace(System.out); System.out.flush(); fail(e.getMessage()); } } - public void testParseUri2(){ + public void testParseUri2() + { try { SAXDriver driver = new SAXDriver(); OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test2.xml"); - + Properties props = result.getProperties(); props.list(System.out); - + System.out.println(result.getBooleanValue2()); System.out.println(result.getIntegerValue2()); System.out.println(result.getLongValue2()); - + assertEquals("value", props.getProperty("param")); assertTrue(result.getBooleanValue().booleanValue()); assertTrue(result.getBooleanValue2().booleanValue()); @@ -82,26 +87,27 @@ assertEquals(result.getLongValue().longValue(), 2); assertEquals(result.getLongValue2().longValue(), 2); } - catch (Throwable e) { + catch(Throwable e) { e.printStackTrace(System.out); System.out.flush(); fail(e.getMessage()); } } - public void testParseUri3(){ + public void testParseUri3() + { try { SAXDriver driver = new SAXDriver(); OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test3-main.xml"); - + Properties props = result.getProperties(); props.list(System.out); - + System.out.println(result.getBooleanValue2()); System.out.println(result.getIntegerValue2()); System.out.println(result.getLongValue2()); - + assertEquals("value", props.getProperty("param")); assertTrue(result.getBooleanValue().booleanValue()); assertTrue(result.getBooleanValue2().booleanValue()); @@ -110,26 +116,27 @@ assertEquals(result.getLongValue().longValue(), 2); assertEquals(result.getLongValue2().longValue(), 2); } - catch (Throwable e) { + catch(Throwable e) { e.printStackTrace(System.out); System.out.flush(); fail(e.getMessage()); } } - public void testParseUri4(){ + public void testParseUri4() + { try { SAXDriver driver = new SAXDriver(); OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test4.xml"); - + Properties props = result.getProperties(); props.list(System.out); - + System.out.println(result.getBooleanValue2()); System.out.println(result.getIntegerValue2()); System.out.println(result.getLongValue2()); - + assertEquals("value1", props.getProperty("param1")); assertEquals("value2", props.getProperty("param2")); assertTrue(result.getBooleanValue().booleanValue()); @@ -139,26 +146,27 @@ assertEquals(result.getLongValue().longValue(), 2); assertEquals(result.getLongValue2().longValue(), 2); } - catch (Throwable e) { + catch(Throwable e) { e.printStackTrace(System.out); System.out.flush(); fail(e.getMessage()); } } - public void testParseUri5(){ + public void testParseUri5() + { try { SAXDriver driver = new SAXDriver(); OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test5.xml"); - + Properties props = result.getProperties(); props.list(System.out); - + System.out.println(result.getBooleanValue2()); System.out.println(result.getIntegerValue2()); System.out.println(result.getLongValue2()); - + assertEquals("value1", props.getProperty("param1")); assertEquals("value2", props.getProperty("param2")); assertNull(props.getProperty("param3")); @@ -169,27 +177,28 @@ assertEquals(result.getLongValue().longValue(), 2); assertEquals(result.getLongValue2().longValue(), 2); } - catch (Throwable e) { + catch(Throwable e) { e.printStackTrace(System.out); System.out.flush(); fail(e.getMessage()); } } - public void testParseUri6(){ + public void testParseUri6() + { try { GenericNamespaceResolver resolver = new GenericNamespaceResolver(); resolver.addAlias("http://www.commonjava.org/schema/test", "opl:testlib"); - + SAXDriver driver = new SAXDriver(); driver.setNamespaceResolver(resolver); - + OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test6.xml"); - + Properties props = result.getProperties(); props.list(System.out); - + assertEquals("value", props.getProperty("param")); assertTrue(result.getBooleanValue().booleanValue()); assertFalse(result.getBooleanValue2().booleanValue()); @@ -198,28 +207,26 @@ assertEquals(result.getLongValue().longValue(), 2); assertEquals(result.getLongValue2().longValue(), 20); } - catch (Throwable e) { + catch(Throwable e) { e.printStackTrace(System.out); System.out.flush(); fail(e.getMessage()); } } - - public void testParseUri7(){ + + public void testParseUri7() + { try { SAXDriver driver = new SAXDriver(); OPLEngine engine = OPLEngine.getInstance(driver); OPLTestParserResult result = (OPLTestParserResult)engine.parse("cprs:///test7.xml"); - + fail("Required attribute was missing and should have triggered a MissingAttributeException."); } - catch (MissingAttributeException e) { - } - catch (ParseException e) - { + catch(MissingAttributeException e) {} + catch(ParseException e) { e.printStackTrace(); fail("Parse of test7.xml failed."); } } - } Index: OPLTestParser.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/test/org/commonjava/opl/OPLTestParser.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- OPLTestParser.java 16 Jan 2004 01:37:13 -0000 1.4 +++ OPLTestParser.java 12 Mar 2004 19:46:54 -0000 1.5 @@ -4,18 +4,19 @@ */ package org.commonjava.opl; -import java.util.Properties; - import org.commonjava.opl.generics.properties.PropertiesContainer; + import org.commonjava.util.Strings; +import java.util.Properties; + + /** * @author jdcasey * */ -public class OPLTestParser extends NodeParser - implements PropertiesContainer, OPLModelRoot{ - +public class OPLTestParser extends NodeParser implements PropertiesContainer, OPLModelRoot +{ private static final String BOOL = "bool"; private static final String INT = "int"; private static final String LONG = "long"; @@ -23,14 +24,14 @@ private static final String INT2 = "int2"; private static final String LONG2 = "long2"; private static final String REQUIRED = "required"; - private OPLTestParserResult result = new OPLTestParserResult(); /** * @param context * @param parent */ - public OPLTestParser(OPLContext context, NodeParser parent) { + public OPLTestParser(OPLContext context, NodeParser parent) + { super(context, parent); addRequiredAttribute(REQUIRED); } @@ -38,7 +39,8 @@ /** * @param context */ - public OPLTestParser(OPLContext context) { + public OPLTestParser(OPLContext context) + { super(context); addRequiredAttribute(REQUIRED); } @@ -47,7 +49,8 @@ * @param properties * @see org.commonjava.opl.generics.properties.PropertiesContainer#setProperties(java.util.Properties) */ - public void setProperties(Properties properties) { + public void setProperties(Properties properties) + { result.setProperties(properties); } @@ -55,7 +58,8 @@ * @return * @see org.commonjava.opl.generics.properties.PropertiesContainer#getProperties() */ - public Properties getProperties() { + public Properties getProperties() + { return result.getProperties(); } @@ -64,11 +68,13 @@ * @throws ParseException * @see org.commonjava.opl.OPLModelRoot#getParsedObject() */ - public Object getParsedObject() throws ParseException { + public Object getParsedObject() throws ParseException + { return result; } //TODO Document OPLTestParser.doAfterChildren() + /** * @param element * @param bodyText @@ -76,7 +82,7 @@ * @see org.commonjava.opl.NodeParser#doAfterChildren(org.commonjava.opl.ElementInfo, java.lang.String) */ protected void doAfterChildren(ElementInfo element, String bodyText) - throws ParseException + throws ParseException { System.out.println("1"); System.out.flush(); @@ -87,15 +93,17 @@ } //TODO Document OPLTestParser.doBeforeChildren() + /** * @param element * @throws ParseException * @see org.commonjava.opl.NodeParser#doBeforeChildren(org.commonjava.opl.ElementInfo) */ - protected void doBeforeChildren(ElementInfo element) throws ParseException { + protected void doBeforeChildren(ElementInfo element) + throws ParseException + { result.setBooleanValue(Strings.toBoolean(getAttribute(BOOL, element))); result.setIntegerValue(Strings.toInteger(getAttribute(INT, element))); result.setLongValue(Strings.toLong(getAttribute(LONG, element))); } - } Index: OPLTestParserResult.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/test/org/commonjava/opl/OPLTestParserResult.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- OPLTestParserResult.java 10 Oct 2003 01:59:42 -0000 1.1 +++ OPLTestParserResult.java 12 Mar 2004 19:46:54 -0000 1.2 @@ -6,13 +6,15 @@ import java.util.Properties; + //TODO Document OPLTestParserResult.java in commonjava-opl + /** * @author jdcasey * */ -public class OPLTestParserResult { - +public class OPLTestParserResult +{ private Properties properties; private Boolean booleanValue; private Integer integerValue; @@ -22,66 +24,79 @@ private Long longValue2; //TODO Document OPLTestParserResult.OPLTestParserResult() + /** - * + * */ - public OPLTestParserResult() { - } - - public void setProperties(Properties properties){ + public OPLTestParserResult() {} + + public void setProperties(Properties properties) + { this.properties = properties; } - - public Properties getProperties(){ + + public Properties getProperties() + { return properties; } - - public void setBooleanValue(Boolean bool){ + + public void setBooleanValue(Boolean bool) + { this.booleanValue = bool; } - - public Boolean getBooleanValue(){ + + public Boolean getBooleanValue() + { return booleanValue; } - public void setIntegerValue(Integer i){ + public void setIntegerValue(Integer i) + { this.integerValue = i; } - - public Integer getIntegerValue(){ + + public Integer getIntegerValue() + { return integerValue; } - public void setLongValue(Long l){ + public void setLongValue(Long l) + { this.longValue = l; } - - public Long getLongValue(){ + + public Long getLongValue() + { return longValue; } - public void setBooleanValue2(Boolean bool){ + public void setBooleanValue2(Boolean bool) + { this.booleanValue2 = bool; } - - public Boolean getBooleanValue2(){ + + public Boolean getBooleanValue2() + { return booleanValue2; } - public void setIntegerValue2(Integer i){ + public void setIntegerValue2(Integer i) + { this.integerValue2 = i; } - - public Integer getIntegerValue2(){ + + public Integer getIntegerValue2() + { return integerValue2; } - public void setLongValue2(Long l){ + public void setLongValue2(Long l) + { this.longValue2 = l; } - - public Long getLongValue2(){ + + public Long getLongValue2() + { return longValue2; } - } |
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/dynalib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2746/src/java/org/commonjava/opl/dynalib Modified Files: DynamicLibraryParser.java DynamicLibraryElements.java DynaLib.java DynamicParserParser.java DynaLibParsingLibrary.java Log Message: updated to 0.2, made method call parameter generation more robust. Index: DynamicLibraryParser.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/dynalib/DynamicLibraryParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- DynamicLibraryParser.java 16 Jan 2004 01:37:33 -0000 1.6 +++ DynamicLibraryParser.java 12 Mar 2004 19:46:55 -0000 1.7 @@ -8,69 +8,72 @@ import org.commonjava.opl.OPLContext; import org.commonjava.opl.OPLModelRoot; import org.commonjava.opl.ParseException; + import org.commonjava.util.Strings; -/** Parses a library xml file into a dynamically-instantiated + +/** Parses a library xml file into a dynamically-instantiated * ParserLibrary instance. - * + * * @author John Casey */ -public class DynamicLibraryParser extends NodeParser - implements OPLModelRoot +public class DynamicLibraryParser extends NodeParser implements OPLModelRoot { - private DynaLib library; /** Create a new DynamicLibraryParser. * @param context the parsing context * @param parent the parent parser */ - public DynamicLibraryParser(OPLContext context, NodeParser parent) { + public DynamicLibraryParser(OPLContext context, NodeParser parent) + { super(context, parent); } /** Create a new NodeParser, presumed to be at the root of a parse model. */ - public DynamicLibraryParser(OPLContext context) { + public DynamicLibraryParser(OPLContext context) + { super(context); } - + /** Return the new ParserLibrary. * NOTE: This method overrides getParsedObject * @return the parser library * @see org.commonjava.opl.OPLModelRoot#getParsedObject() */ - public Object getParsedObject() { + public Object getParsedObject() + { return library; } - + /** Register a new NodeParser type with the embedded library. * @param nodeName The name of the node for this parser * @param parserClass The class of parser to use for this node. */ - public void registerParser(String nodeName, Class parserClass){ - + public void registerParser(String nodeName, Class parserClass) + { library.register(nodeName, parserClass); } - + /** Just before we parse the children, determine if we should locally * ignore unrecognized elements in our new parser library, and setup * the library itself. - * + * * NOTE: This method overrides doBeforeChildren * @param node the current node. * @throws ParseException * @see org.commonjava.opl.NodeParser#doBeforeChildren(org.w3c.dom.Node) */ - protected void doBeforeChildren(ElementInfo info) throws ParseException { + protected void doBeforeChildren(ElementInfo info) throws ParseException + { library = new DynaLib(getParserLibrary().getNamespace()); - Boolean ignore = Strings.toBoolean(getAttribute( - DynamicLibraryElements.IGNORE_UNRECOGNIZED_ELEMENTS, info - )); - - if(ignore != null){ + + Boolean ignore = + Strings.toBoolean(getAttribute(DynamicLibraryElements.IGNORE_UNRECOGNIZED_ELEMENTS, info)); + + if(ignore != null) { library.setLocallyIgnoreUnrecognized(ignore.booleanValue()); } } - } Index: DynamicLibraryElements.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/dynalib/DynamicLibraryElements.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- DynamicLibraryElements.java 18 Sep 2003 04:57:09 -0000 1.1 +++ DynamicLibraryElements.java 12 Mar 2004 19:46:55 -0000 1.2 @@ -3,29 +3,32 @@ */ package org.commonjava.opl.dynalib; + /** Parser constants for xml-based parser libraries. - * + * * @author John Casey */ -public final class DynamicLibraryElements { - +public final class DynamicLibraryElements +{ /** A parser library root node. */ public static final String PARSER_LIBRARY = "parser-library"; + /** A parser definition. */ public static final String PARSER = "parser"; + /** A parser's associated node name. */ public static final String NODE_NAME = "node"; + /** The implementation class for the parser. */ public static final String CLASS = "class"; + /** Whether to ignore (pass-through) unrecognized elements. */ public static final String IGNORE_UNRECOGNIZED_ELEMENTS = "ignore-unrecognized"; - + /** The namespace which denotes a dynamic library in XML format. */ public static final String DYNALIB_NAMESPACE = "dynalib"; /** Deny creation */ - private DynamicLibraryElements() { - } - + private DynamicLibraryElements() {} } Index: DynaLib.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/dynalib/DynaLib.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- DynaLib.java 8 Jan 2004 20:35:11 -0000 1.1 +++ DynaLib.java 12 Mar 2004 19:46:55 -0000 1.2 @@ -3,14 +3,14 @@ import org.commonjava.opl.ParserLibrary; - /** Parser library which allows this NodeParser to register new - * parsers for the library. - * - * @author John Casey - */ + +/** Parser library which allows this NodeParser to register new + * parsers for the library. + * + * @author John Casey + */ public class DynaLib extends ParserLibrary { - /** Create a new dynamically-generated ParserLibrary instance * @param namespace The namespace of the library */ @@ -23,7 +23,8 @@ * @param node The node name * @param parserClass The NodeParser class. */ - void register(String node, Class parserClass){ + void register(String node, Class parserClass) + { registerParser(node, parserClass); } } Index: DynamicParserParser.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/dynalib/DynamicParserParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- DynamicParserParser.java 16 Jan 2004 01:37:33 -0000 1.6 +++ DynamicParserParser.java 12 Mar 2004 19:46:55 -0000 1.7 @@ -8,17 +8,19 @@ import org.commonjava.opl.OPLContext; import org.commonjava.opl.ParseException; + /** Parse a new NodeParser registration into a dynamically- * created parser library. - * + * * @author John Casey */ -public class DynamicParserParser extends NodeParser{ - +public class DynamicParserParser extends NodeParser +{ /** Create a new DynamicParserParser * @param context the context in which this parser acts. */ - public DynamicParserParser(OPLContext context) { + public DynamicParserParser(OPLContext context) + { super(context); addRequiredAttribute(DynamicLibraryElements.NODE_NAME); addRequiredAttribute(DynamicLibraryElements.CLASS); @@ -28,40 +30,41 @@ * @param context the context in which this parser acts. * @param parent The parent of this parser. */ - public DynamicParserParser(OPLContext context, NodeParser parent) { + public DynamicParserParser(OPLContext context, NodeParser parent) + { super(context, parent); addRequiredAttribute(DynamicLibraryElements.NODE_NAME); addRequiredAttribute(DynamicLibraryElements.CLASS); } - - /** Register the parser contained within this node with the + + /** Register the parser contained within this node with the * DynamicLibraryParser ancestor of this parser. * NOTE: This method overrides doAfterChildren * @param node The node to parse - * @throws ParseException in case of invalid data within the node or + * @throws ParseException in case of invalid data within the node or * parse-tree structure. * @see org.commonjava.opl.NodeParser#doAfterChildren(org.w3c.dom.Node) */ - protected void doAfterChildren(ElementInfo info, String body) throws ParseException { + protected void doAfterChildren(ElementInfo info, String body) + throws ParseException + { try { String nodeName = getAttribute(DynamicLibraryElements.NODE_NAME, info); String className = getAttribute(DynamicLibraryElements.CLASS, info); - + Class implCls = Class.forName(className); - - DynamicLibraryParser dynalib = (DynamicLibraryParser)findAncestorOfType( - DynamicLibraryParser.class - ); - - if(dynalib == null){ + + DynamicLibraryParser dynalib = + (DynamicLibraryParser)findAncestorOfType(DynamicLibraryParser.class); + + if(dynalib == null) { throw new ParseException("No DynamicLibraryParser ancestor found."); } - + dynalib.registerParser(nodeName, implCls); } - catch (ClassNotFoundException e) { + catch(ClassNotFoundException e) { throw new ParseException("Cannot load parser implementation class.", e); } } - } Index: DynaLibParsingLibrary.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/dynalib/DynaLibParsingLibrary.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- DynaLibParsingLibrary.java 18 Sep 2003 04:57:09 -0000 1.1 +++ DynaLibParsingLibrary.java 12 Mar 2004 19:46:55 -0000 1.2 @@ -5,35 +5,30 @@ import org.commonjava.opl.ParserLibrary; + /** ParserLibrary used to parse dynalib config xml files. * These files are used to dynamically build a parser library * from a set of parser classes (in the classpath), along with * an XML file in META-INF/parsers/<lib-namespace>.opl - * - * Specification for use of such a dynalib is a namespace which + * + * Specification for use of such a dynalib is a namespace which * matches the pattern "opl:<i>dynalib-parser-file</i>)". - * + * * @author John Casey */ -public class DynaLibParsingLibrary extends ParserLibrary { - +public class DynaLibParsingLibrary extends ParserLibrary +{ /** Create a new DynaLibParsingLibrary, for parsing dynalib * dynamic parser library xml configuration files. - * + * * @param namespace The namespace of this library. */ - public DynaLibParsingLibrary(String namespace) { + public DynaLibParsingLibrary(String namespace) + { super(namespace); - - registerParser( - DynamicLibraryElements.PARSER_LIBRARY, - DynamicLibraryParser.class - ); - - registerParser( - DynamicLibraryElements.PARSER, - DynamicParserParser.class - ); - } + registerParser(DynamicLibraryElements.PARSER_LIBRARY, DynamicLibraryParser.class); + + registerParser(DynamicLibraryElements.PARSER, DynamicParserParser.class); + } } |
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/generics/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2746/src/java/org/commonjava/opl/generics/config Modified Files: ConfigSnapIn.java ConfigSupport.java ConfigSnapInContainer.java Log Message: updated to 0.2, made method call parameter generation more robust. Index: ConfigSnapIn.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/generics/config/ConfigSnapIn.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ConfigSnapIn.java 9 Jan 2004 05:07:43 -0000 1.2 +++ ConfigSnapIn.java 12 Mar 2004 19:46:54 -0000 1.3 @@ -4,18 +4,18 @@ */ package org.commonjava.opl.generics.config; + /** For now, just a marker interface for [parsed] objects capable of snapping * into a configuration object. Provides the getId() method, only to enforce * consistent naming of snapIns. - * + * * @author John Casey * @deprecated Use CommonJava-config/org.commonjava.config.snapin.ConfigSnapIn. */ -public interface ConfigSnapIn { - +public interface ConfigSnapIn +{ /** Return the ID used to locate this snapIn within the configuration. * @return the snapIn identifier. */ public String getSnapInId(); - } Index: ConfigSupport.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/generics/config/ConfigSupport.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ConfigSupport.java 9 Jan 2004 05:07:43 -0000 1.3 +++ ConfigSupport.java 12 Mar 2004 19:46:54 -0000 1.4 @@ -7,37 +7,38 @@ import java.util.HashMap; import java.util.Map; -/** Contains the functionality to store and retrieve SnapIns, in support of + +/** Contains the functionality to store and retrieve SnapIns, in support of * configuration classes. - * + * * @author John Casey * @deprecated Use CommonJava-config/org.commonjava.config.snapin.SnapInContainerSupport. */ -public abstract class ConfigSupport implements ConfigSnapInContainer { - +public abstract class ConfigSupport implements ConfigSnapInContainer +{ private Map snapIns = new HashMap(); - + /** Create a new configuration support object, with the ability to store * snapIns. */ - protected ConfigSupport() { - } + protected ConfigSupport() {} /** Return the snapIn for the specified id, within this configuration instance. * @param snapInId The identifier to lookup * @return the associated snapIn, or null. */ - public ConfigSnapIn getSnapIn(String snapInId){ + public ConfigSnapIn getSnapIn(String snapInId) + { return (ConfigSnapIn)snapIns.get(snapInId); } - + /** Add a snapIn to this configuration instance. The id is extracted, and the * snapIn is keyed by it within the snapIn map. NOTE: This will override any * previously-added snapIns with the same ID. * @param snapIn The snapIn to add. */ - public void addSnapIn(ConfigSnapIn snapIn){ + public void addSnapIn(ConfigSnapIn snapIn) + { snapIns.put(snapIn.getSnapInId(), snapIn); } - } Index: ConfigSnapInContainer.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/generics/config/ConfigSnapInContainer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ConfigSnapInContainer.java 9 Jan 2004 05:07:43 -0000 1.2 +++ ConfigSnapInContainer.java 12 Mar 2004 19:46:54 -0000 1.3 @@ -4,24 +4,24 @@ */ package org.commonjava.opl.generics.config; + /** Represents something capable of storing and retrieving configuration snap-ins. - * + * * @author John Casey * @deprecated Use CommonJava-config/org.commonjava.config.snapin.SnapInContainer. */ -public interface ConfigSnapInContainer { - +public interface ConfigSnapInContainer +{ /** Return the snapIn for the specified id, within this configuration instance. * @param snapInId The identifier to lookup * @return the associated snapIn, or null. */ public ConfigSnapIn getSnapIn(String snapInId); - + /** Add a snapIn to this configuration instance. The id is extracted, and the * snapIn is keyed by it within the snapIn map. NOTE: This will override any * previously-added snapIns with the same ID. * @param snapIn The snapIn to add. */ public void addSnapIn(ConfigSnapIn snapIn); - -} \ No newline at end of file +} |