Source Code Cross Referenced for Filters.java in  » UML » AndroMDA-3.2 » org » andromda » core » configuration » 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 » UML » AndroMDA 3.2 » org.andromda.core.configuration 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.andromda.core.configuration;
002:
003:        import java.io.Serializable;
004:
005:        import java.util.ArrayList;
006:        import java.util.Collection;
007:        import java.util.Iterator;
008:        import java.util.regex.PatternSyntaxException;
009:
010:        import org.andromda.core.metafacade.MetafacadeConstants;
011:        import org.apache.commons.lang.StringUtils;
012:
013:        /**
014:         * Stores information about all {@link Filter} instances that should or should not be applied
015:         * to a model.
016:         *
017:         * @author Chad Brandon
018:         * @see org.andromda.core.configuration.Filter
019:         */
020:        public class Filters implements  Serializable {
021:            /**
022:             * The flag indicating whether or not all filter
023:             * should be applied.
024:             */
025:            private boolean applyAll = true;
026:
027:            /**
028:             * Sets whether or not AndroMDA should apply all filters on a model. If this is set to true, then filter values should be
029:             * specified if you want to keep certain filters from being being applied. If this is set to false, then you would want
030:             * to define filter elements to specify which filters <strong>SHOULD BE</strong> applied.
031:             *
032:             * @param applyAll whether or not we should apply all filters true/false
033:             */
034:            public void setApplyAll(final boolean applyAll) {
035:                this .applyAll = applyAll;
036:            }
037:
038:            /**
039:             * Stores the filters as they're added.
040:             */
041:            private final Collection filters = new ArrayList();
042:
043:            /**
044:             * Adds the filter to the underlying filters store.
045:             *
046:             * @param filter the Filter instance.
047:             */
048:            public void addFilter(final Filter filter) {
049:                this .filters.add(filter);
050:            }
051:
052:            /**
053:             * Adds all {@link Filter} instances in the given <code>filters</code>
054:             * to this instance.
055:             *
056:             * @param filters the Filters instance to add.
057:             */
058:            public void addFilters(final Filters filters) {
059:                this .filters.addAll(filters.filters);
060:            }
061:
062:            /**
063:             * Gets the actual filters that belong to this filters instance.
064:             *
065:             * @return the filters to retrieve.
066:             */
067:            public Filter[] getFilters() {
068:                return (Filter[]) this .filters.toArray(new Filter[0]);
069:            }
070:
071:            /**
072:             * Determines whether or not the <code>value</code> should be applied. If
073:             * <code>applyAll</code> is true, then this method will return false only if the Filter
074:             * corresponding to the <code>value</code> has apply set to false.
075:             *
076:             * @param value the name of the model filter to check.
077:             * @return true/false
078:             */
079:            public boolean isApply(final String value) {
080:                boolean shouldApply = this .applyAll;
081:                for (final Iterator iterator = this .filters.iterator(); iterator
082:                        .hasNext();) {
083:                    final Filter filter = (Filter) iterator.next();
084:                    if (match(value, filter.getValue())) {
085:                        shouldApply = filter.isApply();
086:                        break;
087:                    }
088:                }
089:                return shouldApply;
090:            }
091:
092:            /**
093:             * Indicates whether or not this model filters instance
094:             * has any filtering defined.
095:             *
096:             * @return true/false
097:             */
098:            public boolean isEmpty() {
099:                return this .filters.isEmpty();
100:            }
101:
102:            /**
103:             * The double star constant.
104:             */
105:            private static final String DOUBLE_STAR = "**";
106:
107:            /**
108:             * Provides matching of simple wildcards. (i.e. '*.java' etc.)
109:             *
110:             * @param value the value to match against.
111:             * @param pattern the pattern to check if the path matches.
112:             * @return true if the <code>value</code> matches the given <code>pattern</code>, false otherwise.
113:             */
114:            public boolean match(String value, String pattern) {
115:                value = StringUtils.trimToEmpty(value);
116:                boolean matches = false;
117:                if (value != null) {
118:                    final String scopeOperator = MetafacadeConstants.NAMESPACE_SCOPE_OPERATOR;
119:                    pattern = StringUtils.replace(pattern, ".", "\\.");
120:                    boolean matchAll = pattern.indexOf(DOUBLE_STAR) != -1;
121:                    pattern = pattern.replaceAll("\\*{1}", "\\.\\*");
122:                    if (matchAll) {
123:                        pattern = StringUtils.replace(pattern, DOUBLE_STAR,
124:                                ".*");
125:                    }
126:                    try {
127:                        matches = value.matches(pattern);
128:                    } catch (final PatternSyntaxException exception) {
129:                        matches = false;
130:                    }
131:                    if (!matchAll) {
132:                        matches = matches
133:                                && StringUtils.countMatches(pattern,
134:                                        scopeOperator) == StringUtils
135:                                        .countMatches(value, scopeOperator);
136:                    }
137:                }
138:                return matches;
139:            }
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.