[CJ-dev] commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/generics/properties Property
Brought to you by:
johnqueso
From: <joh...@co...> - 2004-03-12 20:14:45
|
Update of /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/generics/properties In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2746/src/java/org/commonjava/opl/generics/properties Modified Files: PropertyElements.java PropertiesParserLibrary.java PropertyParser.java PropertiesParser.java PropertiesContainer.java PropertySet.java Log Message: updated to 0.2, made method call parameter generation more robust. Index: PropertyElements.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/generics/properties/PropertyElements.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PropertyElements.java 18 Sep 2003 04:57:09 -0000 1.1 +++ PropertyElements.java 12 Mar 2004 19:46:55 -0000 1.2 @@ -3,21 +3,19 @@ */ package org.commonjava.opl.generics.properties; + /** Elements and attributes that go with the PropertiesParserLibrary - * + * * @author John Casey */ -public class PropertyElements { - +public class PropertyElements +{ public static final String PROPERTY = "property"; public static final String PROPERTIES = "properties"; - public static final String PROPERTY_NAME = "name"; public static final String PROPERTY_VALUE = "value"; /** Deny creation */ - private PropertyElements() { - } - + private PropertyElements() {} } Index: PropertiesParserLibrary.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/generics/properties/PropertiesParserLibrary.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PropertiesParserLibrary.java 18 Sep 2003 04:57:09 -0000 1.1 +++ PropertiesParserLibrary.java 12 Mar 2004 19:46:56 -0000 1.2 @@ -5,19 +5,20 @@ import org.commonjava.opl.ParserLibrary; + /** Parser library which handles parsing common properties objects. * @author John Casey */ -public class PropertiesParserLibrary extends ParserLibrary { - +public class PropertiesParserLibrary extends ParserLibrary +{ /** Create a new PropertiesParserLibrary * @param namespace the namespace... */ - public PropertiesParserLibrary(String namespace) { + public PropertiesParserLibrary(String namespace) + { super(namespace); - + registerParser(PropertyElements.PROPERTIES, PropertiesParser.class); registerParser(PropertyElements.PROPERTY, PropertyParser.class); } - } Index: PropertyParser.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/generics/properties/PropertyParser.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- PropertyParser.java 16 Jan 2004 01:37:33 -0000 1.4 +++ PropertyParser.java 12 Mar 2004 19:46:56 -0000 1.5 @@ -8,17 +8,20 @@ import org.commonjava.opl.OPLContext; import org.commonjava.opl.ParseException; + //TODO: Document PropertyParser + /** * @author jdcasey */ -public class PropertyParser extends NodeParser { - +public class PropertyParser extends NodeParser +{ /** Create a new PropertyParser * @param context the parsing context * @param parent the parent parser */ - public PropertyParser(OPLContext context, NodeParser parent) { + public PropertyParser(OPLContext context, NodeParser parent) + { super(context, parent); addRequiredAttribute(PropertyElements.PROPERTY_NAME); addRequiredAttribute(PropertyElements.PROPERTY_VALUE); @@ -27,12 +30,13 @@ /** Create a new PropertyParser * @param context the parsing context */ - public PropertyParser(OPLContext context) { + public PropertyParser(OPLContext context) + { super(context); addRequiredAttribute(PropertyElements.PROPERTY_NAME); addRequiredAttribute(PropertyElements.PROPERTY_VALUE); } - + /** Pull the name and value attributes, lookup the PropertySet ancestor, * and set the property. * NOTE: This method overrides doBeforeChildren @@ -40,17 +44,17 @@ * @throws ParseException in case there is no PropertySet ancestor * @see org.commonjava.opl.NodeParser#doBeforeChildren(org.w3c.dom.Node) */ - protected void doBeforeChildren(ElementInfo info) - throws ParseException { + protected void doBeforeChildren(ElementInfo info) throws ParseException + { String name = getAttribute(PropertyElements.PROPERTY_NAME, info); String value = getAttribute(PropertyElements.PROPERTY_VALUE, info); - + PropertySet set = (PropertySet)findAncestorOfType(PropertySet.class); - if(set == null){ + + if(set == null) { throw new ParseException("No PropertySet ancestor found for property parser."); } - + set.setProperty(name, value); } - } Index: PropertiesParser.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/generics/properties/PropertiesParser.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- PropertiesParser.java 10 Oct 2003 00:15:46 -0000 1.2 +++ PropertiesParser.java 12 Mar 2004 19:46:56 -0000 1.3 @@ -3,53 +3,57 @@ */ package org.commonjava.opl.generics.properties; -import java.util.Properties; - import org.commonjava.opl.ElementInfo; import org.commonjava.opl.NodeParser; import org.commonjava.opl.OPLContext; import org.commonjava.opl.ParseException; +import java.util.Properties; + + /** parser for property sets. - * + * * @author John Casey */ -public class PropertiesParser extends NodeParser implements PropertySet { - +public class PropertiesParser extends NodeParser implements PropertySet +{ private Properties properties = new Properties(); /** Create a new PropertiesParser. * @param context the context in which we're parsing XML * @param parent the parent parser. */ - public PropertiesParser(OPLContext context, NodeParser parent) { + public PropertiesParser(OPLContext context, NodeParser parent) + { super(context, parent); } /** Create a new PropertiesParser. * @param context the context in which we're parsing XML */ - public PropertiesParser(OPLContext context) { + public PropertiesParser(OPLContext context) + { super(context); } /** After all the children are processed (these will be Property parsers), * set the properties on the ancestor of type PropertiesContainer. - * + * * NOTE: This method overrides doAfterChildren * @param node the node to parse for a property set * @throws ParseException in case no ancestor implements PropertiesContainer. * @see org.commonjava.opl.NodeParser#doAfterChildren(org.w3c.dom.Node) */ - protected void doAfterChildren(ElementInfo info, String body) throws ParseException { - PropertiesContainer container = (PropertiesContainer)findAncestorOfType( - PropertiesContainer.class - ); - - if(container != null){ + protected void doAfterChildren(ElementInfo info, String body) + throws ParseException + { + PropertiesContainer container = + (PropertiesContainer)findAncestorOfType(PropertiesContainer.class); + + if(container != null) { container.setProperties(properties); } - else{ + else { throw new ParseException("Error: no ancestor PropertiesContainer implementation found."); } } @@ -60,7 +64,8 @@ * @param value the property's value * @see org.commonjava.opl.PropertySet#setProperty(java.lang.String, java.lang.String) */ - public void setProperty(String name, String value) { + public void setProperty(String name, String value) + { properties.setProperty(name, value); } @@ -70,8 +75,8 @@ * @return the value associated with the name * @see org.commonjava.opl.PropertySet#getProperty(java.lang.String) */ - public String getProperty(String name) { + public String getProperty(String name) + { return properties.getProperty(name); } - } Index: PropertiesContainer.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/generics/properties/PropertiesContainer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PropertiesContainer.java 18 Sep 2003 04:57:09 -0000 1.1 +++ PropertiesContainer.java 12 Mar 2004 19:46:56 -0000 1.2 @@ -5,14 +5,15 @@ import java.util.Properties; + //TODO: Document PropertiesContainer + /** * @author jdcasey */ -public interface PropertiesContainer { - +public interface PropertiesContainer +{ public void setProperties(Properties properties); - - public Properties getProperties(); + public Properties getProperties(); } Index: PropertySet.java =================================================================== RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-opl/src/java/org/commonjava/opl/generics/properties/PropertySet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PropertySet.java 18 Sep 2003 04:57:09 -0000 1.1 +++ PropertySet.java 12 Mar 2004 19:46:56 -0000 1.2 @@ -3,14 +3,15 @@ */ package org.commonjava.opl.generics.properties; + //TODO: Document PropertySet + /** * @author jdcasey */ -public interface PropertySet { - +public interface PropertySet +{ public void setProperty(String name, String value); - - public String getProperty(String name); + public String getProperty(String name); } |