commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/read BeanBindAction.java ReadContext.java
Date Sat, 13 Mar 2004 19:19:43 GMT
rdonkin     2004/03/13 11:19:43

  Modified:    betwixt/src/java/org/apache/commons/betwixt/io/read Tag:
                        REFACTORING-BRANCH_2004-01-13 BeanBindAction.java
                        ReadContext.java
  Log:
  Removed unused methods and documented those that are likely to stay
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.8   +6 -6      jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/read/Attic/BeanBindAction.java
  
  Index: BeanBindAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/read/Attic/BeanBindAction.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- BeanBindAction.java	13 Mar 2004 18:36:33 -0000	1.1.2.7
  +++ BeanBindAction.java	13 Mar 2004 19:19:43 -0000	1.1.2.8
  @@ -94,7 +94,7 @@
                           
           Log log = context.getLog();
   
  -        ElementDescriptor computedDescriptor = context.getActiveDescriptor();
  +        ElementDescriptor computedDescriptor = context.getCurrentDescriptor();
   
           if (computedDescriptor == null) {
               log.trace("No Descriptor");
  
  
  
  1.4.2.6   +66 -97    jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/read/ReadContext.java
  
  Index: ReadContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/read/ReadContext.java,v
  retrieving revision 1.4.2.5
  retrieving revision 1.4.2.6
  diff -u -r1.4.2.5 -r1.4.2.6
  --- ReadContext.java	13 Mar 2004 18:36:33 -0000	1.4.2.5
  +++ ReadContext.java	13 Mar 2004 19:19:43 -0000	1.4.2.6
  @@ -100,7 +100,7 @@
   	private ArrayStack objectStack = new ArrayStack();
   
   	private Class rootClass;
  -
  +    /** The <code>XMLIntrospector</code> to be used to map the xml*/
   	private XMLIntrospector xmlIntrospector;
   
   	/** 
  @@ -238,6 +238,11 @@
   		return (String) top;
   	}
   
  +    /**
  +     * Gets the element name for the currently mapped element.
  +     * @return the name of the currently mapped element, 
  +     * or null if there has been no element mapped 
  +     */
   	public String getCurrentElement() {
   		return (String) elementMappingStack.peek();
   	}
  @@ -255,20 +260,6 @@
   		return new RelativePathIterator();
   	}
   
  -	public ElementDescriptor getRelativePathElementDescriptor()
  -		throws IntrospectionException {
  -		ElementDescriptor result = null;
  -		XMLBeanInfo lastMappedClazzInfo = getLastMappedClassXMLBeanInfo();
  -		if (lastMappedClazzInfo != null) {
  -			result =
  -				lastMappedClazzInfo
  -					.getElementDescriptor()
  -					.getElementDescriptor(
  -					getRelativeElementPathIterator());
  -		}
  -		return result;
  -	}
  -
   	/**
   	  * Gets an iterator for the current relative path.
   	  * This is not guarenteed to behave safely if the underlying array
  @@ -278,7 +269,7 @@
   	  *
   	  * @return an Iterator over String's
   	  */
  -	public Iterator getParentElementPathIterator() {
  +	private Iterator getParentElementPathIterator() {
   		Object top = elementMappingStack.peek();
   		if (top instanceof Class) {
   			return new RelativePathIterator(1);
  @@ -286,45 +277,26 @@
   		return new RelativePathIterator();
   	}
   
  -	public ElementDescriptor getParentPathElementDescriptor()
  -		throws IntrospectionException {
  -		ElementDescriptor result = null;
  -		XMLBeanInfo lastMappedClazzInfo = getLastMappedClassXMLBeanInfo();
  -		if (lastMappedClazzInfo != null) {
  -            Iterator it = getParentElementPathIterator();
  -            Object test = it.next();
  -			result =
  -				lastMappedClazzInfo
  -					.getElementDescriptor()
  -					.getElementDescriptor(it);
  -		}
  -		return result;
  -	}
  -
   	/**
   	  * Gets the Class that was last mapped, if there is one.
   	  * 
  -	  * @return the Class last marked as mapped or null if no class has been mapped
  +	  * @return the Class last marked as mapped 
  +      * or null if no class has been mapped
   	  */
   	public Class getLastMappedClass() {
  -		return getLastMappedClass(0);
  -	}
  -
  -	public Class getLastMappedClass(int offset) {
  -		Class lastMapped = null;
  -		for (int i = offset, size = elementMappingStack.size();
  -			i < size;
  -			i++) {
  -			Object entry = elementMappingStack.peek(i);
  -			if (entry instanceof Class) {
  -				lastMapped = (Class) entry;
  -				break;
  -			}
  -		}
  -		return lastMapped;
  +        Class lastMapped = null;
  +        for (int i = 0, size = elementMappingStack.size();
  +            i < size;
  +            i++) {
  +            Object entry = elementMappingStack.peek(i);
  +            if (entry instanceof Class) {
  +                lastMapped = (Class) entry;
  +                break;
  +            }
  +        }
  +        return lastMapped;
   	}
       
  -    
       private Class getParentClass()
       {
           Class result = null;
  @@ -374,21 +346,6 @@
       }
       
   
  -	public XMLBeanInfo getLastMappedClassXMLBeanInfo()
  -		throws IntrospectionException {
  -		XMLBeanInfo lastMappedXMLBeanInfo = null;
  -		Class lastMappedClass = getLastMappedClass();
  -		if (lastMappedClass != null) {
  -			lastMappedXMLBeanInfo =
  -				getXMLIntrospector().introspect(lastMappedClass);
  -		}
  -		return lastMappedXMLBeanInfo;
  -	}
  -
  -	public Iterator getRelativeElementPathIterator(int offset) {
  -		return new RelativePathIterator(1);
  -	}
  -
   	/** 
   	  * Pushes the given element onto the element mapping stack.
   	  *
  @@ -405,10 +362,19 @@
   		}
   	}
   
  +    /**
  +     * Is the root element currently being mapped?
  +     * @return true if the element being mapped is the root element
  +     * but false if the stack is empty
  +     */    
   	public boolean isAtRootElement() {
   		return (elementMappingStack.size() == 1);
   	}
   
  +    /**
  +     * Is the element mapping stack empty?
  +     * @return true if the element mapping stack is empty
  +     */
       public boolean isStackEmpty() {
           return (elementMappingStack.size() == 0);
       }
  @@ -504,18 +470,37 @@
   		// for now, do nothing		
   	}
   
  +    /**
  +     * Pops the last mapping <code>Object</code> from the 
  +     * stack containing beans that have been mapped.
  +     * @return 
  +     */
   	public Object popBean() {
   		return objectStack.pop();
   	}
   
  +    /**
  +     * Pushs a newly mapped <code>Object</code> onto the mapped bean stack.
  +     * @param bean
  +     */
   	public void pushBean(Object bean) {
   		objectStack.push(bean);
   	}
   
  +    /**
  +     * Gets the <code>XMLIntrospector</code> to be used to create
  +     * the mappings for the xml.
  +     * @return <code>XMLIntrospector, not null
  +     */
   	public XMLIntrospector getXMLIntrospector() {
   		return xmlIntrospector;
   	}
   
  +    /**
  +     * Sets the <code>XMLIntrospector</code> to be used to create
  +     * the mappings for the xml.
  +     * @param xmlIntrospector <code>XMLIntrospector</code>, not null
  +     */
   	public void setXMLIntrospector(XMLIntrospector xmlIntrospector) {
   		this.xmlIntrospector = xmlIntrospector;
   	}
  @@ -528,6 +513,13 @@
   		this.rootClass = rootClass;
   	}
   
  +    /**
  +     * Gets the <code>ElementDescriptor</code> that describes the
  +     * mapping for the current element.
  +     * @return <code>ElementDescriptor</code> or null if there is no
  +     * current mapping
  +     * @throws Exception
  +     */
   	public ElementDescriptor getCurrentDescriptor() throws Exception {
   		ElementDescriptor result = null;
   		Iterator relativePathIterator = getRelativeElementPathIterator();
  @@ -555,36 +547,13 @@
   		}
   		return result;
   	}
  -
  -	public ElementDescriptor getActiveDescriptor() throws Exception {
  -
  -		ElementDescriptor computedDescriptor =
  -			getRelativePathElementDescriptor();
  -		if (computedDescriptor == null) {
  -			computedDescriptor = getParentPathElementDescriptor();
  -		}
  -		ElementDescriptor parentDescriptor = null;
  -		if (computedDescriptor != null
  -			&& computedDescriptor.getPropertyType() == null) {
  -			XMLBeanInfo childXMLBeanInfo = getLastMappedClassXMLBeanInfo();
  -			if (childXMLBeanInfo == null) {
  -				getLog().trace("No XMLBeanInfo");
  -
  -			} else {
  -
  -				parentDescriptor =
  -					childXMLBeanInfo.getElementDescriptor().findParent(
  -						computedDescriptor);
  -			}
  -		}
  -
  -		if (computedDescriptor == null
  -			|| computedDescriptor.getSingularPropertyType() == null) {
  -			computedDescriptor = parentDescriptor;
  -		}
  -		return computedDescriptor;
  -	}
  -	
  +    
  +    /**
  +     * Populates the object mapped by the <code>AttributeDescriptor</code>s
  +     * with the values in the given <code>Attributes</code>.
  +     * @param attributeDescriptors <code>AttributeDescriptor</code>s, not null
  +     * @param attributes <code>Attributes</code>, not null
  +     */
   	public void populateAttributes(
   		AttributeDescriptor[] attributeDescriptors,
   		Attributes attributes) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message