Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMAttributePointer.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMAttributePointer.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMAttributePointer.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMAttributePointer.java Sun Feb 3 18:04:13 2008 @@ -33,22 +33,36 @@ public class DOMAttributePointer extends NodePointer { private Attr attr; + /** + * Create a new DOMAttributePointer. + * @param parent pointer + * @param attr pointed + */ public DOMAttributePointer(NodePointer parent, Attr attr) { super(parent); this.attr = attr; } + /** + * [EMAIL PROTECTED] + */ public QName getName() { return new QName( DOMNodePointer.getPrefix(attr), DOMNodePointer.getLocalName(attr)); } + /** + * [EMAIL PROTECTED] + */ public String getNamespaceURI() { String prefix = DOMNodePointer.getPrefix(attr); return prefix == null ? null : parent.getNamespaceURI(prefix); } + /** + * [EMAIL PROTECTED] + */ public Object getValue() { String value = attr.getValue(); if (value == null || (value.equals("") && !attr.getSpecified())) { @@ -57,30 +71,51 @@ return value; } + /** + * [EMAIL PROTECTED] + */ public Object getBaseValue() { return attr; } + /** + * [EMAIL PROTECTED] + */ public boolean isCollection() { return false; } + /** + * [EMAIL PROTECTED] + */ public int getLength() { return 1; } + /** + * [EMAIL PROTECTED] + */ public Object getImmediateNode() { return attr; } + /** + * [EMAIL PROTECTED] + */ public boolean isActual() { return true; } + /** + * [EMAIL PROTECTED] + */ public boolean isLeaf() { return true; } + /** + * [EMAIL PROTECTED] + */ public boolean testNode(NodeTest nodeTest) { return nodeTest == null || ((nodeTest instanceof NodeTypeTest) @@ -89,16 +124,21 @@ /** * Sets the value of this attribute. + * @param value to set */ public void setValue(Object value) { attr.setValue((String) TypeUtils.convert(value, String.class)); } + /** + * [EMAIL PROTECTED] + */ public void remove() { attr.getOwnerElement().removeAttributeNode(attr); } /** + * [EMAIL PROTECTED] */ public String asPath() { StringBuffer buffer = new StringBuffer(); @@ -114,19 +154,26 @@ return buffer.toString(); } + /** + * [EMAIL PROTECTED] + */ public int hashCode() { return System.identityHashCode(attr); } + /** + * [EMAIL PROTECTED] + */ public boolean equals(Object object) { return object == this || object instanceof DOMAttributePointer && attr == ((DOMAttributePointer) object).attr; } - public int compareChildNodePointers( - NodePointer pointer1, - NodePointer pointer2) - { + /** + * [EMAIL PROTECTED] + */ + public int compareChildNodePointers(NodePointer pointer1, + NodePointer pointer2) { // Won't happen - attributes don't have children return 0; }
Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java Sun Feb 3 18:04:13 2008 @@ -20,7 +20,6 @@ import java.util.Locale; import java.util.Map; -import org.apache.commons.jxpath.AbstractFactory; import org.apache.commons.jxpath.JXPathAbstractFactoryException; import org.apache.commons.jxpath.JXPathContext; import org.apache.commons.jxpath.JXPathException; @@ -152,8 +151,9 @@ return nodeType == Node.COMMENT_NODE; case Compiler.NODE_TYPE_PI : return nodeType == Node.PROCESSING_INSTRUCTION_NODE; + default: + return false; } - return false; } if (test instanceof ProcessingInstructionTest) { if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { @@ -207,11 +207,8 @@ /** * [EMAIL PROTECTED] */ - public NodeIterator childIterator( - NodeTest test, - boolean reverse, - NodePointer startWith) - { + public NodeIterator childIterator(NodeTest test, boolean reverse, + NodePointer startWith) { return new DOMNodeIterator(this, test, reverse, startWith); } @@ -275,7 +272,7 @@ String qname = "xmlns:" + prefix; Node aNode = node; if (aNode instanceof Document) { - aNode = ((Document)aNode).getDocumentElement(); + aNode = ((Document) aNode).getDocumentElement(); } while (aNode != null) { if (aNode.getNodeType() == Node.ELEMENT_NODE) { @@ -405,7 +402,7 @@ } /** - * Get the language attribute for this node. + * Get the language attribute for this node. * @return String language name */ protected String getLanguage() { @@ -466,11 +463,7 @@ /** * [EMAIL PROTECTED] */ - public NodePointer createChild( - JXPathContext context, - QName name, - int index) - { + public NodePointer createChild(JXPathContext context, QName name, int index) { if (index == WHOLE_COLLECTION) { index = 0; } @@ -484,8 +477,8 @@ if (success) { NodeTest nodeTest; String prefix = name.getPrefix(); - String namespaceURI = prefix == null ? null : - context.getNamespaceURI(prefix); + String namespaceURI = prefix == null ? null : context + .getNamespaceURI(prefix); nodeTest = new NodeNameTest(name, namespaceURI); NodeIterator it = childIterator(nodeTest, false, null); @@ -501,9 +494,8 @@ /** * [EMAIL PROTECTED] */ - public NodePointer createChild(JXPathContext context, - QName name, int index, Object value) - { + public NodePointer createChild(JXPathContext context, QName name, + int index, Object value) { NodePointer ptr = createChild(context, name, index); ptr.setValue(value); return ptr; @@ -613,6 +605,9 @@ break; case Node.DOCUMENT_NODE : // That'll be empty + break; + default: + break; } return buffer.toString(); } @@ -797,7 +792,7 @@ return text == null ? "" : trim ? text.trim() : text; } NodeList list = node.getChildNodes(); - StringBuffer buf = new StringBuffer(16); + StringBuffer buf = new StringBuffer(); for (int i = 0; i < list.getLength(); i++) { Node child = list.item(i); buf.append(stringValue(child)); @@ -822,9 +817,8 @@ /** * [EMAIL PROTECTED] */ - public int compareChildNodePointers( - NodePointer pointer1, NodePointer pointer2) - { + public int compareChildNodePointers(NodePointer pointer1, + NodePointer pointer2) { Node node1 = (Node) pointer1.getBaseValue(); Node node2 = (Node) pointer2.getBaseValue(); if (node1 == node2) { Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointer.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointer.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointer.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointer.java Sun Feb 3 18:04:13 2008 @@ -35,6 +35,12 @@ private QName name; private DynaBean dynaBean; + /** + * Create a new DynaBeanPointer. + * @param name is the name given to the first node + * @param dynaBean pointed + * @param locale Locale + */ public DynaBeanPointer(QName name, DynaBean dynaBean, Locale locale) { super(null, locale); this.name = name; @@ -42,7 +48,10 @@ } /** + * Create a new DynaBeanPointer. + * @param parent pointer * @param name is the name given to the first node + * @param dynaBean pointed */ public DynaBeanPointer(NodePointer parent, QName name, DynaBean dynaBean) { super(parent); @@ -50,44 +59,65 @@ this.dynaBean = dynaBean; } + /** + * [EMAIL PROTECTED] + */ public PropertyPointer getPropertyPointer() { return new DynaBeanPropertyPointer(this, dynaBean); } + /** + * [EMAIL PROTECTED] + */ public QName getName() { return name; } /** - * Returns the bean itself + * [EMAIL PROTECTED] */ public Object getBaseValue() { return dynaBean; } + /** + * [EMAIL PROTECTED] + */ public Object getImmediateNode() { return dynaBean; } + /** + * [EMAIL PROTECTED] + */ public boolean isCollection() { return false; } /** - * Returns 1. + * [EMAIL PROTECTED] */ public int getLength() { return 1; } + /** + * [EMAIL PROTECTED] + */ public boolean isLeaf() { return false; } + /** + * [EMAIL PROTECTED] + */ public int hashCode() { return name == null ? 0 : name.hashCode(); } + /** + * [EMAIL PROTECTED] + */ public boolean equals(Object object) { if (object == this) { return true; @@ -108,12 +138,18 @@ } /** - * If there's a parent - parent's path, otherwise "/". + * [EMAIL PROTECTED] */ public String asPath() { return parent == null ? "/" : super.asPath(); } + /** + * Learn whether two objects are == || .equals(). + * @param o1 first object + * @param o2 second object + * @return boolean + */ private static boolean equalObjects(Object o1, Object o2) { return o1 == o2 || o1 != null && o1.equals(o2); } Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointerFactory.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointerFactory.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointerFactory.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointerFactory.java Sun Feb 3 18:04:13 2008 @@ -34,21 +34,28 @@ */ public class DynaBeanPointerFactory implements NodePointerFactory { + /** factory order constant */ public static final int DYNA_BEAN_POINTER_FACTORY_ORDER = 700; + /** + * [EMAIL PROTECTED] + */ public int getOrder() { return DYNA_BEAN_POINTER_FACTORY_ORDER; } - public NodePointer createNodePointer( - QName name, Object bean, Locale locale) - { + /** + * [EMAIL PROTECTED] + */ + public NodePointer createNodePointer(QName name, Object bean, Locale locale) { return bean instanceof DynaBean ? new DynaBeanPointer(name, (DynaBean) bean, locale) : null; } - public NodePointer createNodePointer( - NodePointer parent, QName name, Object bean) - { + /** + * [EMAIL PROTECTED] + */ + public NodePointer createNodePointer(NodePointer parent, QName name, + Object bean) { return bean instanceof DynaBean ? new DynaBeanPointer(parent, name, (DynaBean) bean) : null; } } Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPropertyPointer.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPropertyPointer.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPropertyPointer.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPropertyPointer.java Sun Feb 3 18:04:13 2008 @@ -38,38 +38,46 @@ private String name; private String[] names; + /** + * Create a new DynaBeanPropertyPointer. + * @param parent pointer + * @param dynaBean pointed + */ public DynaBeanPropertyPointer(NodePointer parent, DynaBean dynaBean) { super(parent); this.dynaBean = dynaBean; } + /** + * [EMAIL PROTECTED] + */ public Object getBaseValue() { return dynaBean.get(getPropertyName()); } /** * This type of node is auxiliary. + * @return true */ public boolean isContainer() { return true; } /** - * Number of the DP object's properties. + * [EMAIL PROTECTED] */ public int getPropertyCount() { return getPropertyNames().length; } /** - * Names of all properties, sorted alphabetically - * - * @todo do something about the sorting + * [EMAIL PROTECTED] */ public String[] getPropertyNames() { + /* @todo do something about the sorting - LIKE WHAT? - MJB */ if (names == null) { DynaClass dynaClass = dynaBean.getDynaClass(); - DynaProperty properties[] = dynaClass.getDynaProperties(); + DynaProperty[] properties = dynaClass.getDynaProperties(); int count = properties.length; boolean hasClass = dynaClass.getDynaProperty("class") != null; if (hasClass) { @@ -90,10 +98,11 @@ /** * Returns the name of the currently selected property or "*" * if none has been selected. + * @return String */ public String getPropertyName() { if (name == null) { - String names[] = getPropertyNames(); + String[] names = getPropertyNames(); name = propertyIndex >= 0 && propertyIndex < names.length ? names[propertyIndex] : "*"; } return name; @@ -101,6 +110,7 @@ /** * Select a property by name. + * @param propertyName to select */ public void setPropertyName(String propertyName) { setPropertyIndex(UNSPECIFIED_PROPERTY); @@ -110,10 +120,11 @@ /** * Index of the currently selected property in the list of all * properties sorted alphabetically. + * @return int */ public int getPropertyIndex() { if (propertyIndex == UNSPECIFIED_PROPERTY) { - String names[] = getPropertyNames(); + String[] names = getPropertyNames(); for (int i = 0; i < names.length; i++) { if (names[i].equals(name)) { propertyIndex = i; @@ -128,6 +139,7 @@ /** * Index a property by its index in the list of all * properties sorted alphabetically. + * @param index to set */ public void setPropertyIndex(int index) { if (propertyIndex != index) { @@ -141,6 +153,7 @@ * the value of the index'th element of the collection represented by the * property. If the property is not a collection, index should be zero * and the value will be the property itself. + * @return Object */ public Object getImmediateNode() { String name = getPropertyName(); @@ -181,13 +194,18 @@ } /** - * Returns true if the bean has the currently selected property + * Returns true if the bean has the currently selected property. + * @return boolean */ protected boolean isActualProperty() { DynaClass dynaClass = dynaBean.getDynaClass(); return dynaClass.getDynaProperty(getPropertyName()) != null; } + /** + * Learn whether the property referenced is an indexed property. + * @return boolean + */ protected boolean isIndexedProperty() { DynaClass dynaClass = dynaBean.getDynaClass(); DynaProperty property = dynaClass.getDynaProperty(name); @@ -198,11 +216,15 @@ * If index == WHOLE_COLLECTION, change the value of the property, otherwise * change the value of the index'th element of the collection * represented by the property. + * @param value to set */ public void setValue(Object value) { setValue(index, value); } + /** + * [EMAIL PROTECTED] + */ public void remove() { if (index == WHOLE_COLLECTION) { dynaBean.set(getPropertyName(), null); @@ -219,6 +241,11 @@ } } + /** + * Set an indexed value. + * @param index to change + * @param value to set + */ private void setValue(int index, Object value) { if (index == WHOLE_COLLECTION) { dynaBean.set(getPropertyName(), convert(value, false)); @@ -230,9 +257,15 @@ Object baseValue = dynaBean.get(getPropertyName()); ValueUtils.setValue(baseValue, index, value); } - } + } + /** + * Convert a value to the appropriate property type. + * @param value to convert + * @param element whether this should be a collection element. + * @return conversion result + */ private Object convert(Object value, boolean element) { DynaClass dynaClass = (DynaClass) dynaBean.getDynaClass(); DynaProperty property = dynaClass.getDynaProperty(getPropertyName()); Added: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/package.html URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/package.html?rev=618149&view=auto ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/package.html (added) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/package.html Sun Feb 3 18:04:13 2008 @@ -0,0 +1,19 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<body> +Implementation of "model" APIs for Commons BeanUtils DynaBeans. +</body> Propchange: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/package.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/package.html ------------------------------------------------------------------------------ --- svn:keywords (added) +++ svn:keywords Sun Feb 3 18:04:13 2008 @@ -0,0 +1,5 @@ +Date +Author +Id +Revision +HeadURL Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynamic/DynamicPointer.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynamic/DynamicPointer.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynamic/DynamicPointer.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynamic/DynamicPointer.java Sun Feb 3 18:04:13 2008 @@ -28,7 +28,7 @@ import org.apache.commons.jxpath.ri.model.beans.PropertyPointer; /** - * A Pointer that points to an object with Dynamic Properties. It is used for + * A Pointer that points to an object with Dynamic Properties. It is used for * the first element of a path; following elements will by of type * PropertyPointer. * Added: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynamic/package.html URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynamic/package.html?rev=618149&view=auto ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynamic/package.html (added) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynamic/package.html Sun Feb 3 18:04:13 2008 @@ -0,0 +1,20 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<body> +Implementation of "model" APIs for dynamic property objects e.g. Maps or anything else for +which a client can provide a DynamicPropertyHandler class. +</body> Propchange: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynamic/package.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynamic/package.html ------------------------------------------------------------------------------ --- svn:keywords (added) +++ svn:keywords Sun Feb 3 18:04:13 2008 @@ -0,0 +1,5 @@ +Date +Author +Id +Revision +HeadURL Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMAttributeIterator.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMAttributeIterator.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMAttributeIterator.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMAttributeIterator.java Sun Feb 3 18:04:13 2008 @@ -38,6 +38,11 @@ private List attributes; private int position = 0; + /** + * Create a new JDOMAttributeIterator. + * @param parent pointer + * @param name test + */ public JDOMAttributeIterator(NodePointer parent, QName name) { this.parent = parent; if (parent.getNode() instanceof Element) { @@ -86,6 +91,9 @@ } } + /** + * [EMAIL PROTECTED] + */ public NodePointer getNodePointer() { if (position == 0) { if (!setPosition(1)) { @@ -102,10 +110,16 @@ (Attribute) attributes.get(index)); } + /** + * [EMAIL PROTECTED] + */ public int getPosition() { return position; } + /** + * [EMAIL PROTECTED] + */ public boolean setPosition(int position) { if (attributes == null) { return false; Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java Sun Feb 3 18:04:13 2008 @@ -419,7 +419,7 @@ } /** - * Execute test against node on behalf of pointer. + * Execute test against node on behalf of pointer. * @param pointer Pointer * @param node to test * @param test to execute @@ -464,8 +464,9 @@ return node instanceof Comment; case Compiler.NODE_TYPE_PI : return node instanceof ProcessingInstruction; + default: + return false; } - return false; } if (test instanceof ProcessingInstructionTest && node instanceof ProcessingInstruction) { String testPI = ((ProcessingInstructionTest) test).getTarget(); @@ -752,7 +753,7 @@ return 1; } - List children = ((Element)parent).getContent(); + List children = ((Element) parent).getContent(); int count = 0; String name = ((Element) node).getQualifiedName(); for (int i = 0; i < children.size(); i++) { Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/HttpSessionHandler.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/HttpSessionHandler.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/HttpSessionHandler.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/HttpSessionHandler.java Sun Feb 3 18:04:13 2008 @@ -32,6 +32,9 @@ */ public class HttpSessionHandler extends ServletContextHandler { + /** + * [EMAIL PROTECTED] + */ protected void collectPropertyNames(HashSet set, Object bean) { HttpSessionAndServletContext handle = (HttpSessionAndServletContext) bean; @@ -45,6 +48,9 @@ } } + /** + * [EMAIL PROTECTED] + */ public Object getProperty(Object bean, String property) { HttpSessionAndServletContext handle = (HttpSessionAndServletContext) bean; @@ -58,6 +64,9 @@ return super.getProperty(handle.getServletContext(), property); } + /** + * [EMAIL PROTECTED] + */ public void setProperty(Object bean, String property, Object value) { HttpSessionAndServletContext handle = (HttpSessionAndServletContext) bean; Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/JXPathServletContexts.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/JXPathServletContexts.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/JXPathServletContexts.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/JXPathServletContexts.java Sun Feb 3 18:04:13 2008 @@ -90,6 +90,8 @@ /** * Returns a JXPathContext bound to the "page" scope. Caches that context * within the PageContext itself. + * @param pageContext as described + * @return JXPathContext */ public static JXPathContext getPageContext(PageContext pageContext) { JXPathContext context = @@ -112,11 +114,12 @@ /** * Returns a JXPathContext bound to the "request" scope. Caches that context * within the request itself. + * @param request as described + * @param servletContext operative + * @return JXPathContext */ - public static JXPathContext getRequestContext( - ServletRequest request, - ServletContext servletContext) - { + public static JXPathContext getRequestContext(ServletRequest request, + ServletContext servletContext) { JXPathContext context = (JXPathContext) request.getAttribute(Constants.JXPATH_CONTEXT); // If we are in an included JSP or Servlet, the request parameter @@ -153,11 +156,12 @@ /** * Returns a JXPathContext bound to the "session" scope. Caches that context * within the session itself. + * @param session as described + * @param servletContext operative + * @return JXPathContext */ - public static JXPathContext getSessionContext( - HttpSession session, - ServletContext servletContext) - { + public static JXPathContext getSessionContext(HttpSession session, + ServletContext servletContext) { JXPathContext context = (JXPathContext) session.getAttribute(Constants.JXPATH_CONTEXT); if (context == null) { @@ -175,10 +179,11 @@ /** * Returns a JXPathContext bound to the "application" scope. Caches that * context within the servlet context itself. + * @param servletContext operative + * @return JXPathContext */ public static JXPathContext getApplicationContext( - ServletContext servletContext) - { + ServletContext servletContext) { JXPathContext context = (JXPathContext) servletContext.getAttribute( Constants.JXPATH_CONTEXT); Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/PageContextHandler.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/PageContextHandler.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/PageContextHandler.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/PageContextHandler.java Sun Feb 3 18:04:13 2008 @@ -32,6 +32,9 @@ */ public class PageContextHandler implements DynamicPropertyHandler { + /** + * [EMAIL PROTECTED] + */ public String[] getPropertyNames(Object pageContext) { HashSet list = new HashSet(); Enumeration e = @@ -63,16 +66,18 @@ /** * Returns <code>pageContext.findAttribute(property)</code>. + * @param pageContext to search + * @param property name + * @return Object value */ public Object getProperty(Object pageContext, String property) { return ((PageContext) pageContext).findAttribute(property); } - public void setProperty( - Object pageContext, - String property, - Object value) - { + /** + * [EMAIL PROTECTED] + */ + public void setProperty(Object pageContext, String property, Object value) { ((PageContext) pageContext).setAttribute( property, value, Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/PageScopeContext.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/PageScopeContext.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/PageScopeContext.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/PageScopeContext.java Sun Feb 3 18:04:13 2008 @@ -32,21 +32,36 @@ public class PageScopeContext { private PageContext pageContext; + /** + * Create a new PageScopeContext. + * @param pageContext base + */ public PageScopeContext(PageContext pageContext) { this.pageContext = pageContext; } /** * Returns attributes of the pageContext declared in the "page" scope. + * @return Enumeration of attribute names */ public Enumeration getAttributeNames() { return pageContext.getAttributeNamesInScope(PageContext.PAGE_SCOPE); } + /** + * Get the value of the specified attribute. + * @param attribute name + * @return Object + */ public Object getAttribute(String attribute) { return pageContext.getAttribute(attribute, PageContext.PAGE_SCOPE); } + /** + * Set the specified attribute. + * @param attribute to set + * @param value to set + */ public void setAttribute(String attribute, Object value) { pageContext.setAttribute(attribute, value, PageContext.PAGE_SCOPE); } Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/PageScopeContextHandler.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/PageScopeContextHandler.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/PageScopeContextHandler.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/PageScopeContextHandler.java Sun Feb 3 18:04:13 2008 @@ -30,21 +30,30 @@ */ public class PageScopeContextHandler implements DynamicPropertyHandler { - private static final String[] STRING_ARRAY = new String[0]; + private static final int DEFAULT_LIST_SIZE = 16; + /** + * [EMAIL PROTECTED] + */ public String[] getPropertyNames(Object pageScope) { Enumeration e = ((PageScopeContext) pageScope).getAttributeNames(); - ArrayList list = new ArrayList(16); + ArrayList list = new ArrayList(DEFAULT_LIST_SIZE); while (e.hasMoreElements()) { list.add(e.nextElement()); } - return (String[]) list.toArray(STRING_ARRAY); + return (String[]) list.toArray(new String[list.size()]); } + /** + * [EMAIL PROTECTED] + */ public Object getProperty(Object pageScope, String property) { return ((PageScopeContext) pageScope).getAttribute(property); } + /** + * [EMAIL PROTECTED] + */ public void setProperty(Object pageScope, String property, Object value) { ((PageScopeContext) pageScope).setAttribute(property, value); } Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/ServletRequestHandler.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/ServletRequestHandler.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/ServletRequestHandler.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/ServletRequestHandler.java Sun Feb 3 18:04:13 2008 @@ -30,6 +30,9 @@ */ public class ServletRequestHandler extends HttpSessionHandler { + /** + * [EMAIL PROTECTED] + */ protected void collectPropertyNames(HashSet set, Object bean) { super.collectPropertyNames(set, bean); ServletRequestAndContext handle = (ServletRequestAndContext) bean; @@ -44,6 +47,9 @@ } } + /** + * [EMAIL PROTECTED] + */ public Object getProperty(Object bean, String property) { ServletRequestAndContext handle = (ServletRequestAndContext) bean; ServletRequest servletRequest = handle.getServletRequest(); @@ -66,6 +72,9 @@ return super.getProperty(bean, property); } + /** + * [EMAIL PROTECTED] + */ public void setProperty(Object request, String property, Object value) { ((ServletRequest) request).setAttribute(property, value); } Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java Sun Feb 3 18:04:13 2008 @@ -47,6 +47,9 @@ /** * Returns true if it can convert the supplied * object to the specified class. + * @param object to check + * @param toType prospective destination class + * @return boolean */ public boolean canConvert(Object object, final Class toType) { if (object == null) { @@ -151,6 +154,9 @@ * Converts the supplied object to the specified * type. Throws a runtime exception if the conversion is * not possible. + * @param object to convert + * @param toType destination class + * @return converted object */ public Object convert(Object object, final Class toType) { if (object == null) { @@ -245,7 +251,8 @@ try { return useType.getConstructor(new Class[] { boolean.class }) .newInstance(new Object[] { object }); - } catch (Exception e) { + } + catch (Exception e) { throw new JXPathTypeConversionException(useType.getName(), e); } } @@ -275,6 +282,11 @@ + object.getClass() + " to " + useType); } + /** + * Convert null to a primitive type. + * @param toType destination class + * @return a wrapper + */ protected Object convertNullToPrimitive(Class toType) { if (toType == boolean.class) { return Boolean.FALSE; @@ -303,6 +315,12 @@ return null; } + /** + * Convert a string to a primitive type. + * @param object String + * @param toType destination class + * @return wrapper + */ protected Object convertStringToPrimitive(Object object, Class toType) { toType = TypeUtils.wrapPrimitive(toType); if (toType == Boolean.class) { @@ -332,6 +350,12 @@ return null; } + /** + * Allocate a number of a given type and value. + * @param type destination class + * @param value double + * @return Number + */ protected Number allocateNumber(Class type, double value) { type = TypeUtils.wrapPrimitive(type); if (type == Byte.class) { @@ -373,29 +397,41 @@ .newInstance( new Object[] { allocateNumber(initialValueType, value) }); - } catch (Exception e) { + } + catch (Exception e) { throw new JXPathTypeConversionException(classname, e); } } return null; } + /** + * Learn whether this BasicTypeConverter can create a collection of the specified type. + * @param type prospective destination class + * @return boolean + */ protected boolean canCreateCollection(Class type) { if (!type.isInterface() && ((type.getModifiers() & Modifier.ABSTRACT) == 0)) { try { type.getConstructor(new Class[0]); return true; - } catch (Exception e) { + } + catch (Exception e) { return false; } } return type == List.class || type == Collection.class || type == Set.class; } + /** + * Create a collection of a given type. + * @param type destination class + * @return Collection + */ protected Collection allocateCollection(Class type) { if (!type.isInterface() - && ((type.getModifiers() & Modifier.ABSTRACT) == 0)) { + && ((type.getModifiers() & Modifier.ABSTRACT) == 0)) { try { return (Collection) type.newInstance(); } @@ -415,6 +451,11 @@ "Cannot create collection of type: " + type); } + /** + * Get an unmodifiable version of a collection. + * @param collection to wrap + * @return Collection + */ protected Collection unmodifiableCollection(Collection collection) { if (collection instanceof List) { return Collections.unmodifiableList((List) collection); @@ -428,22 +469,38 @@ return Collections.unmodifiableCollection(collection); } + /** + * NodeSet implementation + */ static final class ValueNodeSet implements NodeSet { private List values; private List pointers; + /** + * Create a new ValueNodeSet. + * @param values to return + */ public ValueNodeSet(List values) { this.values = values; } + /** + * [EMAIL PROTECTED] + */ public List getValues() { return Collections.unmodifiableList(values); } + /** + * [EMAIL PROTECTED] + */ public List getNodes() { return Collections.unmodifiableList(values); } + /** + * [EMAIL PROTECTED] + */ public List getPointers() { if (pointers == null) { pointers = new ArrayList(); @@ -456,37 +513,65 @@ } } + /** + * Value pointer + */ static final class ValuePointer implements Pointer { private Object bean; + /** + * Create a new ValuePointer. + * @param object value + */ public ValuePointer(Object object) { this.bean = object; } + /** + * [EMAIL PROTECTED] + */ public Object getValue() { return bean; } + /** + * [EMAIL PROTECTED] + */ public Object getNode() { return bean; } + /** + * [EMAIL PROTECTED] + */ public Object getRootNode() { return bean; } + /** + * [EMAIL PROTECTED] + */ public void setValue(Object value) { throw new UnsupportedOperationException(); } + /** + * [EMAIL PROTECTED] + */ public Object clone() { return this; } + /** + * [EMAIL PROTECTED] + */ public int compareTo(Object object) { return 0; } + /** + * [EMAIL PROTECTED] + */ public String asPath() { if (bean == null) { return "null()"; Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/KeyManagerUtils.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/KeyManagerUtils.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/KeyManagerUtils.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/KeyManagerUtils.java Sun Feb 3 18:04:13 2008 @@ -31,14 +31,24 @@ * @version $Revision$ $Date$ */ public class KeyManagerUtils { + /** + * Adapt KeyManager to implement ExtendedKeyManager. + */ private static class SingleNodeExtendedKeyManager implements ExtendedKeyManager { private KeyManager delegate; + /** + * Create a new SingleNodeExtendedKeyManager. + * @param delegate KeyManager to wrap + */ public SingleNodeExtendedKeyManager(KeyManager delegate) { this.delegate = delegate; } + /** + * [EMAIL PROTECTED] + */ public NodeSet getNodeSetByKey(JXPathContext context, String key, Object value) { Pointer pointer = delegate.getPointerByKey(context, key, InfoSetUtil.stringValue(value)); @@ -47,6 +57,9 @@ return result; } + /** + * [EMAIL PROTECTED] + */ public Pointer getPointerByKey(JXPathContext context, String keyName, String keyValue) { return delegate.getPointerByKey(context, keyName, keyValue); @@ -55,7 +68,7 @@ /** * Get an ExtendedKeyManager from the specified KeyManager. - * @param keyManager + * @param keyManager to adapt, if necessary * @return <code>keyManager</code> if it implements ExtendedKeyManager * or a basic single-result ExtendedKeyManager that delegates to * <code>keyManager</code>. Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java Sun Feb 3 18:04:13 2008 @@ -600,6 +600,7 @@ return clazz.getDeclaredMethod(name, parameterTypes); } catch (NoSuchMethodException e) { + //ignore } } } @@ -637,6 +638,7 @@ interfaces[i].getDeclaredMethod(methodName, parameterTypes); } catch (NoSuchMethodException e) { + //ignore } if (method != null) { break; Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/JDOMParser.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/JDOMParser.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/JDOMParser.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/JDOMParser.java Sun Feb 3 18:04:13 2008 @@ -29,6 +29,9 @@ */ public class JDOMParser extends XMLParser2 { + /** + * [EMAIL PROTECTED] + */ public Object parseXML(InputStream stream) { if (!isNamespaceAware()) { throw new JXPathException("JDOM parser configuration error. JDOM " Modified: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/XMLParser2.java URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/XMLParser2.java?rev=618149&r1=618148&r2=618149&view=diff ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/XMLParser2.java (original) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/XMLParser2.java Sun Feb 3 18:04:13 2008 @@ -25,8 +25,7 @@ * @author Dmitri Plotnikov * @version $Revision$ $Date$ */ -public abstract class XMLParser2 implements XMLParser -{ +public abstract class XMLParser2 implements XMLParser { private boolean validating = false; private boolean namespaceAware = true; private boolean whitespace = false; @@ -35,6 +34,8 @@ private boolean coalescing = false; /** + * Set whether the underlying parser should be validating. + * @param validating flag * @see DocumentBuilderFactory#setValidating(boolean) */ public void setValidating(boolean validating) { @@ -42,6 +43,8 @@ } /** + * Learn whether the underlying parser is validating. + * @return boolean * @see DocumentBuilderFactory#isValidating() */ public boolean isValidating() { @@ -49,6 +52,8 @@ } /** + * Learn whether the underlying parser is ns-aware. + * @return boolean * @see DocumentBuilderFactory#isNamespaceAware() */ public boolean isNamespaceAware() { @@ -56,6 +61,8 @@ } /** + * Set whether the underlying parser is ns-aware. + * @param namespaceAware flag * @see DocumentBuilderFactory#setNamespaceAware(boolean) */ public void setNamespaceAware(boolean namespaceAware) { @@ -63,6 +70,8 @@ } /** + * Set whether the underlying parser is ignoring whitespace. + * @param whitespace flag * @see DocumentBuilderFactory#setIgnoringElementContentWhitespace(boolean) */ public void setIgnoringElementContentWhitespace(boolean whitespace) { @@ -70,6 +79,8 @@ } /** + * Learn whether the underlying parser is ignoring whitespace. + * @return boolean * @see DocumentBuilderFactory#isIgnoringElementContentWhitespace() */ public boolean isIgnoringElementContentWhitespace() { @@ -77,6 +88,8 @@ } /** + * Learn whether the underlying parser expands entity references. + * @return boolean * @see DocumentBuilderFactory#isExpandEntityReferences() */ public boolean isExpandEntityReferences() { @@ -84,6 +97,8 @@ } /** + * Set whether the underlying parser expands entity references. + * @param expandEntityRef flag * @see DocumentBuilderFactory#setExpandEntityReferences(boolean) */ public void setExpandEntityReferences(boolean expandEntityRef) { @@ -91,6 +106,8 @@ } /** + * Learn whether the underlying parser ignores comments. + * @return boolean * @see DocumentBuilderFactory#isIgnoringComments() */ public boolean isIgnoringComments() { @@ -98,6 +115,8 @@ } /** + * Set whether the underlying parser ignores comments. + * @param ignoreComments flag * @see DocumentBuilderFactory#setIgnoringComments(boolean) */ public void setIgnoringComments(boolean ignoreComments) { @@ -105,6 +124,8 @@ } /** + * Learn whether the underlying parser is coalescing. + * @return boolean * @see DocumentBuilderFactory#isCoalescing() */ public boolean isCoalescing() { @@ -112,11 +133,16 @@ } /** + * Set whether the underlying parser is coalescing. + * @param coalescing flag * @see DocumentBuilderFactory#setCoalescing(boolean) */ public void setCoalescing(boolean coalescing) { this.coalescing = coalescing; } + /** + * [EMAIL PROTECTED] + */ public abstract Object parseXML(InputStream stream); } Added: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/package.html URL: http://svn.apache.org/viewvc/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/package.html?rev=618149&view=auto ============================================================================== --- commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/package.html (added) +++ commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/package.html Sun Feb 3 18:04:13 2008 @@ -0,0 +1,19 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<body> +Support classes for working with XML. +</body> Propchange: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/package.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/xml/package.html ------------------------------------------------------------------------------ --- svn:keywords (added) +++ svn:keywords Sun Feb 3 18:04:13 2008 @@ -0,0 +1,5 @@ +Date +Author +Id +Revision +HeadURL