Java Doc for AbstractArray.java in  » Scripting » jython » org » python » core » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » jython » org.python.core 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.python.core.AbstractArray

All known Subclasses:   org.python.core.PyObjectArray,
AbstractArray
abstract public class AbstractArray implements Serializable(Code)
Abstract class that manages bulk structural and data operations on arrays, defering type-specific element-wise operations to the subclass. Subclasses supply the underlying array and the type-specific operations--greatly reducing the need for casting (thus achieving array-like performances with collection-like flexibility). Also includes functionality to support integration with the the jdk's collections (via methods that return a modification increment).

Subclasses will want to provide the following methods (which are not declared in this class since subclasses should specify the explicit return type):

  • <type> get(int)
  • void set(int, <type>)
  • void add(<type>)
  • void add(int, <type>)
  • <type>[] toArray()

Clone cannot be supported since the array is not held locally. But the @link #AbstractArray(AbstractArray) constructor can be used for suclasses that need to support clone.

This "type-specific collections" approach was originally developed by Dennis Sosnoski, who provides a more complete library at the referenced URL. Sosnoski's library does not integrate with the jdk collection classes but provides collection-like classes.
author:
   Clark Updike
See Also:    * Sosnoski's Type-Specific Collection Library



Field Summary
protected  intcapacity
     Size of the current array, which can be larger than the size field.
protected  intmodCountIncr
     The modification count increment indicates if a structural change occured as a result of an operation that would make concurrent iteration over the array invalid.
protected  intsize
     The number of values currently present in the array.

Constructor Summary
public  AbstractArray(AbstractArray toCopy)
     Since AbstractArray can support a clone method, this facilitates sublcasses that want to implement clone (poor man's cloning).
public  AbstractArray(int size)
     Use when the subclass has a preexisting array.
public  AbstractArray(Class type)
     Creates the managed array with a default size of 10.
public  AbstractArray(Class type, int[] dimensions)
     Construtor for multi-dimensional array types. For example, char[][].
public  AbstractArray(Class type, int size)
     Creates the managed array with the specified size.

Method Summary
public  voidappendArray(Object ofArrayType)
     Appends the supplied array, which must be an array of the same type as this, to the end of this.
public  voidclear()
     Set the array to the empty state, clearing all the data out and nulling objects (or "zero-ing" primitives).
protected  voidclearRange(int start, int stop)
     Clears out the values in the specified range.
public  ObjectcopyArray()
     Constructs and returns a simple array containing the same data as held in this growable array.
protected  voidensureCapacity(int minCapacity)
     Ensures that the base array has at least the specified minimum capacity.
protected  intgetAddIndex()
     Gets the next add position for appending a value to those in the array.
abstract protected  ObjectgetArray()
     Get the backing array.
public  intgetModCountIncr()
     Returns the modification count increment, which is used by AbstractList subclasses to adjust modCount AbstractList uses it's modCount field to invalidate concurrent operations (like iteration) that should fail if the underlying array changes structurally during the operation.
public  intgetSize()
     Get the number of values currently present in the array.
protected  booleanisEmpty()
    
protected  voidmakeInsertSpace(int index)
     Makes room to insert a value at a specified index in the array.

AbstractList subclasses should update their modCount after calling this method.

protected  voidmakeInsertSpace(int index, int length)
    
public  voidremove(int index)
     Remove a value from the array.
public  voidremove(int start, int stop)
     Removes a range from the array at the specified indices.
public  voidreplaceSubArray(Object array, int atIndex)
     Allows an array type to overwrite a segment of the array.
public  voidreplaceSubArray(int thisStart, int thisStop, Object srcArray, int srcStart, int srcStop)
     Replace a range of this array with another subarray.
abstract protected  voidsetArray(Object array)
     Set the backing array.
public  voidsetSize(int count)
     Sets the number of values currently present in the array.
public  StringtoString()
     Provides a default comma-delimited representation of array.
protected  voidtrimToSize()
     Removes any excess capacity in the backing array so it is just big enough to hold the amount of data actually in the array.

Field Detail
capacity
protected int capacity(Code)
Size of the current array, which can be larger than the size field.



modCountIncr
protected int modCountIncr(Code)
The modification count increment indicates if a structural change occured as a result of an operation that would make concurrent iteration over the array invalid. It is typically used by subclasses that extend AbstractList, by adding the value to AbstractList.modCount after performing a potentially structure-altering operation. A value of 0 indicates that it is still valid to iterate over the array. A value of 1 indicates it is no longer valid to iterate over the range.

This class uses a somewhat stricter semantic for modCount. Namely, modCountIncr is only set to 1 if a structural change occurred. The jdk collections generally increment modCount if a potentially structure-altering method is called, regardless of whether or not a change actually occurred. See also: java.util.AbstractList#modCount




size
protected int size(Code)
The number of values currently present in the array.




Constructor Detail
AbstractArray
public AbstractArray(AbstractArray toCopy)(Code)
Since AbstractArray can support a clone method, this facilitates sublcasses that want to implement clone (poor man's cloning). Sublclasses can then do this:
 public MyManagedArray(MyManagedArray toCopy) {
 super(this);
 this.baseArray = ()toCopy.copyArray();
 this.someProp = toCopy.someProp;
 
 }
 

public Object clone() { return new MyManagedArray(this); }


Parameters:
  toCopy -



AbstractArray
public AbstractArray(int size)(Code)
Use when the subclass has a preexisting array.
Parameters:
  size - the initial size of the array



AbstractArray
public AbstractArray(Class type)(Code)
Creates the managed array with a default size of 10.
Parameters:
  type - array element type (primitive type or object class)



AbstractArray
public AbstractArray(Class type, int[] dimensions)(Code)
Construtor for multi-dimensional array types. For example, char[][]. This class only manages the top level dimension of the array. For single dimension arrays (the more typical usage), use the other constructors.


Parameters:
  type - Array element type (primitive type or object class).
Parameters:
  dimensions - An int array specifying the dimensions. Fora 2D array, something like new int[] {10,0} tocreate 10 elements each of which can hold an reference to anarray of the same type.
See Also:   Array.newInstance(java.lang.Classint[])




AbstractArray
public AbstractArray(Class type, int size)(Code)
Creates the managed array with the specified size.
Parameters:
  type - array element type (primitive type or object class)
Parameters:
  size - number of elements initially allowed in array




Method Detail
appendArray
public void appendArray(Object ofArrayType)(Code)
Appends the supplied array, which must be an array of the same type as this, to the end of this.

AbstractList subclasses should update their modCount after calling this method.
Parameters:
  ofArrayType - the array to append




clear
public void clear()(Code)
Set the array to the empty state, clearing all the data out and nulling objects (or "zero-ing" primitives).

Note: This method does not set modCountIncr to 1 even though java.util.ArrayList would.

AbstractList subclasses should update their modCount after calling this method.




clearRange
protected void clearRange(int start, int stop)(Code)
Clears out the values in the specified range. For object arrays, the cleared range is nullified. For primitve arrays, it is "zero-ed" out.

Note: This method does not set modCountIncr to 1 even though java.util.ArrayList would.
Parameters:
  start - the start index, inclusive
Parameters:
  stop - the stop index, exclusive




copyArray
public Object copyArray()(Code)
Constructs and returns a simple array containing the same data as held in this growable array. array containing a shallow copy of the data.



ensureCapacity
protected void ensureCapacity(int minCapacity)(Code)
Ensures that the base array has at least the specified minimum capacity.

AbstractList subclasses should update their modCount after calling this method.
Parameters:
  minCapacity - new minimum size required




getAddIndex
protected int getAddIndex()(Code)
Gets the next add position for appending a value to those in the array. If the underlying array is full, it is grown by the appropriate size increment so that the index value returned is always valid for the array in use by the time of the return.

AbstractList subclasses should update their modCount after calling this method. index position for next added element




getArray
abstract protected Object getArray()(Code)
Get the backing array. This method is used by the type-agnostic base class code to access the array used for type-specific storage by the child class. backing array object



getModCountIncr
public int getModCountIncr()(Code)
Returns the modification count increment, which is used by AbstractList subclasses to adjust modCount AbstractList uses it's modCount field to invalidate concurrent operations (like iteration) that should fail if the underlying array changes structurally during the operation. the modification count increment (0 if no change, 1 if changed)



getSize
public int getSize()(Code)
Get the number of values currently present in the array. count of values present



isEmpty
protected boolean isEmpty()(Code)



makeInsertSpace
protected void makeInsertSpace(int index)(Code)
Makes room to insert a value at a specified index in the array.

AbstractList subclasses should update their modCount after calling this method. Does not change the size property of the array.
Parameters:
  index - index position at which to insert element




makeInsertSpace
protected void makeInsertSpace(int index, int length)(Code)



remove
public void remove(int index)(Code)
Remove a value from the array. All values above the index removed are moved down one index position.

AbstractList subclasses should always increment their modCount method after calling this, as remove always causes a structural modification.
Parameters:
  index - index number of value to be removed




remove
public void remove(int start, int stop)(Code)
Removes a range from the array at the specified indices.
Parameters:
  start - inclusive
Parameters:
  stop - exclusive



replaceSubArray
public void replaceSubArray(Object array, int atIndex)(Code)
Allows an array type to overwrite a segment of the array. Will expand the array if (atIndex + 1) + ofArrayType's length is greater than the current length.

AbstractList subclasses should update their modCount after calling this method.
Parameters:
  array -
Parameters:
  atIndex -




replaceSubArray
public void replaceSubArray(int thisStart, int thisStop, Object srcArray, int srcStart, int srcStop)(Code)
Replace a range of this array with another subarray.
Parameters:
  thisStart - the start index (inclusive) of the subarray in this array to be replaced
Parameters:
  thisStop - the stop index (exclusive) of the subarray in this array to be replaced
Parameters:
  srcArray - the source array from which to copy
Parameters:
  srcStart - the start index (inclusive) of the replacement subarray
Parameters:
  srcStop - the stop index (exclusive) of the replacement subarray



setArray
abstract protected void setArray(Object array)(Code)
Set the backing array. This method is used by the type-agnostic base class code to set the array used for type-specific storage by the child class.
Parameters:
  array - the backing array object



setSize
public void setSize(int count)(Code)
Sets the number of values currently present in the array. If the new size is greater than the current size, the added values are initialized to the default values. If the new size is less than the current size, all values dropped from the array are discarded.

AbstractList subclasses should update their modCount after calling this method.
Parameters:
  count - number of values to be set




toString
public String toString()(Code)
Provides a default comma-delimited representation of array.
See Also:   java.lang.Object.toString



trimToSize
protected void trimToSize()(Code)
Removes any excess capacity in the backing array so it is just big enough to hold the amount of data actually in the array.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.