Source Code Cross Referenced for MarkerQuery.java in  » IDE-Eclipse » ui-ide » org » eclipse » ui » internal » ide » registry » 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 » IDE Eclipse » ui ide » org.eclipse.ui.internal.ide.registry 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal.ide.registry;
011:
012:        import org.eclipse.core.resources.IMarker;
013:        import org.eclipse.core.runtime.CoreException;
014:        import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
015:
016:        /**
017:         * Instances of this class hold a marker type id and/or 
018:         * a series of marker attributes. This information may be used 
019:         * to determine if a given marker is of the same marker
020:         * type and determine its values for the attributes.
021:         */
022:        public class MarkerQuery {
023:            /**
024:             * The marker type targetted by this query. 
025:             * May be <code>null</code>.
026:             */
027:            private String type;
028:
029:            /**
030:             * A sorted list of the attributes targetted by this query.
031:             * The list is sorted from least to greatest according to
032:             * <code>Sting.compare</code>
033:             */
034:            private String[] attributes;
035:
036:            /**
037:             * Cached hash code value
038:             */
039:            private int hashCode;
040:
041:            /**
042:             * Creates a new marker query with the given type
043:             * and attributes.
044:             * <p>
045:             * The type may be <code>null</code>. The attributes may 
046:             * be empty, but not <code>null</code>.
047:             * </p>
048:             * 
049:             * @param markerType the targetted marker type
050:             * @param markerAttributes the targetted marker attributes
051:             */
052:            public MarkerQuery(String markerType, String[] markerAttributes) {
053:                if (markerAttributes == null) {
054:                    throw new IllegalArgumentException();
055:                }
056:
057:                type = markerType;
058:                attributes = markerAttributes;
059:                computeHashCode();
060:            }
061:
062:            /**
063:             * Performs a query against the given marker.
064:             * <p>
065:             * Returns a <code>MarkerQueryResult</code> if the marker
066:             * is appropriate for this query (correct type and has
067:             * all of the query attributes), otherwise <code>null</code>
068:             * is returned.
069:             * 
070:             * @param marker the marker to perform the query against
071:             * @return a marker query result or <code>null</code>
072:             */
073:            public MarkerQueryResult performQuery(IMarker marker) {
074:                // Check type
075:                try {
076:                    if (type != null && !type.equals(marker.getType())) {
077:                        return null;
078:                    }
079:                } catch (CoreException e) {
080:                    IDEWorkbenchPlugin.log(
081:                            "Error accessing marker type", e.getStatus()); //$NON-NLS-1$
082:                    return null;
083:                }
084:
085:                // Check attributes
086:                String[] values = new String[attributes.length];
087:                for (int i = 0; i < attributes.length; i++) {
088:                    try {
089:                        Object value = marker.getAttribute(attributes[i]);
090:                        if (value == null) {
091:                            return null;
092:                        }
093:                        values[i] = value.toString();
094:                    } catch (CoreException e) {
095:                        IDEWorkbenchPlugin
096:                                .log(
097:                                        "Error accessing marker attribute", e.getStatus()); //$NON-NLS-1$
098:                        return null;
099:                    }
100:                }
101:
102:                // Create and return the result
103:                return new MarkerQueryResult(values);
104:            }
105:
106:            /* (non-Javadoc)
107:             * Method declared on Object.
108:             */
109:            public boolean equals(Object o) {
110:                if (!(o instanceof  MarkerQuery)) {
111:                    return false;
112:                }
113:
114:                if (o == this ) {
115:                    return true;
116:                }
117:
118:                MarkerQuery mq = (MarkerQuery) o;
119:                if (!(type == null ? mq.type == null : type.equals(mq.type))) {
120:                    return false;
121:                }
122:
123:                if (attributes.length != mq.attributes.length) {
124:                    return false;
125:                }
126:
127:                for (int i = 0; i < attributes.length; i++) {
128:                    if (!(attributes[i].equals(mq.attributes[i]))) {
129:                        return false;
130:                    }
131:                }
132:
133:                return true;
134:            }
135:
136:            /* (non-Javadoc)
137:             * Method declared on Object.
138:             */
139:            public int hashCode() {
140:                return hashCode;
141:            }
142:
143:            /**
144:             * Computes the hash code for this instance.
145:             */
146:            public void computeHashCode() {
147:                hashCode = 19;
148:
149:                if (type != null) {
150:                    hashCode = hashCode * 37 + type.hashCode();
151:                }
152:
153:                for (int i = 0; i < attributes.length; i++) {
154:                    hashCode = hashCode * 37 + attributes[i].hashCode();
155:                }
156:            }
157:
158:            /**
159:             * Returns the targetted marker type. May be 
160:             * <code>null</code>
161:             * 
162:             * @return the targetted marker type
163:             */
164:            public String getType() {
165:                return type;
166:            }
167:
168:            /**
169:             * Returns the targetted attributes.
170:             * The array may be empty.
171:             * 
172:             * @return the targetted attributes
173:             */
174:            public String[] getAttributes() {
175:                return attributes;
176:            }
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.