提交 10be0b0b 编写于 作者: J Josh

made changes according to 2nd batch of comments

上级 5383eb9f
......@@ -437,7 +437,7 @@ Presentation Tier patterns are the top-most level of the application, this is co
**Applicability:** Use the Callback pattern when
* 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)
**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:**
* [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain) prototype inheritance
>>>>>>> origin/master
# Frequently asked questions
......@@ -515,14 +515,14 @@ The difference is the intent of the patterns. While Proxy controls access to the
* [Let’s 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)
* [Martin Fowler - Event Aggregator](http://martinfowler.com/eaaDev/EventAggregator.html)
<<<<<<< HEAD
* [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)
=======
* [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
......
/**
* 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
*
*/
......
......@@ -12,11 +12,11 @@ import java.awt.event.*;
*
*/
public class Client extends JFrame{
FilterManager filterManager;
JLabel jl;
JTextField[] jtFields;
JTextArea[] jtAreas;
JButton clearButton, processButton;
private FilterManager filterManager;
private JLabel jl;
private JTextField[] jtFields;
private JTextArea[] jtAreas;
private JButton clearButton, processButton;
public Client(){
super("Client System");
setDefaultCloseOperation(EXIT_ON_CLOSE);
......@@ -69,7 +69,9 @@ public class Client extends JFrame{
processButton.addActionListener(new ActionListener(){
@Override
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));
}
});
......
/**
* 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
*
*/
......
/**
* Concrete implementation of filter
*
*
* This checks for the deposit code, returns null when deposit field is empty
* @author joshzambales
*
*/
......
/**
* 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
*
*/
......
......@@ -6,7 +6,7 @@
*/
public class FilterChain{
private ArrayList<Filter> filters = new ArrayList<Filter>();
private Target target;
private final Target target;
public FilterChain(Target target){
this.target = target;
......
......@@ -9,7 +9,7 @@ import java.awt.event.*;
*
*/
public class FilterManager{
FilterChain filterChain;
private FilterChain filterChain;
public FilterManager(Target target){
filterChain = new FilterChain(target);
......
/**
* 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 String execute(String[] request){
if(request[0].equals("") || request[0].matches(".*[^\\w|\\s]+.*")){
......
/**
* Concrete implementation of filter
* This checks for the order field, returns null when order field is empty
*
* @author joshzambales
*
......
......@@ -10,10 +10,10 @@ import java.awt.event.*;
*
*/
public class Target extends JFrame{
JTable jt;
JScrollPane jsp;
DefaultTableModel dtm;
JButton del;
private JTable jt;
private JScrollPane jsp;
private DefaultTableModel dtm;
private JButton del;
public Target(){
super("Order System");
setDefaultCloseOperation(EXIT_ON_CLOSE);
......
......@@ -43,7 +43,6 @@
<module>callback</module>
<module>execute-around</module>
<module>property</module>
<module>intercepting-filter</module>
</modules>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册