Thread: [CJ-dev] commonjava-projects/commonjava-opl/src/java/org/commonjava/opl NodeParser.java,1.15,1.16 OP
Brought to you by:
johnqueso
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] |