Oreilly upload source components
Abstract: Oreilly upload source components
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> upload open source components. Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( "CommentXMLStore"); document . getElementById (ElementID). CommentsPersistDiv.getAttribute value = ( "CommentContent");) </ td> </ tr> <tr>
↑ Back
Chinese Version jdom2.5 source jive
Abstract: Chinese Version jdom2.5 source jive
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> learning jsp Forum production and design patterns classical source. </ Td> </ tr> <tr>
↑ Back
JSP source holy message boards
Abstract: holy JSP source message board
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td width="362" height="86" align="center" valign="top">
JSP source holy message boards
Win2k Server procedures Resin + + + Mysql J2sdk Below passed.
Lyb to copy the folder to your virtual directory.
Chclyb copy the folder to X: \ mysql \ data \ Below.
Class class_lyb copied to the folder Below, at the same time changed its name to lyb
Operation http://127.0.0.1:8080/lyb/
See!
If you have any problems please contact
Chen_shengjie@tom.com
PS: There is no copyright.
</ Td> <td width="377" valign="top"> </ td> </ tr> <tr> <td height="20" colspan="2">
</ Td> </ tr> </ table>
</ Td> </ tr> <tr>
↑ Back
Javabean automatically to the source
Abstract: javabean automatically to the source
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td width="338" height="86" align="left" valign="top">
Following is the source java
ReturnTo.java
Package examples;
Import java.io. *;
Import java.util .*;
Import javax.servlet .*;
Import javax.servlet.http .*;
/ *
Automatic steering javabean
* /
Public class ReturnTo extends HttpServlet
(
Private String Msg;
Private String Rurl;
Private boolean isA;
Public void setMsg (String inMsg) (
This.Msg = inMsg;
)
Public void setRurl (String inRurl) (
This.Rurl = inRurl;
)
Public void setIsA (boolean inisA) (
This.isA = inisA;
)
Public String getMsg () (
Return this.Msg;
)
Public String getRurl () (
Return this.Rurl;
)
Public boolean getIsA () (
Return this.isA;
)
Public void go (HttpServletResponse response) throws IOException, ServletException (
PrintWriter out = response.getWriter ();
Out.print ( "<script language='javascript'>");
If (this.isA) (
Out.print ( "alert ( '" + + "!');"); Msg
)
Out.print ( "location.href = '" + Rurl +"';");
Out.print ( "</ script>");
)
)
Application test.jsp
<% @ Page contentType = "text / html; GBK charset ="%>
<%
String Msg = "automatic shift in ….";
String Url = "http://www.java3z.com";
We.setMsg (Msg);
We.setRurl (Url);
We.setIsA (true);
We.go (response);
%>
Notes:
1: Save the file position
ReturnTo.class ===> web-inf/classes/examples /
Test.jsp arbitrary position
2, wrote this page is not too many of javascript code:) simply frivolous.
3, in testing jdk1.5 tomcat + + win2k3 through.
</ Td> </ tr> <tr> ↑ Back
Access to a database with Struts source
Abstract: Access to a database with Struts source
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle">
First, preparation work
Create a database in access eBookStore.mdb and table book (download from the Site), and in the windows control panel set up good data source page
<table Width="681" height="24" border="0"> <tr> <td width="412"> at eBookStore.mdb. Three other needs jar documents:
1, commons-dbcp-1.2.1.jar
Download Address: http://apache.linuxforum.net/dist/jakarta/commons/dbcp/binaries/
2, struts-legacy.jar
Download Address: http://apache.linuxforum.net/dist/jakarta/struts/struts-legacy/
3, commons-pool-1.2.jar
Download Address: http://apache.linuxforum.net/dist/jakarta/commons/pool/binaries/
Second, struts-config.xml configuration
<? Xml version = "1.0" encoding = "ISO-8859-1"> </ td> <td width="259"> </ td> </ tr> </ table>
Struts-config PUBLIC
"- / / Apache Software Foundation / / DTD Struts Configuration 1.2 / / EN"
"Http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<form-beans>
</ Form-beans>
3. Action categories: DataSourceAction.java
Package page;
Import org.apache.struts.action .*;
Import javax.servlet.http .*;
Import java.util .*;
Import javax.sql .*;
Import java.sql .*;
Public class DataSourceAction extends Action (
Public DataSourceAction () ()
Public ActionForward execute (ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception (
Try (
This.getDataSource DataSource ds = (request, "dataSource");
Connection con = ds.getConnection ();
Statement stmt = con.createStatement ();
String sql = "SELECT * FROM book";
ResultSet rs = stmt.executeQuery (sql);
Request.setAttribute ( "result", rs);
) Catch (Exception e) (
E.printStackTrace ();
System.out.println ( "Database Connection unusual");
)
Return (mapping.findForward ( "success"));
)
)
Fourth, the test page: testpage.jsp
<% @ Page contentType = "text / html; charset = gb2312" language = "java"%>
<% @ Page import = "java.sql .*"%>
<%
ResultSet rs = (ResultSet) request.getAttribute ( "result");
While (rs.next ()) (
Out.println (rs.getString ( "name ")+"—–");
Out.println (rs.getString ( "author") + "
");
)
%>
OK!!
5. Test:
Test Site downloaded from the directory structure TestPage Add tomcat the webapps directory in the browser, type:
Http://127.0.0.1:8080/TestPage/page.do
Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( "CommentXMLStore"); document . getElementById (ElementID). CommentsPersistDiv.getAttribute value = ( "CommentContent");) </ td> </ tr> <tr>
↑ Back
Three-dimensional mapping procedures source Bingtu
Abstract: The three-dimensional mapping procedures source Bingtu
</ Td> </ tr> <tr> <td width="528" height="35" valign="top" class="ArticleTeitle"> / / program name: pie-shaped map ↑ Back Abstract: Hanoi Tower animation demo source </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td width="255" height="86" align="center" valign="top"> </ td> <td width="429" valign="top"> Hanoi Tower Yuanyou from ancient India, the legend is a temple, which is the centre of the universe. Placed in a temple above inserted three long peg with the wood, in which a peg, top-down of the 64 have been placed in ascending from the diameter circular metal sheets. Ancient Hindu god instructed its 64 monks will go to the metal in the three peg on which one. During each of the provisions in the mobile, can only remove a metal piece, and in the process must be maintained pieces of metal from the top diameter is ascending order, in other words, regardless of which one peg, the circular Metal films are smaller in diameter was placed on top. Until one day, monks can be 64 to the metal in accordance with the rules specified peg from the root of all mobile peg to another, then, that subsequent to the end of the world, and all the world will eventually be destroyed, everything are approaching the World of Ultimate Bliss. </ Td> </ tr> <tr> <td height="20" colspan="2">
</ Td> </ tr> </ table>
Procedures diagram: Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( "CommentXMLStore"); document . getElementById (ElementID). CommentsPersistDiv.getAttribute value = ( "CommentContent");) </ td> </ tr> <tr>
↑ Back Abstract: The source of AbstractList </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td width="457" height="86" align="center" valign="top">
List AbstractList to provide a framework to achieve, which the statement is as follows: Public boolean add (Object o) ( Abstract public Object get (int index); Public Object set (int index, Object element) ( Public void add (int index, Object element) ( Public Object remove (int index) ( Public int indexOf (Object o) ( Public int lastIndexOf (Object o) ( </ Td> <td width="227" valign="top"> </ td> </ tr> <tr> <td height="20" colspan="2">
</ Td> </ tr> </ table>
xmlns:dc=”http://purl.org/dc/elements/1.1/” xmlns:trackback=”http://madskills.com/public/xml/rss/module/trackback/”> rdf:about=”http://blog.csdn.net/treeroot/archive/2004/09/14/104743.aspx” dc:identifier=”http://blog.csdn.net/treeroot/archive/2004/09/14/104743.aspx” dc:title=”AbstractListæºç 分枔 trackback:ping=”http://tb.blog.csdn.net/TrackBack.aspx?PostId=104743″ /> This method is almost the same as above, but from the front after facing only to find, is an index to find the maximum. Public void clear () ( Public boolean addAll (int index, Collection c) ( Public Iterator iterator () ( Public ListIterator listIterator () ( Public ListIterator listIterator (final int index) ( Following is the definition of Itr: Private internal category Int lastRet = -1; Int expectedModCount = modCount; Public boolean hasNext () ( Public Object next () ( Public void remove () ( Final void checkForComodification () ( Following is the definition of ListItr: Internal private category Public boolean hasPrevious () ( Public Object previous () ( Public int nextIndex () ( Public int previousIndex () ( Public void set (Object o) ( Public void add (Object o) ( Back to the method AbstractList Public boolean equals (Object o) ( ListIterator e1 = listIterator (); Public int hashCode () ( Protected void removeRange (int fromIndex, int toIndex) ( Protected transient int modCount = 0; AbstractList the end of the content, but we also used two categories: RandomAccessList and SubList. SubList (AbstractList list, int fromIndex, int toIndex) ( Public Object set (int index, Object element) ( Public Object get (int index) ( Public int size () ( Public void add (int index, Object element) ( Public Object remove (int index) ( Protected void removeRange (int fromIndex, int toIndex) ( Public boolean addAll (Collection c) ( Public boolean addAll (int index, Collection c) ( CheckForComodification (); Public Iterator iterator () ( Public ListIterator listIterator (final int index) ( Return new ListIterator () ( Public List subList (int fromIndex, int toIndex) ( Private void rangeCheck (int index) ( Private void checkForComodification () ( Finally, there is RandomAccessSubList Public List subList (int fromIndex, int toIndex) ( Analysis here is the realization of this type, there is no evaluation of this class design is good or bad, but I hate nested class is more (especially nested class can call the method category external), the return of another SubList is a view, rather than a fully independent List, so in the end好ä¸well? Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=104743 </ Td> </ tr> <tr>
↑ Back Abstract: Quanbing Chinese characters into the JAVA program source code. </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td height="86" colspan="2" align="center" valign="top">
Quanbing Chinese characters into the JAVA program source code. Below is the chart:
/ / Process type: JAVA APPLET
/ / File types: template file, HTML driven by the data for simulation data
/ / The original document: CakeChart.java
/ / Procedures version: 1.5
/ / Program Design: Yang Yong
/ / Date: update-3-13
Import java.awt .*;
Import javax.swing .*;
Import java.awt.event .*;
Import java.math .*;
Import java.util .*;
Import java.awt.geom.Arc2D;
Import java.awt.geom .*;
Import java.awt.Polygon;
Import java.util.Date;
Import java.applet .*;
Public class CakeChart extends Applet (
/ / Initial data
Private double data [] = (100., 50113., 127., 299.234,120., 93., 123., 127., 199., 157., 189.);
Private String percent [] = new String [data.length]; / / percentage of each data
Private int radian [] = new int [data.length]; / / data corresponding to each of the arc
Private double max, min;
/ / Initialize the color of each piece of the pie
Private int dia = 240; / / transparency settings Bingtu
Private Color c1 = new Color (0,255,0, dia);
Private Color c2 = new Color (255,255,0, dia);
Private Color c3 = new Color (255,0,0, dia);
Private Color c4 = new Color (255,128,64, dia);
Private Color c5 = new Color (255,128,255, dia);
Private Color c6 = new Color (255,0,128, dia);
Private Color c7 = new Color (233,124,24, dia);
Private Color c8 = new Color (204,119,115, dia);
Private Color c9 = new Color (89,159,230, dia);
Private Color c10 = new Color (148,140,179, dia);
Private Color c11 = new Color (128,0,64, dia);
Private Color c12 = new Color (174,197,208, dia);
Private Color colors [] = (c1, c2 and c3, c12 and c11, c6, c4, c8, c9, c10, c5, c7);
/ / Figures on the width and height
Private int width = 600;
Private int height = 400;
/ / Definition of variables heading initial coordinates
Private int titleStart_x;
Private int titleStart_y;
/ / Definition center coordinates
Private int oval_x = 60;
Private int oval_y = 90;
/ / Definition of the long axis and short axis of the ellipse
Private int long_axes = 280;
Private int short_axes = 200;
/ / Define the starting point coordinate regional Legend
Private int cutlineRect_x = 70;
Private int cutlineRect_y = 450;
/ / Definition of the regional map inverted rectangle the width and height
Private int cutlineRect_width = 100;
Private int cutlineRect_heigth = 235;
/ / Date variable definition
Private Date date = new Date ();
/ / Definition of the other charts show only the information super-coordinates
Private int otherInfo_x1;
Private int otherInfo_y1;
Private int otherInfo_x2;
Private int otherInfo_y2;
Private int otherInfo_x3;
Private int otherInfo_y3;
/ / Definition of the title \ X \ Y-axis information
Private String title = "server traffic statistics (pie-charts)";
Private String otherInfo1 = "Southwest China Normal University Network Education Institute";
Private String otherInfo2 = "www.eduwest.com";
Private String otherInfo3 = "Drawing Date:";
/ / Double buffer settings
Private Image offScreenImage = null;
Private Graphics offScreenBuffer = null;
Public CakeChart () ()
Public void init () (
OffScreenImage = this.createImage (width, height);
OffScreenBuffer = offScreenImage.getGraphics ();
NumberBudget ();
CoorBudget ();
)
Public void NumberBudget () (
/ / Data for the maximum and minimum
Max = data [0];
Min = data [0];
For (int mm = 0; mm
Max = data [mm];
If (data [mm]
)
/ / Operational data Summation
Float allData_sum = 0;
For (int s = 0; s
)
/ / Calculated for each percentage of the total number of data
For (int p = 0; p
)
/ / Data of each of the corresponding arc
For (int r = 0; r
)
)
Public void CoorBudget () (
/ / Start budget heading coordinates information
TitleStart_x = 22;
TitleStart_y = (width / 2) - (title.length () * 15 / 2);
/ / Initialization Figures on the initial display information other coordinates (fixed position)
OtherInfo_x1 = 390;
OtherInfo_y1 = 450;
OtherInfo_x2 = 400;
OtherInfo_y2 = 480;
OtherInfo_x3 = 390;
OtherInfo_y3 = 5;
)
Public void update (Graphics g) (
Paint (g);
)
Public void paint (Graphics g) (
PaintBackground (offScreenBuffer);
PaintChart (offScreenBuffer);
G.drawImage (offScreenImage, 0, 0, this);
)
Public void PaintBackground (Graphics g) (
/ / Graded initial background color
Color BackStartColor = Color.white;
Color BackLastColor = new Color (162,189,230);
Color titleColor = Color.black;
Color otherInfoColor = new Color (41,78,118);
/ / Title background color
Color titleBackColor = new Color (147,179,225);
/ / Color Figures regional centres
Color cutlineColor = new Color (0,128,255,50);
/ / Legend color data
Color cutDataColor = Color.white;
Font titleFont = new Font ( "bold" Font.BOLD, 18);
Font otherFont = new Font ( "10 lines," Font.PLAIN, 12);
String year = "";
String month = "";
String day = "";
Graphics2D g2 = (Graphics2D) g;
RenderingHints hints = new RenderingHints (null);
Hints.put (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
G2.setRenderingHints (hints);
GradientPaint gradient = new GradientPaint (0,0, BackStartColor, 0400, BackLastColor, false);
G2.setPaint (gradient);
Rectangle2D rect = new Rectangle2D.Double (0,0, width, height);
G2.fill (rect);
/ / Draw heading background
G2.setColor (titleBackColor);
G2.fill3DRect (0,0, width, 30, true);
/ / Draw Legend regional context
G2.setColor (cutlineColor);
G2.fillRect (cutlineRect_y, cutlineRect_x, cutlineRect_width, cutlineRect_heigth);
G2.setColor (Color.white);
G2.drawRect (cutlineRect_y, cutlineRect_x, cutlineRect_width, cutlineRect_heigth);
/ / Draw charts Title
G2.setFont (titleFont);
G2.setColor (titleColor);
G2.drawString (title, titleStart_y, titleStart_x);
/ / Figures show other information
G2.setFont (otherFont);
G2.setColor (otherInfoColor);
G2.drawString (otherInfo1, otherInfo_y1, otherInfo_x1);
G2.drawString (otherInfo2, otherInfo_y2, otherInfo_x2);
G2.drawString (otherInfo3, otherInfo_y3, otherInfo_x3);
/ / Display Drawing Date
Integer.toString year = (1900 + date.getYear ());
Month = Integer.toString (date.getMonth () +1);
Day = Integer.toString (date.getDate ());
G2.drawString (year + "" + month + "," + + day "," otherInfo_y3 +60, otherInfo_x3);
/ / Display data Percentage
Int colorRectWH = 15;
Int space = 5; / / Legend of small and medium distance from the interval between color
Int addData = cutlineRect_x;
For (int i = 0; i
G2.fill3DRect (cutlineRect_y, addData, colorRectWH, colorRectWH, true);
If (data [i] == max | | data [i] == min)
G2.setColor (Color.red);
Else
G2.setColor (cutDataColor);
G2.drawString (String.valueOf (data [i]) + "(" + percent [i]
+")", CutlineRect_y +20, addData + colorRectWH-space);
AddData + + = colorRectWH space;
)
)
Public void PaintChart (Graphics g) (
Int start = 0;
Int rVal = 192;
Int gVal = 192;
Int bVal = 192;
Int frameCount = 60;
Graphics2D g2 = (Graphics2D) g;
RenderingHints hints = new RenderingHints (null);
Hints.put (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
G2.setRenderingHints (hints);
For (int t = 20, t> = 0, t -) (
* 255/frameCount rVal = t;
* 255/frameCount gVal = t;
* 255/frameCount bVal = t;
G2.setColor (new Color (rVal, gVal, bVal, 50));
G2.drawOval (oval_x, oval_y + t, long_axes, short_axes);
)
For (int a = 0; a
G2.setColor (colors [a]);
Arc.setFrame (oval_x, oval_y, long_axes, short_axes);
Arc.setAngleStart (start);
Arc.setAngleExtent (radian [a]);
G2.fill (arc);
If (data [a] == max | | data [a] == min)
G2.setColor (Color.white);
Else
G2.setColor (new Color (223,223,223,150));
G2.draw (arc);
Radian start + = [a];
)
)
)
</ Td> <td width="156" valign="top" class="ArticleTeitle">
</ Td> </ tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle">
Hanoi Tower animation demo source
Hanoi Tower animation demo source.
AbstractList source analysis
Public abstract class AbstractList extends AbstractCollection implements List
Below look at the way in this category
Add (size (), o);
Return true;
)
Directly call methods add (int index, Object o) at the end inserted into a data
The method of achieving
Throw new UnsupportedOperationException ();
)
The method unsupported
Throw new UnsupportedOperationException ();
)
The method is not supported, this is a direct impact on the above public boolean add (Object o) method.
Throw new UnsupportedOperationException ();
)
The method unsupported
ListIterator e = listIterator ();
If (o == null) (
While (e.hasNext ())
If (e.next () == null)
Return e.previousIndex ();
Else ()
While (e.hasNext ())
If (o.equals (e.next ()))
Return e.previousIndex ();
)
Return -1;
)
The method was designated in the list of elements in the index, positive search and find is a minimum.
It will not return to the 1, the situation will not traverse the entire list.
ListIterator ListIterator e = (size ());
If (o == null) (
While (e.hasPrevious ())
If (e.previous () == null)
Return e.nextIndex ();
Else ()
While (e.hasPrevious ())
If (o.equals (e.previous ()))
Return e.nextIndex ();
)
Return -1;
)
RemoveRange (0, size ());
)
Clearly between the two indexing all the elements, including the beginning, not including the end, see removeRange methods.
Boolean modified = false;
Iterator e = c.iterator ();
While (e.hasNext ()) (
Add (index + +, e.next ());
Modified = true;
)
Return modified;
)
This method calls through the cycle add methods to achieve, because each method call add the following elements must complete the shift, a mobile needs
C.size (), and relatively low efficiency. Sub-category will generally cover this method.
Return new Itr ();
)
There is a category within Itr, see the following definition.
Return listIterator (0);
)
Back to the default list iteration, starting position in the forefront.
If (index <0 | | index> size ())
Throw new IndexOutOfBoundsException ( "Index:" + index);
Return new ListItr (index);
)
Check cross-border, also has an internal ListItr category, see the following definition.
The Iterator interface: http://blog.csdn.net/treeroot/archive/2004/09/11/101589.aspx
Private class Itr implements Iterator (
Int cursor = 0;
Records of the cursor position
Last call next () or previous () Index, in fact no definition of previous Iterator ().
Revised record number in AbstractList modCount defined in the List for structural change in the number of words.
Here to visit the Iterator ListIterotor List, and a concurrent visit, we discussed this issue back again.
Return cursor! = Size ();
)
If the cursor does not mean that the current set of size (0 to less certain size () -1 of a value) that are under a value.
Size () is the method of AbstractList.
Try (
Object next = get (cursor);
CheckForComodification ();
LastRet = cursor + +;
Return next;
) Catch (IndexOutOfBoundsException e) (
CheckForComodification ();
Throw new NoSuchElementException ();
)
)
Comparison of hate here is a call AbstractList get in the way (int index), where a system to capture anomalies (which may not capture the abnormal) IndexOutOfBoundsException. In any case first made the visit with abnormal ConcurrentModificationException
(If any). Under normal circumstances the current cursor and the last visit have been added to an index.
If (lastRet == -1)
Throw new IllegalStateException ();
CheckForComodification ();
Try (
AbstractList.this.remove (lastRet);
If (lastRet <cursor)
Cursor -;
LastRet = -1;
ExpectedModCount = modCount;
) Catch (IndexOutOfBoundsException e) (
Throw new ConcurrentModificationException ();
)
)
If last visit index is 1 (Iterator has just been such that when the time), dished out IllegalStateException anomaly.
Otherwise the deletion of the elements, if the elements in the current cursor before the cursor value to advancement. Iterator change because it is the structure of the List,
Here, we must amend expertedModCount value. If the deletion of time here when cross-border, it is revising the other places in the List,
So dished out to visit with abnormal. NOTE: To set up here to lastRet -1, and at this time can not call ListIterator remove the add, set the method.
If (modCount! = ExpectedModCount)
Throw new ConcurrentModificationException ();
)
)
If the two local record number of amendments are not the same, that there are other places in revising the List.
)
The ListIterator Interface: http://blog.csdn.net/treeroot/archive/2004/09/14/104608.aspx
Private class ListItr extends Itr implements ListIterator (
ListItr (int index) (
Cursor = index;
)
Constructor function, initialize the current cursor position.
Return cursor! = 0;
)
0 current cursor that is not in front element.
Try (
Int i = cursor - 1;
Object previous = get (i);
CheckForComodification ();
LastRet = cursor = i;
Return previous;
) Catch (IndexOutOfBoundsException e) (
CheckForComodification ();
Throw new NoSuchElementException ();
)
)
Back to the current cursor before an element of the cursor and the last visit index has changed, the reference concurrency control Itr
Return cursor;
)
Under an element of the same index and the current cursor.
Return cursor-1;
)
Needless to say
If (lastRet == -1)
Throw new IllegalStateException ();
CheckForComodification ();
Try (
AbstractList.this.set (lastRet, o);
ExpectedModCount = modCount;
) Catch (IndexOutOfBoundsException e) (
Throw new ConcurrentModificationException ();
)
)
Calling the set of external, concurrency control in reference Itr remove an explanation of the methodology.
CheckForComodification ();
Try (
AbstractList.this.add (cursor + + o);
LastRet = -1;
ExpectedModCount = modCount;
) Catch (IndexOutOfBoundsException e) (
Throw new ConcurrentModificationException ();
)
)
Itr remove reference in an explanation of the methodology.
)
Public List subList (int fromIndex, int toIndex) (
Return (this instanceof RandomAccess?
New RandomAccessSubList (this, fromIndex, toIndex):
New SubList (this, fromIndex, toIndex));
)
If the List has RandomAccess interface, a new return RandomAccessSubList example,
Otherwise return a SubList example, the two categories defined in the back.
If (o == this)
Return true;
If (! (O instanceof List))
Return false;
ListIterator e2 = ((List) o). ListIterator ();
While (e1.hasNext () & & e2.hasNext ()) (
Object o1 = e1.next ();
Object o2 = e2.next ();
If (! (O1 == null? O2 == null: o1.equals (o2)))
Return false;
)
Return! (E1.hasNext () | | e2.hasNext ());
)
Comparison of this method is simple and traverse through the list to compare the two, only two elements of the list, as well as the same sequence is exactly the same as before.
Int hashCode = 1;
Iterator i = iterator ();
While (i.hasNext ()) (
Object obj = i.next ();
HashCode hashCode * = 31 + (obj == null? 0: obj.hashCode ());
)
Return hashCode;
)
This method can be fully guaranteed: List equal to two hashCode also their equal.
ListIterator it = listIterator (fromIndex);
For (int i = 0, n = toIndex-fromIndex; i
It.remove ();
)
)
Adopted here iterators to delete the specified elements, and iterators remove method is called, so the efficiency of this method is not high.
Fenwick said that the revision of the List was the number of concurrent purpose is to control access.
SubList look at the definition:
(Class SubList extends AbstractList
Private AbstractList l;
Private int offset;
Private int size;
Private int expectedModCount;
If (fromIndex <0)
Throw new IndexOutOfBoundsException ( "fromIndex =" + fromIndex);
If (toIndex> list.size ())
Throw new IndexOutOfBoundsException ( "toIndex =" + toIndex);
If (fromIndex> toIndex)
Throw new IllegalArgumentException ( "fromIndex (" + + fromIndex
")> ToIndex (" + + ")"); toIndex
L = list;
Offset = fromIndex;
Size = toIndex - fromIndex;
ExpectedModCount = l.modCount;
)
RangeCheck (index);
CheckForComodification ();
Return l.set (index + offset, element);
)
RangeCheck (index);
CheckForComodification ();
Return l.get (index + offset);
)
CheckForComodification ();
Return size;
)
If (index <0 | | index> size)
Throw new IndexOutOfBoundsException ();
CheckForComodification ();
L.add (index + offset, element);
ExpectedModCount = l.modCount;
Size + +;
ModCount + +;
)
RangeCheck (index);
CheckForComodification ();
Object result = l.remove (index + offset);
ExpectedModCount = l.modCount;
Size -;
ModCount + +;
Return result;
)
CheckForComodification ();
L.removeRange (fromIndex + offset, toIndex + offset);
ExpectedModCount = l.modCount;
Size -= (toIndex-fromIndex);
ModCount + +;
)
Return addAll (size, c);
)
If (index <0 | | index> size)
Throw new IndexOutOfBoundsException (
"Index:" + index + ", Size:" + size);
Int cSize = c.size ();
If (cSize == 0)
Return false;
L.addAll (offset + index, c);
ExpectedModCount = l.modCount;
Size + = cSize;
ModCount + +;
Return true;
)
Return listIterator ();
)
CheckForComodification ();
If (index <0 | | index> size)
Throw new IndexOutOfBoundsException (
"Index:" + index + ", Size:" + size);
Private ListIterator i = l.listIterator (index + offset);
Public boolean hasNext () (
Return nextIndex () <size;
)
Public Object next () (
If (hasNext ())
Return i.next ();
Else
Throw new NoSuchElementException ();
)
Public boolean hasPrevious () (
Return previousIndex ()> = 0;
)
Public Object previous () (
If (hasPrevious ())
Return i.previous ();
Else
Throw new NoSuchElementException ();
)
Public int nextIndex () (
Return i.nextIndex () - offset;
)
Public int previousIndex () (
Return i.previousIndex () - offset;
)
Public void remove () (
I.remove ();
ExpectedModCount = l.modCount;
Size -;
ModCount + +;
)
Public void set (Object o) (
I.set (o);
)
Public void add (Object o) (
I.add (o);
ExpectedModCount = l.modCount;
Size + +;
ModCount + +;
)
);
)
Return new SubList (this, fromIndex, toIndex);
)
If (index <0 | | index> = size)
Throw new IndexOutOfBoundsException ( "Index:" + + index
"Size:" + size);
)
If (l.modCount! = ExpectedModCount)
Throw new ConcurrentModificationException ();
)
)
This class inheritance AbstractList basically well understood, but there are several major needs:
1. Attention l.modCount, modCount, expectedModCount difference between modCount is inherited domain SubList
ExpectedModCount SubList is to prevent the visit with the new Canadian domain l.modCount certainly understandable.
2.public ListIterator listIterator (final int index) method used an anonymous category.
3. Attention SubList only one of the constructor function requires three parameters belt, but only a SubList view, modify SubList
It is amended in the list of parameters.
Class RandomAccessSubList extends SubList implements RandomAccess (
RandomAccessSubList (AbstractList list, int fromIndex, int toIndex) (
Super (list, fromIndex, toIndex);
)
Return new RandomAccessSubList (this, fromIndex, toIndex);
)
)
This class is not something, but is not the same type and SubList it (because one more RandomAccess interface).
Quanbing Chinese characters into the JAVA program source code.
</ Td> </ tr> <tr> <td width="205" height="20" valign="top">
</ Td> <td width="479" height="20">
Download:
Flights enquiries and the counting procedures source 2006-01-13
JAVA version of Lightning Source 2006-01-12
Fireworks procedures 2006-01-10
An RSS parser source 2006-01-09
Guestbook board 2006-01-08
Iraqi tanks java pirated 2006-01-07
Gobang another procedure 2006-01-06
Call eclipse 2006-01-03
Gobang games online source 2006-01-03
Using Java to achieve Fractal procedures 2006-01-02
24 games magical source 2006-01-02
Jsp2.0 expression language learning materials 2005-12-31
'Storm' book v1.0 jsp version 2005-12-30
Shengjie JSP message boards source 2005-12-30
Versus network of international chess source 2005-12-29
CNDS community java magazine Phase II: J2SE 5.0 new features fine of 2005-12-28
C / S structure of the examination system source 2005-12-27
A library management procedures 2005-12-23
Also a spider games 2005-12-17
Gobang game 2006-09-26
Java examination procedures 2005-12-12
Applet piano simulation program 2005-12-10
An English typing procedures 2005-12-03
Java programming radio, multiple-choice, fill in the blank, judge Exercise 2005-12-02
Grasping HTTP header information tools ieHTTPHeader 2005-11-30
A simple voting procedures 2005-11-29
Shithead poker game source 2005-11-24
Scjp three sets of simulated test 2005-11-24
Simple calculator source 2005-11-22
Upload a document JSF components 2005-11-21
Hanoi Tower animation demo source 2005-11-20
Java examination title and answer a set of 2005-11-19
Jsp entry Example: good-electronic bookstore 2005-11-19
Java based exercises, tests that nine 2005-11-18
Ergo 0.93 Go-client source 2005-11-17
Basic knowledge of java Exercises and answers a set of 2005-11-16
Simulation tests that java and answer three sets of 2005-11-15
Picture for the Games can be 2005-11-15
Russian box online 2005-11-15
Java "program design basis" Exercises and answer three sets of 2005-11-14
Playing a chess spectrum procedures 2005-11-13
Jsf a paging component 2005-11-10
Web Form Password crackers 2005-11-06
A simple web browser source 2005-11-06
In Java made an issue of the Notes 2005-11-05
Sun SCJP certification exam Simulator Whizlabs SCJP 1.4 2005-10-31
Eat beans games 2005-10-28
Web traffic statistics with IP 2005-10-23
Zhang Jian's Lianliankan game 2005-10-21
Spider Solitaire games 2005-10-20
Java Rubik's cube 2005-10-19
Jsf study examples 2005-10-13
Another Lianliankan procedures 2005-10-06
Chinese chess Java version V3.0 2005-10-06
Jaoso news articles Publishing System 0.9.1 final 2005-10-02
SUN JAVA training materials SCJP examinations for Chinese edition of the book 2005-09-28
Database-based mail system 2005-09-22
Throwing eggs game 2005-09-17
JSTL entry marked with the core 2005-09-07 Introduction
24 points poker game 2005-09-05
MVC-based framework prepared by the minesweeper game 2005-08-21
Jsp a counter 2005-08-21
Java object persistence technology Hibernate 2005-08-21
Spring Framework development of a reference manual version 1.1 2005-08-21
FCKEditor 2.0b2 - JSP version of online html editor 2005-08-21
EWebEditor online text editor Exocet modified version 2005-08-21
Spring Gossip v0.4 2005-08-21
Java source 2005-08-31 achieve Lianliankan </ td> </ tr> </ table>
</ Td> </ tr> <tr>
↑ Back
Java prepared by the simple download manager (with source code)
Abstract: java prepared by the simple download manager (with source code)
</ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> simple download tools, GUI interface, it can download more than one file, and report downloaded bytes few, download progress and completion percentage download status. Xuchuan breakpoint support, to suspend, resume, cancel the download tasks.
This source of four documents: Download.java, DownloadManager.java, DownloadsTableModel.java, ProgressRenderer.java.
Commencement of the proceedings:
C: \ ja> javac *. java
C: \ ja> java DownloadManager
<table Width="731" border="0"> <tr> <td> </ td> </ tr> </ table>
Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( "CommentXMLStore"); document . getElementById (ElementID). CommentsPersistDiv.getAttribute value = ( "CommentContent");) </ td> </ tr> <tr>
↑ Back