Chapter 11. Collections and Regular Expressions

   

This chapter introduces a set of interfaces in the API known as Collections. The java.util.Collections interfaces and classes are meant to be implemented in situations requiring logically related sets of name -value pairs. In this chapter we will overview Collections and discuss the most popular and useful of them by turn .

It is easy to determine when and why you would want to implement a collection in Java: When you find yourself wishing you had a ColdFusion structure or a list, then use one of the collections. Collections are more complex than ColdFusion structures and lists, however. That is, Cold-Fusion defines only one type of thing for holding name-value pairs: the structure. There are many different kinds of Java collections, including Hashmaps, Linked Lists, Vectors, Maps, Hashtables, and so on. These are all very similar, but have slight variations, and some collections are better suited for certain situations than others. Also, some of the collections are regular classes, and some are interfaces, and must be implemented as such. If you need a refresher on interfaces, refer back to Chapter 9.

Having discussed Collections, we will look briefly at an interesting aspect of Java: preferences. The Preferences API, new with Java 1.4, provides a simple way to store primitive data preferences that persist over time. You might think of them as a combination of ColdFusion's Session and Application scopes. Their job is to store data for change notification, user preferences, or application settings. Since writing this kind of thing is such a frequent part of a developer's life, it is nice to have such a structure put together for us.

We finish up with a quick look at how you can use regular expressions in Java to perform pattern matching on objects.

We begin this chapter with synchronization. Not only is it important in its own right, but it is difficult to say much about Collections without running into it. This chapter unlocks the secrets of Java synchronization by way of a key concept in ColdFusion.


   
Top


Java for ColdFusion Developers
Java for ColdFusion Developers
ISBN: 0130461806
EAN: 2147483647
Year: 2005
Pages: 206
Authors: Eben Hewitt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net