`
DavyJones2010
  • 浏览: 148274 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论
文章列表
Decorator Pattern   1) Motivation:     Extending an object's functionality can be done statically (at compile time) by using inherientence. However it might be necessary to extend an object's functionality dynamically(at runtime) as an object is used.       Consider the typical example of a gr ...
Primitive Types: 1) byte:     size: 8-Bit = 1-Byte     range: -128~+127     usage:         1> The byte data type can be useful for saving memory in large arrays, where memory saving actually matters.         2> They can also be used in place of int where their limits help to clearify yo ...
Composite Design Pattern 1) Motivation:         There are many times when a program need to manipulate a tree data structure and it is necessary to treat both Branches as well as Leaf Nodes uniformly.         Consider for example a program that manipulates a file system. A file system is a tree ...
1. Dependency:         A dependency is a weak relationship between two classes.         In this example, there is dependency between Point and LineSegment, because LineSegment's draw() operation uses the Point class.         It indicates that LineSegment has to know about Point, event if it has ...
1 Using Eclipse      1) Create project using archetype: maven-archetype-webapp       2) Update Build Path Using JDK-1.7 and Compiler Level to 1.7     3) Add "javax.servlet" dependency in pom.xml     4) Add "jetty" build into pom.xml for validation that web-project successful ...
1. In the following example, we will read data from multiple csv files and then write to Derby DB.     1) In order to read from multiple csv, we need "org.springframework.batch.item.file.MultiResourceItemReader" as reader.         And config flatFileReader for delegate which reading sin ...
1. Intro to Spring Batch     1) Spring Batch is a framework for Batch Processing - Execution of a series of Jobs.     2) Each "Job" contains many "Steps". And one "Step" can be a single "tasklet" or a "READ-PROCESS-WRITE" task.   2. An overview ...
1) DelayQueue class implements the BlockingQueue interface.     The DelayQueue keeps the elements internally until a certain delay has expired.     The elements must implement the interface java.util.concurrent.Delayed. public interface Delayed extends Comparable<Delayed> { long getDe ...
1. Problem Description:     When replacement contains "$", either IllegalArgumentException or StringIndexOutOfBoundsException will be thrown.     The reason is that replaceAll() is not simply character replacement, it uses regex as "placeholder expression".     And the charac ...
Synchronized & ReentrantLock   1) Basic Thread Operations     1) void notifyAll()         1> unblocks the threads that called wait on this object.         2> This method can only be called from within a synchronized method or block.         3> This method throws an IllegalMonit ...
1) Reader&Writer Problem Intro     1> Reader&Writer task may share a resource, say a DB.     2> Many Reader may access a DB without fear of data corruption.     3> Only one Writer may access a DB at a time.     Read Access: If no threads are writing, and no threads have acquired ...
1) BlockingQueue Intro      A queue is a data structure with two fundamental operations: to add an element to the tail of the queue and remove an element from the head.      That is, the queue follows FIFO(First In First Out) discipline.      A blocking queue is a queue that blocks when you try ...
1) Why would we use InnserClass?     1> Inner class methods can access the data from the scope in which they are defined - including data that would otherwise be private.     2> Inner classes can be hidden from other classes in the same package.     3> Anonymous inner class are handy wh ...
1) Check if a cell is intuitively empty public class CellUtil { private CellUtil() { } /** * <p> * If cell is null or intuitively empty <br/> * NPE Safe<br/> * </p> * * @param cell * @return */ publ ...
1. Main Function import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.Collection; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import org.apache.log4j.Logger; public class FileCompress ...
Global site tag (gtag.js) - Google Analytics