Source Code Cross Referenced for StackedFilterMatcher.java in  » Code-Analyzer » findbugs » edu » umd » cs » findbugs » gui2 » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » findbugs » edu.umd.cs.findbugs.gui2 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * FindBugs - Find Bugs in Java programs
003:         * Copyright (C) 2006, University of Maryland
004:         * 
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         * 
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013:         * Lesser General Public License for more details.
014:         * 
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307, USA
018:         */
019:
020:        package edu.umd.cs.findbugs.gui2;
021:
022:        import java.util.ArrayList;
023:        import java.util.Arrays;
024:        import java.util.List;
025:
026:        import javax.swing.event.TreeModelEvent;
027:
028:        import edu.umd.cs.findbugs.BugInstance;
029:        import edu.umd.cs.findbugs.gui2.BugTreeModel.BranchOperationException;
030:
031:        /**
032:         * Filter out bugs which fail (match) all filters.
033:         * This is what happens when you filter out a branch.
034:         */
035:        @Deprecated
036:        public class StackedFilterMatcher extends FilterMatcher {
037:            private static final long serialVersionUID = 3958267780332359162L;
038:            private FilterMatcher[] filters;
039:
040:            @Override
041:            Sortables getFilterBy() {
042:                throw new UnsupportedOperationException(
043:                        "Stacked filter matchers do not filter out a single Sortables, use getFilters()");
044:            }
045:
046:            @Override
047:            String getValue() {
048:                throw new UnsupportedOperationException(
049:                        "Stacked filter matchers do not filter out a single Sortables's value, use getFilters and getValue individually on returned filters.");
050:            }
051:
052:            public StackedFilterMatcher(FilterMatcher... filters) {
053:                super (null, null);
054:                this .filters = filters;
055:            }
056:
057:            //If only FilterMatcher's setActive were as simple as this one... not.
058:            //See BugTreeModel's long ranting comment about filtering to see the reason for all this
059:            //All this does is not force the tree to rebuild when you turn filters for branches on and off
060:            @Override
061:            public void setActive(boolean active) {
062:                TreeModelEvent event = null;
063:                BugTreeModel.TreeModification whatToDo;
064:
065:                if (active != this .active) {
066:                    if (active == false)
067:                        this .active = active;
068:
069:                    StackedFilterMatcher theSame = this ;
070:                    FilterMatcher[] filtersInStack = theSame.getFilters();
071:                    ArrayList<Sortables> order = MainFrame.getInstance()
072:                            .getSorter().getOrder();
073:                    int sizeToCheck = filtersInStack.length;
074:                    if (order.contains(Sortables.DIVIDER))
075:                        if (order.indexOf(Sortables.DIVIDER) < filtersInStack.length) {
076:                            sizeToCheck++;
077:                        }
078:                    List<Sortables> sortablesToCheck = order.subList(0, Math
079:                            .min(sizeToCheck, order.size()));
080:                    Debug.println("Size to check" + sizeToCheck
081:                            + " checking list" + sortablesToCheck);
082:                    Debug.println("checking filters");
083:                    ArrayList<String> almostPath = new ArrayList<String>();
084:                    ArrayList<Sortables> almostPathSortables = new ArrayList<Sortables>();
085:                    for (int x = 0; x < sortablesToCheck.size(); x++) {
086:                        Sortables s = sortablesToCheck.get(x);
087:                        for (FilterMatcher fm : filtersInStack) {
088:                            if (s.equals(fm.getFilterBy())) {
089:                                almostPath.add(fm.getValue());
090:                                almostPathSortables.add(fm.getFilterBy());
091:                            }
092:                        }
093:                    }
094:                    ArrayList<String> finalPath = new ArrayList<String>();
095:                    for (int x = 0; x < almostPath.size(); x++) {
096:                        Sortables s = almostPathSortables.get(x);
097:                        if (MainFrame.getInstance().getSorter()
098:                                .getOrderBeforeDivider().contains(s))
099:                            finalPath.add(almostPath.get(x));
100:                    }
101:                    try {
102:                        if (finalPath.size() == filtersInStack.length) {
103:                            if (active == true) {
104:                                event = (MainFrame.getInstance()
105:                                        .getBugTreeModel())
106:                                        .removeBranch(finalPath);
107:                                whatToDo = BugTreeModel.TreeModification.REMOVE;
108:                            } else {
109:                                event = (MainFrame.getInstance()
110:                                        .getBugTreeModel())
111:                                        .insertBranch(finalPath);
112:                                whatToDo = BugTreeModel.TreeModification.INSERT;
113:                            }
114:                        } else {
115:                            event = (MainFrame.getInstance().getBugTreeModel())
116:                                    .restructureBranch(finalPath, active);//if active is true, this removes, if active if false, it inserts
117:                            if (active)
118:                                whatToDo = BugTreeModel.TreeModification.REMOVERESTRUCTURE;
119:                            else
120:                                whatToDo = BugTreeModel.TreeModification.INSERTRESTRUCTURE;
121:                        }
122:
123:                        if (active == true)
124:                            this .active = active;
125:                        (MainFrame.getInstance().getBugTreeModel()).sendEvent(
126:                                event, whatToDo);
127:                    } catch (BranchOperationException e) {
128:                        //Another filter already filters out the branch this filter would filter out, set active, but dont send any tree model events.
129:                        this .active = active;
130:                    }
131:                }
132:
133:            }
134:
135:            public FilterMatcher[] getFilters() {
136:                return filters;
137:            }
138:
139:            @Override
140:            public boolean match(BugInstance bugInstance) {
141:                if (!isActive())
142:                    return true;
143:
144:                for (FilterMatcher i : filters)
145:                    if (i.match(bugInstance))
146:                        return true;
147:
148:                return false;
149:            }
150:
151:            @Override
152:            public String toString() {
153:                //return "StackedFilterMatcher: " + Arrays.toString(filters);
154:                StringBuilder result = new StringBuilder();
155:                for (int i = 0; i < filters.length - 1; i++)
156:                    result.append(filters[i].toString()
157:                            + (i == filters.length - 2 ? " " : ", "));
158:                if (filters.length > 1)
159:                    result.append("and ");
160:                if (filters.length > 0)
161:                    result.append(filters[filters.length - 1]);
162:                return result.toString();
163:            }
164:
165:            @Override
166:            public boolean equals(Object o) {
167:                if (o == null || !(o instanceof  StackedFilterMatcher))
168:                    return false;
169:
170:                FilterMatcher[] mine = new FilterMatcher[filters.length];
171:                System.arraycopy(this .filters, 0, mine, 0, mine.length);
172:                Arrays.sort(mine);
173:
174:                FilterMatcher[] others = new FilterMatcher[((StackedFilterMatcher) o).filters.length];
175:                System.arraycopy(((StackedFilterMatcher) o).filters, 0, others,
176:                        0, others.length);
177:                Arrays.sort(others);
178:
179:                return (Arrays.equals(mine, others));
180:            }
181:
182:            @Override
183:            public int hashCode() {
184:                return filters.hashCode();
185:            }
186:
187:            public static void main(String[] args) {
188:                System.out.println(new StackedFilterMatcher(
189:                        new FilterMatcher[0]).equals(new StackedFilterMatcher(
190:                        new FilterMatcher[0])));
191:            }
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.