Overload and the distinction Override
Overload and the distinction Override
Rewriting Override is father and son type of performance between a polymorphism, is a heavy-duty category Overload polymorphism of a performance.
In the Java language specification, a method of characteristics include only the names of methods, the number and types of parameters, but not the return type, name and dished out the parameters of the abnormal. Java compiler test for heavy-duty Overload will be judged according to these conditions Heavy whether the two methods.
But in the Java compiler checks method of rewriting, will be further examined two of the return type and dished out whether the same anomaly.
Posted on 2007-06-16 15:31 itkui reading (112) Comments (0) edit their collections quoted Category: J2SE related
Filter limit users to use authority
Filter limit users to use authority
In a system usually has multiple user permissions. Different permissions users can browse different pages. Filter use to judge not only save of the code, but if we only need to change it in the document Filter can be motivated.
Filter paper is the following code:
Package cn.itkui.filter;
Import java.io.IOException;
Import javax.servlet.Filter;
Import javax.servlet.FilterChain;
Import javax.servlet.FilterConfig;
Import javax.servlet.ServletException;
Import javax.servlet.ServletRequest;
Import javax.servlet.ServletResponse;
Import javax.servlet.http.HttpServletRequest;
Public class RightFilter implements Filter
Public void destroy ()
)
Public void doFilter (ServletRequest sreq, ServletResponse sres, FilterChain arg2) throws IOException, ServletException / / get uri Address
HttpServletRequest request = (HttpServletRequest) sreq;
String uri = request.getRequestURI ();
String ctx = request.getContextPath ();
Uri = uri.substring (ctx.length ());
/ / Admin-level judgement page views competence
If (uri.startsWith ( "/ admin")) if (request.getSession (). GetAttribute ( "admin") == null) request.setAttribute ( "message", "You do not have the authority");
Request.getRequestDispatcher ( "/ login.jsp"). Forward (sreq, sres);
Return;
)
)
/ / Judgement manage Web browser-level competence
If (uri.startsWith ( "/ manage")) / / omitted here
)
)
/ / Below can also add other user rights to save.
)
Public void init (FilterConfig arg0) throws ServletException
)
)
Following is the code needs to join the web.xml
<! - Determine access pages ->
<filter>
<filter-name> RightFilter </ filter-name>
<filter-class> Cn.itkui.filter.RightFilter </ filter-class>
</ Filter>
<filter-mapping>
<filter-name> RightFilter </ filter-name>
<url-pattern> / Admin / * </ url-pattern>
</ Filter-mapping>
<filter-mapping>
<filter-name> RightFilter </ filter-name>
<url-pattern> / Manage / * </ url-pattern>
</ Filter-mapping>
Posted on 2007-07-18 17:35 itkui reading (996) Comments (10) edit their collections quoted Category: Struts
Open-source object-oriented database db4o Tour (2)
At the same time, db4o is a feature of the management of the need DBA, occupied a very small resources, it is suitable for embedded applications, as well as Cache applications, it has since released db4o quickly attracted a large number of users will be db4o used in a variety of embedded systems , including mobile software, medical equipment and real-time control systems.
Db4o from Silicon Valley, California open-source database company db4objects responsible for the development and commercial operations and support. Db4o is based on the GPL. Db4objects in 2004, the CEO Christof Wittig, under the leadership of composition, funding background includes Mark Leslie, Veritas software company CEO, Vinod Khosla (Sun one of the founders of the company), Sun CEO of the Silicon Valley, composed of senior investment. There is no doubt that today db4objects hottest companies in Silicon Valley and one of the technological innovation.
Db4o Characteristics
Db4o objective is to provide a powerful, suitable for embedded database engine can work in the equipment, and mobile products, such as desktop and server platforms. Main features are as follows:
* The open-source model. And other ODBMS different db4o for open-source software, by the strength of the open source community-driven development db4o products.
* Original database. Db4o is 100% of the original object-oriented database programming language used to directly operate the database. OR mapping the need for programmers to store objects, saving programmers in the development of data storage time.
* High-performance. Figure 2 for the official announcement db4o benchmarking data, db4o than a Hibernate / MySQL test programme in some lines as much as 44 times higher than the speed! Installation is simple and only needs about 400Kb. Jar or. Dll library files. In the next series of articles, we will be only concerned with the application of the Java platform, but actually db4o will undoubtedly good. NET platform work.
Figure 2. Db4o official benchmark data
Open-source object-oriented database db4o trip: Acquaint db4o (Figure 2) 
* ECO embedded. Db4o use only the introduction of more than 400 k jar files or dll file, minimal memory consumption.
* Zero management. Db4o without the use of DBA, zero management.
* Support for multiple platforms. Db4o Java support from 1.1 to Java 5.0, in addition to support. NET, CompactFramework, such as Mono. NET platform, but also can run in the CDC, PersonalProfile, Symbian, and the Zaurus Savaje reflection of that support J2ME dialect environment, but also in the running CLDC, MIDP, RIM / Blackberry, Palm OS does not support this reflection J2ME environment.
Perhaps developers will be asked if the existing application environment has been a relational database how do? It does not matter, the dRS db4o (db4o Replication System) can be realized db4o relational database with a two-way synchronization (reproduction), in Figure 3. DRS is based on Hibernate development, the current version is 1.0, and running on the Java platform version 1.2 or higher, can be realized based on dRS db4o to Hibernate / RDBMS, db4o to db4o and Hibernate / RDBMS to Hibernate / RDBMS two-way replication. DRS model in Figure 3
Figure 3. DRS model of open source object-oriented database db4o trip: Acquaint db4o (Figure 3) 
Conclusion
Db4o because of its open-source philosophy, as well as the realization of innovation, access to the Java Pro 2006 Readers Choice Award. Whether or db4o from a successful case itself, this pure object-oriented databases are worthy of our attention, feedback from the official forum, a considerable users preparing to move to relational database db4o. And the latest release of version 5.5, has even more made many performance upgrade again. In the next article, I will continue to share with you db4o has brought us this object-oriented database turmoil.
About the author
Rosen Jiang from Chengdu, and OO db4o is the loyal fans, db4o is the 2005 winner of one of dvp. He is J2me applications using db4o, and you can contact him through rosener_722@hotmail.com.
Zhang Huang Zhu, love open-source software, and is familiar with Java / C / C + + programming language, database technology are interested in network technology. You can contact him through zhanghuangzhu@gmail.com.
Chris from Hong Kong, love and open source db4o. He founded the China's most fervent Java and the open-source community Matrix (http://www.Matrix.org.cn), and you can contact him through chris@Matrix.org.cn.
Successful domain name registration
Successful domain name registration
Starting from today, I have a domain name of their own.
Http://www.itkui.cn/
Http://itkui.cn/
Jump are two of this URL.
Hereby commemorate wrote.
Posted on 2007-07-06 13:37 itkui Reading (53) Comments (3) edit collections cited
Dynamic binding and Static Binding
Dynamic binding and Static Binding
Java bundled in two forms-static binding Static Binding (early binding early-binding) dynamic binding dynamic-binding (late-night bonding binding, or runtime binding runtime-binding)
Static Binding is binding at compile-time, and dynamic run-time binding in accordance with the actual situation of targets to choose bundled father of a certain category or categories of the method. In the implementation of efficiency, Static Binding is superior dynamic binding, but the loss of flexibility.
Variables in Java is a dynamic binding, is an example of the dynamic binding. In the "progressive transformation" of sub-categories will be covered Father instance of the class will cover methods and the father of variables.
Posted on 2007-07-07 14:57 itkui reading (106) Comments (1) edit their collections quoted Category: J2SE related
Impletringearch preliminary study
SimpleStringSearch preliminary study by lostfire
Today was originally the station will be a replacement procedure, I think of a couple of days ago to see SimpleStringSearch, read about, the station's results made no replacement procedures, the study of this.
I used dox made a chm documents (Download), but look at that document is of no use. I do not know because the data structure, the original has not been related aspects.
So I modified the source code to print the information to finally clear his data organization.
First look at the kind of inheritance, the data structure is important, the search tree structure. SearchTreeNode which is the interface, AbstractSearchTreeNode is below the succession of abstract categories, including the realization of specific ExactSearchTreeNode, SingleWildcardSearchTreeNode and WildcardSearchTreeNode.
To the members of the variables stored in the data storage AbstractSearchTreeNode Therefore, I add a print code, but also on the AbstractSearchTreeNode in.
? 1public? String? ToString ()???????? StringBuffer? Buffer? =? New? StringBuffer ();
? 3 ????????
? 4 ???????? buffer.append ( "Depth:" + depth + "\ t");
? 5 ???????? buffer.append ( "Children? Num:" + children.size ());
? 6 ???????? buffer.append ( "\ t" + "Character:" character + + "\ n");
? 7 ???????? depth + +;
? 8 ???????? for (int? I = 0?;? I <children.size ();? I ++)???????????? SearchTreeNode? Stn? =? Children . get (i);
10 ???????????? buffer.append (stn.toString ());
11 ????????}
12 ???????? depth -;
13 ???????? return? Buffer.toString ();
14 ????} depth is a record level of static int variable.
Below are the test code:
? 1public? Static? Void? Main (String []? Args )????????????? try ???????????????????? StringSearch ? s? =? new? StringSearch ();
? 4 ???????????????????? MyHitHandler? Handler? =? New? MyHitHandler ();???????????????? ?
? 5 ???????????????????? s.addSearchTerm ( "do", the handler );???????????????? ?
? 6 ???????????????????? s.addSearchTerm ( "Java", the handler);
? 7 ???????????????????? s.addSearchTerm ( "ava," handler);
? 8 ???????????????????? s.addSearchTerm ( "da", the handler);
? 9 ???????????????????? System.out.println (s.getRoot (). To2String ());
10 //???????????????????? s.getRoot (). PrintString ();
11 ???????????????????? s.search ( "Do,? Or? Do? Not.? Except? In? Java .?–? Yoda");
12 ???????????????????? System.out.println ( "Count? Is :?"?+? handler.getCount ());
13 ????????????}
14 ???????????? catch (IOException? Ex )???????????????????? ex.printStackTrace ();
16 ????????????}
17 ????}
Several prompting StringSearch inside this after following the formation of a binary tree.
?
Here we can see very clearly.
In the root below, no sort, and beneath each node, according to the search string order of binary search trees, it is not a standard binary search tree, but the order related characters retrieval.
Posted on 2006-06-04 02:20 lostfire reading (908) Comments (0) edit their collections quoted Category: other
Hibernate O / R mapping of the foundation
Hibernate (hereinafter referred to hiber) for the first study was completed. Learning process, summed up some experience and
Learning notes, special and share out of, as I am limited capacity and can not be proficient hiber, also requested the
- Identification and if found any mistakes, but also look generous advice, thank you to the Fuzheng.
Hiber of the process, I bought the book: "easy to hibernate," Xia Xin, Cao Xiaogang, of the Tang Yong, since
I feel good writing, the real easy to do. But I think the inadequacies of the few instances in actual combat poor. Need
To everyone to think of more ways to achieve some applications, the only way to truly experience the essence of which, to his own use.
Gangchachu hiber time, online learning how to find a postcard hiber article seriously for reading, keep in mind that the author can not be
In order to study the hiber learning, and should be a higher level to understand its meaning. Our article is also a jr
/ Article/24993.htm, when we can look at the study.
Hiber's main task is to achieve data persistence layer operation, and what persistence layer? Can be understood as: the level of the system logic
, The focus on achieving a lasting data of a relatively independent of the field. Hiber is to be accomplished by achieving in the field
Data manipulation, and this is not complete as long as the general realization of the ultimate goal of complete if completed, the performance of its pursuit of elimination
Consumption small coupling of small, data encapsulation, and so on-is it really sense the completion of the data persistence layer operation.
Hiber the basis of the allocation and use of this no longer speak, if you ready for a school is not your hiber these obstacles. Below I
Really belong to discuss some obstacles.
Hiber the o / r mapping
O: object, r: relational. Put together is the relationship between objects. Hiher itself and should be regarded as special java object-oriented
And the traditional relations of the contradiction between the product data. Also on the web and hiber based on the basic understanding, then o / r mapping undoubtedly
Orm framework has become the most critical element.
Or mapping in the study, we first on the basic data types hiber understand.
Below is the link http://hi.baidu.com/rufeizi/blog/item/243279f49db50dd9f2d385fb.html
Hiber java data types and the type of data comparison, we can look at.
Entities and mapping technology as a form of the link between the realization orm plays a vital role. With the hiber
Households, the mapping between more reflected in the configuration file maintenance process. Hiber chosen as its mapping xml configuration file
Since the benefits Needless to say, as long as the xml knowledge understand, we can understand this point.
We configuration o / r mapping, the first is
1. Class name and the mapping table,
2. Followed by the primary key mapping,
3. Finally field mapping.
A complete o / r mapping is the basis of the establishment of the existence of the database table, and then have a database table by table-type configuration media
Referral. Hbm.xml document. Finally write entity categories, namely from the database tables mapping out the java class.
I have here a complete o / r mapping, we can look at:
In accordance with the above steps, first of all, a database table:
CREATE TABLE `reg` (
`Id` int (6) unsigned NOT NULL auto_increment,
`Username` varchar (16) default NULL,
`Password` varchar (20) default NULL,
“ Int phone (11) default NULL,
“ Email varchar (30) default NULL,
“ Address varchar (50) default NULL,
`Sex` varchar (4) default NULL,
PRIMARY KEY ( `Id`)
) InnoDB DEFAULT CHARSET ENGINE = = gbk;
In the data table on the basis of the establishment. Hbm.xml documents:
<? Xml version = "1.0" encoding = "UTF-8">
<! DOCTYPE hibernate-mapping PUBLIC
"- / / Hibernate / Hibernate Mapping DTD 3.0 / / EN"
"Http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class Name="mypack.Customer" table="reg">
<comment> Users may bid for or sell auction items. </ Comment>
<Id name = "id"
Column = "id"
Type = "int">
<generator Class="native"/>
</ Id>
<Property name = "username"
Not-null = "true"
Column = "username"
Type = "string" />
<Property name = "password"
Not-null = "true"
Column = "password"
Type = "string"
/>
<Property name = "phone"
Not-null = "true"
Column = "phone"
Type = "string"
/>
<Property name = "email"
Not-null = "true"
Column = "email"
Type = "string"
/>
<Property name = "address"
Not-null = "true"
Column = "address"
Type = "string"
/>
<Property name = "sex"
Not-null = "true"
Column = "sex"
Type = "string"
/>
</ Class>
</ Hibernate-mapping>
Then established entities categories:
Package mypack;
Import java.io.Serializable;
Public class Customer implements Serializable (
Private int id;
Private String username;
Private String email;
Private String password;
Private String phone;
Private String sex;
Private String address;
Public Customer () ()
Public int getId () (
Return id;
)
Public void setId (int id) (
This.id = id;
)
Public String getUsername () (
Return this.username;
)
Public void setUsername (String username) (
This.username = username;
)
Public String getPassword () (
Return password;
)
Public void setPassword (String password) (
This.password = password;
)
Public String getPhone () (
Return this.phone;
)
Public void setPhone (String phone) (
This.phone = phone;
)
Public String getEmail () (
Return email;
)
Public void setEmail (String email) (
This.email = email;
)
Public String getAddress () (
Return this.address;
)
Public void setAddress (String address) (
This.address = address;
)
Public String getSex () (
Return this.sex;
)
Public void setSex (String sex) (
This.sex = sex;
)
)
<class Name="mypack.Customer" table="reg">
Below on this to be a document mapping analysis:
1. Category-table should be configured:
<class Name="mypack.Customer" table="reg">
Name designated mapping class names.
Table designated by the corresponding database table
2.id mapping configuration
<id Name="id" column="id" type="int">
<generator Class="native"/>
</ Id>
Name specified in the current mapping of the properties: id, the corresponding database table in the main table reg key fields
Column designated the current mapping table reg id for the unique identifier for this field.
Type designation of the current field data type
Generator designated a primary key generation, in the main on hiber bond formation mechanism of the relevant here, we can
To see: http://blog.csdn.net/watano_cc/archive/2006/02/28/612286.aspx
3. Attribute / database field mapping configuration:
<Property name = "address"
Not-null = "true"
Column = "address"
Type = "string" />
Believe that this would not have introduced the small phase? We look at to understand [:)]
Finally, we said that this path,
. Hbm.xml default on documents generated by the entities of the class where the paper package. Such a complete o / r mapping on the establishment of a fact, the crux of the problem is not operating itself, but rather whether the idea is clear, as long as a clear line of thinking, then others stated in accordance with the configuration methods, operation can definitely be successful.
A bit mean
A bit mean
Posted on 2005-12-21 16:45 YanJiang reading (124) Comments (1) edit collections cited
'' Zhuaizhai intanceof keyword in Java
'Java' Zhuaizhai keyword in the instanceof
Instanceof Java is a binary operator, and is the same type of ==,>,< Dongdong. Because it is composed of the letters, so reservations are Java keyword. Its role is to the left of testing whether it is its right of the instance of the class, returning to the boolean types of data. For example:
String s = "I AM an Object!";
Boolean isObject = s instanceof Object;
We declare a String object reference, point to a String object, and then use it at instancof to test whether the object is an instance of Object class, it is clear that this is true, so true return, which is the value of isObject True.
Instanceof some usefulness. For instance, we wrote an invoice processing system, including the following three categories:
Public class Bill (/ /) omitted details
Public class PhoneBill extends Bill (/ /) omitted details
Public class GasBill extends Bill (/ /) omitted details
In the process, there is a method to accept a Bill type of object, the amount of calculation. Two bills hypothetical calculation method different from that of imported Bill object may be in any of the two, so use instanceof to judge:
Public double calculate (Bill bill) (
If (bill instanceof PhoneBill) (
/ /) Calculated phone bills
If (bill instanceof GasBill) (
/ / Calculate gas bills)
…
)
This can be a way of dealing with two categories.
However, this practice is often think there is no good use of the object-oriented polymorphism. In fact, the functional requirements of the above methods can be achieved completely override, it is a proper object-oriented approach to avoid return to the structure of the programming model. As long as the two names and provide all the same return value, types of acceptable parameters can be different ways:
Public double calculate (PhoneBill bill) (
/ /) Calculated phone bills
Public double calculate (GasBill bill) (
/ / Calculate gas bills)
Therefore, the use instanceof in the vast majority of cases the practice is not recommended, should make good use of polymorphism.
Posted on 2007-06-16 21:24 itkui Reading (89) Comments (0) edit their collections quoted Category: J2SE related
OO What is the future?
According to technology from concept to prototype and then to products 5 - 5 - 5 rules, object-oriented technology is now moving towards maturity, it was time to consider what is the future OO. This has not yet appeared in the new technical standard time, everyone has the right to think, the following is my future on OO thinking.
OO after, what is it? I think it is FO - Function Oriented (for functions). Function different from us here in the current programming by using the function Function. Here Function module that functions. The so-called functional modules, is independent of specific tasks to complete, and the inability to complete the task of finding themselves with the completion of the tasks of other functional modules functions, and establish links with efforts to complete the work of the function body.
In explaining my reasons before the first to take a look at what we have experienced. We first experienced PO - process-oriented, then OO - Object-oriented. Why is such a process? Because it is becoming more and more a specific abstract process. People to more easily solve the problem, as far as possible, abstract always hope that the description of the problem and solve the problem, too-specific Sometimes people will feel very painful. In the process-oriented, our method is "produced what do what do what the final", which act like an adult means he knows every step of the doing it that the steps by Quan. In object-oriented, our method is "Regardless of how to achieve the target, we only know that it can do, how it Quan", it is like a child ways of doing things, he did not know how that thing is to the He only knows that things can be used to do it Quan and the use of the things he wanted to do. Whether they bench is how do? It can be used to sit on! More small child is how do? They do not even know that the bench can be used sitting. Very simple, "Mummy, I want to……" of his mother going to do or who to ask what help? Anyway, all mothers will be well, and her mother is a panacea.
And then take a look at our industrial production. Hand workshop is a beginning, a person from scratch to the end, and step by step to do, just like the OP. Then the machine of mass production, the machines made in the different parts, and then assembled them into one;-made parts only know that the role of a separate parts, but I do not know in the end it is used bike or aircraft; The assembly was not aware of the parts come from is, who is doing; This is like OO. What is the pattern now? The company received a business, then dispersed business entrusted to others do need the Legal Adviser to the law firm to a lawyer; needs planning, or public relations companies need to advertise to find advertising companies for the production of specialized manufacturing company; their companies need do is received business, the company can stem its own stem, and will be unable to stem their efficiency is not high dry part of the company to the specialized stem.
Function module is the "mother", the company is now. It can stem its own stem the task of the stem can not, it knows that there can be found capable of this task modules, and with the collaboration of common complete the work. Customers will issue to the software, software to complete A module contains functions procedures and submitted to the customer. Customer use of the procedure to solve the problem, it completed completed module A part of the part can not be completed by the A search can be completed automatically to the remaining part of the B, C, D, B, C, D, but also to find E, F, G , H…… feedback to return to a level A, from A-assemble into submission to the customers.
The above is adopted in other areas of the OO introduced after the FO, then in some areas of our computer what to support this idea? As we all know, in the computer field on the process had three formulas:
1, procedures + Data Structures = Algorithm
2, + = logic control procedures
3, procedures targets = (1, 2 object,……, object n) + Data Structures = Object methods
The first formula is the FO times, the third formula is the OO times. The third formula can be seen on the object and the definition of a formula in the process of the definition of similarity. In fact object of the proceedings prior to and indeed very similar, it is the lack of procedures for the control structure, whether or control programming framework programming, should be completed by the programmer to control structure. Now we can imagine, the data structure and method of combining objects, the next step to do? Of course, is to get control of. This is our function module, combines the control of the automatic and intelligent modules.
As we all know, Microsoft recently announced its. "Net" plan. Its future products will be on the local machine for basic functions, and will be more high-end functionality to Microsoft's server process requests from the server to complete. Although this is the client software to fixed address requests, not by their own modules and complete lack of intelligence, but we can still be regarded as a very primitive FO very primitive prototype.
FO need to realize what? Need high-speed intelligent network, intelligent interfaces, distributed, parallel technology, the most important is the need for an international regulatory body.
Why do we need these? Obviously, based on global-oriented functions of the Internet, which will inevitably use distributed technology. As we all know, distributed technology is the biggest problem of the large amount of information on the network transmission, which requires a high-speed Internet. Information on the network consumed time and parallel technology can make up for the return to space-time. Module functions to find their own requirements to help complete its mandate of the other modules, the current network can not be done this, and that is needed is an intelligent network. A module in collaboration with the needs of other modules, to its request to the network and updates on the search module, the module will search to find a number of the required function modules, the modules A to find himself the most Module B, in accordance with the interface requirements for B B sent the requested information; At the same time, B to be a good description of their functions, the exact make their own requests, and from A to the information sent from their own the information needed, which requires a Smart Intelligent Interface Module. Intelligent Module standard definition, a large number of registration module, the module information, the coordination of the use of modules, etc. need an international organization to manage.
What we are now to support these? Distributed Computing that will, of course, think of CORBA. In fact, the CORBA and module functions of this work is very similar way. Use function module, the module can work completed through the Internet to seek help from other modules. CORBA application is sent through the Smart Agent news, and through the smart agent to find the corresponding CORBA object to complete its work. However, CORBA Object interface is so determined, a lot of work is still controlled by the programmer completed. Functions of the interface module is ambiguous, intelligent, all controlled by their own modules to complete. Find module must pass high-speed intelligent network. - Is now increasingly becoming a problem. And the intelligent, by CISCO DEN-based company of intelligent network solutions to solve the problem of the people to see the dawn. The trouble is that the most intelligent interface, which requires extremely advanced artificial intelligence technology. Artificial neural network may be the way to solve the problem, but from all thoroughly solve the problem also too far off.
When everything is resolved, we have desktop applications will become so simple and so similar. They have different interfaces, but they have done the same: to accept orders, contact search module, will all have specific work to supply modules to provide the functions of modules Quan!
In the machine can understand natural language, the language in the work of the computer era orders will come naturally!