Source Code Cross Referenced for MarkerUtil.java in  » IDE-Eclipse » ui-ide » org » eclipse » ui » views » bookmarkexplorer » 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.views.bookmarkexplorer 
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.views.bookmarkexplorer;
011:
012:        import com.ibm.icu.text.DateFormat;
013:        import java.util.Date;
014:
015:        import org.eclipse.core.resources.IMarker;
016:        import org.eclipse.core.runtime.CoreException;
017:        import org.eclipse.core.runtime.IPath;
018:
019:        /**
020:         * Utility class for accessing marker attributes.
021:         */
022:        class MarkerUtil {
023:
024:            /**
025:             * Don't allow instantiation.
026:             */
027:            private MarkerUtil() {
028:            }
029:
030:            /**
031:             * Returns the ending character offset of the given marker.
032:             */
033:            static int getCharEnd(IMarker marker) {
034:                return marker.getAttribute(IMarker.CHAR_END, -1);
035:            }
036:
037:            /**
038:             * Returns the starting character offset of the given marker.
039:             */
040:            static int getCharStart(IMarker marker) {
041:                return marker.getAttribute(IMarker.CHAR_START, -1);
042:            }
043:
044:            /**
045:             * Returns the container name if it is defined, or empty string if not.
046:             */
047:            static String getContainerName(IMarker marker) {
048:                IPath path = marker.getResource().getFullPath();
049:                int n = path.segmentCount() - 1; // n is the number of segments in container, not path
050:                if (n <= 0) {
051:                    return ""; //$NON-NLS-1$
052:                }
053:                int len = 0;
054:                for (int i = 0; i < n; ++i) {
055:                    len += path.segment(i).length();
056:                }
057:                // account for /'s
058:                if (n > 1) {
059:                    len += n - 1;
060:                }
061:                StringBuffer sb = new StringBuffer(len);
062:                for (int i = 0; i < n; ++i) {
063:                    if (i != 0) {
064:                        sb.append('/');
065:                    }
066:                    sb.append(path.segment(i));
067:                }
068:                return sb.toString();
069:            }
070:
071:            /**
072:             * Returns the line number of the given marker.
073:             */
074:            static int getLineNumber(IMarker marker) {
075:                return marker.getAttribute(IMarker.LINE_NUMBER, -1);
076:            }
077:
078:            /**
079:             * Returns the text for the location field.
080:             */
081:            static String getLocation(IMarker marker) {
082:                return marker.getAttribute(IMarker.LOCATION, "");//$NON-NLS-1$
083:            }
084:
085:            /**
086:             * Returns the message attribute of the given marker,
087:             * or the empty string if the message attribute is not defined.
088:             */
089:            static String getMessage(IMarker marker) {
090:                return marker.getAttribute(IMarker.MESSAGE, "");//$NON-NLS-1$
091:            }
092:
093:            /**
094:             * Returns the numeric value of the given string, which is assumed to represent a numeric value.
095:             *
096:             * @return <code>true</code> if numeric, <code>false</code> if not
097:             */
098:            static int getNumericValue(String value) {
099:                boolean negative = false;
100:                int i = 0;
101:                int len = value.length();
102:
103:                // skip any leading '#'
104:                // workaround for 1GCE69U: ITPJCORE:ALL - Java problems should not have '#' in location.
105:                if (i < len && value.charAt(i) == '#') {
106:                    ++i;
107:                }
108:
109:                if (i < len && value.charAt(i) == '-') {
110:                    negative = true;
111:                    ++i;
112:                }
113:
114:                int result = 0;
115:                while (i < len) {
116:                    int digit = Character.digit(value.charAt(i++), 10);
117:                    if (digit < 0) {
118:                        return result;
119:                    }
120:                    result = result * 10 + digit;
121:                }
122:                if (negative) {
123:                    result = -result;
124:                }
125:                return result;
126:            }
127:
128:            /**
129:             * Implements IProvider interface by supporting a number of
130:             * properties required for visual representation of markers
131:             * in the tasklist.
132:             */
133:
134:            /**
135:             * Returns name if it is defined, or
136:             * blank string if not.
137:             */
138:            static String getResourceName(IMarker marker) {
139:                return marker.getResource().getName();
140:            }
141:
142:            /**
143:             * Returns the creation time of the marker as a string.
144:             */
145:            static String getCreationTime(IMarker marker) {
146:                try {
147:                    return DateFormat.getDateTimeInstance(DateFormat.LONG,
148:                            DateFormat.MEDIUM).format(
149:                            new Date(marker.getCreationTime()));
150:                } catch (CoreException e) {
151:                    return null;
152:                }
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.