made changes according to 2nd batch of comments

This commit is contained in:
Josh 2015-04-04 21:37:36 +08:00
parent 5383eb9f56
commit 10be0b0b10
12 changed files with 33 additions and 21 deletions

View File

@ -437,7 +437,7 @@ Presentation Tier patterns are the top-most level of the application, this is co
**Applicability:** Use the Callback pattern when **Applicability:** Use the Callback pattern when
* When some arbitrary synchronous or asynchronous action must be performed after execution of some defined activity. * When some arbitrary synchronous or asynchronous action must be performed after execution of some defined activity.
<<<<<<< HEAD
## <a name="intercepting-filter">Intercepting Filter</a> [&#8593;](#list-of-design-patterns) ## <a name="intercepting-filter">Intercepting Filter</a> [&#8593;](#list-of-design-patterns)
**Intent:** Provide pluggable filters to conduct necessary pre-processing and post-processing to requests from a client to a target **Intent:** Provide pluggable filters to conduct necessary pre-processing and post-processing to requests from a client to a target
@ -469,7 +469,7 @@ Presentation Tier patterns are the top-most level of the application, this is co
**Real world examples:** **Real world examples:**
* [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain) prototype inheritance * [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain) prototype inheritance
>>>>>>> origin/master
# Frequently asked questions # Frequently asked questions
@ -515,14 +515,14 @@ The difference is the intent of the patterns. While Proxy controls access to the
* [Lets Modify the Objects-First Approach into Design-Patterns-First](http://edu.pecinovsky.cz/papers/2006_ITiCSE_Design_Patterns_First.pdf) * [Lets Modify the Objects-First Approach into Design-Patterns-First](http://edu.pecinovsky.cz/papers/2006_ITiCSE_Design_Patterns_First.pdf)
* [Pattern Languages of Program Design](http://www.amazon.com/Pattern-Languages-Program-Design-Coplien/dp/0201607344/ref=sr_1_1) * [Pattern Languages of Program Design](http://www.amazon.com/Pattern-Languages-Program-Design-Coplien/dp/0201607344/ref=sr_1_1)
* [Martin Fowler - Event Aggregator](http://martinfowler.com/eaaDev/EventAggregator.html) * [Martin Fowler - Event Aggregator](http://martinfowler.com/eaaDev/EventAggregator.html)
<<<<<<< HEAD
* [TutorialsPoint - Intercepting Filter](http://www.tutorialspoint.com/design_pattern/intercepting_filter_pattern.htm) * [TutorialsPoint - Intercepting Filter](http://www.tutorialspoint.com/design_pattern/intercepting_filter_pattern.htm)
* [Presentation Tier Pattern](http://www.javagyan.com/tutorials/corej2eepatterns/presentation-tier-patterns) * [Presentation Tier Pattern](http://www.javagyan.com/tutorials/corej2eepatterns/presentation-tier-patterns)
======= =======
* [Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions](http://www.amazon.com/Functional-Programming-Java-Harnessing-Expressions/dp/1937785467/ref=sr_1_1) * [Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions](http://www.amazon.com/Functional-Programming-Java-Harnessing-Expressions/dp/1937785467/ref=sr_1_1)
>>>>>>> origin/master
# License # License

View File

@ -1,7 +1,7 @@
/** /**
* Concrete implementation of filter * Concrete implementation of filter
* * This filter is responsible for checking/filtering the input in the address field, returns null if field is empty
* @author joshzambales * @author joshzambales
* *
*/ */

View File

@ -12,11 +12,11 @@ import java.awt.event.*;
* *
*/ */
public class Client extends JFrame{ public class Client extends JFrame{
FilterManager filterManager; private FilterManager filterManager;
JLabel jl; private JLabel jl;
JTextField[] jtFields; private JTextField[] jtFields;
JTextArea[] jtAreas; private JTextArea[] jtAreas;
JButton clearButton, processButton; private JButton clearButton, processButton;
public Client(){ public Client(){
super("Client System"); super("Client System");
setDefaultCloseOperation(EXIT_ON_CLOSE); setDefaultCloseOperation(EXIT_ON_CLOSE);
@ -69,7 +69,9 @@ public class Client extends JFrame{
processButton.addActionListener(new ActionListener(){ processButton.addActionListener(new ActionListener(){
@Override @Override
public void actionPerformed(ActionEvent e){ public void actionPerformed(ActionEvent e){
jl.setText(sendRequest(jtFields[0].getText()+"&"+jtFields[1].getText()+"&"+jtAreas[0].getText()+"&"+jtFields[2].getText()+"&"+jtAreas[1].getText())); String request = String.format("%s&%s&%s&%s&%s",jtFields[0].getText(),jtFields[1].getText(),jtAreas[0].getText(),jtFields[2].getText(),jtAreas[1].getText());
jl.setText(sendRequest(request));
} }
}); });

View File

@ -1,6 +1,6 @@
/** /**
* Concrete implementation of filter * Concrete implementation of filter
* * This filter checks for the contact field in which it checks if the input consist of numbers and it also checks if the input follows the length constraint (11 digits)
* @author joshzambales * @author joshzambales
* *
*/ */

View File

@ -1,6 +1,7 @@
/** /**
* Concrete implementation of filter * Concrete implementation of filter
* *
* This checks for the deposit code, returns null when deposit field is empty
* @author joshzambales * @author joshzambales
* *
*/ */

View File

@ -1,5 +1,7 @@
/** /**
* Filter interface * Filter interface
* Filters perform certain tasks prior or after execution of request by request handler.
* In this case, before the request is handled by the target, the request undergoes through each Filter
* @author joshzambales * @author joshzambales
* *
*/ */

View File

@ -6,7 +6,7 @@
*/ */
public class FilterChain{ public class FilterChain{
private ArrayList<Filter> filters = new ArrayList<Filter>(); private ArrayList<Filter> filters = new ArrayList<Filter>();
private Target target; private final Target target;
public FilterChain(Target target){ public FilterChain(Target target){
this.target = target; this.target = target;

View File

@ -9,7 +9,7 @@ import java.awt.event.*;
* *
*/ */
public class FilterManager{ public class FilterManager{
FilterChain filterChain; private FilterChain filterChain;
public FilterManager(Target target){ public FilterManager(Target target){
filterChain = new FilterChain(target); filterChain = new FilterChain(target);

View File

@ -1,3 +1,10 @@
/**
* Concrete implementation of filter
* This filter checks if the input in the Name field is valid. (alphanumeric)
* @author joshzambales
*
*/
public class NameFilter implements Filter{ public class NameFilter implements Filter{
public String execute(String[] request){ public String execute(String[] request){
if(request[0].equals("") || request[0].matches(".*[^\\w|\\s]+.*")){ if(request[0].equals("") || request[0].matches(".*[^\\w|\\s]+.*")){

View File

@ -1,5 +1,6 @@
/** /**
* Concrete implementation of filter * Concrete implementation of filter
* This checks for the order field, returns null when order field is empty
* *
* @author joshzambales * @author joshzambales
* *

View File

@ -10,10 +10,10 @@ import java.awt.event.*;
* *
*/ */
public class Target extends JFrame{ public class Target extends JFrame{
JTable jt; private JTable jt;
JScrollPane jsp; private JScrollPane jsp;
DefaultTableModel dtm; private DefaultTableModel dtm;
JButton del; private JButton del;
public Target(){ public Target(){
super("Order System"); super("Order System");
setDefaultCloseOperation(EXIT_ON_CLOSE); setDefaultCloseOperation(EXIT_ON_CLOSE);

View File

@ -43,7 +43,6 @@
<module>callback</module> <module>callback</module>
<module>execute-around</module> <module>execute-around</module>
<module>property</module> <module>property</module>
<module>intercepting-filter</module> <module>intercepting-filter</module>
</modules> </modules>